From cef81a6adf1e3e34e4b5e337c8c2a277df0b0c0a Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 24 Feb 2017 16:21:52 -0800 Subject: [PATCH] funding: ensure reservations are cancelled if error'd at final stage --- fundingmanager.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index 8acb6bb9..fa5cfb3e 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -504,7 +504,6 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) { // attempt may be rejected. Note that since we're on the responding // side of a single funder workflow, we don't commit any funds to the // channel ourselves. - // TODO(roasbeef): passing num confs 1 is irrelevant here, make signed? // TODO(roasbeef): assuming this was an inbound connection, replace // port with default advertised port reservation, err := f.cfg.Wallet.InitChannelReservation(amt, 0, @@ -519,9 +518,9 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) { reservation.SetTheirDustLimit(theirDustlimit) - // Once the reservation has been created successfully, we add it to this - // peers map of pending reservations to track this particular reservation - // until either abort or completion. + // Once the reservation has been created successfully, we add it to + // this peers map of pending reservations to track this particular + // reservation until either abort or completion. f.resMtx.Lock() if _, ok := f.activeReservations[peerIDKey]; !ok { f.activeReservations[peerIDKey] = make(pendingChannels) @@ -810,6 +809,10 @@ func (f *fundingManager) handleFundingSignComplete(fmsg *fundingSignCompleteMsg) if err != nil { fndgLog.Errorf("unable to complete reservation sign complete: %v", err) resCtx.err <- err + + if _, err := f.cancelReservationCtx(peerKey, chanID); err != nil { + fndgLog.Errorf("unable to cancel reservation: %v", err) + } return }