From c823aeafab11a6ffab381fd8bce6a14590363ef0 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 31 Jan 2018 13:52:21 -0800 Subject: [PATCH] funding: during funding error fail before sending Error to peer In this commit, we modify the logic executed when we decide that we need to fail a funding flow. Before this commit, if the remote party disconnected while we were attempting to fail the funding flow with an error. Then we'd never actually cancel the reservation. This meant that any inputs selected for that transaction would be locked until a restart. We fix this issue by always cancelling the reservation first, and ensuring that failure to cancel the reservation doesn't prevent us from sending the error. Partially addresses #710. --- fundingmanager.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fundingmanager.go b/fundingmanager.go index 656e728e..9e6b128b 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -676,13 +676,16 @@ func (f *fundingManager) failFundingFlow(peer *btcec.PublicKey, fndgLog.Errorf("Failing funding flow: %v", spew.Sdump(errMsg)) + if _, err := f.cancelReservationCtx(peer, tempChanID); err != nil { + fndgLog.Errorf("unable to cancel reservation: %v", err) + } + err := f.cfg.SendToPeer(peer, errMsg) if err != nil { fndgLog.Errorf("unable to send error message to peer %v", err) return } - f.cancelReservationCtx(peer, tempChanID) return }