sweep: create sweep tx even the budget cannot be met

We now always create the sweeping tx even though the budget cannot be
covered so we don't miss the deadline. Note that the fee bump will fail
once the provided wallet input cannot cover the increase fees, which is
fine as these inputs will be marked as failed and be retried again in
the next block. When that happens, if there are new wallet UTXOs, a new
batch will be created to perform the fee bump.
This commit is contained in:
yyforyongyu
2025-03-19 17:32:42 +08:00
parent 3c4fd1b484
commit 861dc145bf
3 changed files with 32 additions and 28 deletions

View File

@@ -1114,6 +1114,14 @@ func (t *TxPublisher) handleInitialTxError(r *monitorRecord, err error) {
case errors.Is(err, ErrZeroFeeRateDelta):
result.Event = TxFailed
// When the error is due to not enough inputs to cover the budget, we'll
// send a TxFailed event so these inputs can be retried when the wallet
// has more UTXOs.
case errors.Is(err, ErrNotEnoughInputs),
errors.Is(err, ErrNotEnoughBudget):
result.Event = TxFailed
// When there are missing inputs, we'll create a TxUnknownSpend bump
// result here so the rest of the inputs can be retried.
case errors.Is(err, ErrInputMissing):
@@ -1757,9 +1765,11 @@ func prepareSweepTx(inputs []input.Input, changePkScript lnwallet.AddrWithKey,
// Make sure total output amount is less than total input amount.
if requiredOutput+txFee > totalInput {
return 0, noChange, noLocktime, fmt.Errorf("insufficient "+
"input to create sweep tx: input_sum=%v, "+
"output_sum=%v", totalInput, requiredOutput+txFee)
log.Errorf("Insufficient input to create sweep tx: "+
"input_sum=%v, output_sum=%v", totalInput,
requiredOutput+txFee)
return 0, noChange, noLocktime, ErrNotEnoughInputs
}
// The value remaining after the required output and fees is the