Conversation
bdk_wallet 3.2.1 verifies the signatures of an unconfirmed transaction's inputs that spend the wallet's own outputs. When they fail it drops the transaction on sync and refuses to fee-bump it. Our manifest admits 3.2.1 and we don't commit a lock file, so CI builds against it. Several wallet tests inserted such transactions with empty witnesses, which the wallet no longer took in. Nine tests failed. Four more kept passing without the transaction they are about: three expect a fee bump to be refused with the error an unknown transaction also yields, and one expects an evicted fee bump to stay out of the wallet. Sign those inputs in the test helpers, and have the helpers check that the wallet took the transaction in, so that a transaction dropped again fails the test that inserts it. Only tests change. The wallet's outputs are all P2WPKH, whose signatures verify without the previous outputs of a transaction's other inputs, and the transactions a chain source relays are signed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
I've assigned @tnull as a reviewer! |
jbesraa
pushed a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
bdk_wallet 3.2.1 verifies the signatures of an unconfirmed transaction's inputs that spend the wallet's own outputs. When they fail it drops the transaction on sync and refuses to fee-bump it. Our manifest admits 3.2.1 and we don't commit a lock file, so CI builds against it. Several wallet tests inserted such transactions with empty witnesses, which the wallet no longer took in. Nine tests failed. Four more kept passing without the transaction they are about: three expect a fee bump to be refused with the error an unknown transaction also yields, and one expects an evicted fee bump to stay out of the wallet. Sign those inputs in the test helpers, and have the helpers check that the wallet took the transaction in, so that a transaction dropped again fails the test that inserts it. Only tests change. The wallet's outputs are all P2WPKH, whose signatures verify without the previous outputs of a transaction's other inputs, and the transactions a chain source relays are signed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit f2822dd) Upstream-PR: lightningdevkit#1255
jbesraa
added a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
bdk_wallet 3.2.1 (2026-11-23, bdk_wallet#660) verifies the signatures of a wallet's own inputs before it takes in an unconfirmed transaction (apply_update, apply_unconfirmed_txs), drops one it can't verify, and refuses to fee-bump one: a malicious chain source could otherwise forge a conflict of a transaction we broadcast and have us bump it into a valid one paying the attacker. Cargo.toml asks for 3.2.1 at least, so no build of the fork takes 3.2.0. The node's own code applies only transactions that are signed or that came from the chain source: a send and a fee bump are applied after sign_with_signers finalized them; restore_evicted_sends reapplies the graph's copy of our own sends; the chain sources' updates are verified by BDK (Electrum syncs with fetch_prev_txouts = true; the node wallet is P2WPKH, whose sighash needs only the input's own prevout); builder.rs applies a checkpoint and no transaction. The wallet tests' fixtures, which 3.2.1 drops unsigned, are signed by upstream's lightningdevkit#1255 (the commit before this one), which replaces the fixture half of the original patch (Esra, 2026-12-02). Regrouped from: 7b9a24b (its Cargo.toml half).
jbesraa
added a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
From "Blocknil patch (ldk3-confirmed-balance): the on-chain balance a splice's coin selection can spend": Node::confirmed_spendable_onchain_balance_sats: the coins confirmed as of the wallet's last sync, unlocked, mature and small enough for tx_add_input, less the anchor reserve. These are the coins splice_in and splice_in_with_change select from (exclude_unconfirmed); BalanceDetails::spendable_onchain_balance_sats is BDK's trusted spendable balance, which also counts our own unconfirmed change, so after an open or splice spends the wallet's coins the two differ until the change confirms and the wallet syncs. Why: Blocknil's provider quoted a splice on arrival on that change, took the wallet's yes, found no coin to splice with, and refused and refunded (bitcoin-wallet lightningdevkit#211; staging smoke, release set c4d54a95). No public API gave the confirmed figure: Wallet::list_confirmed_funding_inputs, which walks the same coins, is crate-private. list_balances is unchanged. Test: confirmed_spendable_balance_leaves_out_unconfirmed_change. A single coin, an open spends it; the trusted figure counts the change and the new one doesn't, also once the open is in a block the wallet hasn't synced; after the sync they agree and a splice spends it. From "Blocknil patch (ldk3-confirmed-balance): the sum is upstream's get_confirmed_unlocked_amount_sats": Follow-up to the previous commit, the same patch. The wallet's sum becomes upstream's Wallet::get_confirmed_unlocked_amount_sats (ldk-node lightningdevkit#1223, 6fb3d52) word for word, taken alone with its unit test, so that the Blocknil part is the public wrapper (Node::confirmed_spendable_onchain_balance_sats, less the anchor reserve) and moving to upstream drops the copy. Upstream's sum leaves out what ours also skipped (immature coinbase outputs, a coin whose transaction is too large for tx_add_input); neither is on a provider's wallet, and either would only make the figure higher than coin selection can use, as before lightningdevkit#211's fix. The rest of lightningdevkit#1223 (the splice anchor-reserve checks) was taken later, hand-merged into our change-keeping splice_in: the three upstream commits that follow this one. Tests: confirmed_unlocked_amount_does_not_depend_on_seeing_a_splice (upstream's, as upstream has it: its insert_unconfirmed_tx signs the splice for bdk_wallet 3.2.1, since lightningdevkit#1255). The integration test drops its "in a block but not synced" assertion: the node's background sync can run first, so it raced (failed once). From "Blocknil test (ldk3-confirmed-balance): run on Esplora, and check the mined-but-unsynced case again": confirmed_spendable_balance_leaves_out_unconfirmed_change picked its chain source at random. On bitcoind (RPC or REST) the node polls the chain every 2 s (src/chain/bitcoind.rs), so the "confirmed on chain, not yet synced: still 0" assertion raced that poll and failed once; the previous commit dropped it, putting the cause down to background sync in general, which was wrong: the test helper turns background sync off for Esplora and Electrum. The test now runs on Esplora, where what the wallet has seen moves only with sync_wallets, and the assertion is back. 5 runs of 5 passed. Regrouped from: b070c76 0060dff a73d527
jbesraa
pushed a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
bdk_wallet 3.2.1 verifies the signatures of an unconfirmed transaction's inputs that spend the wallet's own outputs. When they fail it drops the transaction on sync and refuses to fee-bump it. Our manifest admits 3.2.1 and we don't commit a lock file, so CI builds against it. Several wallet tests inserted such transactions with empty witnesses, which the wallet no longer took in. Nine tests failed. Four more kept passing without the transaction they are about: three expect a fee bump to be refused with the error an unknown transaction also yields, and one expects an evicted fee bump to stay out of the wallet. Sign those inputs in the test helpers, and have the helpers check that the wallet took the transaction in, so that a transaction dropped again fails the test that inserts it. Only tests change. The wallet's outputs are all P2WPKH, whose signatures verify without the previous outputs of a transaction's other inputs, and the transactions a chain source relays are signed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit f2822dd) Upstream-PR: lightningdevkit#1255
jbesraa
added a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
bdk_wallet 3.2.1 (2026-11-23, bdk_wallet#660) verifies the signatures of a wallet's own inputs before it takes in an unconfirmed transaction (apply_update, apply_unconfirmed_txs), drops one it can't verify, and refuses to fee-bump one: a malicious chain source could otherwise forge a conflict of a transaction we broadcast and have us bump it into a valid one paying the attacker. Cargo.toml asks for 3.2.1 at least, so no build of the fork takes 3.2.0. The node's own code applies only transactions that are signed or that came from the chain source: a send and a fee bump are applied after sign_with_signers finalized them; restore_evicted_sends reapplies the graph's copy of our own sends; the chain sources' updates are verified by BDK (Electrum syncs with fetch_prev_txouts = true; the node wallet is P2WPKH, whose sighash needs only the input's own prevout); builder.rs applies a checkpoint and no transaction. The wallet tests' fixtures, which 3.2.1 drops unsigned, are signed by upstream's lightningdevkit#1255 (the commit before this one), which replaces the fixture half of the original patch (Esra, 2026-12-02). Regrouped from: 7b9a24b (its Cargo.toml half).
jbesraa
added a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
From "Blocknil patch (ldk3-confirmed-balance): the on-chain balance a splice's coin selection can spend": Node::confirmed_spendable_onchain_balance_sats: the coins confirmed as of the wallet's last sync, unlocked, mature and small enough for tx_add_input, less the anchor reserve. These are the coins splice_in and splice_in_with_change select from (exclude_unconfirmed); BalanceDetails::spendable_onchain_balance_sats is BDK's trusted spendable balance, which also counts our own unconfirmed change, so after an open or splice spends the wallet's coins the two differ until the change confirms and the wallet syncs. Why: Blocknil's provider quoted a splice on arrival on that change, took the wallet's yes, found no coin to splice with, and refused and refunded (bitcoin-wallet lightningdevkit#211; staging smoke, release set c4d54a95). No public API gave the confirmed figure: Wallet::list_confirmed_funding_inputs, which walks the same coins, is crate-private. list_balances is unchanged. Test: confirmed_spendable_balance_leaves_out_unconfirmed_change. A single coin, an open spends it; the trusted figure counts the change and the new one doesn't, also once the open is in a block the wallet hasn't synced; after the sync they agree and a splice spends it. From "Blocknil patch (ldk3-confirmed-balance): the sum is upstream's get_confirmed_unlocked_amount_sats": Follow-up to the previous commit, the same patch. The wallet's sum becomes upstream's Wallet::get_confirmed_unlocked_amount_sats (ldk-node lightningdevkit#1223, 6fb3d52) word for word, taken alone with its unit test, so that the Blocknil part is the public wrapper (Node::confirmed_spendable_onchain_balance_sats, less the anchor reserve) and moving to upstream drops the copy. Upstream's sum leaves out what ours also skipped (immature coinbase outputs, a coin whose transaction is too large for tx_add_input); neither is on a provider's wallet, and either would only make the figure higher than coin selection can use, as before lightningdevkit#211's fix. The rest of lightningdevkit#1223 (the splice anchor-reserve checks) was taken later, hand-merged into our change-keeping splice_in: the three upstream commits that follow this one. Tests: confirmed_unlocked_amount_does_not_depend_on_seeing_a_splice (upstream's, as upstream has it: its insert_unconfirmed_tx signs the splice for bdk_wallet 3.2.1, since lightningdevkit#1255). The integration test drops its "in a block but not synced" assertion: the node's background sync can run first, so it raced (failed once). From "Blocknil test (ldk3-confirmed-balance): run on Esplora, and check the mined-but-unsynced case again": confirmed_spendable_balance_leaves_out_unconfirmed_change picked its chain source at random. On bitcoind (RPC or REST) the node polls the chain every 2 s (src/chain/bitcoind.rs), so the "confirmed on chain, not yet synced: still 0" assertion raced that poll and failed once; the previous commit dropped it, putting the cause down to background sync in general, which was wrong: the test helper turns background sync off for Esplora and Electrum. The test now runs on Esplora, where what the wallet has seen moves only with sync_wallets, and the assertion is back. 5 runs of 5 passed. Regrouped from: b070c76 0060dff a73d527
jbesraa
pushed a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
bdk_wallet 3.2.1 verifies the signatures of an unconfirmed transaction's inputs that spend the wallet's own outputs. When they fail it drops the transaction on sync and refuses to fee-bump it. Our manifest admits 3.2.1 and we don't commit a lock file, so CI builds against it. Several wallet tests inserted such transactions with empty witnesses, which the wallet no longer took in. Nine tests failed. Four more kept passing without the transaction they are about: three expect a fee bump to be refused with the error an unknown transaction also yields, and one expects an evicted fee bump to stay out of the wallet. Sign those inputs in the test helpers, and have the helpers check that the wallet took the transaction in, so that a transaction dropped again fails the test that inserts it. Only tests change. The wallet's outputs are all P2WPKH, whose signatures verify without the previous outputs of a transaction's other inputs, and the transactions a chain source relays are signed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit f2822dd) Upstream-PR: lightningdevkit#1255
jbesraa
added a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
bdk_wallet 3.2.1 (2026-11-23, bdk_wallet#660) verifies the signatures of a wallet's own inputs before it takes in an unconfirmed transaction (apply_update, apply_unconfirmed_txs), drops one it can't verify, and refuses to fee-bump one: a malicious chain source could otherwise forge a conflict of a transaction we broadcast and have us bump it into a valid one paying the attacker. Cargo.toml asks for 3.2.1 at least, so no build of the fork takes 3.2.0. The node's own code applies only transactions that are signed or that came from the chain source: a send and a fee bump are applied after sign_with_signers finalized them; restore_evicted_sends reapplies the graph's copy of our own sends; the chain sources' updates are verified by BDK (Electrum syncs with fetch_prev_txouts = true; the node wallet is P2WPKH, whose sighash needs only the input's own prevout); builder.rs applies a checkpoint and no transaction. The wallet tests' fixtures, which 3.2.1 drops unsigned, are signed by upstream's lightningdevkit#1255 (the commit before this one), which replaces the fixture half of the original patch (Esra, 2026-12-02). Regrouped from: 7b9a24b (its Cargo.toml half).
jbesraa
added a commit
to blocknil/ldk-node
that referenced
this pull request
Dec 2, 2026
From "Blocknil patch (ldk3-confirmed-balance): the on-chain balance a splice's coin selection can spend": Node::confirmed_spendable_onchain_balance_sats: the coins confirmed as of the wallet's last sync, unlocked, mature and small enough for tx_add_input, less the anchor reserve. These are the coins splice_in and splice_in_with_change select from (exclude_unconfirmed); BalanceDetails::spendable_onchain_balance_sats is BDK's trusted spendable balance, which also counts our own unconfirmed change, so after an open or splice spends the wallet's coins the two differ until the change confirms and the wallet syncs. Why: Blocknil's provider quoted a splice on arrival on that change, took the wallet's yes, found no coin to splice with, and refused and refunded (bitcoin-wallet lightningdevkit#211; staging smoke, release set c4d54a95). No public API gave the confirmed figure: Wallet::list_confirmed_funding_inputs, which walks the same coins, is crate-private. list_balances is unchanged. Test: confirmed_spendable_balance_leaves_out_unconfirmed_change. A single coin, an open spends it; the trusted figure counts the change and the new one doesn't, also once the open is in a block the wallet hasn't synced; after the sync they agree and a splice spends it. From "Blocknil patch (ldk3-confirmed-balance): the sum is upstream's get_confirmed_unlocked_amount_sats": Follow-up to the previous commit, the same patch. The wallet's sum becomes upstream's Wallet::get_confirmed_unlocked_amount_sats (ldk-node lightningdevkit#1223, 6fb3d52) word for word, taken alone with its unit test, so that the Blocknil part is the public wrapper (Node::confirmed_spendable_onchain_balance_sats, less the anchor reserve) and moving to upstream drops the copy. Upstream's sum leaves out what ours also skipped (immature coinbase outputs, a coin whose transaction is too large for tx_add_input); neither is on a provider's wallet, and either would only make the figure higher than coin selection can use, as before lightningdevkit#211's fix. The rest of lightningdevkit#1223 (the splice anchor-reserve checks) was taken later, hand-merged into our change-keeping splice_in: the three upstream commits that follow this one. Tests: confirmed_unlocked_amount_does_not_depend_on_seeing_a_splice (upstream's, as upstream has it: its insert_unconfirmed_tx signs the splice for bdk_wallet 3.2.1, since lightningdevkit#1255). The integration test drops its "in a block but not synced" assertion: the node's background sync can run first, so it raced (failed once). From "Blocknil test (ldk3-confirmed-balance): run on Esplora, and check the mined-but-unsynced case again": confirmed_spendable_balance_leaves_out_unconfirmed_change picked its chain source at random. On bitcoind (RPC or REST) the node polls the chain every 2 s (src/chain/bitcoind.rs), so the "confirmed on chain, not yet synced: still 0" assertion raced that poll and failed once; the previous commit dropped it, putting the cause down to background sync in general, which was wrong: the test helper turns background sync off for Esplora and Electrum. The test now runs on Esplora, where what the wallet has seen moves only with sync_wallets, and the assertion is back. 5 runs of 5 passed. Regrouped from: b070c76 0060dff a73d527
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bdk_wallet3.2.1 (released 2026-11-23) verifies the signatures of an unconfirmed transaction's inputs that spend the wallet's own outputs. When they fail,Wallet::apply_updateandWallet::apply_unconfirmed_txsdrop the transaction andWallet::build_fee_bumprefuses it. We ask forbdk_wallet = "3.2.0"and don't commit a lock file, so every fresh CI run now builds against 3.2.1.Several wallet tests insert spends of wallet coins with empty witnesses, which the wallet no longer takes in. On main with 3.2.1:
a_sync_evicting_a_pending_send_returns_it_to_the_walletan_evicted_fee_bump_returns_over_the_transaction_it_replacedan_evicted_send_does_not_return_over_other_transactionsan_on_chain_fee_bump_passes_a_transaction_that_funds_no_channelan_on_chain_fee_bump_refuses_a_transaction_whose_facts_cannot_be_readan_on_chain_fee_bump_refuses_while_the_channel_state_cannot_be_consultedbump_fee_rbf_keeps_replaced_txid_mappedconfirmed_unlocked_amount_does_not_depend_on_seeing_a_spliceevicted_sends_return_along_with_the_sends_they_spendInvalidPaymentId, which is also what a transaction missing from the wallet yields:an_on_chain_fee_bump_refuses_a_transaction_a_channel_reportedan_on_chain_fee_bump_refuses_a_transaction_spending_a_coin_the_wallet_does_not_ownan_on_chain_fee_bump_refuses_a_transaction_whose_output_belongs_to_a_channelan_evicted_fee_bump_does_not_return_over_a_confirmed_transactionexpects the bump to stay out of the wallet, where it never was.This PR signs those inputs in the test helpers. The helpers also assert that the wallet took the transaction in, so that a transaction dropped again fails the test that inserts it.
Production code
Only tests change. The wallet's descriptors are BIP84, so every input it owns is P2WPKH, and its signature verifies from that input's own previous output. The case the release notes warn about (a taproot input next to foreign inputs, for which Electrum users should sync with
fetch_prev_txouts = true) does not arise, and our Electrum sync already passestrue. Transactions a chain source relays are signed, and the ones the node inserts itself are signed first.Testing
cargo test --libwith 3.2.1 in the lock file: 478 passed, 9 failed on main; 487 passed with this PR.cargo test --libwith 3.2.0: 487 passed with this PR.OnchainPaymentTracker#1240 addsa_late_funding_classification_tracks_the_channels, which fails on 3.2.1 for the same reason. With this commit on top of its head3d522b8b, all 495 lib tests pass.🤖 Generated with Claude Code