lnwallet: ensure reservation state is cleaned up in case of Cancel

This commit fixes a bug in the wallet’s internal reservation manager
that prevented it from cleaning up the resources used by a reservation
after it was finished running through the workflow.

We fix this issue by ensuring the reservations context is deleted from
the funding limbo.

It is the callers responsibility to properly .Cancel() a reservation in
the case of an error during the funding workflow.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-02-22 14:51:41 -08:00
1 parent d759e05a1c
commit bd775b9bb3
2 files changed
+25

No files matched your search

+12
View File
@@ -1242,6 +1242,12 @@ func (l *LightningWallet) handleChannelOpen(req *channelOpenMsg) {
res.chanOpen <- &openChanDetails{
channel: channel,
}
// As this reservation has concluded, we can now safely remove the
// reservation from the limbo map.
l.limboMtx.Lock()
delete(l.fundingLimbo, req.pendingFundingID)
l.limboMtx.Unlock()
}
// openChannelAfterConfirmations creates, and opens a payment channel after
@@ -1299,6 +1305,12 @@ out:
blockHeight: confDetails.BlockHeight,
txIndex: confDetails.TxIndex,
}
// As this reservation has concluded, we can now safely remove the
// reservation from the limbo map.
l.limboMtx.Lock()
delete(l.fundingLimbo, res.reservationID)
l.limboMtx.Unlock()
}
// selectCoinsAndChange performs coin selection in order to obtain witness