mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
contractcourt: offer outgoing htlc one block earlier before its expiry
We need to offer the outgoing htlc one block earlier to make sure when the expiry height hits, the sweeper will not miss sweeping it in the same block. This also means the outgoing contest resolver now only does one thing - watch for preimage spend till height expiry-1, which can easily be moved into the timeout resolver instead in the future.
This commit is contained in:
parent
819c15fa0b
commit
63aa5aa6e9
1 changed files with 8 additions and 1 deletions
|
@ -155,7 +155,14 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
|
|||
// fail.
|
||||
newHeight := uint32(newBlock.Height)
|
||||
expiry := h.htlcResolution.Expiry
|
||||
if newHeight >= expiry {
|
||||
|
||||
// Check if the expiry height is about to be reached.
|
||||
// We offer this HTLC one block earlier to make sure
|
||||
// when the next block arrives, the sweeper will pick
|
||||
// up this input and sweep it immediately. The sweeper
|
||||
// will handle the waiting for the one last block till
|
||||
// expiry.
|
||||
if newHeight >= expiry-1 {
|
||||
h.log.Infof("HTLC about to expire "+
|
||||
"(height=%v, expiry=%v), transforming "+
|
||||
"into timeout resolver", h,
|
||||
|
|
Loading…
Add table
Reference in a new issue