diff --git a/docs/release-notes/release-notes-0.21.0.md b/docs/release-notes/release-notes-0.21.0.md index 23b93a0fd0d..f2bc1a2f66d 100644 --- a/docs/release-notes/release-notes-0.21.0.md +++ b/docs/release-notes/release-notes-0.21.0.md @@ -71,7 +71,7 @@ the chain watch filter on restart. This was a pre-existing bug since private taproot channels were first introduced. -* [Fixed a shutdown race in the +* [Fixed a shutdown race in the channel link](https://github.com/lightningnetwork/lnd/pull/10719) that could deadlock the invoice registry during concurrent peer disconnect. The link now waits for `htlcManager` to fully exit before tearing down hodl @@ -88,6 +88,13 @@ RBF close state machine does not yet thread through the `AuxCloser` hook that overlay channels rely on to build aux-aware close transactions. +- [Fixed `BudgetInputSet.AddWalletInputs` to roll back partially-added + wallet inputs on error](https://github.com/lightningnetwork/lnd/pull/10723). + Previously, if adding a wallet input failed midway through the loop, any + inputs already appended to the set would remain, leaving it in an + inconsistent state. The method now restores the input set to its original + state before returning the error. + # New Features - [Basic Support](https://github.com/lightningnetwork/lnd/pull/9868) for onion diff --git a/sweep/tx_input_set.go b/sweep/tx_input_set.go index 7b533c232f2..dfdeb737028 100644 --- a/sweep/tx_input_set.go +++ b/sweep/tx_input_set.go @@ -367,10 +367,16 @@ func (b *BudgetInputSet) AddWalletInputs(wallet Wallet) error { return utxos[i].Value < utxos[j].Value }) + // We'll track the initial number of inputs to ensure we can restore the + // set to its original state if we fail to add the required wallet + // inputs. + inputsBefore := len(b.inputs) + // Add wallet inputs to the set until the specified budget is covered. for _, utxo := range utxos { err := b.addWalletInput(utxo) if err != nil { + b.inputs = b.inputs[:inputsBefore] return err }