mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user