sweep: delay sweeping inputs with future locktimes

This commit fixes an edge case that the sweeper's best known block
height is behind arbitrator's, which may cause an issue when creating
sweeping tx, as we may end up using an old block height from
arbitrator's view.
This commit is contained in:
yyforyongyu
2024-03-20 16:48:58 +08:00
parent 0527b2d7a6
commit 658ba445ea
2 changed files with 46 additions and 7 deletions

View File

@@ -1520,6 +1520,17 @@ func (s *UtxoSweeper) updateSweeperInputs() InputsMap {
continue
}
// If the input has a locktime that's not yet reached, we will
// skip this input and wait for the locktime to be reached.
locktime, _ := input.RequiredLockTime()
if uint32(s.currentHeight) < locktime {
log.Warnf("Skipping input %v due to locktime=%v not "+
"reached, current height is %v", op, locktime,
s.currentHeight)
continue
}
// If this input is new or has been failed to be published,
// we'd retry it. The assumption here is that when an error is
// returned from `PublishTransaction`, it means the tx has