Registry Mirror
Skip to content

Conversation

@jkczyz

@jkczyz jkczyz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

bdk_wallet 3.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_update and Wallet::apply_unconfirmed_txs drop the transaction and Wallet::build_fee_bump refuses it. We ask for bdk_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:

  • Nine lib tests fail:
    • a_sync_evicting_a_pending_send_returns_it_to_the_wallet
    • an_evicted_fee_bump_returns_over_the_transaction_it_replaced
    • an_evicted_send_does_not_return_over_other_transactions
    • an_on_chain_fee_bump_passes_a_transaction_that_funds_no_channel
    • an_on_chain_fee_bump_refuses_a_transaction_whose_facts_cannot_be_read
    • an_on_chain_fee_bump_refuses_while_the_channel_state_cannot_be_consulted
    • bump_fee_rbf_keeps_replaced_txid_mapped
    • confirmed_unlocked_amount_does_not_depend_on_seeing_a_splice
    • evicted_sends_return_along_with_the_sends_they_spend
  • Four more keep passing without the transaction they are about:
    • Three expect a fee bump to be refused with InvalidPaymentId, which is also what a transaction missing from the wallet yields:
      • an_on_chain_fee_bump_refuses_a_transaction_a_channel_reported
      • an_on_chain_fee_bump_refuses_a_transaction_spending_a_coin_the_wallet_does_not_own
      • an_on_chain_fee_bump_refuses_a_transaction_whose_output_belongs_to_a_channel
    • an_evicted_fee_bump_does_not_return_over_a_confirmed_transaction expects 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 passes true. Transactions a chain source relays are signed, and the ones the node inserts itself are signed first.

Testing

  • cargo test --lib with 3.2.1 in the lock file: 478 passed, 9 failed on main; 487 passed with this PR.
  • cargo test --lib with 3.2.0: 487 passed with this PR.
  • Turn the pending payment store into an OnchainPaymentTracker #1240 adds a_late_funding_classification_tracks_the_channels, which fails on 3.2.1 for the same reason. With this commit on top of its head 3d522b8b, all 495 lib tests pass.

🤖 Generated with Claude Code

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>
@ldk-reviews-bot

ldk-reviews-bot commented Nov 23, 2026 •

Copy link
Copy Markdown

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tnull
tnull merged commit fb63dfe into lightningdevkit:main Nov 24, 2026
15 of 27 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants