Silent Payments: Sending (take 2) #35302

Open
Eunovo wants to merge 16 commits from implement-bip352-sending into master AGit
Eunovo commented 2026-05-16 04:16:08 +00:00 (Migrated from github.com)

This PR is part of integrating silent payments into Bitcoin Core. It is the second iteration of https://github.com/bitcoin/bitcoin/pull/28201. Status and tracking for the project is managed in https://github.com/bitcoin/bitcoin/issues/28536

Prerequisite PRs:

Sending

Silent Payments logic
Key things to note in this PR:

  • PaymentDestination is added to contain CTxDestination or SilentPaymentsDestination
  • coin selection logic for silent payments requires at least one shared secret derivation-eligible coin to be present in the result set
  • recipient silent payments destinations are now persisted to the wallet to make it possible to RBF
  • silent payment txs created on the latest wallet software then loaded into older software are not replaceable
  • any operation that produces a silent payments tx that is not safe to fee bump later is blocked; this includes operations that create psbts and send with add_to_wallet=False
This PR is part of integrating silent payments into Bitcoin Core. It is the second iteration of https://github.com/bitcoin/bitcoin/pull/28201. Status and tracking for the project is managed in https://github.com/bitcoin/bitcoin/issues/28536 Prerequisite PRs: - [x] https://github.com/bitcoin/bitcoin/pull/35301 - [ ] https://github.com/bitcoin/bitcoin/pull/36962 ### Sending **Silent Payments logic** Key things to note in this PR: - `PaymentDestination` is added to contain `CTxDestination` or `SilentPaymentsDestination` - coin selection logic for silent payments requires at least one shared secret derivation-eligible coin to be present in the result set - recipient silent payments destinations are now persisted to the wallet to make it possible to RBF - silent payment txs created on the latest wallet software then loaded into older software are not replaceable - any operation that produces a silent payments tx that is not safe to fee bump later is blocked; this includes operations that create psbts and send with `add_to_wallet=False`
DrahtBot commented 2026-05-16 04:16:16 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK rkrux, w0xlt, rustaceanrob, polespinasa, davidgumberg
Stale ACK Yudis-bit, fametrano

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37017 (wallet: Use util::Result for fee bumping methods by rustaceanrob)
  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36978 (rpc: require a hex string for OP_RETURN data by l0rinc)
  • #36976 (rpc: Use OBJ_NAMED_PARAMS in estimatesmartfee by maflcko)
  • #36962 (wallet/feebumper: reject an original_change_index output without a destination by Eunovo)
  • #36946 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
  • #36897 (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101)
  • #36885 (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc)
  • #36823 (wallet, migration: Skip legacy wallet records rather than erasing them, and drop unused record erase functions by achow101)
  • #36167 (build: Enable -Wunused by fanquake)
  • #35998 (wallet: Handle or explicitly ignore WalletBatch write failures by achow101)
  • #35444 (wallet: make descriptor SPKM mutex non-recursive by w0xlt)
  • #34872 (wallet: fix mixed-input transaction accounting in history RPCs by w0xlt)
  • #34698 (wallet: handle MiniMiner bump fee calculation failures by shuv-amp)
  • #34405 (wallet: skip APS when no partial spend exists by 8144225309)
  • #32857 (wallet: allow skipping script paths by Sjors)
  • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
  • #27260 (Enhanced error messages for invalid network prefix during address parsing. by portlandhodl)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • src/wallet/spend.cpp: CreateTransaction(wallet, recipients, /*change_pos=*/std::nullopt, new_coin_control, false)

Possible places where comparison-specific test macros should replace generic comparisons:

  • test/functional/wallet_sendall.py: assert 0 < self.wallet.getbalances()["mine"]["trusted"] → Prefer assert_greater_than(self.wallet.getbalances()["mine"]["trusted"], 0).

2026-12-03 14:42:53

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35302 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35302.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35302#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [rkrux](https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-4496579793), [w0xlt](https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-6093027739), [rustaceanrob](https://github.com/bitcoin/bitcoin/pull/35302#pullrequestreview-5466883215), [polespinasa](https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-6601889671), [davidgumberg](https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-6700596092) | | Stale ACK | [Yudis-bit](https://github.com/bitcoin/bitcoin/pull/35302#pullrequestreview-5802044782), [fametrano](https://github.com/bitcoin/bitcoin/pull/35302#pullrequestreview-5849905130) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#37017](https://github.com/bitcoin/bitcoin/pull/37017) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37017.svg"></sub> (wallet: Use `util::Result` for fee bumping methods by rustaceanrob) * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#36978](https://github.com/bitcoin/bitcoin/pull/36978) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36978.svg"></sub> (rpc: require a hex string for OP_RETURN data by l0rinc) * [#36976](https://github.com/bitcoin/bitcoin/pull/36976) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36976.svg"></sub> (rpc: Use OBJ_NAMED_PARAMS in estimatesmartfee by maflcko) * [#36962](https://github.com/bitcoin/bitcoin/pull/36962) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36962.svg"></sub> (wallet/feebumper: reject an `original_change_index` output without a destination by Eunovo) * [#36946](https://github.com/bitcoin/bitcoin/pull/36946) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36946.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) * [#36897](https://github.com/bitcoin/bitcoin/pull/36897) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36897.svg"></sub> (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101) * [#36885](https://github.com/bitcoin/bitcoin/pull/36885) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36885.svg"></sub> (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc) * [#36823](https://github.com/bitcoin/bitcoin/pull/36823) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36823.svg"></sub> (wallet, migration: Skip legacy wallet records rather than erasing them, and drop unused record erase functions by achow101) * [#36167](https://github.com/bitcoin/bitcoin/pull/36167) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> (build: Enable `-Wunused` by fanquake) * [#35998](https://github.com/bitcoin/bitcoin/pull/35998) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35998.svg"></sub> (wallet: Handle or explicitly ignore `WalletBatch` write failures by achow101) * [#35444](https://github.com/bitcoin/bitcoin/pull/35444) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35444.svg"></sub> (wallet: make descriptor SPKM mutex non-recursive by w0xlt) * [#34872](https://github.com/bitcoin/bitcoin/pull/34872) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34872.svg"></sub> (wallet: fix mixed-input transaction accounting in history RPCs by w0xlt) * [#34698](https://github.com/bitcoin/bitcoin/pull/34698) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34698.svg"></sub> (wallet: handle MiniMiner bump fee calculation failures by shuv-amp) * [#34405](https://github.com/bitcoin/bitcoin/pull/34405) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34405.svg"></sub> (wallet: skip APS when no partial spend exists by 8144225309) * [#32857](https://github.com/bitcoin/bitcoin/pull/32857) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32857.svg"></sub> (wallet: allow skipping script paths by Sjors) * [#27865](https://github.com/bitcoin/bitcoin/pull/27865) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27865.svg"></sub> (wallet: Track no-longer-spendable TXOs separately by achow101) * [#27260](https://github.com/bitcoin/bitcoin/pull/27260) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27260.svg"></sub> (Enhanced error messages for invalid network prefix during address parsing. by portlandhodl) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible places where named args for integral literals may be used (e.g. `func(x, /*named_arg=*/0)` in C++, and `func(x, named_arg=0)` in Python): - `src/wallet/spend.cpp`: `CreateTransaction(wallet, recipients, /*change_pos=*/std::nullopt, new_coin_control, false)` Possible places where comparison-specific test macros should replace generic comparisons: - `test/functional/wallet_sendall.py`: `assert 0 < self.wallet.getbalances()["mine"]["trusted"]` → Prefer `assert_greater_than(self.wallet.getbalances()["mine"]["trusted"], 0)`. <sup>2026-12-03 14:42:53</sup>
rkrux commented 2026-05-20 09:11:27 +00:00 (Migrated from github.com)

Concept ACK 03c835d

Concept ACK [03c835d](https://github.com/bitcoin/bitcoin/pull/35302/commits/03c835dbd6d78182b546713ed495373c7d07b01c)
theStack (Migrated from github.com) reviewed 2026-05-23 01:50:51 +00:00
theStack (Migrated from github.com) commented 2026-05-23 01:42:41 +00:00

in e3ef349ad5: any reason why the coin_control instance got moved up?

in e3ef349ad5ad2bc283644b5faaa1a6fa234e16bd: any reason why the coin_control instance got moved up?
theStack (Migrated from github.com) commented 2026-05-23 01:45:52 +00:00

in e3ef349ad5: for functions starting with Is, I'd usually expect to return a boolean value. maybe rename with using Ensure as a prefix instead?

in e3ef349ad5ad2bc283644b5faaa1a6fa234e16bd: for functions starting with `Is`, I'd usually expect to return a boolean value. maybe rename with using `Ensure` as a prefix instead?
theStack (Migrated from github.com) commented 2026-05-23 01:41:57 +00:00

in e3ef349ad5: could slightly simplify by using std::any_of instead (returns a bool instead of an iterator)

in e3ef349ad5ad2bc283644b5faaa1a6fa234e16bd: could slightly simplify by using `std::any_of` instead (returns a bool instead of an iterator)
theStack (Migrated from github.com) commented 2026-05-23 01:21:45 +00:00

in f9a10e9ea9: I think it would be more robust to express this condition using the explicit list of relevant output script types as specified in the BIP, i.e. return early if whichType is not any of P2TR, P2WPKH, P2SH-P2WPKH or P2PKH. Otherwise, the condition has to be extended whenever the TxoutType enum class gets extended (e.g. P2A has been added since and is not there in the condition).

in f9a10e9ea9b57f6b21a6dbfd1239c3ba60f721f8: I think it would be more robust to express this condition using the explicit list of relevant output script types as [specified in the BIP](https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#user-content-Inputs_For_Shared_Secret_Derivation), i.e. return early if whichType is _not_ any of P2TR, P2WPKH, P2SH-P2WPKH or P2PKH. Otherwise, the condition has to be extended whenever the TxoutType enum class gets extended (e.g. P2A has been added since and is not there in the condition).
theStack (Migrated from github.com) commented 2026-05-23 01:34:58 +00:00

f9a10e9ea9: nit: is this line needed? Not sure what the exact rules in C++ are about the single underscore identifier, but I haven't seen this fake-use pattern (probably with the intention to avoid warnings) in other similar places where we use it.

f9a10e9ea9b57f6b21a6dbfd1239c3ba60f721f8: nit: is this line needed? Not sure what the exact rules in C++ are about the single underscore identifier, but I haven't seen this fake-use pattern (probably with the intention to avoid warnings) in other similar places where we use it.
Eunovo commented 2026-05-25 11:45:40 +00:00 (Migrated from github.com)
@theStack I'll attend to your reviews when I rebase on https://github.com/bitcoin/bitcoin/pull/35301
Eunovo (Migrated from github.com) reviewed 2026-06-07 11:07:45 +00:00
Eunovo (Migrated from github.com) commented 2026-06-07 11:07:45 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-06-07 11:07:58 +00:00
Eunovo (Migrated from github.com) commented 2026-06-07 11:07:58 +00:00

Removed.

Removed.
Eunovo (Migrated from github.com) reviewed 2026-06-07 11:08:09 +00:00
Eunovo (Migrated from github.com) commented 2026-06-07 11:08:09 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-06-07 11:08:18 +00:00
Eunovo (Migrated from github.com) commented 2026-06-07 11:08:18 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-06-07 11:08:43 +00:00
Eunovo (Migrated from github.com) commented 2026-06-07 11:08:43 +00:00

Reverted.

Reverted.
DrahtBot commented 2026-06-07 11:15:24 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/27090770600/job/79953877713
LLM reason (✨ experimental): (empty)

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `lint`: https://github.com/bitcoin/bitcoin/actions/runs/27090770600/job/79953877713</sub> <sub>LLM reason (✨ experimental): (empty)</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-06-12 10:56:20 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
rkrux (Migrated from github.com) reviewed 2026-06-24 14:09:12 +00:00
rkrux (Migrated from github.com) left a comment

Reviewed only the last testing commit partially 989d354 "tests: add sending functional tests".

Reviewed only the last testing commit partially 989d354 "tests: add sending functional tests".
rkrux (Migrated from github.com) commented 2026-06-24 13:41:52 +00:00

In 989d3548c6933a4bc31b82a6f950029440e1d232 "tests: add sending functional tests"

descriptors=True

Please remove all occurrences of this createwallet argument, it's not required post disallowing loading legacy wallets.

I see a new SP specific wallet flag is introduced in the SP receiving PR #32966. I have not checked the implementation yet but from a pure functionality POV, the addition of that new wallet flag should not necessitate the passing of the descriptors flag now (which I assume, in all likelihood, is not happening and thus this flag should be removed from the tests).

In 989d3548c6933a4bc31b82a6f950029440e1d232 "tests: add sending functional tests" > descriptors=True Please remove all occurrences of this createwallet argument, it's not required post disallowing loading legacy wallets. I see a new SP specific wallet flag is introduced in the SP receiving PR #32966. I have not checked the implementation yet but from a pure functionality POV, the addition of that new wallet flag should not necessitate the passing of the descriptors flag now (which I assume, in all likelihood, is not happening and thus this flag should be removed from the tests).
rkrux (Migrated from github.com) commented 2026-06-24 13:44:08 +00:00

In 989d354 "tests: add sending functional tests"

"replaceable": True

Please remove all occurrences of this in transaction/psbt creation/fund/send RPCs that are being used in this test. PR #35433 seeks to deprecate it (hopefully in the upcoming release) because of prevalence of fullrbf in the network and we shouldn't encourage the use of this argument in the functional tests.

In 989d354 "tests: add sending functional tests" > "replaceable": True Please remove all occurrences of this in transaction/psbt creation/fund/send RPCs that are being used in this test. PR #35433 seeks to deprecate it (hopefully in the upcoming release) because of prevalence of fullrbf in the network and we shouldn't encourage the use of this argument in the functional tests.
rkrux (Migrated from github.com) commented 2026-06-24 13:58:09 +00:00

In 989d354 "tests: add sending functional tests"

github.com/bitcoin/bitcoin@d84fc352cb/src/wallet/rpc/spend.cpp (L1003-L1006)

  1. There's an outputs argument in the (psbt)bumpfee RPCs that allows to add new outputs in the replacing transaction. Please add a test case covering the behaviour when this argument is passed while replacing a silent payment transaction.
  2. Please also add a test case covering the scenario where the user is able to rbf-cancel the SP transaction by sending the funds to themselves.
In 989d354 "tests: add sending functional tests" https://github.com/bitcoin/bitcoin/blob/d84fc352cbc1363df5cd6024a22e73fc63283e4f/src/wallet/rpc/spend.cpp#L1003-L1006 1. There's an outputs argument in the (psbt)bumpfee RPCs that allows to add new outputs in the replacing transaction. Please add a test case covering the behaviour when this argument is passed while replacing a silent payment transaction. 2. Please also add a test case covering the scenario where the user is able to rbf-cancel the SP transaction by sending the funds to themselves.
DrahtBot commented 2026-06-26 09:37:07 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task Windows native, fuzz, VS: https://github.com/bitcoin/bitcoin/actions/runs/28226175984/job/83618564020
LLM reason (✨ experimental): CI failed because the fuzz RPC target errored out: scantxforsilentpayments RPC command is missing from rpc.cpp’s RPC_COMMANDS_SAFE_FOR_FUZZING/RPC_COMMANDS_NOT_SAFE_FOR_FUZZING.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Windows native, fuzz, VS`: https://github.com/bitcoin/bitcoin/actions/runs/28226175984/job/83618564020</sub> <sub>LLM reason (✨ experimental): CI failed because the fuzz RPC target errored out: `scantxforsilentpayments` RPC command is missing from `rpc.cpp`’s `RPC_COMMANDS_SAFE_FOR_FUZZING`/`RPC_COMMANDS_NOT_SAFE_FOR_FUZZING`.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
Eunovo (Migrated from github.com) reviewed 2026-06-26 09:38:15 +00:00
Eunovo (Migrated from github.com) reviewed 2026-06-26 09:38:28 +00:00
Eunovo (Migrated from github.com) reviewed 2026-06-26 09:38:59 +00:00
Eunovo (Migrated from github.com) commented 2026-06-26 09:38:59 +00:00

Added new tests for bumpfee with the outputs replaced.

Added new tests for bumpfee with the outputs replaced.
rkrux (Migrated from github.com) reviewed 2026-06-27 13:14:19 +00:00
rkrux (Migrated from github.com) left a comment

Thanks for addressing the previous suggestions in both the source code and the tests - git range-diff 989d354...22e42cb

Partial review of the test commit 22e42cb "tests: add sending functional tests".

Thanks for addressing the previous suggestions in both the source code and the tests - git range-diff 989d354...22e42cb Partial review of the test commit 22e42cb "tests: add sending functional tests".
rkrux (Migrated from github.com) commented 2026-06-27 12:48:15 +00:00

In 22e42cb9b58a3406ab1870be71aa38f861fbba4d "tests: add sending functional tests"

After PR #35543 is merged, we don't need to (manually find and) hardcode xprvs and xpubs in the functional tests anymore. Something like the following can be done, similar to how ECKey.generate() is used:

from test_framework.extendedkey import ExtendedPrivateKey
...
extended_key = ExtendedPrivateKey.generate()
xprv, xpub = extended_key.to_string(), extended_key.pubkey().to_string()
In 22e42cb9b58a3406ab1870be71aa38f861fbba4d "tests: add sending functional tests" After PR #35543 is merged, we don't need to (manually find and) hardcode xprvs and xpubs in the functional tests anymore. Something like the following can be done, similar to how `ECKey.generate()` is used: ```python from test_framework.extendedkey import ExtendedPrivateKey ... extended_key = ExtendedPrivateKey.generate() xprv, xpub = extended_key.to_string(), extended_key.pubkey().to_string() ```
rkrux (Migrated from github.com) commented 2026-06-27 12:49:59 +00:00

In 22e42cb9b58a3406ab1870be71aa38f861fbba4d "tests: add sending functional tests"

I assume it's taken from wallet_taproot.py? It's dead code and should be removed.

In 22e42cb9b58a3406ab1870be71aa38f861fbba4d "tests: add sending functional tests" I assume it's taken from wallet_taproot.py? It's dead code and should be removed.
rkrux (Migrated from github.com) commented 2026-06-27 12:52:31 +00:00

In 22e42cb9b58a3406ab1870be71aa38f861fbba4d "tests: add sending functional tests"

There are many asserts in the file of the form assert X == Y. Not sure why the Drahtbot has not mentioned in this PR (because it has commented on several PRs before), but the preference is to use the assert_equal(X, Y) utility function from the testing framework.

In 22e42cb9b58a3406ab1870be71aa38f861fbba4d "tests: add sending functional tests" There are many asserts in the file of the form `assert X == Y`. Not sure why the Drahtbot has not mentioned in this PR (because it has commented on several PRs before), but the preference is to use the `assert_equal(X, Y)` utility function from the testing framework.
rkrux (Migrated from github.com) commented 2026-06-27 13:04:17 +00:00

In 22e42cb "tests: add sending functional tests"

For all these cases where the testing functionality is preceded by setup() and succeeded by cleanup(), a local context manager can be used for readability. Refer how a custom WalletUnlock context manager is used.

github.com/bitcoin/bitcoin@7a74f65293/test/functional/test_framework/wallet_util.py (L95-L112)

In 22e42cb "tests: add sending functional tests" For all these cases where the testing functionality is preceded by setup() and succeeded by cleanup(), a local context manager can be used for readability. Refer how a custom WalletUnlock context manager is used. https://github.com/bitcoin/bitcoin/blob/7a74f6529357cf78ee74f0316b9502664f56889e/test/functional/test_framework/wallet_util.py#L95-L112
rkrux (Migrated from github.com) commented 2026-06-27 12:56:27 +00:00

In 22e42cb "tests: add sending functional tests"

Similar to the equality: s/assert X <= Y/assert_greater_than(Y, X)

In 22e42cb "tests: add sending functional tests" Similar to the equality: `s/assert X <= Y/assert_greater_than(Y, X)`
Eunovo (Migrated from github.com) reviewed 2026-06-29 08:55:26 +00:00
Eunovo (Migrated from github.com) commented 2026-06-29 08:55:26 +00:00

It seems a bit overkill to create a Context Manager class for this one test function. I think the current setup-cleanup code is better for this case

It seems a bit overkill to create a Context Manager class for this one test function. I think the current `setup-cleanup` code is better for this case
Eunovo (Migrated from github.com) reviewed 2026-06-29 09:04:21 +00:00
Eunovo (Migrated from github.com) commented 2026-06-29 09:04:21 +00:00

Will fix when I rebase.

Will fix when I rebase.
Eunovo (Migrated from github.com) reviewed 2026-06-29 09:22:17 +00:00
Eunovo (Migrated from github.com) commented 2026-06-29 09:22:17 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-06-29 09:22:25 +00:00
Eunovo (Migrated from github.com) commented 2026-06-29 09:22:25 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-06-29 09:22:44 +00:00
Eunovo (Migrated from github.com) commented 2026-06-29 09:22:44 +00:00

Done.

Done.
rkrux (Migrated from github.com) reviewed 2026-06-30 09:50:04 +00:00
rkrux (Migrated from github.com) commented 2026-06-30 09:50:04 +00:00

There is a precedent (or soon going to be) of using context managers in a single test file: https://github.com/bitcoin/bitcoin/pull/35003/changes#diff-815ba9df1be928d33d72629e1cdd6208a68493b24a4cdee0c823fb0375acd44aR34-R47

I think it seems reasonable to create and use a context manager if it improves readability.
I also feel it's a nice-to-have and not a must-have.

There is a precedent (or soon going to be) of using context managers in a single test file: https://github.com/bitcoin/bitcoin/pull/35003/changes#diff-815ba9df1be928d33d72629e1cdd6208a68493b24a4cdee0c823fb0375acd44aR34-R47 I think it seems reasonable to create and use a context manager if it improves readability. I also feel it's a nice-to-have and not a must-have.
Eunovo (Migrated from github.com) reviewed 2026-07-01 06:40:44 +00:00
Eunovo (Migrated from github.com) commented 2026-07-01 06:40:44 +00:00

Changed the code to use the generator context manager pattern.

Changed the code to use the generator context manager pattern.
Eunovo commented 2026-07-07 15:09:27 +00:00 (Migrated from github.com)

CI failure seems unrelated.

CI failure seems unrelated.
DrahtBot commented 2026-07-13 22:24:53 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Eunovo (Migrated from github.com) reviewed 2026-07-24 15:25:50 +00:00
Eunovo (Migrated from github.com) commented 2026-07-24 15:25:50 +00:00

Fixed.

Fixed.
DrahtBot commented 2026-08-04 22:56:42 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
First-time contributor

11 additional verified findings in the Review report.

Earlier concerns neither republished nor resolved: 1 major finding · 1 minor finding · 3 suggestions. See the Run archive linked from the Review report for their assessments.

🟠 Minor · Automatic selection can omit every silent-payment-eligible input

A wallet with spendable 10 BTC P2WSH and 1 BTC P2TR coins cannot automatically send 5 BTC to a silent-payment address, even though a valid mixed input set exists.

Location: src/wallet/spend.cpp:1459 (head).

🟠 Minor · Restored silent-payment sends lose fee-bump protection

Restoring without construction metadata lets bumpfee preserve silent-payment scripts while changing their derivation inputs, so scanning only the replacement can miss the payment.

Location: src/wallet/feebumper.cpp:272 (head).

🟠 Minor · Rejected silent-payment requests can leave inputs locked

With lock_unspents=true, an otherwise fundable silent-payment request can return an error after locking inputs, leaving them unavailable to automatic selection until explicitly unlocked or the wallet restarts.

Location: src/wallet/rpc/spend.cpp:1367 (head).

🔵 Suggestion · Failed replacement writes still erase recipient metadata

If WriteTxMetadata fails but EraseSpRecipients succeeds, the stored transaction retains its silent-payment marker while losing the recipients needed to bump it.

Location: src/wallet/wallet.cpp:973 (head).

🔵 Suggestion · Silent-payment recipients without the mode flag reach Assert

An SP CRecipient passed without m_silent_payments can abort instead of returning an error, although no current caller supplying that combination was found.

Location: src/wallet/spend.cpp:1468 (head).

🔵 Suggestion · Identical SP recommits violate Assume(new_tx)

A deterministic resend of an abandoned silent-payment transaction can abort a build that enforces Assume, because its txid already exists in the wallet.

Location: src/wallet/wallet.cpp:2133 (head).

Review coverage was incomplete.


Reviewed: b81cb5f71c5e · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:e1a29e5e677c47d383756f0fcf8f3760725c91d1104dd3ccb2f333b6217eba26:47880f5569fd2047d249266f337c4f2a509adf7d96c3ccb1c7644c2c2a650bff --> <!-- ralph-base:19209e520634ea5e55757895229fe2881105b71e --> <!-- ralph-head:b81cb5f71c5ecc532049f507020e2fe54a59636c --> <!-- ralph-case:c803d5d5f53561c84a15d17f9d5bef4840bffa980539d03cc95c9c9cfcd468a4 --> [11 additional verified findings in the Review report](<https://review.fish.foo/report/35302-b81cb5f71c5ecc532049f507020e2fe54a59636c-3488-21.html>). Earlier concerns neither republished nor resolved: 1 major finding · 1 minor finding · 3 suggestions. See the Run archive linked from the Review report for their assessments. **🟠 Minor · Automatic selection can omit every silent-payment-eligible input** A wallet with spendable 10 BTC P2WSH and 1 BTC P2TR coins cannot automatically send 5 BTC to a silent-payment address, even though a valid mixed input set exists. Location: [`src/wallet/spend.cpp:1459`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c/src/wallet/spend.cpp#L1459>) (head). **🟠 Minor · Restored silent-payment sends lose fee-bump protection** Restoring without construction metadata lets `bumpfee` preserve silent-payment scripts while changing their derivation inputs, so scanning only the replacement can miss the payment. Location: [`src/wallet/feebumper.cpp:272`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c/src/wallet/feebumper.cpp#L272>) (head). **🟠 Minor · Rejected silent-payment requests can leave inputs locked** With `lock_unspents=true`, an otherwise fundable silent-payment request can return an error after locking inputs, leaving them unavailable to automatic selection until explicitly unlocked or the wallet restarts. Location: [`src/wallet/rpc/spend.cpp:1367`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c/src/wallet/rpc/spend.cpp#L1367>) (head). **🔵 Suggestion · Failed replacement writes still erase recipient metadata** If `WriteTxMetadata` fails but `EraseSpRecipients` succeeds, the stored transaction retains its silent-payment marker while losing the recipients needed to bump it. Location: [`src/wallet/wallet.cpp:973`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c/src/wallet/wallet.cpp#L973>) (head). **🔵 Suggestion · Silent-payment recipients without the mode flag reach `Assert`** An SP `CRecipient` passed without `m_silent_payments` can abort instead of returning an error, although no current caller supplying that combination was found. Location: [`src/wallet/spend.cpp:1468`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c/src/wallet/spend.cpp#L1468>) (head). **🔵 Suggestion · Identical SP recommits violate `Assume(new_tx)`** A deterministic resend of an abandoned silent-payment transaction can abort a build that enforces `Assume`, because its txid already exists in the wallet. Location: [`src/wallet/wallet.cpp:2133`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c/src/wallet/wallet.cpp#L2133>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`b81cb5f71c5e`](<https://git.fish.foo/bitcoin/bitcoin/commit/b81cb5f71c5ecc532049f507020e2fe54a59636c>) · [Review report](<https://review.fish.foo/report/35302-b81cb5f71c5ecc532049f507020e2fe54a59636c-3488-21.html>) · [Previous reports](<https://review.fish.foo/traces/35302/>) [permalink](<https://review.fish.foo/report/35302-b81cb5f71c5ecc532049f507020e2fe54a59636c-3488-21.html>)
Eunovo commented 2026-10-03 22:03:23 +00:00 (Migrated from github.com)
This PR has changed drastically due to feedback from https://github.com/bitcoin/bitcoin/pull/35301 and other edge cases that were spotted and handled. See https://github.com/bitcoin/bitcoin/pull/35302#issue-4458487609 for some key ideas in this PR.
Yudis-bit commented 2026-10-04 03:48:40 +00:00 (Migrated from github.com)

The Windows native, VS failure in CI is reproducible on MSVC and directly related to src/qt/walletmodel.cpp:457:

src\qt\walletmodel.cpp(457,38): error C2280: 'WalletModel::UnlockContext::UnlockContext(WalletModel::UnlockContext &&)': attempting to reference a deleted function

The ternary operator is_silent_payments ? requestUnlock() : UnlockContext(this, false, false) requires the common type of both prvalue operands to be move-constructible under MSVC, but move constructors were explicitly deleted in 9fa43b5af6 (UnlockContext(UnlockContext&&) = delete;). GCC and Clang elide the temporary, but MSVC strictly enforces the standard requirement here.

Initializing sp_ctx via an immediately-invoked lambda avoids the move constructor requirement entirely through guaranteed copy elision:

    const auto sp_ctx = [&] {
        if (is_silent_payments) {
            return requestUnlock();
        }
        return UnlockContext(this, /*valid=*/false, /*relock=*/false);
    }();

Alternatively, move semantics could be restored to UnlockContext in src/qt/walletmodel.h by making relock non-const and transferring ownership with relock(std::exchange(other.relock, false)).

The `Windows native, VS` failure in CI is reproducible on MSVC and directly related to `src/qt/walletmodel.cpp:457`: ```text src\qt\walletmodel.cpp(457,38): error C2280: 'WalletModel::UnlockContext::UnlockContext(WalletModel::UnlockContext &&)': attempting to reference a deleted function ``` The ternary operator `is_silent_payments ? requestUnlock() : UnlockContext(this, false, false)` requires the common type of both prvalue operands to be move-constructible under MSVC, but move constructors were explicitly deleted in `9fa43b5af6` (`UnlockContext(UnlockContext&&) = delete;`). GCC and Clang elide the temporary, but MSVC strictly enforces the standard requirement here. Initializing `sp_ctx` via an immediately-invoked lambda avoids the move constructor requirement entirely through guaranteed copy elision: ```cpp const auto sp_ctx = [&] { if (is_silent_payments) { return requestUnlock(); } return UnlockContext(this, /*valid=*/false, /*relock=*/false); }(); ``` Alternatively, move semantics could be restored to `UnlockContext` in `src/qt/walletmodel.h` by making `relock` non-const and transferring ownership with `relock(std::exchange(other.relock, false))`.
Yudis-bit commented 2026-10-07 19:59:35 +00:00 (Migrated from github.com)

A few subtle edge cases around descriptor key derivation, RBF state persistence, and coin selection diverge across the branch.

In src/wallet/spend.cpp, IsInputForSharedSecretDerivation assumes any Taproot output where internal_key != NUMS_H is eligible. For descriptors where the wallet only owns a leaf key (tr(unspendable_key, pk(leaf))), this returns true, but CreateSilentPaymentsOutputs subsequently fails with Missing the private key of silent payments eligible input COutPoint(...) when GetPrivKeyForSilentPayments cannot tweak the missing internal key. On the PUBKEYHASH branch, IsInputForSharedSecretDerivation also assumes unresolvable inputs are compressed if provider->GetPubKey fails.

This causes an inconsistency between send and sendall. AvailableCoins skips all Taproot coins with script path spend data, causing sendall without inputs to fail with an error instructing the user to choose coins via inputs. If those coins are supplied to send, line 382 explicitly rejects them with Found script data for ... Only key path spends are allowed. If supplied to sendall, the transaction succeeds when the wallet owns both keys because sendall's input path bypasses HasTaprootScriptPath.

In src/wallet/feebumper.cpp:460, CommitTransaction calls EraseSpRecipients(oldWtx.GetHash()), erasing the original transaction's recipient metadata from the wallet database. If the replacement is evicted from the mempool or dropped while an older block template mines the original transaction, the record of who it paid to is permanently lost. Since database records are keyed per transaction, keeping historical recipient records is harmless and avoids state loss during reorgs.

Relatedly, multiplexing m_is_sp_tx into string_values["replaced_by_txid"] using GetHash().ToString() in src/wallet/transaction.h only persists until the transaction is bumped. Once replaced, m_replaced_by_txid becomes the new transaction id. On the next wallet load, key == "replaced_by_txid" sees the replacement txid rather than GetHash(), leaving m_is_sp_tx as false. Combined with EraseSpRecipients, a replaced transaction loses its silent payments identity entirely across restarts.

In AttemptSelectionSP (spend.cpp:1058), anchor candidates are restricted to positive_group. At high fee rates, a small eligible coin (such as a 1,000 sat P2WPKH UTXO) can have effective_value <= 0 and land in negative_group. Even if the wallet holds large ineligible outputs (e.g. 5 BTC P2WSH) that easily cover the payment and fees, candidate collection comes up empty and fails with INSUFFICIENT_FUNDS. Additionally, when subtracting fees from outputs, candidates are sorted by effective_value while target reduction uses nominal value.

A few subtle edge cases around descriptor key derivation, RBF state persistence, and coin selection diverge across the branch. In `src/wallet/spend.cpp`, `IsInputForSharedSecretDerivation` assumes any Taproot output where `internal_key != NUMS_H` is eligible. For descriptors where the wallet only owns a leaf key (`tr(unspendable_key, pk(leaf))`), this returns `true`, but `CreateSilentPaymentsOutputs` subsequently fails with `Missing the private key of silent payments eligible input COutPoint(...)` when `GetPrivKeyForSilentPayments` cannot tweak the missing internal key. On the `PUBKEYHASH` branch, `IsInputForSharedSecretDerivation` also assumes unresolvable inputs are compressed if `provider->GetPubKey` fails. This causes an inconsistency between `send` and `sendall`. `AvailableCoins` skips all Taproot coins with script path spend data, causing `sendall` without inputs to fail with an error instructing the user to choose coins via `inputs`. If those coins are supplied to `send`, line 382 explicitly rejects them with `Found script data for ... Only key path spends are allowed`. If supplied to `sendall`, the transaction succeeds when the wallet owns both keys because `sendall`'s input path bypasses `HasTaprootScriptPath`. In `src/wallet/feebumper.cpp:460`, `CommitTransaction` calls `EraseSpRecipients(oldWtx.GetHash())`, erasing the original transaction's recipient metadata from the wallet database. If the replacement is evicted from the mempool or dropped while an older block template mines the original transaction, the record of who it paid to is permanently lost. Since database records are keyed per transaction, keeping historical recipient records is harmless and avoids state loss during reorgs. Relatedly, multiplexing `m_is_sp_tx` into `string_values["replaced_by_txid"]` using `GetHash().ToString()` in `src/wallet/transaction.h` only persists until the transaction is bumped. Once replaced, `m_replaced_by_txid` becomes the new transaction id. On the next wallet load, `key == "replaced_by_txid"` sees the replacement txid rather than `GetHash()`, leaving `m_is_sp_tx` as `false`. Combined with `EraseSpRecipients`, a replaced transaction loses its silent payments identity entirely across restarts. In `AttemptSelectionSP` (`spend.cpp:1058`), anchor candidates are restricted to `positive_group`. At high fee rates, a small eligible coin (such as a 1,000 sat P2WPKH UTXO) can have `effective_value <= 0` and land in `negative_group`. Even if the wallet holds large ineligible outputs (e.g. 5 BTC P2WSH) that easily cover the payment and fees, candidate collection comes up empty and fails with `INSUFFICIENT_FUNDS`. Additionally, when subtracting fees from outputs, candidates are sorted by `effective_value` while target reduction uses nominal value.
w0xlt commented 2026-10-10 02:54:31 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
rustaceanrob (Migrated from github.com) reviewed 2026-10-10 10:36:32 +00:00
rustaceanrob (Migrated from github.com) left a comment

Concept ACK, have lots of opinions on approach.

It seems a01dc8e712 could potentially be split out into a small PR. I think it is a simple and big readability improvement. Perhaps 09127c62b1 also could be split off.

Concept ACK, have lots of opinions on approach. It seems a01dc8e7123fd44d0786c41503e13c78ada1f516 could potentially be split out into a small PR. I think it is a simple and big readability improvement. Perhaps 09127c62b12b25d1fe26035e9fe3bcdd27b15c13 also could be split off.
rustaceanrob (Migrated from github.com) commented 2026-10-09 07:19:14 +00:00

The BIP allows for multiple outputs to the same recipient, which is particularly good for privacy:

^ Why allow for more than one output? Allowing Alice to break her payment to Bob into multiple amounts opens up a number of privacy improving techniques for Alice, making the transaction look like a CoinJoin or better hiding the change amount by splitting both the payment and change outputs into multiple amounts. It also allows for Alice and Carol to both have their own unique output paying Bob in the event they are in a collaborative transaction and both paying Bob's silent payment address.

Can we remove this and only check for duplicate CTxDestination in ParseOutputs? AFICT use of set in sendall is to compute the distribution of the remaining value over the addresses without amounts specified. I have a patch here that gets around it, but I will spend some time trying to make it a bit cleaner.

Diff removing the use of set
diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp
index 6b8ed82898..3284f4368e 100644
--- a/src/rpc/rawtransaction_util.cpp
+++ b/src/rpc/rawtransaction_util.cpp
@@ -115,7 +115,7 @@ UniValue NormalizeOutputs(const UniValue& outputs_in)
 std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& outputs, bool allow_silent_payments)
 {
     // Duplicate checking
-    std::set<PaymentDestination> destinations;
+    std::set<CTxDestination> destinations;
     std::vector<std::pair<PaymentDestination, CAmount>> parsed_outputs;
     bool has_data{false};
     const auto& keys{outputs.getKeys()};
@@ -142,7 +142,8 @@ std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue&
                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Silent payments are not supported by this RPC");
             }

-            if (!destinations.insert(*destination).second) {
+            const CTxDestination* tx_destination{destination->GetTxDestination()};
+            if (tx_destination && !destinations.insert(*tx_destination).second) {
                 throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
             }
             parsed_outputs.emplace_back(std::move(*destination), amount);
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 2684b4ce70..17c1bf1a46 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -1440,7 +1440,6 @@ RPCMethod sendall()
             PreventOutdatedOptions(options);


-            std::set<PaymentDestination> addresses_without_amount;
             UniValue recipient_key_value_pairs(UniValue::VARR);
             const UniValue& recipients{request.params[0]};
             for (unsigned int i = 0; i < recipients.size(); ++i) {
@@ -1449,15 +1448,12 @@ RPCMethod sendall()
                     UniValue rkvp(UniValue::VOBJ);
                     rkvp.pushKV(recipient.get_str(), 0);
                     recipient_key_value_pairs.push_back(std::move(rkvp));
-                    // Store the decoded destination, so it matches the outputs below
-                    // also when the address was given in another case (e.g. uppercase bech32)
-                    addresses_without_amount.insert(PaymentDestination::FromString(recipient.get_str()).value_or(PaymentDestination
{}));
                 } else {
                     recipient_key_value_pairs.push_back(recipient);
                 }
             }

-            if (addresses_without_amount.size() == 0) {
+            if (std::ranges::none_of(recipients.getValues(), [](const UniValue& recipient) { return recipient.isStr(); })) {
                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Must provide at least one address without a specified amount");
             }

@@ -1518,9 +1514,15 @@ RPCMethod sendall()
             // Output i pays to the address in key i of the normalized outputs
             const UniValue outputs{NormalizeOutputs(recipient_key_value_pairs)};
             const auto parsed_outputs{ParseOutputs(outputs, /*allow_silent_payments=*/true)};
-            std::map<size_t, SilentPaymentsDestination> sp_destinations;
+            std::vector<std::pair<PaymentDestination, std::optional<CAmount>>> sendall_outputs;
+            sendall_outputs.reserve(parsed_outputs.size());
             for (size_t i = 0; i < parsed_outputs.size(); ++i) {
-                if (const auto* sp = parsed_outputs[i].first.GetSilentPaymentsDestination()) {
+                const auto& [dest, amount] = parsed_outputs[i];
+                sendall_outputs.emplace_back(dest, recipients[i].isStr() ? std::nullopt : std::optional{amount});
+            }
+            std::map<size_t, SilentPaymentsDestination> sp_destinations;
+            for (size_t i = 0; i < sendall_outputs.size(); ++i) {
+                if (const auto* sp = sendall_outputs[i].first.GetSilentPaymentsDestination()) {
                     sp_destinations.emplace(i, *sp);
                 }
             }
@@ -1603,10 +1605,10 @@ RPCMethod sendall()
                 }
                 sp_outputs = std::move(*sp_result);
             }
-            for (size_t i = 0; i < parsed_outputs.size(); ++i) {
-                const auto& [dest, amount] = parsed_outputs[i];
+            for (size_t i = 0; i < sendall_outputs.size(); ++i) {
+                const auto& [dest, amount] = sendall_outputs[i];
                 const auto sp_it{sp_outputs.find(i)};
-                rawTx.vout.emplace_back(amount, sp_it != sp_outputs.end() ? GetScriptForDestination(sp_it->second) : *CHECK_NONFATA
L(dest.GetStaticScript()));
+                rawTx.vout.emplace_back(amount.value_or(0), sp_it != sp_outputs.end() ? GetScriptForDestination(sp_it->second) : *C
HECK_NONFATAL(dest.GetStaticScript()));
             }

             std::vector<COutPoint> outpoints_spent;
@@ -1660,15 +1662,16 @@ RPCMethod sendall()
                 throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds for fees after creating specified outputs.");
             }

-            const CAmount per_output_without_amount{remainder / (long)addresses_without_amount.size()};
+            const auto num_outputs_without_amount{std::ranges::count_if(sendall_outputs, [](const auto& output) { return !output.se
cond; })};
+            const CAmount per_output_without_amount{remainder / num_outputs_without_amount};

             bool gave_remaining_to_first{false};
             for (size_t i = 0; i < rawTx.vout.size(); ++i) {
                 CTxOut& out = rawTx.vout[i];
-                if (addresses_without_amount.contains(parsed_outputs[i].first)) {
+                if (!sendall_outputs[i].second) {
                     out.nValue = per_output_without_amount;
                     if (!gave_remaining_to_first) {
-                        out.nValue += remainder % addresses_without_amount.size();
+                        out.nValue += remainder % num_outputs_without_amount;
                         gave_remaining_to_first = true;
                     }
                     if (IsDust(out, pwallet->chain().relayDustFee())) {
diff --git a/test/functional/wallet_sendall.py b/test/functional/wallet_sendall.py
index 8a5ced520e..144f2f672f 100755
--- a/test/functional/wallet_sendall.py
+++ b/test/functional/wallet_sendall.py
@@ -169,7 +169,7 @@ class SendallTest(BitcoinTestFramework):
                 [{self.recipient: 5}]
             )

-    @for_each_target
+    @for_each_target(allow_sp=False)
     def sendall_duplicate_recipient(self):
         self.log.info("Test duplicate destination")
         self.add_utxos([1, 8, 3, 9])
The BIP allows for multiple outputs to the same recipient, which is particularly good for privacy: > [^](https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#cite_ref-why_more_than_one_output_2-0) Why allow for more than one output? Allowing Alice to break her payment to Bob into multiple amounts opens up a number of privacy improving techniques for Alice, making the transaction look like a CoinJoin or better hiding the change amount by splitting both the payment and change outputs into multiple amounts. It also allows for Alice and Carol to both have their own unique output paying Bob in the event they are in a collaborative transaction and both paying Bob's silent payment address. Can we remove this and only check for duplicate `CTxDestination` in `ParseOutputs`? AFICT use of `set` in `sendall` is to compute the distribution of the remaining value over the addresses without amounts specified. I have a patch here that gets around it, but I will spend some time trying to make it a bit cleaner. <details> <summary>Diff removing the use of set</summary> ```diff diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp index 6b8ed82898..3284f4368e 100644 --- a/src/rpc/rawtransaction_util.cpp +++ b/src/rpc/rawtransaction_util.cpp @@ -115,7 +115,7 @@ UniValue NormalizeOutputs(const UniValue& outputs_in) std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& outputs, bool allow_silent_payments) { // Duplicate checking - std::set<PaymentDestination> destinations; + std::set<CTxDestination> destinations; std::vector<std::pair<PaymentDestination, CAmount>> parsed_outputs; bool has_data{false}; const auto& keys{outputs.getKeys()}; @@ -142,7 +142,8 @@ std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& throw JSONRPCError(RPC_INVALID_PARAMETER, "Silent payments are not supported by this RPC"); } - if (!destinations.insert(*destination).second) { + const CTxDestination* tx_destination{destination->GetTxDestination()}; + if (tx_destination && !destinations.insert(*tx_destination).second) { throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_); } parsed_outputs.emplace_back(std::move(*destination), amount); diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 2684b4ce70..17c1bf1a46 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -1440,7 +1440,6 @@ RPCMethod sendall() PreventOutdatedOptions(options); - std::set<PaymentDestination> addresses_without_amount; UniValue recipient_key_value_pairs(UniValue::VARR); const UniValue& recipients{request.params[0]}; for (unsigned int i = 0; i < recipients.size(); ++i) { @@ -1449,15 +1448,12 @@ RPCMethod sendall() UniValue rkvp(UniValue::VOBJ); rkvp.pushKV(recipient.get_str(), 0); recipient_key_value_pairs.push_back(std::move(rkvp)); - // Store the decoded destination, so it matches the outputs below - // also when the address was given in another case (e.g. uppercase bech32) - addresses_without_amount.insert(PaymentDestination::FromString(recipient.get_str()).value_or(PaymentDestination {})); } else { recipient_key_value_pairs.push_back(recipient); } } - if (addresses_without_amount.size() == 0) { + if (std::ranges::none_of(recipients.getValues(), [](const UniValue& recipient) { return recipient.isStr(); })) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Must provide at least one address without a specified amount"); } @@ -1518,9 +1514,15 @@ RPCMethod sendall() // Output i pays to the address in key i of the normalized outputs const UniValue outputs{NormalizeOutputs(recipient_key_value_pairs)}; const auto parsed_outputs{ParseOutputs(outputs, /*allow_silent_payments=*/true)}; - std::map<size_t, SilentPaymentsDestination> sp_destinations; + std::vector<std::pair<PaymentDestination, std::optional<CAmount>>> sendall_outputs; + sendall_outputs.reserve(parsed_outputs.size()); for (size_t i = 0; i < parsed_outputs.size(); ++i) { - if (const auto* sp = parsed_outputs[i].first.GetSilentPaymentsDestination()) { + const auto& [dest, amount] = parsed_outputs[i]; + sendall_outputs.emplace_back(dest, recipients[i].isStr() ? std::nullopt : std::optional{amount}); + } + std::map<size_t, SilentPaymentsDestination> sp_destinations; + for (size_t i = 0; i < sendall_outputs.size(); ++i) { + if (const auto* sp = sendall_outputs[i].first.GetSilentPaymentsDestination()) { sp_destinations.emplace(i, *sp); } } @@ -1603,10 +1605,10 @@ RPCMethod sendall() } sp_outputs = std::move(*sp_result); } - for (size_t i = 0; i < parsed_outputs.size(); ++i) { - const auto& [dest, amount] = parsed_outputs[i]; + for (size_t i = 0; i < sendall_outputs.size(); ++i) { + const auto& [dest, amount] = sendall_outputs[i]; const auto sp_it{sp_outputs.find(i)}; - rawTx.vout.emplace_back(amount, sp_it != sp_outputs.end() ? GetScriptForDestination(sp_it->second) : *CHECK_NONFATA L(dest.GetStaticScript())); + rawTx.vout.emplace_back(amount.value_or(0), sp_it != sp_outputs.end() ? GetScriptForDestination(sp_it->second) : *C HECK_NONFATAL(dest.GetStaticScript())); } std::vector<COutPoint> outpoints_spent; @@ -1660,15 +1662,16 @@ RPCMethod sendall() throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds for fees after creating specified outputs."); } - const CAmount per_output_without_amount{remainder / (long)addresses_without_amount.size()}; + const auto num_outputs_without_amount{std::ranges::count_if(sendall_outputs, [](const auto& output) { return !output.se cond; })}; + const CAmount per_output_without_amount{remainder / num_outputs_without_amount}; bool gave_remaining_to_first{false}; for (size_t i = 0; i < rawTx.vout.size(); ++i) { CTxOut& out = rawTx.vout[i]; - if (addresses_without_amount.contains(parsed_outputs[i].first)) { + if (!sendall_outputs[i].second) { out.nValue = per_output_without_amount; if (!gave_remaining_to_first) { - out.nValue += remainder % addresses_without_amount.size(); + out.nValue += remainder % num_outputs_without_amount; gave_remaining_to_first = true; } if (IsDust(out, pwallet->chain().relayDustFee())) { diff --git a/test/functional/wallet_sendall.py b/test/functional/wallet_sendall.py index 8a5ced520e..144f2f672f 100755 --- a/test/functional/wallet_sendall.py +++ b/test/functional/wallet_sendall.py @@ -169,7 +169,7 @@ class SendallTest(BitcoinTestFramework): [{self.recipient: 5}] ) - @for_each_target + @for_each_target(allow_sp=False) def sendall_duplicate_recipient(self): self.log.info("Test duplicate destination") self.add_utxos([1, 8, 3, 9]) ``` </details>
rustaceanrob (Migrated from github.com) commented 2026-10-09 11:46:09 +00:00

I don't think it makes sense to have this. The type can be correct by construction and not rely on the doc comment for the convention. If the default constructor is deleted we can also remove the IsValid method as well. The need for this in part stems from the coin control field being a plain CTxDestination/PaymentDestination, but I think it should be an optional there to express the intent. A nullopt implies the change will be generated. This removes the overloaded meaning of the CTxNoDestination to mean either invalid or needs an address.

Suggested diff with optional change dest
diff --git a/src/common/paymentdestination.cpp b/src/common/paymentdestination.cpp
index a908cccf47ec..f39430979f4a 100644
--- a/src/common/paymentdestination.cpp
+++ b/src/common/paymentdestination.cpp
@@ -47,11 +47,3 @@ std::optional<CScript> PaymentDestination::GetStaticScript() const
     if (const auto* dest{GetTxDestination()}) return GetScriptForDestination(*dest);
     return std::nullopt;
 }
-
-bool PaymentDestination::IsValid() const
-{
-    if (const auto* dest{GetTxDestination()}) {
-        return !std::holds_alternative<CNoDestination>(*dest);
-    }
-    return IsSilentPayment();
-}
diff --git a/src/common/paymentdestination.h b/src/common/paymentdestination.h
index 9315b6ff81f2..3fc1cb304458 100644
--- a/src/common/paymentdestination.h
+++ b/src/common/paymentdestination.h
@@ -22,8 +22,6 @@
  * which maps to a fixed scriptPubKey, or a SilentPaymentsDestination, whose
  * scriptPubKey can only be derived once the inputs of the paying transaction
  * are known.
- *
- * A default constructed PaymentDestination holds a CNoDestination.
  */
 class PaymentDestination
 {
@@ -31,7 +29,6 @@ class PaymentDestination
     std::variant<CTxDestination, bip352::SilentPaymentsDestination> m_destination;
 
 public:
-    PaymentDestination() = default;
     /** Build a payment destination from a CTxDestination. This does not validate the CTxDestination. */
     explicit PaymentDestination(CTxDestination dest) : m_destination(std::move(dest)) {}
     explicit PaymentDestination(bip352::SilentPaymentsDestination dest) : m_destination(std::move(dest)) {}
@@ -49,9 +46,6 @@ class PaymentDestination
     /** Return the SilentPaymentsDestination, or nullptr if this is not a silent payments destination. */
     const bip352::SilentPaymentsDestination* GetSilentPaymentsDestination() const { return std::get_if<bip352::SilentPaymentsDestination>(&m_destination); }
 
-    /** Whether this is a valid CTxDestination or a SilentPaymentsDestination */
-    bool IsValid() const;
-
     /** Whether this is a silent payments destination. */
     bool IsSilentPayment() const { return std::holds_alternative<bip352::SilentPaymentsDestination>(m_destination); }
 
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 08faf73399d1..2377e97082c6 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -931,7 +931,7 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
 {
     if (state == Qt::Unchecked)
     {
-        m_coin_control->destChange = PaymentDestination{};
+        m_coin_control->destChange.reset();
         ui->labelCoinControlChangeLabel->clear();
     }
     else
@@ -947,7 +947,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
     if (model && model->getAddressTableModel())
     {
         // Default to no change address until verified
-        m_coin_control->destChange = PaymentDestination{};
+        m_coin_control->destChange.reset();
         ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
 
         const CTxDestination dest = DecodeDestination(text.toStdString());
diff --git a/src/test/paymentdestination_tests.cpp b/src/test/paymentdestination_tests.cpp
index 4ba4e79a4e60..f6c6da52e906 100644
--- a/src/test/paymentdestination_tests.cpp
+++ b/src/test/paymentdestination_tests.cpp
@@ -22,16 +22,6 @@ BOOST_FIXTURE_TEST_SUITE(paymentdestination_tests, BasicTestingSetup)
 static const std::string SP_ADDRESS{"sp1qq22l5s6l9460ww6t4tkzsy2a7zejurcmzz35pt0ffrzk5erlaykdcqugecjjnjqf7ggq39vl6wexjlm00n66z94v675n7wcux6d2krr68gdjvfn2"};
 static const std::string P2WPKH_ADDRESS{"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"};
 
-BOOST_AUTO_TEST_CASE(default_destination)
-{
-    const PaymentDestination dest;
-    BOOST_CHECK(!dest.IsSilentPayment());
-    BOOST_CHECK(!dest.GetSilentPaymentsDestination());
-    BOOST_REQUIRE(dest.GetTxDestination());
-    BOOST_CHECK(std::holds_alternative<CNoDestination>(*dest.GetTxDestination()));
-    BOOST_CHECK(dest == PaymentDestination{CNoDestination{}});
-}
-
 BOOST_AUTO_TEST_CASE(from_string_silent_payments)
 {
     const auto sp_dest{bip352::DecodeSilentPaymentsAddress(SP_ADDRESS, Params())};
diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h
index b074587da89a..cb127d7bf1d6 100644
--- a/src/wallet/coincontrol.h
+++ b/src/wallet/coincontrol.h
@@ -84,7 +84,7 @@ class CCoinControl
 {
 public:
     //! Custom change destination, if not set an address is generated
-    PaymentDestination destChange;
+    std::optional<PaymentDestination> destChange;
     //! Override the default change type if set, ignored if destChange is set
     std::optional<OutputType> m_change_type;
     //! If false, only safe inputs will be used
@@ -123,6 +123,8 @@ class CCoinControl
 
     CCoinControl();
 
+    const bip352::SilentPaymentsDestination* GetSilentPaymentsChange() const { return destChange ? destChange->GetSilentPaymentsDestination() : nullptr; }
+
     /**
      * Returns true if there are pre-selected inputs.
      */
diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp
index 136345573d5a..eb60ded37726 100644
--- a/src/wallet/feebumper.cpp
+++ b/src/wallet/feebumper.cpp
@@ -311,15 +311,14 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa
         for (size_t i = 0; i < tx->vout.size(); ++i) {
             const CTxOut& output = tx->vout[i];
 
-            PaymentDestination dest;
-            if (const auto it = sp_scripts.find(output.scriptPubKey); it != sp_scripts.end()) {
-                dest = PaymentDestination{wtx.m_sprecipients[it->second]};
-                new_coin_control.m_silent_payments = true;
-            } else {
+            const auto it{sp_scripts.find(output.scriptPubKey)};
+            const PaymentDestination dest{[&] {
+                if (it != sp_scripts.end()) return PaymentDestination{wtx.m_sprecipients[it->second]};
                 CTxDestination tx_dest;
                 ExtractDestination(output.scriptPubKey, tx_dest);
-                dest = PaymentDestination{tx_dest};
-            }
+                return PaymentDestination{tx_dest};
+            }()};
+            if (it != sp_scripts.end()) new_coin_control.m_silent_payments = true;
 
             if (original_change_index.has_value() ? original_change_index.value() == i : OutputIsChange(wallet, output)) {
                 new_coin_control.destChange = dest;
@@ -333,15 +332,15 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa
     // If no recipients, means that we are sending coins to a change address
     if (recipients.empty()) {
         // Just as a sanity check, ensure that the change address exist
-        if (!new_coin_control.destChange.IsValid()) {
+        if (!new_coin_control.destChange) {
             errors.emplace_back(Untranslated("Unable to create transaction. Transaction must have at least one recipient"));
             return util::Unexpected{BumpError{Result::INVALID_PARAMETER, std::move(errors)}};
         }
 
         // Add change as recipient with SFFO flag enabled, so fees are deduced from it.
         // If the output differs from the original tx output (because the user customized it) a new change output will be created.
-        recipients.emplace_back(CRecipient{new_coin_control.destChange, new_outputs_value, /*fSubtractFeeFromAmount=*/true});
-        new_coin_control.destChange = PaymentDestination{};
+        recipients.emplace_back(CRecipient{*new_coin_control.destChange, new_outputs_value, /*fSubtractFeeFromAmount=*/true});
+        new_coin_control.destChange.reset();
     }
 
     if (coin_control.m_feerate) {
@@ -396,7 +395,7 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa
     // CreateTransaction: recipients first, then a silent payments change destination if the
     // transaction has a change output
     std::vector<bip352::SilentPaymentsDestination> sp_recipients{GetSilentPaymentsDestinations(recipients)};
-    if (const auto* sp = new_coin_control.destChange.GetSilentPaymentsDestination(); sp && txr.change_pos) {
+    if (const auto* sp = new_coin_control.GetSilentPaymentsChange(); sp && txr.change_pos) {
         sp_recipients.push_back(*sp);
     }
 
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 4c50a47bbfab..407ed7002df1 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -1433,12 +1433,12 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
     bilingual_str error; // possible error str
 
     // coin control: send change to custom address
-    if (coin_control.destChange.IsValid()) {
+    if (coin_control.destChange) {
         // A silent payments change output script is derived once the inputs are selected, see below
-        if (coin_control.destChange.IsSilentPayment() && !coin_control.m_silent_payments) {
+        if (coin_control.destChange->IsSilentPayment() && !coin_control.m_silent_payments) {
             return util::Error{_("Silent payments change requires a silent payments transaction")};
         }
-        scriptChange = GetDummyTxOut(coin_control.destChange, /*amount=*/0).scriptPubKey;
+        scriptChange = GetDummyTxOut(*coin_control.destChange, /*amount=*/0).scriptPubKey;
     } else { // no coin control: send change to newly generated address
         // Note: We use a new key here to keep it from being obvious which side is the change.
         //  The drawback is that by not reusing a previous key, the change may be lost if a
@@ -1591,7 +1591,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
         // A silent payments change destination is keyed after all recipients, so its output is
         // numbered after those of recipients with the same scan key. It is only derived if there
         // is a change output.
-        if (const auto* sp = coin_control.destChange.GetSilentPaymentsDestination(); sp && change_amount > 0) {
+        if (const auto* sp = coin_control.GetSilentPaymentsChange(); sp && change_amount > 0) {
             sp_dests.emplace(vecSend.size(), *sp);
         }
         auto res{CreateSilentPaymentsOutputs(wallet, sp_dests, result.GetInputSet())};
@@ -1828,7 +1828,7 @@ util::Result<CreatedTransactionResult> CreateTransaction(
 
         // Reuse the change destination from the first creation attempt to avoid skipping BIP44 indexes.
         // A silent payments change output script depends on the selected inputs, so it is not reused.
-        if (txr_ungrouped.change_pos && !coin_control.destChange.IsSilentPayment()) {
+        if (txr_ungrouped.change_pos && !coin_control.GetSilentPaymentsChange()) {
             CTxDestination change_dest;
             ExtractDestination(txr_ungrouped.tx->vout[*txr_ungrouped.change_pos].scriptPubKey, change_dest);
             tmp_cc.destChange = PaymentDestination{change_dest};
diff --git a/src/wallet/test/fuzz/spend.cpp b/src/wallet/test/fuzz/spend.cpp
index 4f61d492e513..1c620ca58d16 100644
--- a/src/wallet/test/fuzz/spend.cpp
+++ b/src/wallet/test/fuzz/spend.cpp
@@ -50,7 +50,8 @@ FUZZ_TARGET(wallet_create_transaction, .init = initialize_setup)
     coin_control.m_avoid_partial_spends = fuzzed_data_provider.ConsumeBool();
     coin_control.m_include_unsafe_inputs = fuzzed_data_provider.ConsumeBool();
     if (fuzzed_data_provider.ConsumeBool()) coin_control.m_confirm_target = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, 999'000);
-    coin_control.destChange = PaymentDestination{fuzzed_data_provider.ConsumeBool() ? fuzzed_wallet.GetDestination(fuzzed_data_provider) : ConsumeTxDestination(fuzzed_data_provider)};
+    const CTxDestination change_dest{fuzzed_data_provider.ConsumeBool() ? fuzzed_wallet.GetDestination(fuzzed_data_provider) : ConsumeTxDestination(fuzzed_data_provider)};
+    if (!std::holds_alternative<CNoDestination>(change_dest)) coin_control.destChange = PaymentDestination{change_dest};
     if (fuzzed_data_provider.ConsumeBool()) coin_control.m_change_type = fuzzed_data_provider.PickValueInArray(OUTPUT_TYPES);
     if (fuzzed_data_provider.ConsumeBool()) coin_control.m_feerate = CFeeRate(ConsumeMoney(fuzzed_data_provider, /*max=*/COIN));
     coin_control.m_allow_other_inputs = fuzzed_data_provider.ConsumeBool();
I don't think it makes sense to have this. The type can be correct by construction and not rely on the doc comment for the convention. If the default constructor is deleted we can also remove the `IsValid` method as well. The need for this in part stems from the coin control field being a plain `CTxDestination`/`PaymentDestination`, but I think it should be an `optional` there to express the intent. A `nullopt` implies the change will be generated. This removes the overloaded meaning of the `CTxNoDestination` to mean either invalid or needs an address. <details> <summary>Suggested diff with optional change dest</summary> ```diff diff --git a/src/common/paymentdestination.cpp b/src/common/paymentdestination.cpp index a908cccf47ec..f39430979f4a 100644 --- a/src/common/paymentdestination.cpp +++ b/src/common/paymentdestination.cpp @@ -47,11 +47,3 @@ std::optional<CScript> PaymentDestination::GetStaticScript() const if (const auto* dest{GetTxDestination()}) return GetScriptForDestination(*dest); return std::nullopt; } - -bool PaymentDestination::IsValid() const -{ - if (const auto* dest{GetTxDestination()}) { - return !std::holds_alternative<CNoDestination>(*dest); - } - return IsSilentPayment(); -} diff --git a/src/common/paymentdestination.h b/src/common/paymentdestination.h index 9315b6ff81f2..3fc1cb304458 100644 --- a/src/common/paymentdestination.h +++ b/src/common/paymentdestination.h @@ -22,8 +22,6 @@ * which maps to a fixed scriptPubKey, or a SilentPaymentsDestination, whose * scriptPubKey can only be derived once the inputs of the paying transaction * are known. - * - * A default constructed PaymentDestination holds a CNoDestination. */ class PaymentDestination { @@ -31,7 +29,6 @@ class PaymentDestination std::variant<CTxDestination, bip352::SilentPaymentsDestination> m_destination; public: - PaymentDestination() = default; /** Build a payment destination from a CTxDestination. This does not validate the CTxDestination. */ explicit PaymentDestination(CTxDestination dest) : m_destination(std::move(dest)) {} explicit PaymentDestination(bip352::SilentPaymentsDestination dest) : m_destination(std::move(dest)) {} @@ -49,9 +46,6 @@ class PaymentDestination /** Return the SilentPaymentsDestination, or nullptr if this is not a silent payments destination. */ const bip352::SilentPaymentsDestination* GetSilentPaymentsDestination() const { return std::get_if<bip352::SilentPaymentsDestination>(&m_destination); } - /** Whether this is a valid CTxDestination or a SilentPaymentsDestination */ - bool IsValid() const; - /** Whether this is a silent payments destination. */ bool IsSilentPayment() const { return std::holds_alternative<bip352::SilentPaymentsDestination>(m_destination); } diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 08faf73399d1..2377e97082c6 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -931,7 +931,7 @@ void SendCoinsDialog::coinControlChangeChecked(int state) { if (state == Qt::Unchecked) { - m_coin_control->destChange = PaymentDestination{}; + m_coin_control->destChange.reset(); ui->labelCoinControlChangeLabel->clear(); } else @@ -947,7 +947,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text) if (model && model->getAddressTableModel()) { // Default to no change address until verified - m_coin_control->destChange = PaymentDestination{}; + m_coin_control->destChange.reset(); ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); const CTxDestination dest = DecodeDestination(text.toStdString()); diff --git a/src/test/paymentdestination_tests.cpp b/src/test/paymentdestination_tests.cpp index 4ba4e79a4e60..f6c6da52e906 100644 --- a/src/test/paymentdestination_tests.cpp +++ b/src/test/paymentdestination_tests.cpp @@ -22,16 +22,6 @@ BOOST_FIXTURE_TEST_SUITE(paymentdestination_tests, BasicTestingSetup) static const std::string SP_ADDRESS{"sp1qq22l5s6l9460ww6t4tkzsy2a7zejurcmzz35pt0ffrzk5erlaykdcqugecjjnjqf7ggq39vl6wexjlm00n66z94v675n7wcux6d2krr68gdjvfn2"}; static const std::string P2WPKH_ADDRESS{"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"}; -BOOST_AUTO_TEST_CASE(default_destination) -{ - const PaymentDestination dest; - BOOST_CHECK(!dest.IsSilentPayment()); - BOOST_CHECK(!dest.GetSilentPaymentsDestination()); - BOOST_REQUIRE(dest.GetTxDestination()); - BOOST_CHECK(std::holds_alternative<CNoDestination>(*dest.GetTxDestination())); - BOOST_CHECK(dest == PaymentDestination{CNoDestination{}}); -} - BOOST_AUTO_TEST_CASE(from_string_silent_payments) { const auto sp_dest{bip352::DecodeSilentPaymentsAddress(SP_ADDRESS, Params())}; diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index b074587da89a..cb127d7bf1d6 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -84,7 +84,7 @@ class CCoinControl { public: //! Custom change destination, if not set an address is generated - PaymentDestination destChange; + std::optional<PaymentDestination> destChange; //! Override the default change type if set, ignored if destChange is set std::optional<OutputType> m_change_type; //! If false, only safe inputs will be used @@ -123,6 +123,8 @@ class CCoinControl CCoinControl(); + const bip352::SilentPaymentsDestination* GetSilentPaymentsChange() const { return destChange ? destChange->GetSilentPaymentsDestination() : nullptr; } + /** * Returns true if there are pre-selected inputs. */ diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 136345573d5a..eb60ded37726 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -311,15 +311,14 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa for (size_t i = 0; i < tx->vout.size(); ++i) { const CTxOut& output = tx->vout[i]; - PaymentDestination dest; - if (const auto it = sp_scripts.find(output.scriptPubKey); it != sp_scripts.end()) { - dest = PaymentDestination{wtx.m_sprecipients[it->second]}; - new_coin_control.m_silent_payments = true; - } else { + const auto it{sp_scripts.find(output.scriptPubKey)}; + const PaymentDestination dest{[&] { + if (it != sp_scripts.end()) return PaymentDestination{wtx.m_sprecipients[it->second]}; CTxDestination tx_dest; ExtractDestination(output.scriptPubKey, tx_dest); - dest = PaymentDestination{tx_dest}; - } + return PaymentDestination{tx_dest}; + }()}; + if (it != sp_scripts.end()) new_coin_control.m_silent_payments = true; if (original_change_index.has_value() ? original_change_index.value() == i : OutputIsChange(wallet, output)) { new_coin_control.destChange = dest; @@ -333,15 +332,15 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa // If no recipients, means that we are sending coins to a change address if (recipients.empty()) { // Just as a sanity check, ensure that the change address exist - if (!new_coin_control.destChange.IsValid()) { + if (!new_coin_control.destChange) { errors.emplace_back(Untranslated("Unable to create transaction. Transaction must have at least one recipient")); return util::Unexpected{BumpError{Result::INVALID_PARAMETER, std::move(errors)}}; } // Add change as recipient with SFFO flag enabled, so fees are deduced from it. // If the output differs from the original tx output (because the user customized it) a new change output will be created. - recipients.emplace_back(CRecipient{new_coin_control.destChange, new_outputs_value, /*fSubtractFeeFromAmount=*/true}); - new_coin_control.destChange = PaymentDestination{}; + recipients.emplace_back(CRecipient{*new_coin_control.destChange, new_outputs_value, /*fSubtractFeeFromAmount=*/true}); + new_coin_control.destChange.reset(); } if (coin_control.m_feerate) { @@ -396,7 +395,7 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa // CreateTransaction: recipients first, then a silent payments change destination if the // transaction has a change output std::vector<bip352::SilentPaymentsDestination> sp_recipients{GetSilentPaymentsDestinations(recipients)}; - if (const auto* sp = new_coin_control.destChange.GetSilentPaymentsDestination(); sp && txr.change_pos) { + if (const auto* sp = new_coin_control.GetSilentPaymentsChange(); sp && txr.change_pos) { sp_recipients.push_back(*sp); } diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 4c50a47bbfab..407ed7002df1 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -1433,12 +1433,12 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( bilingual_str error; // possible error str // coin control: send change to custom address - if (coin_control.destChange.IsValid()) { + if (coin_control.destChange) { // A silent payments change output script is derived once the inputs are selected, see below - if (coin_control.destChange.IsSilentPayment() && !coin_control.m_silent_payments) { + if (coin_control.destChange->IsSilentPayment() && !coin_control.m_silent_payments) { return util::Error{_("Silent payments change requires a silent payments transaction")}; } - scriptChange = GetDummyTxOut(coin_control.destChange, /*amount=*/0).scriptPubKey; + scriptChange = GetDummyTxOut(*coin_control.destChange, /*amount=*/0).scriptPubKey; } else { // no coin control: send change to newly generated address // Note: We use a new key here to keep it from being obvious which side is the change. // The drawback is that by not reusing a previous key, the change may be lost if a @@ -1591,7 +1591,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( // A silent payments change destination is keyed after all recipients, so its output is // numbered after those of recipients with the same scan key. It is only derived if there // is a change output. - if (const auto* sp = coin_control.destChange.GetSilentPaymentsDestination(); sp && change_amount > 0) { + if (const auto* sp = coin_control.GetSilentPaymentsChange(); sp && change_amount > 0) { sp_dests.emplace(vecSend.size(), *sp); } auto res{CreateSilentPaymentsOutputs(wallet, sp_dests, result.GetInputSet())}; @@ -1828,7 +1828,7 @@ util::Result<CreatedTransactionResult> CreateTransaction( // Reuse the change destination from the first creation attempt to avoid skipping BIP44 indexes. // A silent payments change output script depends on the selected inputs, so it is not reused. - if (txr_ungrouped.change_pos && !coin_control.destChange.IsSilentPayment()) { + if (txr_ungrouped.change_pos && !coin_control.GetSilentPaymentsChange()) { CTxDestination change_dest; ExtractDestination(txr_ungrouped.tx->vout[*txr_ungrouped.change_pos].scriptPubKey, change_dest); tmp_cc.destChange = PaymentDestination{change_dest}; diff --git a/src/wallet/test/fuzz/spend.cpp b/src/wallet/test/fuzz/spend.cpp index 4f61d492e513..1c620ca58d16 100644 --- a/src/wallet/test/fuzz/spend.cpp +++ b/src/wallet/test/fuzz/spend.cpp @@ -50,7 +50,8 @@ FUZZ_TARGET(wallet_create_transaction, .init = initialize_setup) coin_control.m_avoid_partial_spends = fuzzed_data_provider.ConsumeBool(); coin_control.m_include_unsafe_inputs = fuzzed_data_provider.ConsumeBool(); if (fuzzed_data_provider.ConsumeBool()) coin_control.m_confirm_target = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, 999'000); - coin_control.destChange = PaymentDestination{fuzzed_data_provider.ConsumeBool() ? fuzzed_wallet.GetDestination(fuzzed_data_provider) : ConsumeTxDestination(fuzzed_data_provider)}; + const CTxDestination change_dest{fuzzed_data_provider.ConsumeBool() ? fuzzed_wallet.GetDestination(fuzzed_data_provider) : ConsumeTxDestination(fuzzed_data_provider)}; + if (!std::holds_alternative<CNoDestination>(change_dest)) coin_control.destChange = PaymentDestination{change_dest}; if (fuzzed_data_provider.ConsumeBool()) coin_control.m_change_type = fuzzed_data_provider.PickValueInArray(OUTPUT_TYPES); if (fuzzed_data_provider.ConsumeBool()) coin_control.m_feerate = CFeeRate(ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)); coin_control.m_allow_other_inputs = fuzzed_data_provider.ConsumeBool(); ``` </details>
rustaceanrob (Migrated from github.com) commented 2026-10-09 07:00:52 +00:00

I see what is going on with this template type, but why not just use a boolean argument and return a PaymentDestination? I think this makes it more explicit as to what this function is doing. I found the two templated functions hard to follow.

Suggested diff
diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp
index 7123d5fde7..6b8ed82898 100644
--- a/src/rpc/rawtransaction_util.cpp
+++ b/src/rpc/rawtransaction_util.cpp
@@ -112,13 +112,11 @@ UniValue NormalizeOutputs(const UniValue& outputs_in)
     return outputs;
 }

-//! Parse normalized outputs, decoding each address with decode, which returns std::nullopt if the address is invalid
-template <typename Destination, typename Decode>
-static std::vector<std::pair<Destination, CAmount>> ParseOutputsWith(const UniValue& outputs, Decode decode)
+std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& outputs, bool allow_silent_payments)
 {
     // Duplicate checking
-    std::set<Destination> destinations;
-    std::vector<std::pair<Destination, CAmount>> parsed_outputs;
+    std::set<PaymentDestination> destinations;
+    std::vector<std::pair<PaymentDestination, CAmount>> parsed_outputs;
     bool has_data{false};
     const auto& keys{outputs.getKeys()};
     const auto& values{outputs.getValues()};
@@ -131,15 +129,18 @@ static std::vector<std::pair<Destination, CAmount>> ParseOutputsWith(const UniVa
             }
             has_data = true;
             std::vector<unsigned char> data = ParseHexV(value.getValStr(), "Data");
-            Destination destination{CNoDestination{CScript() << OP_RETURN << data}};
+            PaymentDestination destination{CNoDestination{CScript() << OP_RETURN << data}};
             CAmount amount{0};
             parsed_outputs.emplace_back(destination, amount);
         } else {
-            std::optional<Destination> destination{decode(name_)};
+            auto destination{PaymentDestination::FromString(name_)};
             CAmount amount{AmountFromValue(value)};
             if (!destination) {
                 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + name_);
             }
+            if (!allow_silent_payments && destination->IsSilentPayment()) {
+                throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Silent payments are not supported by this RPC");
+            }

             if (!destinations.insert(*destination).second) {
                 throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
@@ -150,32 +151,14 @@ static std::vector<std::pair<Destination, CAmount>> ParseOutputsWith(const UniVa
     return parsed_outputs;
 }

-std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs)
-{
-    return ParseOutputsWith<CTxDestination>(outputs, [](const std::string& address) -> std::optional<CTxDestination> {
-        CTxDestination destination{DecodeDestination(address)};
-        if (!IsValidDestination(destination)) return std::nullopt;
-        return destination;
-    });
-}
-
-std::vector<std::pair<PaymentDestination, CAmount>> ParsePaymentOutputs(const UniValue& outputs)
-{
-    return ParseOutputsWith<PaymentDestination>(outputs, [](const std::string& address) -> std::optional<PaymentDestination> {
-        auto destination{PaymentDestination::FromString(address)};
-        if (!destination) return std::nullopt;
-        return std::move(*destination);
-    });
-}
-
 void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
 {
     UniValue outputs(UniValue::VOBJ);
     outputs = NormalizeOutputs(outputs_in);

-    std::vector<std::pair<CTxDestination, CAmount>> parsed_outputs = ParseOutputs(outputs);
+    std::vector<std::pair<PaymentDestination, CAmount>> parsed_outputs = ParseOutputs(outputs, /*allow_silent_payments=*/false);
     for (const auto& [destination, nAmount] : parsed_outputs) {
-        CScript scriptPubKey = GetScriptForDestination(destination);
+        CScript scriptPubKey = *CHECK_NONFATAL(destination.GetStaticScript());

         CTxOut out(nAmount, scriptPubKey);
         rawTx.vout.push_back(out);
diff --git a/src/rpc/rawtransaction_util.h b/src/rpc/rawtransaction_util.h
index 3850285cc4..449a5e2216 100644
--- a/src/rpc/rawtransaction_util.h
+++ b/src/rpc/rawtransaction_util.h
@@ -52,11 +52,8 @@ void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, bool rbf);
 /** Normalize univalue-represented outputs */
 UniValue NormalizeOutputs(const UniValue& outputs_in);

-/** Parse normalized outputs into destination, amount tuples. Silent payments addresses are rejected. */
-std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs);
-
-/** Parse normalized outputs into destination, amount tuples, accepting silent payments addresses */
-std::vector<std::pair<PaymentDestination, CAmount>> ParsePaymentOutputs(const UniValue& outputs);
+/** Parse normalized outputs into destination, amount tuples. Silent payments addresses are rejected unless allow_silent_payments i
s true. */
+std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& outputs, bool allow_silent_payments);

 /** Normalize, parse, and add outputs to the transaction */
 void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in);
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 776ac12a35..2684b4ce70 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -33,13 +33,12 @@ using common::TransactionErrorString;
 using node::TransactionError;

 namespace wallet {
-template <typename Destination>
-static std::vector<CRecipient> CreateRecipients(const std::vector<std::pair<Destination, CAmount>>& outputs, const std::set<int>& s
ubtract_fee_outputs)
+std::vector<CRecipient> CreateRecipients(const std::vector<std::pair<PaymentDestination, CAmount>>& outputs, const std::set<int>& s
ubtract_fee_outputs)
 {
     std::vector<CRecipient> recipients;
     for (size_t i = 0; i < outputs.size(); ++i) {
         const auto& [destination, amount] = outputs.at(i);
-        CRecipient recipient{PaymentDestination{destination}, amount, subtract_fee_outputs.contains(i)};
+        CRecipient recipient{destination, amount, subtract_fee_outputs.contains(i)};
         recipients.push_back(recipient);
     }
     return recipients;
@@ -371,7 +370,7 @@ RPCMethod sendtoaddress()
         sffo_set.insert(0);
     }

-    std::vector<CRecipient> recipients{CreateRecipients(ParsePaymentOutputs(address_amounts), sffo_set)};
+    std::vector<CRecipient> recipients{CreateRecipients(ParseOutputs(address_amounts, /*allow_silent_payments=*/true), sffo_set)};
     const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()};

     return SendMoney(*pwallet, coin_control, recipients, comment, comment_to, verbose);
@@ -465,7 +464,7 @@ RPCMethod sendmany()
     SetFeeEstimateMode(*pwallet, coin_control, /*conf_target=*/request.params[6], /*estimate_mode=*/request.params[7], /*fee_rate=*
/request.params[8], /*override_min_fee=*/false);

     std::vector<CRecipient> recipients = CreateRecipients(
-            ParsePaymentOutputs(sendTo),
+            ParseOutputs(sendTo, /*allow_silent_payments=*/true),
             InterpretSubtractFeeFromOutputInstructions(request.params[4], sendTo.getKeys())
     );
     const bool verbose{request.params[9].isNull() ? false : request.params[9].get_bool()};
@@ -856,11 +855,11 @@ RPCMethod fundrawtransaction()
         throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
     }
     UniValue options = request.params[1];
-    std::vector<std::pair<CTxDestination, CAmount>> destinations;
+    std::vector<std::pair<PaymentDestination, CAmount>> destinations;
     for (const auto& tx_out : tx.vout) {
         CTxDestination dest;
         ExtractDestination(tx_out.scriptPubKey, dest);
-        destinations.emplace_back(dest, tx_out.nValue);
+        destinations.emplace_back(PaymentDestination{dest}, tx_out.nValue);
     }
     std::vector<std::string> dummy(destinations.size(), "dummy");
     std::vector<CRecipient> recipients = CreateRecipients(
@@ -1131,14 +1130,7 @@ static RPCMethod bumpfee_helper(std::string method_name)
             // inputs, and the transaction must be added to the wallet when it is created, see
             // EnsureSilentPaymentsTxIsAddedToWallet. A PSBT may be signed elsewhere and its inputs
             // may change before signing, so only allow silent payments addresses for bumpfee RPC.
-            const UniValue normalized_outputs{NormalizeOutputs(options["outputs"])};
-            if (want_psbt) {
-                for (auto& [dest, amount] : ParseOutputs(normalized_outputs)) {
-                    outputs.emplace_back(PaymentDestination{std::move(dest)}, amount);
-                }
-            } else {
-                outputs = ParsePaymentOutputs(normalized_outputs);
-            }
+            outputs = ParseOutputs(NormalizeOutputs(options["outputs"]), /*allow_silent_payments=*/!want_psbt);
         }

         if (options.exists("original_change_index")) {
@@ -1336,7 +1328,7 @@ RPCMethod send()
             UniValue outputs(UniValue::VOBJ);
             outputs = NormalizeOutputs(request.params[0]);
             std::vector<CRecipient> recipients = CreateRecipients(
-                    ParsePaymentOutputs(outputs),
+                    ParseOutputs(outputs, /*allow_silent_payments=*/true),
                     InterpretSubtractFeeFromOutputInstructions(options["subtract_fee_from_outputs"], outputs.getKeys())
             );
             if (std::ranges::any_of(recipients, [](const auto& r) { return r.dest.IsSilentPayment(); })) {
@@ -1525,7 +1517,7 @@ RPCMethod sendall()
             CMutableTransaction rawTx{ConstructTransaction(options["inputs"], /*outputs_in=*/std::nullopt, options["locktime"], rbf
, coin_control.m_version)};
             // Output i pays to the address in key i of the normalized outputs
             const UniValue outputs{NormalizeOutputs(recipient_key_value_pairs)};
-            const auto parsed_outputs{ParsePaymentOutputs(outputs)};
+            const auto parsed_outputs{ParseOutputs(outputs, /*allow_silent_payments=*/true)};
             std::map<size_t, SilentPaymentsDestination> sp_destinations;
             for (size_t i = 0; i < parsed_outputs.size(); ++i) {
                 if (const auto* sp = parsed_outputs[i].first.GetSilentPaymentsDestination()) {
@@ -1895,7 +1887,7 @@ RPCMethod walletcreatefundedpsbt()
     UniValue outputs(UniValue::VOBJ);
     outputs = NormalizeOutputs(request.params[1]);
     std::vector<CRecipient> recipients = CreateRecipients(
-            ParseOutputs(outputs),
+            ParseOutputs(outputs, /*allow_silent_payments=*/false),
             InterpretSubtractFeeFromOutputInstructions(options["subtractFeeFromOutputs"], outputs.getKeys())
     );
     // Automatically select coins, unless at least one is manually selected. Can
I see what is going on with this template type, but why not just use a boolean argument and return a `PaymentDestination`? I think this makes it more explicit as to what this function is doing. I found the two templated functions hard to follow. <details> <summary>Suggested diff</summary> ```diff diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp index 7123d5fde7..6b8ed82898 100644 --- a/src/rpc/rawtransaction_util.cpp +++ b/src/rpc/rawtransaction_util.cpp @@ -112,13 +112,11 @@ UniValue NormalizeOutputs(const UniValue& outputs_in) return outputs; } -//! Parse normalized outputs, decoding each address with decode, which returns std::nullopt if the address is invalid -template <typename Destination, typename Decode> -static std::vector<std::pair<Destination, CAmount>> ParseOutputsWith(const UniValue& outputs, Decode decode) +std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& outputs, bool allow_silent_payments) { // Duplicate checking - std::set<Destination> destinations; - std::vector<std::pair<Destination, CAmount>> parsed_outputs; + std::set<PaymentDestination> destinations; + std::vector<std::pair<PaymentDestination, CAmount>> parsed_outputs; bool has_data{false}; const auto& keys{outputs.getKeys()}; const auto& values{outputs.getValues()}; @@ -131,15 +129,18 @@ static std::vector<std::pair<Destination, CAmount>> ParseOutputsWith(const UniVa } has_data = true; std::vector<unsigned char> data = ParseHexV(value.getValStr(), "Data"); - Destination destination{CNoDestination{CScript() << OP_RETURN << data}}; + PaymentDestination destination{CNoDestination{CScript() << OP_RETURN << data}}; CAmount amount{0}; parsed_outputs.emplace_back(destination, amount); } else { - std::optional<Destination> destination{decode(name_)}; + auto destination{PaymentDestination::FromString(name_)}; CAmount amount{AmountFromValue(value)}; if (!destination) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + name_); } + if (!allow_silent_payments && destination->IsSilentPayment()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Silent payments are not supported by this RPC"); + } if (!destinations.insert(*destination).second) { throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_); @@ -150,32 +151,14 @@ static std::vector<std::pair<Destination, CAmount>> ParseOutputsWith(const UniVa return parsed_outputs; } -std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs) -{ - return ParseOutputsWith<CTxDestination>(outputs, [](const std::string& address) -> std::optional<CTxDestination> { - CTxDestination destination{DecodeDestination(address)}; - if (!IsValidDestination(destination)) return std::nullopt; - return destination; - }); -} - -std::vector<std::pair<PaymentDestination, CAmount>> ParsePaymentOutputs(const UniValue& outputs) -{ - return ParseOutputsWith<PaymentDestination>(outputs, [](const std::string& address) -> std::optional<PaymentDestination> { - auto destination{PaymentDestination::FromString(address)}; - if (!destination) return std::nullopt; - return std::move(*destination); - }); -} - void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in) { UniValue outputs(UniValue::VOBJ); outputs = NormalizeOutputs(outputs_in); - std::vector<std::pair<CTxDestination, CAmount>> parsed_outputs = ParseOutputs(outputs); + std::vector<std::pair<PaymentDestination, CAmount>> parsed_outputs = ParseOutputs(outputs, /*allow_silent_payments=*/false); for (const auto& [destination, nAmount] : parsed_outputs) { - CScript scriptPubKey = GetScriptForDestination(destination); + CScript scriptPubKey = *CHECK_NONFATAL(destination.GetStaticScript()); CTxOut out(nAmount, scriptPubKey); rawTx.vout.push_back(out); diff --git a/src/rpc/rawtransaction_util.h b/src/rpc/rawtransaction_util.h index 3850285cc4..449a5e2216 100644 --- a/src/rpc/rawtransaction_util.h +++ b/src/rpc/rawtransaction_util.h @@ -52,11 +52,8 @@ void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, bool rbf); /** Normalize univalue-represented outputs */ UniValue NormalizeOutputs(const UniValue& outputs_in); -/** Parse normalized outputs into destination, amount tuples. Silent payments addresses are rejected. */ -std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs); - -/** Parse normalized outputs into destination, amount tuples, accepting silent payments addresses */ -std::vector<std::pair<PaymentDestination, CAmount>> ParsePaymentOutputs(const UniValue& outputs); +/** Parse normalized outputs into destination, amount tuples. Silent payments addresses are rejected unless allow_silent_payments i s true. */ +std::vector<std::pair<PaymentDestination, CAmount>> ParseOutputs(const UniValue& outputs, bool allow_silent_payments); /** Normalize, parse, and add outputs to the transaction */ void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in); diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 776ac12a35..2684b4ce70 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -33,13 +33,12 @@ using common::TransactionErrorString; using node::TransactionError; namespace wallet { -template <typename Destination> -static std::vector<CRecipient> CreateRecipients(const std::vector<std::pair<Destination, CAmount>>& outputs, const std::set<int>& s ubtract_fee_outputs) +std::vector<CRecipient> CreateRecipients(const std::vector<std::pair<PaymentDestination, CAmount>>& outputs, const std::set<int>& s ubtract_fee_outputs) { std::vector<CRecipient> recipients; for (size_t i = 0; i < outputs.size(); ++i) { const auto& [destination, amount] = outputs.at(i); - CRecipient recipient{PaymentDestination{destination}, amount, subtract_fee_outputs.contains(i)}; + CRecipient recipient{destination, amount, subtract_fee_outputs.contains(i)}; recipients.push_back(recipient); } return recipients; @@ -371,7 +370,7 @@ RPCMethod sendtoaddress() sffo_set.insert(0); } - std::vector<CRecipient> recipients{CreateRecipients(ParsePaymentOutputs(address_amounts), sffo_set)}; + std::vector<CRecipient> recipients{CreateRecipients(ParseOutputs(address_amounts, /*allow_silent_payments=*/true), sffo_set)}; const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()}; return SendMoney(*pwallet, coin_control, recipients, comment, comment_to, verbose); @@ -465,7 +464,7 @@ RPCMethod sendmany() SetFeeEstimateMode(*pwallet, coin_control, /*conf_target=*/request.params[6], /*estimate_mode=*/request.params[7], /*fee_rate=* /request.params[8], /*override_min_fee=*/false); std::vector<CRecipient> recipients = CreateRecipients( - ParsePaymentOutputs(sendTo), + ParseOutputs(sendTo, /*allow_silent_payments=*/true), InterpretSubtractFeeFromOutputInstructions(request.params[4], sendTo.getKeys()) ); const bool verbose{request.params[9].isNull() ? false : request.params[9].get_bool()}; @@ -856,11 +855,11 @@ RPCMethod fundrawtransaction() throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); } UniValue options = request.params[1]; - std::vector<std::pair<CTxDestination, CAmount>> destinations; + std::vector<std::pair<PaymentDestination, CAmount>> destinations; for (const auto& tx_out : tx.vout) { CTxDestination dest; ExtractDestination(tx_out.scriptPubKey, dest); - destinations.emplace_back(dest, tx_out.nValue); + destinations.emplace_back(PaymentDestination{dest}, tx_out.nValue); } std::vector<std::string> dummy(destinations.size(), "dummy"); std::vector<CRecipient> recipients = CreateRecipients( @@ -1131,14 +1130,7 @@ static RPCMethod bumpfee_helper(std::string method_name) // inputs, and the transaction must be added to the wallet when it is created, see // EnsureSilentPaymentsTxIsAddedToWallet. A PSBT may be signed elsewhere and its inputs // may change before signing, so only allow silent payments addresses for bumpfee RPC. - const UniValue normalized_outputs{NormalizeOutputs(options["outputs"])}; - if (want_psbt) { - for (auto& [dest, amount] : ParseOutputs(normalized_outputs)) { - outputs.emplace_back(PaymentDestination{std::move(dest)}, amount); - } - } else { - outputs = ParsePaymentOutputs(normalized_outputs); - } + outputs = ParseOutputs(NormalizeOutputs(options["outputs"]), /*allow_silent_payments=*/!want_psbt); } if (options.exists("original_change_index")) { @@ -1336,7 +1328,7 @@ RPCMethod send() UniValue outputs(UniValue::VOBJ); outputs = NormalizeOutputs(request.params[0]); std::vector<CRecipient> recipients = CreateRecipients( - ParsePaymentOutputs(outputs), + ParseOutputs(outputs, /*allow_silent_payments=*/true), InterpretSubtractFeeFromOutputInstructions(options["subtract_fee_from_outputs"], outputs.getKeys()) ); if (std::ranges::any_of(recipients, [](const auto& r) { return r.dest.IsSilentPayment(); })) { @@ -1525,7 +1517,7 @@ RPCMethod sendall() CMutableTransaction rawTx{ConstructTransaction(options["inputs"], /*outputs_in=*/std::nullopt, options["locktime"], rbf , coin_control.m_version)}; // Output i pays to the address in key i of the normalized outputs const UniValue outputs{NormalizeOutputs(recipient_key_value_pairs)}; - const auto parsed_outputs{ParsePaymentOutputs(outputs)}; + const auto parsed_outputs{ParseOutputs(outputs, /*allow_silent_payments=*/true)}; std::map<size_t, SilentPaymentsDestination> sp_destinations; for (size_t i = 0; i < parsed_outputs.size(); ++i) { if (const auto* sp = parsed_outputs[i].first.GetSilentPaymentsDestination()) { @@ -1895,7 +1887,7 @@ RPCMethod walletcreatefundedpsbt() UniValue outputs(UniValue::VOBJ); outputs = NormalizeOutputs(request.params[1]); std::vector<CRecipient> recipients = CreateRecipients( - ParseOutputs(outputs), + ParseOutputs(outputs, /*allow_silent_payments=*/false), InterpretSubtractFeeFromOutputInstructions(options["subtractFeeFromOutputs"], outputs.getKeys()) ); // Automatically select coins, unless at least one is manually selected. Can ``` </details>
rustaceanrob (Migrated from github.com) commented 2026-10-10 10:23:30 +00:00

I appreciate the thought on how to make this backwards compatible, but I fear this would be very confusing as a user. When bumping a transaction the user likely has some urgency, and this would leave the UI in an opaque/hard to understand state. An alternative could be to set a new and unknown wallet flag, and older software versions would refuse to open the wallet. I think this would make the issue far more clear, that the user cannot use the wallet at all if there is a silent payments send. Below is the simple version where the flag is set once, but it can also be set/unset each time there is a pending silent payment:

Wallet flag
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 28a839e2b4..292a8ba050 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2138,6 +2138,10 @@ void CWallet::CommitTransaction(
     LOCK(cs_wallet);
     WalletLogPrintf("CommitTransaction:\n%s\n", util::RemoveSuffixView(tx->ToString(), "\n"));

+    if (!sp_recipients.empty() && !IsWalletFlagSet(WALLET_FLAG_SILENT_PAYMENTS_SENT)) {
+        SetWalletFlag(WALLET_FLAG_SILENT_PAYMENTS_SENT);
+    }
+
     // Add tx to wallet, because if it has change it's also ours,
     // otherwise just for transaction history.
     CWalletTx* wtx = AddToWallet(tx, TxStateInactive{}, [&](CWalletTx& wtx, bool new_tx) {
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 181a2c6d17..b70c1be657 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -164,7 +164,8 @@ inline constexpr uint64_t KNOWN_WALLET_FLAGS =
     |   WALLET_FLAG_LAST_HARDENED_XPUB_CACHED
     |   WALLET_FLAG_DISABLE_PRIVATE_KEYS
     |   WALLET_FLAG_DESCRIPTORS
-    |   WALLET_FLAG_EXTERNAL_SIGNER;
+    |   WALLET_FLAG_EXTERNAL_SIGNER
+    |   WALLET_FLAG_SILENT_PAYMENTS_SENT;

 inline constexpr uint64_t MUTABLE_WALLET_FLAGS =
         WALLET_FLAG_AVOID_REUSE;
@@ -176,7 +177,8 @@ static const std::map<WalletFlags, std::string> WALLET_FLAG_TO_STRING{
     {WALLET_FLAG_LAST_HARDENED_XPUB_CACHED, "last_hardened_xpub_cached"},
     {WALLET_FLAG_DISABLE_PRIVATE_KEYS, "disable_private_keys"},
     {WALLET_FLAG_DESCRIPTORS, "descriptor_wallet"},
-    {WALLET_FLAG_EXTERNAL_SIGNER, "external_signer"}
+    {WALLET_FLAG_EXTERNAL_SIGNER, "external_signer"},
+    {WALLET_FLAG_SILENT_PAYMENTS_SENT, "silent_payments_sent"}
 };

 static const std::map<std::string, WalletFlags> STRING_TO_WALLET_FLAG{
@@ -186,7 +188,8 @@ static const std::map<std::string, WalletFlags> STRING_TO_WALLET_FLAG{
     {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED), WALLET_FLAG_LAST_HARDENED_XPUB_CACHED},
     {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_DISABLE_PRIVATE_KEYS), WALLET_FLAG_DISABLE_PRIVATE_KEYS},
     {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_DESCRIPTORS), WALLET_FLAG_DESCRIPTORS},
-    {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_EXTERNAL_SIGNER), WALLET_FLAG_EXTERNAL_SIGNER}
+    {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_EXTERNAL_SIGNER), WALLET_FLAG_EXTERNAL_SIGNER},
+    {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_SILENT_PAYMENTS_SENT), WALLET_FLAG_SILENT_PAYMENTS_SENT}
 };

 /** A wrapper to reserve an address from a wallet
diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h
index 8a973c59aa..be3c530ae8 100644
--- a/src/wallet/walletutil.h
+++ b/src/wallet/walletutil.h
@@ -54,6 +54,8 @@ enum WalletFlags : uint64_t {

     //! Indicates that the wallet needs an external signer
     WALLET_FLAG_EXTERNAL_SIGNER = (1ULL << 35),
+
+    WALLET_FLAG_SILENT_PAYMENTS_SENT = (1ULL << 36),
 };

There is no way to make RBF fully backward compatible, so I think we should fail as loudly as possible IMO

I appreciate the thought on how to make this backwards compatible, but I fear this would be very confusing as a user. When bumping a transaction the user likely has some urgency, and this would leave the UI in an opaque/hard to understand state. An alternative could be to set a new and unknown wallet flag, and older software versions would refuse to open the wallet. I think this would make the issue far more clear, that the user cannot use the wallet at all if there is a silent payments send. Below is the simple version where the flag is set once, but it can also be set/unset each time there is a pending silent payment: <details> <summary>Wallet flag</summary> ```diff diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 28a839e2b4..292a8ba050 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2138,6 +2138,10 @@ void CWallet::CommitTransaction( LOCK(cs_wallet); WalletLogPrintf("CommitTransaction:\n%s\n", util::RemoveSuffixView(tx->ToString(), "\n")); + if (!sp_recipients.empty() && !IsWalletFlagSet(WALLET_FLAG_SILENT_PAYMENTS_SENT)) { + SetWalletFlag(WALLET_FLAG_SILENT_PAYMENTS_SENT); + } + // Add tx to wallet, because if it has change it's also ours, // otherwise just for transaction history. CWalletTx* wtx = AddToWallet(tx, TxStateInactive{}, [&](CWalletTx& wtx, bool new_tx) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 181a2c6d17..b70c1be657 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -164,7 +164,8 @@ inline constexpr uint64_t KNOWN_WALLET_FLAGS = | WALLET_FLAG_LAST_HARDENED_XPUB_CACHED | WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_DESCRIPTORS - | WALLET_FLAG_EXTERNAL_SIGNER; + | WALLET_FLAG_EXTERNAL_SIGNER + | WALLET_FLAG_SILENT_PAYMENTS_SENT; inline constexpr uint64_t MUTABLE_WALLET_FLAGS = WALLET_FLAG_AVOID_REUSE; @@ -176,7 +177,8 @@ static const std::map<WalletFlags, std::string> WALLET_FLAG_TO_STRING{ {WALLET_FLAG_LAST_HARDENED_XPUB_CACHED, "last_hardened_xpub_cached"}, {WALLET_FLAG_DISABLE_PRIVATE_KEYS, "disable_private_keys"}, {WALLET_FLAG_DESCRIPTORS, "descriptor_wallet"}, - {WALLET_FLAG_EXTERNAL_SIGNER, "external_signer"} + {WALLET_FLAG_EXTERNAL_SIGNER, "external_signer"}, + {WALLET_FLAG_SILENT_PAYMENTS_SENT, "silent_payments_sent"} }; static const std::map<std::string, WalletFlags> STRING_TO_WALLET_FLAG{ @@ -186,7 +188,8 @@ static const std::map<std::string, WalletFlags> STRING_TO_WALLET_FLAG{ {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED), WALLET_FLAG_LAST_HARDENED_XPUB_CACHED}, {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_DISABLE_PRIVATE_KEYS), WALLET_FLAG_DISABLE_PRIVATE_KEYS}, {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_DESCRIPTORS), WALLET_FLAG_DESCRIPTORS}, - {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_EXTERNAL_SIGNER), WALLET_FLAG_EXTERNAL_SIGNER} + {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_EXTERNAL_SIGNER), WALLET_FLAG_EXTERNAL_SIGNER}, + {WALLET_FLAG_TO_STRING.at(WALLET_FLAG_SILENT_PAYMENTS_SENT), WALLET_FLAG_SILENT_PAYMENTS_SENT} }; /** A wrapper to reserve an address from a wallet diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index 8a973c59aa..be3c530ae8 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -54,6 +54,8 @@ enum WalletFlags : uint64_t { //! Indicates that the wallet needs an external signer WALLET_FLAG_EXTERNAL_SIGNER = (1ULL << 35), + + WALLET_FLAG_SILENT_PAYMENTS_SENT = (1ULL << 36), }; ``` </details> There is no way to make RBF fully backward compatible, so I think we should fail as loudly as possible IMO
rustaceanrob commented 2026-10-13 05:31:11 +00:00 (Migrated from github.com)

cc @theStack @murchandamus

cc @theStack @murchandamus
rustaceanrob (Migrated from github.com) reviewed 2026-10-13 06:29:30 +00:00
rustaceanrob (Migrated from github.com) commented 2026-10-13 06:29:30 +00:00

And if we do go this route, this can be simpler with:

return std::tie(a.m_version, a.m_scan_pubkey, a.m_spend_pubkey, a.m_extension_data)
     < std::tie(b.m_version, b.m_scan_pubkey, b.m_spend_pubkey, b.m_extension_data);
And if we do go this route, this can be simpler with: ``` return std::tie(a.m_version, a.m_scan_pubkey, a.m_spend_pubkey, a.m_extension_data) < std::tie(b.m_version, b.m_scan_pubkey, b.m_spend_pubkey, b.m_extension_data); ```
DrahtBot commented 2026-10-13 10:44:59 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task i686, no IPC: https://github.com/bitcoin/bitcoin/actions/runs/38374955165/job/115220901904
LLM reason (✨ experimental): CI failed during compilation: GCC 15’s -Wmaybe-uninitialized warning in prevector.h was treated as an error while building the Qt wallet tests.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `i686, no IPC`: https://github.com/bitcoin/bitcoin/actions/runs/38374955165/job/115220901904</sub> <sub>LLM reason (✨ experimental): CI failed during compilation: GCC 15’s `-Wmaybe-uninitialized` warning in `prevector.h` was treated as an error while building the Qt wallet tests.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
Eunovo (Migrated from github.com) reviewed 2026-10-13 13:03:41 +00:00
Eunovo (Migrated from github.com) commented 2026-10-13 13:03:41 +00:00

Done

Done
Eunovo (Migrated from github.com) reviewed 2026-10-13 13:03:58 +00:00
Eunovo (Migrated from github.com) commented 2026-10-13 13:03:58 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-10-13 13:04:34 +00:00
Eunovo (Migrated from github.com) commented 2026-10-13 13:04:34 +00:00

Changed to use std::tie

Changed to use `std::tie`
Eunovo commented 2026-10-13 13:18:20 +00:00 (Migrated from github.com)

A few subtle edge cases around descriptor key derivation, RBF state persistence, and coin selection diverge across the branch.

In src/wallet/spend.cpp, IsInputForSharedSecretDerivation assumes any Taproot output where internal_key != NUMS_H is eligible. For descriptors where the wallet only owns a leaf key (tr(unspendable_key, pk(leaf))), this returns true, but CreateSilentPaymentsOutputs subsequently fails with Missing the private key of silent payments eligible input COutPoint(...) when GetPrivKeyForSilentPayments cannot tweak the missing internal key. On the PUBKEYHASH branch, IsInputForSharedSecretDerivation also assumes unresolvable inputs are compressed if provider->GetPubKey fails.

This is the intended behaviour.

This causes an inconsistency between send and sendall. AvailableCoins skips all Taproot coins with script path spend data, causing sendall without inputs to fail with an error instructing the user to choose coins via inputs. If those coins are supplied to send, line 382 explicitly rejects them with Found script data for ... Only key path spends are allowed. If supplied to sendall, the transaction succeeds when the wallet owns both keys because sendall's input path bypasses HasTaprootScriptPath.

send and sendall (with inputs selected) now follow the same rules.

In src/wallet/feebumper.cpp:460, CommitTransaction calls EraseSpRecipients(oldWtx.GetHash()), erasing the original transaction's recipient metadata from the wallet database. If the replacement is evicted from the mempool or dropped while an older block template mines the original transaction, the record of who it paid to is permanently lost. Since database records are keyed per transaction, keeping historical recipient records is harmless and avoids state loss during reorgs.

The persisted SP recipients information is only useful for bumping the transaction. This can only happen before it is confirmed.

Relatedly, multiplexing m_is_sp_tx into string_values["replaced_by_txid"] using GetHash().ToString() in src/wallet/transaction.h only persists until the transaction is bumped. Once replaced, m_replaced_by_txid becomes the new transaction id. On the next wallet load, key == "replaced_by_txid" sees the replacement txid rather than GetHash(), leaving m_is_sp_tx as false. Combined with EraseSpRecipients, a replaced transaction loses its silent payments identity entirely across restarts.

m_is_sp_tx is only useful before the transaction is bumped.

In AttemptSelectionSP (spend.cpp:1058), anchor candidates are restricted to positive_group. At high fee rates, a small eligible coin (such as a 1,000 sat P2WPKH UTXO) can have effective_value <= 0 and land in negative_group. Even if the wallet holds large ineligible outputs (e.g. 5 BTC P2WSH) that easily cover the payment and fees, candidate collection comes up empty and fails with INSUFFICIENT_FUNDS. Additionally, when subtracting fees from outputs, candidates are sorted by effective_value while target reduction uses nominal value.

AttemptSelectionSP has been updated to use the "negative" group. GetSelectionValue() is now used in place of effective_value for sorting the eligible groups.

> A few subtle edge cases around descriptor key derivation, RBF state persistence, and coin selection diverge across the branch. > > In `src/wallet/spend.cpp`, `IsInputForSharedSecretDerivation` assumes any Taproot output where `internal_key != NUMS_H` is eligible. For descriptors where the wallet only owns a leaf key (`tr(unspendable_key, pk(leaf))`), this returns `true`, but `CreateSilentPaymentsOutputs` subsequently fails with `Missing the private key of silent payments eligible input COutPoint(...)` when `GetPrivKeyForSilentPayments` cannot tweak the missing internal key. On the `PUBKEYHASH` branch, `IsInputForSharedSecretDerivation` also assumes unresolvable inputs are compressed if `provider->GetPubKey` fails. This is the intended behaviour. > This causes an inconsistency between `send` and `sendall`. `AvailableCoins` skips all Taproot coins with script path spend data, causing `sendall` without inputs to fail with an error instructing the user to choose coins via `inputs`. If those coins are supplied to `send`, line 382 explicitly rejects them with `Found script data for ... Only key path spends are allowed`. If supplied to `sendall`, the transaction succeeds when the wallet owns both keys because `sendall`'s input path bypasses `HasTaprootScriptPath`. `send` and `sendall` (with inputs selected) now follow the same rules. > In `src/wallet/feebumper.cpp:460`, `CommitTransaction` calls `EraseSpRecipients(oldWtx.GetHash())`, erasing the original transaction's recipient metadata from the wallet database. If the replacement is evicted from the mempool or dropped while an older block template mines the original transaction, the record of who it paid to is permanently lost. Since database records are keyed per transaction, keeping historical recipient records is harmless and avoids state loss during reorgs. The persisted SP recipients information is only useful for bumping the transaction. This can only happen before it is confirmed. > Relatedly, multiplexing `m_is_sp_tx` into `string_values["replaced_by_txid"]` using `GetHash().ToString()` in `src/wallet/transaction.h` only persists until the transaction is bumped. Once replaced, `m_replaced_by_txid` becomes the new transaction id. On the next wallet load, `key == "replaced_by_txid"` sees the replacement txid rather than `GetHash()`, leaving `m_is_sp_tx` as `false`. Combined with `EraseSpRecipients`, a replaced transaction loses its silent payments identity entirely across restarts. `m_is_sp_tx` is only useful before the transaction is bumped. > In `AttemptSelectionSP` (`spend.cpp:1058`), anchor candidates are restricted to `positive_group`. At high fee rates, a small eligible coin (such as a 1,000 sat P2WPKH UTXO) can have `effective_value <= 0` and land in `negative_group`. Even if the wallet holds large ineligible outputs (e.g. 5 BTC P2WSH) that easily cover the payment and fees, candidate collection comes up empty and fails with `INSUFFICIENT_FUNDS`. Additionally, when subtracting fees from outputs, candidates are sorted by `effective_value` while target reduction uses nominal value. `AttemptSelectionSP` has been updated to use the "negative" group. `GetSelectionValue()` is now used in place of `effective_value` for sorting the eligible groups.
rustaceanrob (Migrated from github.com) reviewed 2026-10-14 05:08:15 +00:00
rustaceanrob (Migrated from github.com) commented 2026-10-14 05:08:15 +00:00

Out of band it was raised to me that the wallet flag would be detrimental for users, as in preventing a wallet open on downgrade is not desirable in basically any circumstance. I can empathize with that approach, although I would recommend something that we can put in the release notes, stack exchange, etc. A dummy replacement value could make this easier to share as expected behavior (00 + silent payments in hex):

diff --git a/src/wallet/test/wallet_transaction_tests.cpp b/src/wallet/test/wallet_transaction_tests.cpp
index 9606f002f2..134d5a301f 100644
--- a/src/wallet/test/wallet_transaction_tests.cpp
+++ b/src/wallet/test/wallet_transaction_tests.cpp
@@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE(silent_payments_flag_roundtrip)
         return CWalletTx(deserialize, ss, no_variants);
     }};

-    // A silent payments tx is written as replaced by itself, which is read back as the flag
+    // A silent payments tx is written as replaced by the placeholder txid, which is read back as the flag
     CWalletTx sp_wtx{tx, TxStateInactive{}};
     sp_wtx.m_is_sp_tx = true;
     const CWalletTx sp_loaded{roundtrip(sp_wtx)};
diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h
index 9bf4f9e5d1..5e5ac8606a 100644
--- a/src/wallet/transaction.h
+++ b/src/wallet/transaction.h
@@ -187,6 +187,9 @@ public:
     }
 };

+//!  zero padding and "silent payments" in ASCII
+static constexpr Txid SILENT_PAYMENTS_PLACEHOLDER_TXID{"000000000000000000000000000000000073696c656e74207061796d656e7473"};
+
 /**
  * A transaction with a bunch of additional info that only the owner cares about.
  * It includes any unrecorded transactions needed to link it back to the block chain.
@@ -294,11 +297,11 @@ public:
         } else if (m_is_sp_tx) {
             // Older releases don't know about silent payments and could fee bump this tx by
             // adding inputs, which would invalidate its silent payments outputs. Mark it as
-            // replaced by itself so they refuse to bump it. No tx can replace itself, so on load
-            // this placeholder flags the tx as a silent payments tx. A new value is not used to
-            // flag it, since releases that throw on unknown values could not load the wallet.
+            // replaced by a placeholder txid so they refuse to bump it. On load, this placeholder
+            // flags the tx as a silent payments tx. A new value is not used to flag it, since
+            // releases that throw on unknown values could not load the wallet.
             // Once the tx is replaced, the flag is not kept, since it can no longer be bumped.
-            string_values["replaced_by_txid"] = GetHash().ToString();
+            string_values["replaced_by_txid"] = SILENT_PAYMENTS_PLACEHOLDER_TXID.ToString();
         }
         string_values["fromaccount"] = "";
         if (nOrderPos != -1) string_values["n"] = util::ToString(nOrderPos);
@@ -353,9 +356,9 @@ public:
             else if (key == "to") m_comment_to = value;
             else if (key == "replaces_txid") m_replaces_txid = Txid::FromHex(value);
             else if (key == "replaced_by_txid") {
-                // A tx replaced by itself is the placeholder written for silent payments txs, see Serialize
+                // The placeholder written for silent payments txs, see Serialize
                 const auto txid{Txid::FromHex(value)};
-                if (txid == GetHash()) {
+                if (txid == SILENT_PAYMENTS_PLACEHOLDER_TXID) {
                     m_is_sp_tx = true;
                 } else {
                     m_replaced_by_txid = txid;
diff --git a/test/functional/wallet_backwards_compatibility.py b/test/functional/wallet_backwards_compatibility.py
index d343c71a4c..96a7870587 100755
--- a/test/functional/wallet_backwards_compatibility.py
+++ b/test/functional/wallet_backwards_compatibility.py
@@ -35,6 +35,7 @@ from test_framework.util import (
 )

 LAST_KEYPOOL_INDEX = 9 # Index of the last derived address with the keypool size of 10
+SILENT_PAYMENTS_PLACEHOLDER_TXID = "000000000000000000000000000000000073696c656e74207061796d656e7473"

 class BackwardsCompatibilityTest(BitcoinTestFramework):
     def set_test_params(self):
@@ -311,8 +312,8 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
             node_old.sendrawtransaction(tx_hex)
             node_old.loadwallet(wallet_name)
             old_wallet = node_old.get_wallet_rpc(wallet_name)
-            assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {txid}", old_walle
t.bumpfee, txid)
-            assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {txid}", old_walle
t.psbtbumpfee, txid)
+            assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {SILENT_PAYMENTS_P
LACEHOLDER_TXID}", old_wallet.bumpfee, txid)
+            assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {SILENT_PAYMENTS_P
LACEHOLDER_TXID}", old_wallet.psbtbumpfee, txid)
             old_wallet.unloadwallet()

             # Upgrade again: master still has the recipient data and can bump the tx
Out of band it was raised to me that the wallet flag would be detrimental for users, as in preventing a wallet open on downgrade is not desirable in basically any circumstance. I can empathize with that approach, although I would recommend something that we can put in the release notes, stack exchange, etc. A dummy replacement value could make this easier to share as expected behavior (`00` + silent payments in hex): ```diff diff --git a/src/wallet/test/wallet_transaction_tests.cpp b/src/wallet/test/wallet_transaction_tests.cpp index 9606f002f2..134d5a301f 100644 --- a/src/wallet/test/wallet_transaction_tests.cpp +++ b/src/wallet/test/wallet_transaction_tests.cpp @@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE(silent_payments_flag_roundtrip) return CWalletTx(deserialize, ss, no_variants); }}; - // A silent payments tx is written as replaced by itself, which is read back as the flag + // A silent payments tx is written as replaced by the placeholder txid, which is read back as the flag CWalletTx sp_wtx{tx, TxStateInactive{}}; sp_wtx.m_is_sp_tx = true; const CWalletTx sp_loaded{roundtrip(sp_wtx)}; diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 9bf4f9e5d1..5e5ac8606a 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -187,6 +187,9 @@ public: } }; +//! zero padding and "silent payments" in ASCII +static constexpr Txid SILENT_PAYMENTS_PLACEHOLDER_TXID{"000000000000000000000000000000000073696c656e74207061796d656e7473"}; + /** * A transaction with a bunch of additional info that only the owner cares about. * It includes any unrecorded transactions needed to link it back to the block chain. @@ -294,11 +297,11 @@ public: } else if (m_is_sp_tx) { // Older releases don't know about silent payments and could fee bump this tx by // adding inputs, which would invalidate its silent payments outputs. Mark it as - // replaced by itself so they refuse to bump it. No tx can replace itself, so on load - // this placeholder flags the tx as a silent payments tx. A new value is not used to - // flag it, since releases that throw on unknown values could not load the wallet. + // replaced by a placeholder txid so they refuse to bump it. On load, this placeholder + // flags the tx as a silent payments tx. A new value is not used to flag it, since + // releases that throw on unknown values could not load the wallet. // Once the tx is replaced, the flag is not kept, since it can no longer be bumped. - string_values["replaced_by_txid"] = GetHash().ToString(); + string_values["replaced_by_txid"] = SILENT_PAYMENTS_PLACEHOLDER_TXID.ToString(); } string_values["fromaccount"] = ""; if (nOrderPos != -1) string_values["n"] = util::ToString(nOrderPos); @@ -353,9 +356,9 @@ public: else if (key == "to") m_comment_to = value; else if (key == "replaces_txid") m_replaces_txid = Txid::FromHex(value); else if (key == "replaced_by_txid") { - // A tx replaced by itself is the placeholder written for silent payments txs, see Serialize + // The placeholder written for silent payments txs, see Serialize const auto txid{Txid::FromHex(value)}; - if (txid == GetHash()) { + if (txid == SILENT_PAYMENTS_PLACEHOLDER_TXID) { m_is_sp_tx = true; } else { m_replaced_by_txid = txid; diff --git a/test/functional/wallet_backwards_compatibility.py b/test/functional/wallet_backwards_compatibility.py index d343c71a4c..96a7870587 100755 --- a/test/functional/wallet_backwards_compatibility.py +++ b/test/functional/wallet_backwards_compatibility.py @@ -35,6 +35,7 @@ from test_framework.util import ( ) LAST_KEYPOOL_INDEX = 9 # Index of the last derived address with the keypool size of 10 +SILENT_PAYMENTS_PLACEHOLDER_TXID = "000000000000000000000000000000000073696c656e74207061796d656e7473" class BackwardsCompatibilityTest(BitcoinTestFramework): def set_test_params(self): @@ -311,8 +312,8 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): node_old.sendrawtransaction(tx_hex) node_old.loadwallet(wallet_name) old_wallet = node_old.get_wallet_rpc(wallet_name) - assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {txid}", old_walle t.bumpfee, txid) - assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {txid}", old_walle t.psbtbumpfee, txid) + assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {SILENT_PAYMENTS_P LACEHOLDER_TXID}", old_wallet.bumpfee, txid) + assert_raises_rpc_error(-4, f"Cannot bump transaction {txid} which was already bumped by transaction {SILENT_PAYMENTS_P LACEHOLDER_TXID}", old_wallet.psbtbumpfee, txid) old_wallet.unloadwallet() # Upgrade again: master still has the recipient data and can bump the tx ```
rustaceanrob (Migrated from github.com) reviewed 2026-10-14 07:50:59 +00:00
rustaceanrob (Migrated from github.com) commented 2026-10-14 07:50:59 +00:00

We may want to introduce an RPC for this, but not sure if it should be introduced as part of this PR. A scanner in python that passes the test vectors is relatively straightforward, and we can open this separately.

Python scanner
diff --git a/test/functional/feature_framework_unit_tests.py b/test/functional/feature_framework_unit_tests.py
index 7da6fb53c3..6947ca3d7b 100755
--- a/test/functional/feature_framework_unit_tests.py
+++ b/test/functional/feature_framework_unit_tests.py
@@ -16,6 +16,7 @@ from test_framework.test_framework import TEST_EXIT_PASSED, TEST_EXIT_FAILED
 # the output of `git grep unittest.TestCase ./test/functional/test_framework`
 TEST_FRAMEWORK_MODULES = [
     "address",
+    "bip352",
     "crypto.bip324_cipher",
     "blocktools",
     "compressor",
diff --git a/test/functional/test_framework/bip352.py b/test/functional/test_framework/bip352.py
new file mode 100644
index 0000000000..74b56929a4
--- /dev/null
+++ b/test/functional/test_framework/bip352.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python3
+# Copyright (c) 2026-present The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""BIP352 silent payments scanning, without labels."""
+
+from io import BytesIO
+import json
+from pathlib import Path
+import unittest
+
+from .crypto.secp256k1 import G, GE
+from .key import H_POINT, ORDER, TaggedHash
+from .messages import COutPoint, CTransaction, deser_string_vector, from_hex
+from .script import hash160
+from .test_node import TestNode
+
+K_MAX = 2323
+
+# (outpoint, scriptSig, witness stack, prevout scriptPubKey)
+ScanInput = tuple[COutPoint, bytes, list[bytes], bytes]
+
+
+def get_input_pubkey(script_sig: bytes, witness: list[bytes], prevout_spk: bytes) -> GE | None:
+    """Return the public key of an input as a GE, or None if the input is not eligible."""
+    if len(prevout_spk) == 34 and prevout_spk[:2] == b"\x51\x20":
+        stack = list(witness)
+        if len(stack) > 1 and stack[-1][:1] == b"\x50":
+            stack.pop()
+        if len(stack) > 1 and stack[-1][1:33] == bytes.fromhex(H_POINT):
+            return None
+        return GE.from_bytes_xonly(prevout_spk[2:])
+    if len(prevout_spk) == 22 and prevout_spk[:2] == b"\x00\x14":
+        if witness and len(witness[-1]) == 33:
+            return GE.from_bytes(witness[-1])
+        return None
+    if len(prevout_spk) == 23 and prevout_spk[:2] == b"\xa9\x14":
+        if script_sig[:3] == b"\x16\x00\x14" and len(script_sig) == 23 and witness and len(witness[-1]) == 33:
+            return GE.from_bytes(witness[-1])
+        return None
+    if len(prevout_spk) == 25 and prevout_spk[:3] == b"\x76\xa9\x14" and prevout_spk[23:] == b"\x88\xac":
+        for i in range(len(script_sig), 32, -1):
+            pubkey = script_sig[i - 33:i]
+            if hash160(pubkey) == prevout_spk[3:23]:
+                return GE.from_bytes(pubkey)
+    return None
+
+
+def scan(inputs: list[ScanInput], output_spks: list[bytes], scan_privkey: bytes, spend_pubkey: bytes) -> list[dict[str, str]]:
+    """Find the outputs paying to a silent payments recipient.
+
+    Return a list of {"output": x-only output key, "tweak": spend key tweak}, both hex.
+    """
+    pubkeys = [pubkey for pubkey in (get_input_pubkey(*i[1:]) for i in inputs) if pubkey is not None]
+    A = sum(pubkeys, GE())
+    if A.infinity:
+        return []
+    smallest_outpoint = min(outpoint.serialize() for outpoint, *_ in inputs)
+    input_hash = int.from_bytes(TaggedHash("BIP0352/Inputs", smallest_outpoint + A.to_bytes_compressed()), "big")
+    ecdh_shared_secret = (input_hash * int.from_bytes(scan_privkey, "big") % ORDER) * A
+    B_spend = GE.from_bytes(spend_pubkey)
+    outputs = {spk[2:] for spk in output_spks if len(spk) == 34 and spk[:2] == b"\x51\x20"}
+    found: list[dict[str, str]] = []
+    for k in range(K_MAX):
+        tweak = TaggedHash("BIP0352/SharedSecret", ecdh_shared_secret.to_bytes_compressed() + k.to_bytes(4, "big"))
+        P_k = (B_spend + int.from_bytes(tweak, "big") * G).to_bytes_xonly()
+        if P_k not in outputs:
+            break
+        found.append({"output": P_k.hex(), "tweak": tweak.hex()})
+    return found
+
+
+def scan_tx(node: TestNode, tx_hex: str, scan_privkey: bytes, spend_pubkey: bytes) -> list[dict[str, str]]:
+    """Scan a transaction, looking up its prevouts in the UTXO set of node, or with getrawtransaction."""
+    tx = from_hex(CTransaction(), tx_hex)
+    inputs: list[ScanInput] = []
+    for i, txin in enumerate(tx.vin):
+        txid, n = f"{txin.prevout.hash:064x}", txin.prevout.n
+        prevout = node.gettxout(txid, n, include_mempool=False) or node.getrawtransaction(txid, True)["vout"][n]
+        witness = tx.wit.vtxinwit[i].scriptWitness.stack if i < len(tx.wit.vtxinwit) else []
+        inputs.append((txin.prevout, txin.scriptSig, witness, bytes.fromhex(prevout["scriptPubKey"]["hex"])))
+    return scan(inputs, [txout.scriptPubKey for txout in tx.vout], scan_privkey, spend_pubkey)
+
+
+class TestFrameworkBIP352(unittest.TestCase):
+    def test_receiving_vectors(self) -> None:
+        with (Path(__file__).parents[3] / "src/test/data/bip352_send_and_receive_vectors.json").open() as vectors_file:
+            for test in json.load(vectors_file):
+                for receiving in test["receiving"]:
+                    given = receiving["given"]
+                    if given["labels"]:
+                        continue
+                    inputs = [(
+                        COutPoint(int(vin["txid"], 16), vin["vout"]),
+                        bytes.fromhex(vin["scriptSig"]),
+                        deser_string_vector(BytesIO(bytes.fromhex(vin["txinwitness"]))) if vin["txinwitness"] else [],
+                        bytes.fromhex(vin["prevout"]["scriptPubKey"]["hex"]),
+                    ) for vin in given["vin"]]
+                    output_spks = [bytes.fromhex("5120" + output) for output in given["outputs"]]
+                    spend_privkey = int(given["key_material"]["spend_priv_key"], 16)
+                    found = scan(inputs, output_spks, bytes.fromhex(given["key_material"]["scan_priv_key"]),
+                                 (spend_privkey * G).to_bytes_compressed())
+                    expected = [{"output": output["pub_key"], "tweak": output["priv_key_tweak"]} for output in receiving["expected"
]["outputs"]]
+                    self.assertEqual(sorted(found, key=lambda o: o["output"]), sorted(expected, key=lambda o: o["output"]), test["c
omment"])
We may want to introduce an RPC for this, but not sure if it should be introduced as part of this PR. A scanner in python that passes the test vectors is relatively straightforward, and we can open this separately. <details> <summary>Python scanner</summary> ```diff diff --git a/test/functional/feature_framework_unit_tests.py b/test/functional/feature_framework_unit_tests.py index 7da6fb53c3..6947ca3d7b 100755 --- a/test/functional/feature_framework_unit_tests.py +++ b/test/functional/feature_framework_unit_tests.py @@ -16,6 +16,7 @@ from test_framework.test_framework import TEST_EXIT_PASSED, TEST_EXIT_FAILED # the output of `git grep unittest.TestCase ./test/functional/test_framework` TEST_FRAMEWORK_MODULES = [ "address", + "bip352", "crypto.bip324_cipher", "blocktools", "compressor", diff --git a/test/functional/test_framework/bip352.py b/test/functional/test_framework/bip352.py new file mode 100644 index 0000000000..74b56929a4 --- /dev/null +++ b/test/functional/test_framework/bip352.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026-present The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""BIP352 silent payments scanning, without labels.""" + +from io import BytesIO +import json +from pathlib import Path +import unittest + +from .crypto.secp256k1 import G, GE +from .key import H_POINT, ORDER, TaggedHash +from .messages import COutPoint, CTransaction, deser_string_vector, from_hex +from .script import hash160 +from .test_node import TestNode + +K_MAX = 2323 + +# (outpoint, scriptSig, witness stack, prevout scriptPubKey) +ScanInput = tuple[COutPoint, bytes, list[bytes], bytes] + + +def get_input_pubkey(script_sig: bytes, witness: list[bytes], prevout_spk: bytes) -> GE | None: + """Return the public key of an input as a GE, or None if the input is not eligible.""" + if len(prevout_spk) == 34 and prevout_spk[:2] == b"\x51\x20": + stack = list(witness) + if len(stack) > 1 and stack[-1][:1] == b"\x50": + stack.pop() + if len(stack) > 1 and stack[-1][1:33] == bytes.fromhex(H_POINT): + return None + return GE.from_bytes_xonly(prevout_spk[2:]) + if len(prevout_spk) == 22 and prevout_spk[:2] == b"\x00\x14": + if witness and len(witness[-1]) == 33: + return GE.from_bytes(witness[-1]) + return None + if len(prevout_spk) == 23 and prevout_spk[:2] == b"\xa9\x14": + if script_sig[:3] == b"\x16\x00\x14" and len(script_sig) == 23 and witness and len(witness[-1]) == 33: + return GE.from_bytes(witness[-1]) + return None + if len(prevout_spk) == 25 and prevout_spk[:3] == b"\x76\xa9\x14" and prevout_spk[23:] == b"\x88\xac": + for i in range(len(script_sig), 32, -1): + pubkey = script_sig[i - 33:i] + if hash160(pubkey) == prevout_spk[3:23]: + return GE.from_bytes(pubkey) + return None + + +def scan(inputs: list[ScanInput], output_spks: list[bytes], scan_privkey: bytes, spend_pubkey: bytes) -> list[dict[str, str]]: + """Find the outputs paying to a silent payments recipient. + + Return a list of {"output": x-only output key, "tweak": spend key tweak}, both hex. + """ + pubkeys = [pubkey for pubkey in (get_input_pubkey(*i[1:]) for i in inputs) if pubkey is not None] + A = sum(pubkeys, GE()) + if A.infinity: + return [] + smallest_outpoint = min(outpoint.serialize() for outpoint, *_ in inputs) + input_hash = int.from_bytes(TaggedHash("BIP0352/Inputs", smallest_outpoint + A.to_bytes_compressed()), "big") + ecdh_shared_secret = (input_hash * int.from_bytes(scan_privkey, "big") % ORDER) * A + B_spend = GE.from_bytes(spend_pubkey) + outputs = {spk[2:] for spk in output_spks if len(spk) == 34 and spk[:2] == b"\x51\x20"} + found: list[dict[str, str]] = [] + for k in range(K_MAX): + tweak = TaggedHash("BIP0352/SharedSecret", ecdh_shared_secret.to_bytes_compressed() + k.to_bytes(4, "big")) + P_k = (B_spend + int.from_bytes(tweak, "big") * G).to_bytes_xonly() + if P_k not in outputs: + break + found.append({"output": P_k.hex(), "tweak": tweak.hex()}) + return found + + +def scan_tx(node: TestNode, tx_hex: str, scan_privkey: bytes, spend_pubkey: bytes) -> list[dict[str, str]]: + """Scan a transaction, looking up its prevouts in the UTXO set of node, or with getrawtransaction.""" + tx = from_hex(CTransaction(), tx_hex) + inputs: list[ScanInput] = [] + for i, txin in enumerate(tx.vin): + txid, n = f"{txin.prevout.hash:064x}", txin.prevout.n + prevout = node.gettxout(txid, n, include_mempool=False) or node.getrawtransaction(txid, True)["vout"][n] + witness = tx.wit.vtxinwit[i].scriptWitness.stack if i < len(tx.wit.vtxinwit) else [] + inputs.append((txin.prevout, txin.scriptSig, witness, bytes.fromhex(prevout["scriptPubKey"]["hex"]))) + return scan(inputs, [txout.scriptPubKey for txout in tx.vout], scan_privkey, spend_pubkey) + + +class TestFrameworkBIP352(unittest.TestCase): + def test_receiving_vectors(self) -> None: + with (Path(__file__).parents[3] / "src/test/data/bip352_send_and_receive_vectors.json").open() as vectors_file: + for test in json.load(vectors_file): + for receiving in test["receiving"]: + given = receiving["given"] + if given["labels"]: + continue + inputs = [( + COutPoint(int(vin["txid"], 16), vin["vout"]), + bytes.fromhex(vin["scriptSig"]), + deser_string_vector(BytesIO(bytes.fromhex(vin["txinwitness"]))) if vin["txinwitness"] else [], + bytes.fromhex(vin["prevout"]["scriptPubKey"]["hex"]), + ) for vin in given["vin"]] + output_spks = [bytes.fromhex("5120" + output) for output in given["outputs"]] + spend_privkey = int(given["key_material"]["spend_priv_key"], 16) + found = scan(inputs, output_spks, bytes.fromhex(given["key_material"]["scan_priv_key"]), + (spend_privkey * G).to_bytes_compressed()) + expected = [{"output": output["pub_key"], "tweak": output["priv_key_tweak"]} for output in receiving["expected" ]["outputs"]] + self.assertEqual(sorted(found, key=lambda o: o["output"]), sorted(expected, key=lambda o: o["output"]), test["c omment"]) ``` </details>
Yudis-bit commented 2026-10-15 13:55:10 +00:00 (Migrated from github.com)

Failing when the key is missing at creation time makes sense, but the issue is during automatic coin selection.

If a wallet holds both tr(unspendable, pk(leaf)) and a wpkh utxo, CheckSilentPaymentsInput passes because provider exists, and AttemptSelectionSP treats it as eligible since internal_key != NUMS_H. If coin selection picks that taproot utxo, send aborts with Missing the private key... even though the wpkh coin alone could fund the tx.

Should AvailableCoins (or CheckSilentPaymentsInput) check if the provider can actually resolve the key first, so coin selection falls back to the wpkh utxo instead of failing the send?

Failing when the key is missing at creation time makes sense, but the issue is during automatic coin selection. If a wallet holds both `tr(unspendable, pk(leaf))` and a `wpkh` utxo, `CheckSilentPaymentsInput` passes because `provider` exists, and `AttemptSelectionSP` treats it as eligible since `internal_key != NUMS_H`. If coin selection picks that taproot utxo, `send` aborts with `Missing the private key...` even though the `wpkh` coin alone could fund the tx. Should `AvailableCoins` (or `CheckSilentPaymentsInput`) check if the provider can actually resolve the key first, so coin selection falls back to the `wpkh` utxo instead of failing the send?
rustaceanrob (Migrated from github.com) reviewed 2026-10-18 05:17:02 +00:00
rustaceanrob (Migrated from github.com) commented 2026-10-18 05:17:02 +00:00

This function seems like it could introduce surface for bugs. In the case of scriptChange for instance, the scriptChange variable is used in the actual transaction later. I would prefer if these calls were inlined if possible. In 3/4 cases it is easily replaceable, and in the case of scriptChange, I would recommend swapping for an optional similar to what was done elsewhere in the PR. It has the nice effect of showing if the change is nullopt when we expect a script for a new CTxOut, then the error is thrown in that same line.

diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp
index 1655346ac7..b85e3c6d5a 100644
--- a/src/wallet/feebumper.cpp
+++ b/src/wallet/feebumper.cpp
@@ -360,7 +360,8 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa
         if (!outputs.empty()) {
             temp_mtx.vout.clear();
             for (const auto& [dest, amount] : outputs) {
-                temp_mtx.vout.push_back(GetDummyTxOut(dest, amount));
+                // Empty placeholder OK, temp_mtx is dropped after the fee rate check
+                temp_mtx.vout.emplace_back(amount, dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{})));
             }
         }

diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 515b299f95..f9b534c8c2 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -1322,21 +1322,16 @@ void DiscourageFeeSniping(CMutableTransaction& tx, FastRandomContext& rng_fast,
     }
 }

-CTxOut GetDummyTxOut(const PaymentDestination& dest, CAmount amount)
-{
-    if (const auto script{dest.GetStaticScript()}) return CTxOut{amount, *script};
-    // BIP352 v0 outputs are P2TR outputs, which all have the same size
-    return CTxOut{amount, GetScriptForDestination(WitnessV1Taproot{})};
-}
-
 uint64_t GetSerializeSizeForRecipient(const CRecipient& recipient)
 {
-    return ::GetSerializeSize(GetDummyTxOut(recipient.dest, recipient.nAmount));
+    const CScript script{recipient.dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))};
+    return ::GetSerializeSize(CTxOut{recipient.nAmount, script});
 }

 bool IsDust(const CRecipient& recipient, const CFeeRate& dustRelayFee)
 {
-    return ::IsDust(GetDummyTxOut(recipient.dest, recipient.nAmount), dustRelayFee);
+    const CScript script{recipient.dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))};
+    return ::IsDust(CTxOut{recipient.nAmount, script}, dustRelayFee);
 }

 std::vector<SilentPaymentsDestination> GetSilentPaymentsDestinations(const std::vector<CRecipient>& recipients, const CCoinControl&
 coin_control, const CreatedTransactionResult& txr)
@@ -1442,7 +1437,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
     }

     // Create change script that will be used if we need change
-    CScript scriptChange;
+    std::optional<CScript> scriptChange;
     bilingual_str error; // possible error str

     // coin control: send change to custom address
@@ -1451,7 +1446,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
         if (coin_control.destChange->IsSilentPayment() && !coin_control.m_silent_payments) {
             return util::Error{_("Silent payments change requires a silent payments transaction")};
         }
-        scriptChange = GetDummyTxOut(*coin_control.destChange, /*amount=*/0).scriptPubKey;
+        scriptChange = coin_control.destChange->GetStaticScript();
     } else { // no coin control: send change to newly generated address
         // Note: We use a new key here to keep it from being obvious which side is the change.
         //  The drawback is that by not reusing a previous key, the change may be lost if a
@@ -1473,9 +1468,10 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
         // A valid destination implies a change script (and
         // vice-versa). An empty change script will abort later, if the
         // change keypool ran out, but change is required.
-        CHECK_NONFATAL(IsValidDestination(dest) != scriptChange.empty());
+        CHECK_NONFATAL(IsValidDestination(dest) == scriptChange.has_value());
     }
-    CTxOut change_prototype_txout(0, scriptChange);
+    const bool sp_change{coin_control.destChange && coin_control.destChange->IsSilentPayment()};
+    CTxOut change_prototype_txout(0, sp_change ? GetScriptForDestination(WitnessV1Taproot{}) : scriptChange.value_or(CScript{}));
     coin_selection_params.change_output_size = GetSerializeSize(change_prototype_txout);

     // Get size of spending the change output
@@ -1623,7 +1619,9 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
         txNew.vout.emplace_back(vecSend[i].nAmount, sp_it != sp_outputs.end() ? GetScriptForDestination(sp_it->second) : *Assert(ve
cSend[i].dest.GetStaticScript()));
     }
     if (change_amount > 0) {
-        CTxOut newTxOut(change_amount, scriptChange);
+        if (!scriptChange) return util::Error{_("Change amount is non-zero but no change address was set")};
+        CTxOut newTxOut(change_amount, *scriptChange);
         if (!change_pos) {
             // Insert change txn at random position:
             change_pos = rng_fast.randrange(txNew.vout.size() + 1);
@@ -1764,11 +1762,6 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
         return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))};
     }

-    // Give up if change keypool ran out and change is required
-    if (scriptChange.empty() && change_pos) {
-        return util::Error{error};
-    }
-
     if (sign && !wallet.SignTransaction(txNew)) {
         return util::Error{_("Signing transaction failed")};
     }
diff --git a/src/wallet/spend.h b/src/wallet/spend.h
index 8ffdc60099..1485dbcb5a 100644
--- a/src/wallet/spend.h
+++ b/src/wallet/spend.h
@@ -219,14 +219,6 @@ util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& av
                                           const CAmount& nTargetValue, const CCoinControl& coin_control,
                                           const CoinSelectionParams& coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wall
et);

-/**
- * Return an output of the same size as the one paying amount to dest, to estimate the
- * transaction size or check for dust before the inputs are known. A silent payments output
- * script is derived from the inputs, so a P2TR output is returned for a silent payments
- * destination, since BIP352 v0 outputs are P2TR outputs.
- */
-CTxOut GetDummyTxOut(const PaymentDestination& dest, CAmount amount);
-
This function seems like it could introduce surface for bugs. In the case of `scriptChange` for instance, the `scriptChange` variable is used in the actual transaction later. I would prefer if these calls were inlined if possible. In 3/4 cases it is easily replaceable, and in the case of `scriptChange`, I would recommend swapping for an `optional` similar to what was done elsewhere in the PR. It has the nice effect of showing if the change is `nullopt` when we expect a script for a new `CTxOut`, then the error is thrown in that same line. ```diff diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 1655346ac7..b85e3c6d5a 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -360,7 +360,8 @@ util::Expected<BumpTransaction, BumpError> CreateRateBumpTransaction(CWallet& wa if (!outputs.empty()) { temp_mtx.vout.clear(); for (const auto& [dest, amount] : outputs) { - temp_mtx.vout.push_back(GetDummyTxOut(dest, amount)); + // Empty placeholder OK, temp_mtx is dropped after the fee rate check + temp_mtx.vout.emplace_back(amount, dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))); } } diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 515b299f95..f9b534c8c2 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -1322,21 +1322,16 @@ void DiscourageFeeSniping(CMutableTransaction& tx, FastRandomContext& rng_fast, } } -CTxOut GetDummyTxOut(const PaymentDestination& dest, CAmount amount) -{ - if (const auto script{dest.GetStaticScript()}) return CTxOut{amount, *script}; - // BIP352 v0 outputs are P2TR outputs, which all have the same size - return CTxOut{amount, GetScriptForDestination(WitnessV1Taproot{})}; -} - uint64_t GetSerializeSizeForRecipient(const CRecipient& recipient) { - return ::GetSerializeSize(GetDummyTxOut(recipient.dest, recipient.nAmount)); + const CScript script{recipient.dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))}; + return ::GetSerializeSize(CTxOut{recipient.nAmount, script}); } bool IsDust(const CRecipient& recipient, const CFeeRate& dustRelayFee) { - return ::IsDust(GetDummyTxOut(recipient.dest, recipient.nAmount), dustRelayFee); + const CScript script{recipient.dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))}; + return ::IsDust(CTxOut{recipient.nAmount, script}, dustRelayFee); } std::vector<SilentPaymentsDestination> GetSilentPaymentsDestinations(const std::vector<CRecipient>& recipients, const CCoinControl& coin_control, const CreatedTransactionResult& txr) @@ -1442,7 +1437,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( } // Create change script that will be used if we need change - CScript scriptChange; + std::optional<CScript> scriptChange; bilingual_str error; // possible error str // coin control: send change to custom address @@ -1451,7 +1446,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( if (coin_control.destChange->IsSilentPayment() && !coin_control.m_silent_payments) { return util::Error{_("Silent payments change requires a silent payments transaction")}; } - scriptChange = GetDummyTxOut(*coin_control.destChange, /*amount=*/0).scriptPubKey; + scriptChange = coin_control.destChange->GetStaticScript(); } else { // no coin control: send change to newly generated address // Note: We use a new key here to keep it from being obvious which side is the change. // The drawback is that by not reusing a previous key, the change may be lost if a @@ -1473,9 +1468,10 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( // A valid destination implies a change script (and // vice-versa). An empty change script will abort later, if the // change keypool ran out, but change is required. - CHECK_NONFATAL(IsValidDestination(dest) != scriptChange.empty()); + CHECK_NONFATAL(IsValidDestination(dest) == scriptChange.has_value()); } - CTxOut change_prototype_txout(0, scriptChange); + const bool sp_change{coin_control.destChange && coin_control.destChange->IsSilentPayment()}; + CTxOut change_prototype_txout(0, sp_change ? GetScriptForDestination(WitnessV1Taproot{}) : scriptChange.value_or(CScript{})); coin_selection_params.change_output_size = GetSerializeSize(change_prototype_txout); // Get size of spending the change output @@ -1623,7 +1619,9 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( txNew.vout.emplace_back(vecSend[i].nAmount, sp_it != sp_outputs.end() ? GetScriptForDestination(sp_it->second) : *Assert(ve cSend[i].dest.GetStaticScript())); } if (change_amount > 0) { - CTxOut newTxOut(change_amount, scriptChange); + if (!scriptChange) return util::Error{_("Change amount is non-zero but no change address was set")}; + CTxOut newTxOut(change_amount, *scriptChange); if (!change_pos) { // Insert change txn at random position: change_pos = rng_fast.randrange(txNew.vout.size() + 1); @@ -1764,11 +1762,6 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal( return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))}; } - // Give up if change keypool ran out and change is required - if (scriptChange.empty() && change_pos) { - return util::Error{error}; - } - if (sign && !wallet.SignTransaction(txNew)) { return util::Error{_("Signing transaction failed")}; } diff --git a/src/wallet/spend.h b/src/wallet/spend.h index 8ffdc60099..1485dbcb5a 100644 --- a/src/wallet/spend.h +++ b/src/wallet/spend.h @@ -219,14 +219,6 @@ util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& av const CAmount& nTargetValue, const CCoinControl& coin_control, const CoinSelectionParams& coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wall et); -/** - * Return an output of the same size as the one paying amount to dest, to estimate the - * transaction size or check for dust before the inputs are known. A silent payments output - * script is derived from the inputs, so a P2TR output is returned for a silent payments - * destination, since BIP352 v0 outputs are P2TR outputs. - */ -CTxOut GetDummyTxOut(const PaymentDestination& dest, CAmount amount); - ```
Yudis-bit (Migrated from github.com) reviewed 2026-10-18 06:11:29 +00:00
Yudis-bit (Migrated from github.com) commented 2026-10-18 06:11:29 +00:00

The proposed change to CreateTransactionInternal introduces an empty error return on custom change failure paths.

In CreateTransactionInternal, bilingual_str error is only assigned when keypool reservation fails under the else branch. Under if (coin_control.destChange), error remains default-constructed. If destChange is a silent payments destination, destChange->GetStaticScript() returns std::nullopt. If change_amount > 0 and scriptChange is not populated, executing if (!scriptChange) return util::Error{error}; returns an empty string, yielding {"code": -4, "message": ""} via RPC. The failure path with coin_control.destChange set cannot reuse error and requires an explicit diagnostic.

Inlining dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{})) across feebumper.cpp, GetSerializeSizeForRecipient, IsDust, and change_prototype_txout duplicates the BIP352 v0 output structure across multiple wallet subsystems. It also necessitates the ad-hoc ternary sp_change solely to re-create the dummy taproot output for change_prototype_txout. A centralized sizing helper keeps the size assumption encapsulated, while unassigned change scripts can be guarded directly at the point scriptChange is resolved.

The proposed change to `CreateTransactionInternal` introduces an empty error return on custom change failure paths. In `CreateTransactionInternal`, `bilingual_str error` is only assigned when keypool reservation fails under the `else` branch. Under `if (coin_control.destChange)`, `error` remains default-constructed. If `destChange` is a silent payments destination, `destChange->GetStaticScript()` returns `std::nullopt`. If `change_amount > 0` and `scriptChange` is not populated, executing `if (!scriptChange) return util::Error{error};` returns an empty string, yielding `{"code": -4, "message": ""}` via RPC. The failure path with `coin_control.destChange` set cannot reuse `error` and requires an explicit diagnostic. Inlining `dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))` across `feebumper.cpp`, `GetSerializeSizeForRecipient`, `IsDust`, and `change_prototype_txout` duplicates the BIP352 v0 output structure across multiple wallet subsystems. It also necessitates the ad-hoc ternary `sp_change` solely to re-create the dummy taproot output for `change_prototype_txout`. A centralized sizing helper keeps the size assumption encapsulated, while unassigned change scripts can be guarded directly at the point `scriptChange` is resolved.
rustaceanrob (Migrated from github.com) reviewed 2026-10-18 11:32:49 +00:00
rustaceanrob (Migrated from github.com) commented 2026-10-18 11:32:49 +00:00

In CreateTransactionInternal, bilingual_str error is only assigned when keypool reservation fails under the else branch. Under if (coin_control.destChange), error remains default-constructed. If destChange is a silent payments destination, destChange->GetStaticScript() returns std::nullopt. If change_amount > 0 and scriptChange is not populated, executing if (!scriptChange) return util::Error{error}; returns an empty string, yielding {"code": -4, "message": ""} via RPC. The failure path with coin_control.destChange set cannot reuse error and requires an explicit diagnostic.

A simple "you did not set the error in the nullopt case" would've sufficed.

Inlining dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{})) across feebumper.cpp, GetSerializeSizeForRecipient, IsDust, and change_prototype_txout duplicates the BIP352 v0 output structure across multiple wallet subsystems. It also necessitates the ad-hoc ternary sp_change solely to re-create the dummy taproot output for change_prototype_txout. A centralized sizing helper keeps the size assumption encapsulated, while unassigned change scripts can be guarded directly at the point scriptChange is resolved.

There is no cost to creating the taproot output so I'm not sure what this comment is trying to imply. Doing this inline allows reviewers to convince themselves that a dummy taproot output will not be signed under any circumstance, and is only used for computing size and dust. In the case of the catch all condition (scriptChange.empty() && change_pos), this would pass for a template taproot output script AFICT. We should just use the type system to ensure we don't sign anything that can result in loss of funds.

> In CreateTransactionInternal, bilingual_str error is only assigned when keypool reservation fails under the else branch. Under if (coin_control.destChange), error remains default-constructed. If destChange is a silent payments destination, destChange->GetStaticScript() returns std::nullopt. If change_amount > 0 and scriptChange is not populated, executing if (!scriptChange) return util::Error{error}; returns an empty string, yielding {"code": -4, "message": ""} via RPC. The failure path with coin_control.destChange set cannot reuse error and requires an explicit diagnostic. A simple "you did not set the error in the nullopt case" would've sufficed. > Inlining dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{})) across feebumper.cpp, GetSerializeSizeForRecipient, IsDust, and change_prototype_txout duplicates the BIP352 v0 output structure across multiple wallet subsystems. It also necessitates the ad-hoc ternary sp_change solely to re-create the dummy taproot output for change_prototype_txout. A centralized sizing helper keeps the size assumption encapsulated, while unassigned change scripts can be guarded directly at the point scriptChange is resolved. There is no cost to creating the taproot output so I'm not sure what this comment is trying to imply. Doing this inline allows reviewers to convince themselves that a dummy taproot output will not be signed under any circumstance, and is only used for computing size and dust. In the case of the catch all condition `(scriptChange.empty() && change_pos)`, this would pass for a template taproot output script AFICT. We should just use the type system to ensure we don't sign anything that can result in loss of funds.
Yudis-bit (Migrated from github.com) reviewed 2026-10-18 14:05:06 +00:00
Yudis-bit (Migrated from github.com) commented 2026-10-18 14:05:06 +00:00

Fair enough, just wanted to flag the empty error on destChange.

Fair enough, just wanted to flag the empty error on `destChange`.
Eunovo (Migrated from github.com) reviewed 2026-10-21 13:14:49 +00:00
Eunovo (Migrated from github.com) commented 2026-10-21 13:14:49 +00:00

The purpose of GetDummyTxOut is to avoid duplicating the dummy script logic for silent payments outputs. I don't think this function inherently introduces bugs; I think it does the opposite by making it possible to change the dummy script logic in one place. I rewrote the scriptChange logic, but left the other code as is.

The purpose of `GetDummyTxOut` is to avoid duplicating the dummy script logic for silent payments outputs. I don't think this function inherently introduces bugs; I think it does the opposite by making it possible to change the dummy script logic in one place. I rewrote the `scriptChange` logic, but left the other code as is.
Eunovo commented 2026-10-21 13:17:40 +00:00 (Migrated from github.com)

If a wallet holds both tr(unspendable, pk(leaf)) and a wpkh utxo, CheckSilentPaymentsInput passes because provider exists, and AttemptSelectionSP treats it as eligible since internal_key != NUMS_H. If coin selection picks that taproot utxo, send aborts with Missing the private key... even though the wpkh coin alone could fund the tx.

Thanks for pointing this out. I have updated the rules in CheckSilentPaymentsInput to exclude eligible coins with missing private keys.

> If a wallet holds both `tr(unspendable, pk(leaf))` and a `wpkh` utxo, `CheckSilentPaymentsInput` passes because `provider` exists, and `AttemptSelectionSP` treats it as eligible since `internal_key != NUMS_H`. If coin selection picks that taproot utxo, `send` aborts with `Missing the private key...` even though the `wpkh` coin alone could fund the tx. Thanks for pointing this out. I have updated the rules in `CheckSilentPaymentsInput` to exclude eligible coins with missing private keys.
Eunovo (Migrated from github.com) reviewed 2026-10-21 13:18:21 +00:00
Eunovo (Migrated from github.com) commented 2026-10-21 13:18:21 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-10-21 13:18:51 +00:00
Eunovo (Migrated from github.com) commented 2026-10-21 13:18:51 +00:00

Done.

Done.
Yudis-bit (Migrated from github.com) reviewed 2026-11-01 01:58:13 +00:00
Yudis-bit (Migrated from github.com) commented 2026-11-01 01:58:13 +00:00

Wait, shouldn't this filter on selection_amount(output) <= 0 instead of output.GetEffectiveValue() <= 0? Under m_subtract_fee_outputs, an eligible anchor's effective value can be negative at higher feerates while its nominal value is positive, with fees absorbed by the recipient outputs. Checking GetEffectiveValue() <= 0 prematurely drops valid anchors and aborts with "No silent payment eligible inputs were found" even when the wallet has sufficient funds to cover the send.

Wait, shouldn't this filter on `selection_amount(output) <= 0` instead of `output.GetEffectiveValue() <= 0`? Under `m_subtract_fee_outputs`, an eligible anchor's effective value can be negative at higher feerates while its nominal value is positive, with fees absorbed by the recipient outputs. Checking `GetEffectiveValue() <= 0` prematurely drops valid anchors and aborts with "No silent payment eligible inputs were found" even when the wallet has sufficient funds to cover the send.
Eunovo (Migrated from github.com) reviewed 2026-11-02 10:06:55 +00:00
Eunovo (Migrated from github.com) commented 2026-11-02 10:06:55 +00:00

A negative effective value indicates that UTXO costs too much to spend. In the previous iteration, I allowed these negative coins, but I have changed my stance on the issue because I struggle to identify scenarios where we spend these coins. If this feature is important, then I suggest that we use an "opt-in" flag to allow this.

A negative effective value indicates that UTXO costs too much to spend. In the previous iteration, I allowed these negative coins, but I have changed my stance on the issue because I struggle to identify scenarios where we spend these coins. If this feature is important, then I suggest that we use an "opt-in" flag to allow this.
Yudis-bit (Migrated from github.com) reviewed 2026-11-02 12:50:22 +00:00
Yudis-bit (Migrated from github.com) commented 2026-11-02 12:50:22 +00:00

I struggle to identify scenarios where we spend these coins.

Consider funding a send from non-eligible inputs (e.g. 2-of-2 multisig or P2WSH holding 1 BTC) where the wallet's sole BIP-352 eligible coin is a 5,000 sat P2TR output.

At 80 sat/vB, that 68 vB input has a negative effective value (-440 sats). Under m_subtract_fee_outputs, the 1 BTC covers the payment and all fees, while the 5,000 sat coin is needed strictly as the BIP-352 key anchor.

Checking GetEffectiveValue() <= 0 discards this sole anchor and aborts with "No silent payment eligible inputs were found", failing a funded transaction.

Core's coin selection already defines GetSelectionAmount() as m_subtract_fee_outputs ? m_value : effective_value (coinselection.cpp:865). Filtering anchors on selection_amount(output) <= 0 aligns with this convention without an ad-hoc flag.

> I struggle to identify scenarios where we spend these coins. Consider funding a send from non-eligible inputs (e.g. 2-of-2 multisig or P2WSH holding 1 BTC) where the wallet's sole BIP-352 eligible coin is a 5,000 sat P2TR output. At 80 sat/vB, that 68 vB input has a negative effective value (-440 sats). Under `m_subtract_fee_outputs`, the 1 BTC covers the payment and all fees, while the 5,000 sat coin is needed strictly as the BIP-352 key anchor. Checking `GetEffectiveValue() <= 0` discards this sole anchor and aborts with "No silent payment eligible inputs were found", failing a funded transaction. Core's coin selection already defines `GetSelectionAmount()` as `m_subtract_fee_outputs ? m_value : effective_value` (`coinselection.cpp:865`). Filtering anchors on `selection_amount(output) <= 0` aligns with this convention without an ad-hoc flag.
Eunovo (Migrated from github.com) reviewed 2026-11-02 13:04:57 +00:00
Eunovo (Migrated from github.com) commented 2026-11-02 13:04:57 +00:00

We don't want to spend negative effective value coins even if they are the only eligible coins.

We don't want to spend negative effective value coins even if they are the only eligible coins.
polespinasa commented 2026-11-03 10:56:56 +00:00 (Migrated from github.com)

concept ACK

Reviewing this soon

concept ACK Reviewing this soon
DrahtBot commented 2026-11-03 19:16:16 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-04 20:48:57 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Yudis-bit (Migrated from github.com) reviewed 2026-11-05 16:21:58 +00:00
Yudis-bit (Migrated from github.com) commented 2026-11-05 16:21:58 +00:00

Can't an anchor with negative effective value still be used when m_subtract_fee_outputs is set?

In the previous iteration we discussed sorting anchors by nominal value for SFFO, but line 1007 still drops negative-effective coins before reaching std::ranges::sort. Should this check selection_amount(output) <= 0 instead?

Can't an anchor with negative effective value still be used when `m_subtract_fee_outputs` is set? In the previous iteration we discussed sorting anchors by nominal value for SFFO, but line 1007 still drops negative-effective coins before reaching `std::ranges::sort`. Should this check `selection_amount(output) <= 0` instead?
DrahtBot commented 2026-11-05 19:33:44 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
fametrano (Migrated from github.com) reviewed 2026-11-06 08:13:40 +00:00
fametrano (Migrated from github.com) left a comment

tACK 41f9f48a2b

Payments sent from this head are found by another BIP352 implementation, btclib-wallet's silent payments module at 155badbb48, each recipient with the amount requested, labelled addresses and shared scan keys included.

On regtest at 41f9f48a2b, I scanned 315 transactions from send, sendmany, sendtoaddress, sendall and bumpfee with that module, which reads the input keys and recomputes every output itself. The inputs mixed P2PKH, P2SH-P2WPKH, P2WPKH and P2TR coins with P2WSH and P2SH ones. The recipients were one scan key with two labels and a second spend key, and an unrelated scan key. 186 transactions had two or more outputs in one scan key group, and 90 had silent payment change on the recipients' scan key, 45 of them bumps after a wallet reload. Each of the 674 outputs matched the address it paid, with k numbered from 0 in each group.

The script, the results, and a control that fails when two labels are swapped: https://gist.github.com/fametrano/dddf157908ec6b92ecb42b16dd7535f7/cfb3b6763c7f4ba8e90704759016ed4c4bd082a2

tACK 41f9f48a2b Payments sent from this head are found by another BIP352 implementation, btclib-wallet's silent payments module at 155badbb48, each recipient with the amount requested, labelled addresses and shared scan keys included. On regtest at 41f9f48a2b, I scanned 315 transactions from send, sendmany, sendtoaddress, sendall and bumpfee with that module, which reads the input keys and recomputes every output itself. The inputs mixed P2PKH, P2SH-P2WPKH, P2WPKH and P2TR coins with P2WSH and P2SH ones. The recipients were one scan key with two labels and a second spend key, and an unrelated scan key. 186 transactions had two or more outputs in one scan key group, and 90 had silent payment change on the recipients' scan key, 45 of them bumps after a wallet reload. Each of the 674 outputs matched the address it paid, with k numbered from 0 in each group. The script, the results, and a control that fails when two labels are swapped: https://gist.github.com/fametrano/dddf157908ec6b92ecb42b16dd7535f7/cfb3b6763c7f4ba8e90704759016ed4c4bd082a2
Eunovo commented 2026-11-06 12:03:30 +00:00 (Migrated from github.com)

Rebased on master: git range-diff master 41f9f48 d5f146e

Rebased on master: `git range-diff master 41f9f48 d5f146e`
Yudis-bit (Migrated from github.com) reviewed 2026-11-06 15:01:11 +00:00
Yudis-bit (Migrated from github.com) left a comment

Re-tested against d5f146e.

Filtering unresolvable keys in AvailableCoins via CheckSilentPaymentsInput resolves the fallback cleanly. Coin selection now drops the leaf-only Taproot coin (tr(pub, pk(priv))) and picks the wpkh UTXO instead of failing the spend.

Also verified feebumper.cpp when change drops below dust. Collapsing the k counter keeps indexes contiguous so BIP-352 scanners don't abort early.

Passes wallet_silentpayments_sending.py and spend_tests. Tested ACK d5f146e.

Re-tested against d5f146e. Filtering unresolvable keys in `AvailableCoins` via `CheckSilentPaymentsInput` resolves the fallback cleanly. Coin selection now drops the leaf-only Taproot coin (`tr(pub, pk(priv))`) and picks the `wpkh` UTXO instead of failing the spend. Also verified `feebumper.cpp` when change drops below dust. Collapsing the k counter keeps indexes contiguous so BIP-352 scanners don't abort early. Passes `wallet_silentpayments_sending.py` and `spend_tests`. Tested ACK d5f146e.
davidgumberg commented 2026-11-07 01:49:55 +00:00 (Migrated from github.com)

Concept ACK

I think the approach here could be made more narrow by avoiding any special coin selection logic for paying to silent payments outputs, I think for most users, they will either have a wallet made up entirely of outputs that can be used for silent payments, or entirely of outputs that cannot be used for silent payments, I think it would be sufficient to just check if the coin selection is valid, and if not return an error, if users complain then I think it can be fixed in a follow-up.

(Also I suspect the current selection logic in this branch would be fingerprintable)

Concept ACK I think the approach here could be made more narrow by avoiding any special coin selection logic for paying to silent payments outputs, I think for most users, they will either have a wallet made up entirely of outputs that can be used for silent payments, or entirely of outputs that cannot be used for silent payments, I think it would be sufficient to just check if the coin selection is valid, and if not return an error, if users complain then I think it can be fixed in a follow-up. (Also I suspect the current selection logic in this branch would be fingerprintable)
Eunovo commented 2026-11-09 18:39:53 +00:00 (Migrated from github.com)

I've taken out the special coin-selection logic. The transaction creation process now fails if no eligible coins are selected.

I've taken out the special coin-selection logic. The transaction creation process now fails if no eligible coins are selected.
rustaceanrob (Migrated from github.com) reviewed 2026-11-10 12:58:45 +00:00
rustaceanrob (Migrated from github.com) left a comment

Did another review pass mostly focused on simplifying the tests

Did another review pass mostly focused on simplifying the tests
rustaceanrob (Migrated from github.com) commented 2026-11-10 10:43:00 +00:00

This could be a small source of confusion, the eventual taproot output will be a witness script. This is already optional so maybe it should be omitted

This could be a small source of confusion, the eventual taproot output will be a witness script. This is already optional so maybe it should be omitted
rustaceanrob (Migrated from github.com) commented 2026-11-10 09:49:14 +00:00

We could also test an uncompressed P2PKH is allowed as an input but does not contribute to the shared secret derivation

diff --git a/src/wallet/test/spend_tests.cpp b/src/wallet/test/spend_tests.cpp
index 9afe45e2da..7b6ea33467 100644
--- a/src/wallet/test/spend_tests.cpp
+++ b/src/wallet/test/spend_tests.cpp
@@ -140,6 +140,8 @@ BOOST_AUTO_TEST_CASE(check_silent_payments_input)
     const std::string priv{EncodeSecret(key)};
     const std::string pub{HexStr(GenerateRandomKey().GetPubKey())};
     const std::string xonly_pub{HexStr(XOnlyPubKey{GenerateRandomKey().GetPubKey()})};
+    const std::string uncompressed_priv{EncodeSecret(GenerateRandomKey(/*compressed=*/false))};
+    const std::string uncompressed_pub{HexStr(GenerateRandomKey(/*compressed=*/false).GetPubKey())};

     // Eligible coins require their private key, which the wallet does not have for external ones
     BOOST_CHECK(check("wpkh(" + priv + ")"));
@@ -154,6 +156,9 @@ BOOST_AUTO_TEST_CASE(check_silent_payments_input)
     const CScript p2wsh{GetScriptForDestination(WitnessV0ScriptHash{CScript{} << OP_TRUE})};
     BOOST_CHECK(check("wsh(pk(" + pub + "))"));
     BOOST_CHECK(check_external(p2wsh));
+    BOOST_CHECK(check("pkh(" + uncompressed_priv + ")"));
+    BOOST_CHECK(check("pkh(" + uncompressed_pub + ")"));
We could also test an uncompressed P2PKH is allowed as an input but does not contribute to the shared secret derivation ```diff diff --git a/src/wallet/test/spend_tests.cpp b/src/wallet/test/spend_tests.cpp index 9afe45e2da..7b6ea33467 100644 --- a/src/wallet/test/spend_tests.cpp +++ b/src/wallet/test/spend_tests.cpp @@ -140,6 +140,8 @@ BOOST_AUTO_TEST_CASE(check_silent_payments_input) const std::string priv{EncodeSecret(key)}; const std::string pub{HexStr(GenerateRandomKey().GetPubKey())}; const std::string xonly_pub{HexStr(XOnlyPubKey{GenerateRandomKey().GetPubKey()})}; + const std::string uncompressed_priv{EncodeSecret(GenerateRandomKey(/*compressed=*/false))}; + const std::string uncompressed_pub{HexStr(GenerateRandomKey(/*compressed=*/false).GetPubKey())}; // Eligible coins require their private key, which the wallet does not have for external ones BOOST_CHECK(check("wpkh(" + priv + ")")); @@ -154,6 +156,9 @@ BOOST_AUTO_TEST_CASE(check_silent_payments_input) const CScript p2wsh{GetScriptForDestination(WitnessV0ScriptHash{CScript{} << OP_TRUE})}; BOOST_CHECK(check("wsh(pk(" + pub + "))")); BOOST_CHECK(check_external(p2wsh)); + BOOST_CHECK(check("pkh(" + uncompressed_priv + ")")); + BOOST_CHECK(check("pkh(" + uncompressed_pub + ")")); ```
rustaceanrob (Migrated from github.com) commented 2026-11-10 12:24:07 +00:00

If this file included make_sp_addr from the head commit then wallet_backwards_compatibility and wallet_silentpayments_sending could both use it

If this file included `make_sp_addr` from the head commit then `wallet_backwards_compatibility` and `wallet_silentpayments_sending` could both use it
rustaceanrob (Migrated from github.com) commented 2026-11-10 09:16:52 +00:00
diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py
index bbc6c29e91f7..220355f2f196 100755
--- a/test/functional/wallet_silentpayments_sending.py
+++ b/test/functional/wallet_silentpayments_sending.py
@@ -41,9 +41,7 @@ def desc(template):
     return {"desc": descsum_create(template), "timestamp": "now", "active": True}
 
 def internal_desc(template):
-    d = desc(template)
-    d["internal"] = True
-    return d
+    return {**desc(template), "internal": True}
 
 class SilentPaymentsSendingTest(BitcoinTestFramework):
     def set_test_params(self):

```diff diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py index bbc6c29e91f7..220355f2f196 100755 --- a/test/functional/wallet_silentpayments_sending.py +++ b/test/functional/wallet_silentpayments_sending.py @@ -41,9 +41,7 @@ def desc(template): return {"desc": descsum_create(template), "timestamp": "now", "active": True} def internal_desc(template): - d = desc(template) - d["internal"] = True - return d + return {**desc(template), "internal": True} class SilentPaymentsSendingTest(BitcoinTestFramework): def set_test_params(self): ```
rustaceanrob (Migrated from github.com) commented 2026-11-10 09:09:58 +00:00

It looks like these are overriding optional arguments that can be passed directly

diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py
index 380ab3d2c708..2abc5631d995 100755
--- a/test/functional/wallet_silentpayments_sending.py
+++ b/test/functional/wallet_silentpayments_sending.py
@@ -64,23 +64,11 @@ def create_funded_wallet(
         disable_private_keys=False,
         address_type=None,
     ):
-        kwargs = {"wallet_name": name}
-        if blank:
-            kwargs["blank"] = True
-        if passphrase:
-            kwargs["passphrase"] = passphrase
-        if disable_private_keys:
-            kwargs["disable_private_keys"] = True
-        self.nodes[0].createwallet(**kwargs)
+        self.nodes[0].createwallet(wallet_name=name, blank=blank, passphrase=passphrase, disable_private_keys=disable_private_keys)
         wallet = self.nodes[0].get_wallet_rpc(name)
         if descriptors:
             wallet.importdescriptors(descriptors)
-        recv_addr = (
-            wallet.getnewaddress(address_type=address_type)
-            if address_type
-            else wallet.getnewaddress()
-        )
-        self.funder.sendtoaddress(recv_addr, amount)
+        self.funder.sendtoaddress(wallet.getnewaddress(address_type=address_type), amount)
         self.generate(self.nodes[0], 1)
         return wallet
 
It looks like these are overriding optional arguments that can be passed directly ```diff diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py index 380ab3d2c708..2abc5631d995 100755 --- a/test/functional/wallet_silentpayments_sending.py +++ b/test/functional/wallet_silentpayments_sending.py @@ -64,23 +64,11 @@ def create_funded_wallet( disable_private_keys=False, address_type=None, ): - kwargs = {"wallet_name": name} - if blank: - kwargs["blank"] = True - if passphrase: - kwargs["passphrase"] = passphrase - if disable_private_keys: - kwargs["disable_private_keys"] = True - self.nodes[0].createwallet(**kwargs) + self.nodes[0].createwallet(wallet_name=name, blank=blank, passphrase=passphrase, disable_private_keys=disable_private_keys) wallet = self.nodes[0].get_wallet_rpc(name) if descriptors: wallet.importdescriptors(descriptors) - recv_addr = ( - wallet.getnewaddress(address_type=address_type) - if address_type - else wallet.getnewaddress() - ) - self.funder.sendtoaddress(recv_addr, amount) + self.funder.sendtoaddress(wallet.getnewaddress(address_type=address_type), amount) self.generate(self.nodes[0], 1) return wallet ```
rustaceanrob (Migrated from github.com) commented 2026-11-10 08:49:29 +00:00

This and a few other places look like find_vout_for_address in util

diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py
index e5e02157ec35..7e7b41e21925 100755
--- a/test/functional/wallet_silentpayments_sending.py
+++ b/test/functional/wallet_silentpayments_sending.py
@@ -13,6 +13,7 @@
     assert_greater_than_or_equal,
     assert_not_equal,
     assert_raises_rpc_error,
+    find_vout_for_address,
 )
 from test_framework.wallet_util import generate_keypair
 
@@ -167,8 +168,7 @@ def fund_descriptor(self, wallet, template, amount):
         addr = self.nodes[0].deriveaddresses(descriptor, [0, 0] if "*" in template else None)[0]
         txid = self.funder.sendtoaddress(addr, amount)
         self.generate(self.nodes[0], 1)
-        vout = next(o["n"] for o in self.nodes[0].getrawtransaction(txid, True)["vout"] if o["scriptPubKey"].get("address") == addr)
-        return {"txid": txid, "vout": vout}
+        return {"txid": txid, "vout": find_vout_for_address(self.nodes[0], txid, addr)}
 
     def test_taproot_script_path_inputs(self):
         self.log.info("Testing explicit taproot inputs that have a script path")
@@ -388,7 +388,7 @@ def test_must_add_to_wallet(self):
         addr = node.deriveaddresses(descriptor)[0]
         external_txid = self.funder.sendtoaddress(addr, 2)
         self.generate(node, 1)
-        vout = next(o["n"] for o in node.getrawtransaction(external_txid, True)["vout"] if o["scriptPubKey"].get("address") == addr)
+        vout = find_vout_for_address(node, external_txid, addr)
         assert_raises_rpc_error(-4, "Silent payments transactions must be fully signed by the wallet",
             wallet.send, outputs=[{self.sp_addr_1: 3}],
             options={"inputs": [{"txid": external_txid, "vout": vout}], "solving_data": {"descriptors": [descriptor]}, "add_inputs": True, "lock_unspents": True})
@@ -554,7 +554,7 @@ def test_external_inputs(self):
             addr = owner.getnewaddress(address_type=address_type)
             txid = self.funder.sendtoaddress(addr, 5)
             self.generate(node, 1)
-            vout = next(o["n"] for o in node.getrawtransaction(txid, True)["vout"] if o["scriptPubKey"].get("address") == addr)
+            vout = find_vout_for_address(node, txid, addr)
             assert_raises_rpc_error(-4, f"External input COutPoint({txid[:10]}, {vout}) cannot be used in a silent payments transaction",
                 wallet.send, outputs=[{self.sp_addr_1: 1}],
                 options={"inputs": [{"txid": txid, "vout": vout}],
This and a few other places look like `find_vout_for_address` in `util` ```diff diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py index e5e02157ec35..7e7b41e21925 100755 --- a/test/functional/wallet_silentpayments_sending.py +++ b/test/functional/wallet_silentpayments_sending.py @@ -13,6 +13,7 @@ assert_greater_than_or_equal, assert_not_equal, assert_raises_rpc_error, + find_vout_for_address, ) from test_framework.wallet_util import generate_keypair @@ -167,8 +168,7 @@ def fund_descriptor(self, wallet, template, amount): addr = self.nodes[0].deriveaddresses(descriptor, [0, 0] if "*" in template else None)[0] txid = self.funder.sendtoaddress(addr, amount) self.generate(self.nodes[0], 1) - vout = next(o["n"] for o in self.nodes[0].getrawtransaction(txid, True)["vout"] if o["scriptPubKey"].get("address") == addr) - return {"txid": txid, "vout": vout} + return {"txid": txid, "vout": find_vout_for_address(self.nodes[0], txid, addr)} def test_taproot_script_path_inputs(self): self.log.info("Testing explicit taproot inputs that have a script path") @@ -388,7 +388,7 @@ def test_must_add_to_wallet(self): addr = node.deriveaddresses(descriptor)[0] external_txid = self.funder.sendtoaddress(addr, 2) self.generate(node, 1) - vout = next(o["n"] for o in node.getrawtransaction(external_txid, True)["vout"] if o["scriptPubKey"].get("address") == addr) + vout = find_vout_for_address(node, external_txid, addr) assert_raises_rpc_error(-4, "Silent payments transactions must be fully signed by the wallet", wallet.send, outputs=[{self.sp_addr_1: 3}], options={"inputs": [{"txid": external_txid, "vout": vout}], "solving_data": {"descriptors": [descriptor]}, "add_inputs": True, "lock_unspents": True}) @@ -554,7 +554,7 @@ def test_external_inputs(self): addr = owner.getnewaddress(address_type=address_type) txid = self.funder.sendtoaddress(addr, 5) self.generate(node, 1) - vout = next(o["n"] for o in node.getrawtransaction(txid, True)["vout"] if o["scriptPubKey"].get("address") == addr) + vout = find_vout_for_address(node, txid, addr) assert_raises_rpc_error(-4, f"External input COutPoint({txid[:10]}, {vout}) cannot be used in a silent payments transaction", wallet.send, outputs=[{self.sp_addr_1: 1}], options={"inputs": [{"txid": txid, "vout": vout}], ```
rustaceanrob (Migrated from github.com) commented 2026-11-10 09:00:28 +00:00

self.sp_addr_1 is a str already so do_send could just take a dictionary of {self.sp_addr: 5} directly

`self.sp_addr_1` is a `str` already so `do_send` could just take a dictionary of `{self.sp_addr: 5}` directly
rustaceanrob (Migrated from github.com) commented 2026-11-10 08:55:16 +00:00

The fee bumping and checking for confirmations comes up a few times. They could be a few small functions.

Suggested diff
diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py
index 106343e6535a..2ae5e6b2654e 100755
--- a/test/functional/wallet_silentpayments_sending.py
+++ b/test/functional/wallet_silentpayments_sending.py
@@ -143,9 +143,7 @@ def do_send(self, wallet, recipients, *, expect=(), expected_error=None, expecte
             self.assert_sp_outputs(txid, *expect)
 
         if mine_block:
-            self.generate(self.nodes[0], 1)
-            for txid in txids.values():
-                assert_equal(wallet.gettransaction(txid)["confirmations"], 1)
+            self.mine_and_check_confirmed(wallet, *txids.values())
 
         return txids
 
@@ -156,6 +154,18 @@ def assert_sp_outputs(self, txid, *recipients, n=1):
             found = scan_tx(self.nodes[0], tx_hex, r.scan_key.get_bytes(), r.spend_key.get_pubkey().get_bytes())
             assert_equal(len(found), n)
 
+    def bumpfee(self, wallet, txid, **options):
+        new_txid = wallet.bumpfee(txid, **options)["txid"]
+        mempool = self.nodes[0].getrawmempool()
+        assert new_txid in mempool
+        assert txid not in mempool
+        return new_txid
+
+    def mine_and_check_confirmed(self, wallet, *txids):
+        self.generate(self.nodes[0], 1)
+        for txid in txids:
+            assert_equal(wallet.gettransaction(txid)["confirmations"], 1)
+
     def fund_descriptor(self, wallet, template, amount):
         """Import a non-active descriptor into wallet and fund its first address. Return the funded outpoint."""
         descriptor = descsum_create(template)
@@ -373,9 +383,8 @@ def test_must_add_to_wallet(self):
 
         txid = wallet.sendtoaddress(self.sp_1.address, 1)
         assert_raises_rpc_error(-8, "psbtbumpfee does not support silent payments transactions, use bumpfee instead", wallet.psbtbumpfee, txid)
-        new_txid = wallet.bumpfee(txid)["txid"]
-        self.generate(node, 1)
-        assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+        new_txid = self.bumpfee(wallet, txid)
+        self.mine_and_check_confirmed(wallet, new_txid)
 
     def test_address_reuse(self):
         self.log.info("Testing that two sends to the same SP address produce distinct outputs")
@@ -444,34 +453,19 @@ def bump_and_confirm(wallet, send_fn):
             regular_addr = self.funder.getnewaddress()
 
             # Plain bumpfee
-            txid = send_fn(wallet)
-            assert txid in node.getrawmempool()
-            new_txid = wallet.bumpfee(txid)["txid"]
-            assert new_txid in node.getrawmempool()
-            assert txid not in node.getrawmempool()
-            self.generate(node, 1)
-            assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+            new_txid = self.bumpfee(wallet, send_fn(wallet))
+            self.mine_and_check_confirmed(wallet, new_txid)
             self.assert_sp_outputs(new_txid, self.sp_1)
 
             # bumpfee with outputs: add a new SP output and a regular output
-            txid = send_fn(wallet)
-            assert txid in node.getrawmempool()
-            new_txid = wallet.bumpfee(txid, outputs=[{self.sp_2.address: 1}, {regular_addr: 0.5}])["txid"]
-            assert new_txid in node.getrawmempool()
-            assert txid not in node.getrawmempool()
-            self.generate(node, 1)
-            assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+            new_txid = self.bumpfee(wallet, send_fn(wallet), outputs=[{self.sp_2.address: 1}, {regular_addr: 0.5}])
+            self.mine_and_check_confirmed(wallet, new_txid)
             # bumpfee with outputs= replaces all outputs; sp_addr_2 + change are the only SP output
             self.assert_sp_outputs(new_txid, self.sp_2)
 
             # bumpfee with outputs: replace existing outputs with a regular output (no SP output)
-            txid = send_fn(wallet)
-            assert txid in node.getrawmempool()
-            new_txid = wallet.bumpfee(txid, outputs=[{regular_addr: 0.5}])["txid"]
-            assert new_txid in node.getrawmempool()
-            assert txid not in node.getrawmempool()
-            self.generate(node, 1)
-            assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+            new_txid = self.bumpfee(wallet, send_fn(wallet), outputs=[{regular_addr: 0.5}])
+            self.mine_and_check_confirmed(wallet, new_txid)
 
         send_methods = [
             ("rbf_sendtoaddress", lambda w: w.sendtoaddress(self.sp_1.address, 5)),
@@ -490,15 +484,10 @@ def bump_and_confirm(wallet, send_fn):
         self.generate(node, 1)  # rbf_sendall funding UTXO now has 2 confs; extra UTXO has 1 conf
 
         txid = wallet.sendall(recipients=[self.sp_1.address], options={"maxconf": 1})["txid"]
-        assert txid in node.getrawmempool()
         original_input_count = len(node.getrawtransaction(txid, True)["vin"])
-        result = wallet.bumpfee(txid, fee_rate=500)
-        new_txid = result["txid"]
-        assert new_txid in node.getrawmempool()
-        assert txid not in node.getrawmempool()
+        new_txid = self.bumpfee(wallet, txid, fee_rate=500)
         assert_greater_than(len(node.getrawtransaction(new_txid, True)["vin"]), original_input_count)
-        self.generate(node, 1)
-        assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+        self.mine_and_check_confirmed(wallet, new_txid)
         self.assert_sp_outputs(new_txid, self.sp_1)
 
         # Test wallet unload/reload: verify m_sprecipients is persisted and RBF still works
@@ -508,11 +497,8 @@ def bump_and_confirm(wallet, send_fn):
         node.unloadwallet("rbf_reload")
         node.loadwallet("rbf_reload")
         wallet = node.get_wallet_rpc("rbf_reload")
-        new_txid = wallet.bumpfee(txid)["txid"]
-        assert new_txid in node.getrawmempool()
-        assert txid not in node.getrawmempool()
-        self.generate(node, 1)
-        assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+        new_txid = self.bumpfee(wallet, txid)
+        self.mine_and_check_confirmed(wallet, new_txid)
         self.assert_sp_outputs(new_txid, self.sp_1)
 
     def test_external_inputs(self):
@@ -540,18 +526,15 @@ def test_rbf_sp_change(self):
         sp_index = next(o["n"] for o in node.getrawtransaction(txid, True)["vout"] if o["value"] == 5)
 
         # The fee is deducted from the silent payments output, which is recomputed for the new inputs
-        new_txid = wallet.bumpfee(txid, {"original_change_index": sp_index})["txid"]
-        assert new_txid in node.getrawmempool()
-        assert txid not in node.getrawmempool()
+        new_txid = self.bumpfee(wallet, txid, original_change_index=sp_index)
         self.assert_sp_outputs(new_txid, self.sp_1)
         found = scan_tx(node, node.getrawtransaction(new_txid), self.sp_1.scan_key.get_bytes(), self.sp_1.spend_key.get_pubkey().get_bytes())
         sp_vout = next(o for o in node.getrawtransaction(new_txid, True)["vout"] if o["scriptPubKey"]["hex"] == "5120" + found[0]["output"])
         assert_greater_than(5, sp_vout["value"])
 
         # The silent payments change destination is persisted, so the output is found again on the next bump
-        newer_txid = wallet.bumpfee(new_txid)["txid"]
-        self.generate(node, 1)
-        assert_equal(wallet.gettransaction(newer_txid)["confirmations"], 1)
+        newer_txid = self.bumpfee(wallet, new_txid)
+        self.mine_and_check_confirmed(wallet, newer_txid)
         self.assert_sp_outputs(newer_txid, self.sp_1)
 
     def test_rbf_sp_change_dropped(self):
@@ -563,15 +546,14 @@ def test_rbf_sp_change_dropped(self):
         sp_index = next(o["n"] for o in node.getrawtransaction(txid, True)["vout"] if o["value"] == Decimal("0.00001"))
 
         # Deducting the higher fee from the sp_addr_1 output leaves less than dust, so it is dropped
-        new_txid = wallet.bumpfee(txid, {"original_change_index": sp_index, "fee_rate": 6})["txid"]
+        new_txid = self.bumpfee(wallet, txid, original_change_index=sp_index, fee_rate=6)
         assert_equal(len(node.getrawtransaction(new_txid, True)["vout"]), 2)
         self.assert_sp_outputs(new_txid, self.sp_1, n=0)
         self.assert_sp_outputs(new_txid, self.sp_3)
 
         # The remaining output is recomputed again when the replacement is bumped
-        newer_txid = wallet.bumpfee(new_txid)["txid"]
-        self.generate(node, 1)
-        assert_equal(wallet.gettransaction(newer_txid)["confirmations"], 1)
+        newer_txid = self.bumpfee(wallet, new_txid)
+        self.mine_and_check_confirmed(wallet, newer_txid)
         self.assert_sp_outputs(newer_txid, self.sp_1, n=0)
         self.assert_sp_outputs(newer_txid, self.sp_3)
 
@@ -591,11 +573,10 @@ def test_sp_change_address(self):
 
         # The change does not return to the wallet, so bumping adds an input, which changes the
         # silent payments output. The change destination is persisted, so the output is recomputed.
-        new_txid = wallet.bumpfee(txid)["txid"]
+        new_txid = self.bumpfee(wallet, txid)
         assert_greater_than(len(node.getrawtransaction(new_txid, True)["vin"]), num_inputs)
         self.assert_sp_outputs(new_txid, self.sp_1)
-        self.generate(node, 1)
-        assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1)
+        self.mine_and_check_confirmed(wallet, new_txid)
 
         self.log.info("- the transaction must be added to the wallet")
         for options, error in [

The fee bumping and checking for confirmations comes up a few times. They could be a few small functions. <details> <summary>Suggested diff</summary> ```diff diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py index 106343e6535a..2ae5e6b2654e 100755 --- a/test/functional/wallet_silentpayments_sending.py +++ b/test/functional/wallet_silentpayments_sending.py @@ -143,9 +143,7 @@ def do_send(self, wallet, recipients, *, expect=(), expected_error=None, expecte self.assert_sp_outputs(txid, *expect) if mine_block: - self.generate(self.nodes[0], 1) - for txid in txids.values(): - assert_equal(wallet.gettransaction(txid)["confirmations"], 1) + self.mine_and_check_confirmed(wallet, *txids.values()) return txids @@ -156,6 +154,18 @@ def assert_sp_outputs(self, txid, *recipients, n=1): found = scan_tx(self.nodes[0], tx_hex, r.scan_key.get_bytes(), r.spend_key.get_pubkey().get_bytes()) assert_equal(len(found), n) + def bumpfee(self, wallet, txid, **options): + new_txid = wallet.bumpfee(txid, **options)["txid"] + mempool = self.nodes[0].getrawmempool() + assert new_txid in mempool + assert txid not in mempool + return new_txid + + def mine_and_check_confirmed(self, wallet, *txids): + self.generate(self.nodes[0], 1) + for txid in txids: + assert_equal(wallet.gettransaction(txid)["confirmations"], 1) + def fund_descriptor(self, wallet, template, amount): """Import a non-active descriptor into wallet and fund its first address. Return the funded outpoint.""" descriptor = descsum_create(template) @@ -373,9 +383,8 @@ def test_must_add_to_wallet(self): txid = wallet.sendtoaddress(self.sp_1.address, 1) assert_raises_rpc_error(-8, "psbtbumpfee does not support silent payments transactions, use bumpfee instead", wallet.psbtbumpfee, txid) - new_txid = wallet.bumpfee(txid)["txid"] - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + new_txid = self.bumpfee(wallet, txid) + self.mine_and_check_confirmed(wallet, new_txid) def test_address_reuse(self): self.log.info("Testing that two sends to the same SP address produce distinct outputs") @@ -444,34 +453,19 @@ def bump_and_confirm(wallet, send_fn): regular_addr = self.funder.getnewaddress() # Plain bumpfee - txid = send_fn(wallet) - assert txid in node.getrawmempool() - new_txid = wallet.bumpfee(txid)["txid"] - assert new_txid in node.getrawmempool() - assert txid not in node.getrawmempool() - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + new_txid = self.bumpfee(wallet, send_fn(wallet)) + self.mine_and_check_confirmed(wallet, new_txid) self.assert_sp_outputs(new_txid, self.sp_1) # bumpfee with outputs: add a new SP output and a regular output - txid = send_fn(wallet) - assert txid in node.getrawmempool() - new_txid = wallet.bumpfee(txid, outputs=[{self.sp_2.address: 1}, {regular_addr: 0.5}])["txid"] - assert new_txid in node.getrawmempool() - assert txid not in node.getrawmempool() - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + new_txid = self.bumpfee(wallet, send_fn(wallet), outputs=[{self.sp_2.address: 1}, {regular_addr: 0.5}]) + self.mine_and_check_confirmed(wallet, new_txid) # bumpfee with outputs= replaces all outputs; sp_addr_2 + change are the only SP output self.assert_sp_outputs(new_txid, self.sp_2) # bumpfee with outputs: replace existing outputs with a regular output (no SP output) - txid = send_fn(wallet) - assert txid in node.getrawmempool() - new_txid = wallet.bumpfee(txid, outputs=[{regular_addr: 0.5}])["txid"] - assert new_txid in node.getrawmempool() - assert txid not in node.getrawmempool() - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + new_txid = self.bumpfee(wallet, send_fn(wallet), outputs=[{regular_addr: 0.5}]) + self.mine_and_check_confirmed(wallet, new_txid) send_methods = [ ("rbf_sendtoaddress", lambda w: w.sendtoaddress(self.sp_1.address, 5)), @@ -490,15 +484,10 @@ def bump_and_confirm(wallet, send_fn): self.generate(node, 1) # rbf_sendall funding UTXO now has 2 confs; extra UTXO has 1 conf txid = wallet.sendall(recipients=[self.sp_1.address], options={"maxconf": 1})["txid"] - assert txid in node.getrawmempool() original_input_count = len(node.getrawtransaction(txid, True)["vin"]) - result = wallet.bumpfee(txid, fee_rate=500) - new_txid = result["txid"] - assert new_txid in node.getrawmempool() - assert txid not in node.getrawmempool() + new_txid = self.bumpfee(wallet, txid, fee_rate=500) assert_greater_than(len(node.getrawtransaction(new_txid, True)["vin"]), original_input_count) - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + self.mine_and_check_confirmed(wallet, new_txid) self.assert_sp_outputs(new_txid, self.sp_1) # Test wallet unload/reload: verify m_sprecipients is persisted and RBF still works @@ -508,11 +497,8 @@ def bump_and_confirm(wallet, send_fn): node.unloadwallet("rbf_reload") node.loadwallet("rbf_reload") wallet = node.get_wallet_rpc("rbf_reload") - new_txid = wallet.bumpfee(txid)["txid"] - assert new_txid in node.getrawmempool() - assert txid not in node.getrawmempool() - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + new_txid = self.bumpfee(wallet, txid) + self.mine_and_check_confirmed(wallet, new_txid) self.assert_sp_outputs(new_txid, self.sp_1) def test_external_inputs(self): @@ -540,18 +526,15 @@ def test_rbf_sp_change(self): sp_index = next(o["n"] for o in node.getrawtransaction(txid, True)["vout"] if o["value"] == 5) # The fee is deducted from the silent payments output, which is recomputed for the new inputs - new_txid = wallet.bumpfee(txid, {"original_change_index": sp_index})["txid"] - assert new_txid in node.getrawmempool() - assert txid not in node.getrawmempool() + new_txid = self.bumpfee(wallet, txid, original_change_index=sp_index) self.assert_sp_outputs(new_txid, self.sp_1) found = scan_tx(node, node.getrawtransaction(new_txid), self.sp_1.scan_key.get_bytes(), self.sp_1.spend_key.get_pubkey().get_bytes()) sp_vout = next(o for o in node.getrawtransaction(new_txid, True)["vout"] if o["scriptPubKey"]["hex"] == "5120" + found[0]["output"]) assert_greater_than(5, sp_vout["value"]) # The silent payments change destination is persisted, so the output is found again on the next bump - newer_txid = wallet.bumpfee(new_txid)["txid"] - self.generate(node, 1) - assert_equal(wallet.gettransaction(newer_txid)["confirmations"], 1) + newer_txid = self.bumpfee(wallet, new_txid) + self.mine_and_check_confirmed(wallet, newer_txid) self.assert_sp_outputs(newer_txid, self.sp_1) def test_rbf_sp_change_dropped(self): @@ -563,15 +546,14 @@ def test_rbf_sp_change_dropped(self): sp_index = next(o["n"] for o in node.getrawtransaction(txid, True)["vout"] if o["value"] == Decimal("0.00001")) # Deducting the higher fee from the sp_addr_1 output leaves less than dust, so it is dropped - new_txid = wallet.bumpfee(txid, {"original_change_index": sp_index, "fee_rate": 6})["txid"] + new_txid = self.bumpfee(wallet, txid, original_change_index=sp_index, fee_rate=6) assert_equal(len(node.getrawtransaction(new_txid, True)["vout"]), 2) self.assert_sp_outputs(new_txid, self.sp_1, n=0) self.assert_sp_outputs(new_txid, self.sp_3) # The remaining output is recomputed again when the replacement is bumped - newer_txid = wallet.bumpfee(new_txid)["txid"] - self.generate(node, 1) - assert_equal(wallet.gettransaction(newer_txid)["confirmations"], 1) + newer_txid = self.bumpfee(wallet, new_txid) + self.mine_and_check_confirmed(wallet, newer_txid) self.assert_sp_outputs(newer_txid, self.sp_1, n=0) self.assert_sp_outputs(newer_txid, self.sp_3) @@ -591,11 +573,10 @@ def test_sp_change_address(self): # The change does not return to the wallet, so bumping adds an input, which changes the # silent payments output. The change destination is persisted, so the output is recomputed. - new_txid = wallet.bumpfee(txid)["txid"] + new_txid = self.bumpfee(wallet, txid) assert_greater_than(len(node.getrawtransaction(new_txid, True)["vin"]), num_inputs) self.assert_sp_outputs(new_txid, self.sp_1) - self.generate(node, 1) - assert_equal(wallet.gettransaction(new_txid)["confirmations"], 1) + self.mine_and_check_confirmed(wallet, new_txid) self.log.info("- the transaction must be added to the wallet") for options, error in [ ``` </details>
rustaceanrob (Migrated from github.com) commented 2026-11-10 09:03:54 +00:00

These are essentially doing the same thing, they could potentially be integrated into one function

Suggested diff
diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py
index 2fd1e8c067be..4ae48213bfc4 100755
--- a/test/functional/wallet_silentpayments_sending.py
+++ b/test/functional/wallet_silentpayments_sending.py
@@ -222,19 +222,6 @@ def test_encrypted_wallet_unlocked(self):
         wallet.walletpassphrase("passphrase", 120)
         self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1])
 
-    def test_p2tr_inputs(self):
-        self.log.info("Testing P2TR inputs are eligible for silent payments")
-        wallet = self.create_funded_wallet(
-            "p2tr_wallet",
-            blank=True,
-            address_type="bech32m",
-            descriptors=[
-                desc(f"tr({self.xprv}/86h/1h/0h/0/*)"),
-                internal_desc(f"tr({self.xprv}/86h/1h/0h/1/*)"),
-            ],
-        )
-        self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1])
-
     def test_inputs_with_multiple_spkms(self):
         self.log.info("Testing inputs whose script is managed by more than one ScriptPubKeyMan")
         recv = f"{self.xprv}/19/0/*"
@@ -251,33 +238,22 @@ def test_inputs_with_multiple_spkms(self):
         assert result["success"], result
         self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1])
 
-    def test_p2pkh_inputs(self):
-        self.log.info("Testing P2PKH inputs are eligible for silent payments")
-        wallet = self.create_funded_wallet(
-            "p2pkh_wallet",
-            blank=True,
-            address_type="legacy",
-            descriptors=[
-                desc(f"pkh({self.xprv}/44h/1h/0h/0/*)"),
-                # P2WPKH for change — wallet default change type is bech32
-                internal_desc(f"wpkh({self.xprv}/84h/1h/0h/1/*)"),
-            ],
-        )
-        self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1])
-
-    def test_p2sh_p2wpkh_inputs(self):
-        self.log.info("Testing P2SH-P2WPKH inputs are eligible for silent payments")
-        wallet = self.create_funded_wallet(
-            "p2sh_p2wpkh_wallet",
-            blank=True,
-            address_type="p2sh-segwit",
-            descriptors=[
-                desc(f"sh(wpkh({self.xprv}/49h/1h/0h/0/*))"),
-                # P2WPKH for change — wallet default change type is bech32
-                internal_desc(f"wpkh({self.xprv}/84h/1h/0h/1/*)"),
-            ],
-        )
-        self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1])
+    def test_eligible_input_types(self):
+        # P2WPKH for change — wallet default change type is bech32
+        wpkh_change = f"wpkh({self.xprv}/84h/1h/0h/1/*)"
+        for input_type, address_type, recv, change in [
+            ("P2TR", "bech32m", f"tr({self.xprv}/86h/1h/0h/0/*)", f"tr({self.xprv}/86h/1h/0h/1/*)"),
+            ("P2PKH", "legacy", f"pkh({self.xprv}/44h/1h/0h/0/*)", wpkh_change),
+            ("P2SH-P2WPKH", "p2sh-segwit", f"sh(wpkh({self.xprv}/49h/1h/0h/0/*))", wpkh_change),
+        ]:
+            self.log.info(f"Testing {input_type} inputs are eligible for silent payments")
+            wallet = self.create_funded_wallet(
+                f"eligible_{address_type}",
+                blank=True,
+                address_type=address_type,
+                descriptors=[desc(recv), internal_desc(change)],
+            )
+            self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1])
 
     def test_no_eligible_inputs(self):
         self.log.info("Testing wallet with only P2WSH inputs cannot send silent payments")
@@ -613,9 +589,7 @@ def run_test(self):
         self.test_encrypted_wallet_locked()
         self.test_encrypted_wallet_unlocked()
 
-        self.test_p2tr_inputs()
-        self.test_p2pkh_inputs()
-        self.test_p2sh_p2wpkh_inputs()
+        self.test_eligible_input_types()
         self.test_no_eligible_inputs()
         self.test_preset_eligible_input()
         self.test_preset_ineligible_input()

These are essentially doing the same thing, they could potentially be integrated into one function <details> <summary>Suggested diff</summary> ```diff diff --git a/test/functional/wallet_silentpayments_sending.py b/test/functional/wallet_silentpayments_sending.py index 2fd1e8c067be..4ae48213bfc4 100755 --- a/test/functional/wallet_silentpayments_sending.py +++ b/test/functional/wallet_silentpayments_sending.py @@ -222,19 +222,6 @@ def test_encrypted_wallet_unlocked(self): wallet.walletpassphrase("passphrase", 120) self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1]) - def test_p2tr_inputs(self): - self.log.info("Testing P2TR inputs are eligible for silent payments") - wallet = self.create_funded_wallet( - "p2tr_wallet", - blank=True, - address_type="bech32m", - descriptors=[ - desc(f"tr({self.xprv}/86h/1h/0h/0/*)"), - internal_desc(f"tr({self.xprv}/86h/1h/0h/1/*)"), - ], - ) - self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1]) - def test_inputs_with_multiple_spkms(self): self.log.info("Testing inputs whose script is managed by more than one ScriptPubKeyMan") recv = f"{self.xprv}/19/0/*" @@ -251,33 +238,22 @@ def test_inputs_with_multiple_spkms(self): assert result["success"], result self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1]) - def test_p2pkh_inputs(self): - self.log.info("Testing P2PKH inputs are eligible for silent payments") - wallet = self.create_funded_wallet( - "p2pkh_wallet", - blank=True, - address_type="legacy", - descriptors=[ - desc(f"pkh({self.xprv}/44h/1h/0h/0/*)"), - # P2WPKH for change — wallet default change type is bech32 - internal_desc(f"wpkh({self.xprv}/84h/1h/0h/1/*)"), - ], - ) - self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1]) - - def test_p2sh_p2wpkh_inputs(self): - self.log.info("Testing P2SH-P2WPKH inputs are eligible for silent payments") - wallet = self.create_funded_wallet( - "p2sh_p2wpkh_wallet", - blank=True, - address_type="p2sh-segwit", - descriptors=[ - desc(f"sh(wpkh({self.xprv}/49h/1h/0h/0/*))"), - # P2WPKH for change — wallet default change type is bech32 - internal_desc(f"wpkh({self.xprv}/84h/1h/0h/1/*)"), - ], - ) - self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1]) + def test_eligible_input_types(self): + # P2WPKH for change — wallet default change type is bech32 + wpkh_change = f"wpkh({self.xprv}/84h/1h/0h/1/*)" + for input_type, address_type, recv, change in [ + ("P2TR", "bech32m", f"tr({self.xprv}/86h/1h/0h/0/*)", f"tr({self.xprv}/86h/1h/0h/1/*)"), + ("P2PKH", "legacy", f"pkh({self.xprv}/44h/1h/0h/0/*)", wpkh_change), + ("P2SH-P2WPKH", "p2sh-segwit", f"sh(wpkh({self.xprv}/49h/1h/0h/0/*))", wpkh_change), + ]: + self.log.info(f"Testing {input_type} inputs are eligible for silent payments") + wallet = self.create_funded_wallet( + f"eligible_{address_type}", + blank=True, + address_type=address_type, + descriptors=[desc(recv), internal_desc(change)], + ) + self.do_send(wallet, {self.sp_1.address: 5}, expect=[self.sp_1]) def test_no_eligible_inputs(self): self.log.info("Testing wallet with only P2WSH inputs cannot send silent payments") @@ -613,9 +589,7 @@ def run_test(self): self.test_encrypted_wallet_locked() self.test_encrypted_wallet_unlocked() - self.test_p2tr_inputs() - self.test_p2pkh_inputs() - self.test_p2sh_p2wpkh_inputs() + self.test_eligible_input_types() self.test_no_eligible_inputs() self.test_preset_eligible_input() self.test_preset_ineligible_input() ``` </details>
rustaceanrob (Migrated from github.com) commented 2026-11-10 09:30:53 +00:00

Some other cases to potentially cover: psbtbumpfee is an error for SP outputs and a transaction paying to a regular address can be bumped to an SP address.

Some other cases to potentially cover: `psbtbumpfee` is an error for SP outputs and a transaction paying to a regular address can be bumped to an SP address.
DrahtBot commented 2026-11-10 17:17:19 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
fametrano (Migrated from github.com) reviewed 2026-11-10 21:42:47 +00:00
fametrano (Migrated from github.com) left a comment

reACK 6cbb0ea9dc

Since 41f9f48a the only non-test change is the removal of SelectCoinsForSilentPayments, as davidgumberg suggested. Its tests went with it: the coinselector_tests cases, test_prefer_eligible_inputs and the add_inputs=True half of test_preset_ineligible_input. The rest of the range-diff moves code between commits and adapts to the new base.

I re-ran the same scan on this head, with the same seeds. It covered 177 transactions from send, sendmany, sendtoaddress, sendall and bumpfee. 30 of them have silent payment change, and half of those 30 are bumps after a wallet reload. Each of the 401 outputs matched the address it paid, with k numbered from 0 in each group. The control that swaps two labels still fails. Updated script and results: https://gist.github.com/fametrano/64b0d2e27c3f852278575c7f53400fe2/4bd8f772441ca5abfb87851cbed3dadb2a7a1f70

reACK 6cbb0ea9dc96cf4ab4a225a4d97e2dae70369b05 Since 41f9f48a the only non-test change is the removal of `SelectCoinsForSilentPayments`, as davidgumberg suggested. Its tests went with it: the `coinselector_tests` cases, `test_prefer_eligible_inputs` and the `add_inputs=True` half of `test_preset_ineligible_input`. The rest of the range-diff moves code between commits and adapts to the new base. I re-ran the same scan on this head, with the same seeds. It covered 177 transactions from send, sendmany, sendtoaddress, sendall and bumpfee. 30 of them have silent payment change, and half of those 30 are bumps after a wallet reload. Each of the 401 outputs matched the address it paid, with k numbered from 0 in each group. The control that swaps two labels still fails. Updated script and results: https://gist.github.com/fametrano/64b0d2e27c3f852278575c7f53400fe2/4bd8f772441ca5abfb87851cbed3dadb2a7a1f70
ValeraFinebits commented 2026-11-11 15:23:37 +00:00 (Migrated from github.com)

Could you please clarify whether this is expected: after restoring a backup made before an SP payment, bumpfee can add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment?

Could you please clarify whether this is expected: after restoring a backup made before an SP payment, `bumpfee` can add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment?
Yudis-bit commented 2026-11-11 16:05:24 +00:00 (Migrated from github.com)

Does bumpfee need to reject adding inputs when an unconfirmed tx has external P2TR outputs and no recipient data?

In feebumper.cpp:263, wtx.RBFNeedsSilentPayments() only catches missing recipient data if the transaction was recorded in that wallet database instance. When restoring a pre-send backup, mempool sync populates mapWallet via AddToWalletIfInvolvingMe without setting m_rbf_needs_sp_outputs.

Because external P2TR outputs are indistinguishable on-chain from standard Taproot sends, bumpfee treats the output as static. If change cannot cover the bump and coin selection adds inputs, the aggregate private key shifts while the scriptPubKey retains the stale tweak, causing BIP-352 scanning to miss the output. Bumping only remains valid here if the input set stays identical (fee deducted from change) or if the caller explicitly supplies the recipient via outputs=[{...}].

Does `bumpfee` need to reject adding inputs when an unconfirmed tx has external P2TR outputs and no recipient data? In `feebumper.cpp:263`, `wtx.RBFNeedsSilentPayments()` only catches missing recipient data if the transaction was recorded in that wallet database instance. When restoring a pre-send backup, mempool sync populates `mapWallet` via `AddToWalletIfInvolvingMe` without setting `m_rbf_needs_sp_outputs`. Because external P2TR outputs are indistinguishable on-chain from standard Taproot sends, `bumpfee` treats the output as static. If change cannot cover the bump and coin selection adds inputs, the aggregate private key shifts while the scriptPubKey retains the stale tweak, causing BIP-352 scanning to miss the output. Bumping only remains valid here if the input set stays identical (fee deducted from change) or if the caller explicitly supplies the recipient via `outputs=[{...}]`.
Eunovo commented 2026-11-12 21:20:35 +00:00 (Migrated from github.com)

Could you please clarify whether this is expected: after restoring a backup made before an SP payment, bumpfee can add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment?

Could you clarify the scenario? Is the restored wallet finding the SP transaction via the mempool? If so, I think this is the same issue as #36605 (a wallet with the keys to an SP transaction it didn't create can wrongly RBF it). Solutions are being discussed there.

> Could you please clarify whether this is expected: after restoring a backup made before an SP payment, `bumpfee` can add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment? Could you clarify the scenario? Is the restored wallet finding the SP transaction via the mempool? If so, I think this is the same issue as #36605 (a wallet with the keys to an SP transaction it didn't create can wrongly RBF it). Solutions are being discussed there.
ValeraFinebits commented 2026-11-13 09:16:58 +00:00 (Migrated from github.com)

Could you please clarify whether this is expected: after restoring a backup made before an SP payment, bumpfee can add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment?

Could you clarify the scenario? Is the restored wallet finding the SP transaction via the mempool? If so, I think this is the same issue as #36605 (a wallet with the keys to an SP transaction it didn't create can wrongly RBF it). Solutions are being discussed there.

Yes, the restored wallet discovers the transaction from the mempool. The backup predates the SP payment, so the wallet has the input keys but lacks the SP recipient metadata. Thanks for pointing me to #36605 this appears to be the same underlying issue.

> > Could you please clarify whether this is expected: after restoring a backup made before an SP payment, `bumpfee` can add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment? > > Could you clarify the scenario? Is the restored wallet finding the SP transaction via the mempool? If so, I think this is the same issue as [#36605](https://github.com/bitcoin/bitcoin/issues/36605) (a wallet with the keys to an SP transaction it didn't create can wrongly RBF it). Solutions are being discussed there. Yes, the restored wallet discovers the transaction from the mempool. The backup predates the SP payment, so the wallet has the input keys but lacks the SP recipient metadata. Thanks for pointing me to #36605 this appears to be the same underlying issue.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:24:42 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:24:42 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:24:56 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:24:56 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:25:57 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:25:57 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:26:20 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:26:20 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:26:57 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:26:57 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:27:14 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:27:14 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:27:28 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:27:28 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:28:04 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:28:04 +00:00

Done.

Done.
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:30:00 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:30:00 +00:00

Done,

Done,
Eunovo (Migrated from github.com) reviewed 2026-11-14 14:30:28 +00:00
Eunovo (Migrated from github.com) commented 2026-11-14 14:30:28 +00:00

Done.

Done.
ValeraFinebits commented 2026-11-17 18:59:08 +00:00 (Migrated from github.com)

Do you plan to let users save Silent Payments addresses with a label in the wallet's address book as part of this PR, like they can with regular addresses?

Do you plan to let users save Silent Payments addresses with a label in the wallet's address book as part of this PR, like they can with regular addresses?
Eunovo commented 2026-11-18 11:59:39 +00:00 (Migrated from github.com)

Do you plan to let users save Silent Payments addresses with a label in the wallet's address book as part of this PR, like they can with regular addresses?

I think this should be done in a follow-up PR. The address book currently accepts CTxDestination, so it won't work for Silent Payments addresses.

> Do you plan to let users save Silent Payments addresses with a label in the wallet's address book as part of this PR, like they can with regular addresses? I think this should be done in a follow-up PR. The address book currently accepts `CTxDestination`, so it won't work for Silent Payments addresses.
Eunovo commented 2026-11-19 11:43:27 +00:00 (Migrated from github.com)

I reverted the decision to make CCoinCointrol::destChange an std::optional, because it creates 2 values (instead of just 1 on master) that CreateTransactionInternal interprets as no custom change:

  • std::nullopt and
  • CNoDestination
    By setting destChange to PaymentDestination(CNoDestination()) by default, CreateTransactionInternal only checks that case and decides whether to generate a change address.

I also slightly adjusted the PaymentDestination API to reduce the code required by users of the API.

I reverted the decision to make `CCoinCointrol::destChange` an `std::optional`, because it creates 2 values (instead of just 1 on master) that `CreateTransactionInternal` interprets as no custom change: - `std::nullopt` and - `CNoDestination` By setting `destChange` to `PaymentDestination(CNoDestination())` by default, `CreateTransactionInternal` only checks that case and decides whether to generate a change address. I also slightly adjusted the `PaymentDestination` API to reduce the code required by users of the API.
DrahtBot commented 2026-11-20 22:56:08 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
rustaceanrob commented 2026-11-24 08:56:21 +00:00 (Migrated from github.com)

Haven't done a full re-review, but is cbc9a4a1bc something we should address in a separate PR? This behavior is a mistake on the user behalf I would imagine, but having the CNoDestination get replaced with something else seems bad for meta protocols. I can imagine a transaction that attempts to commit to a proof in an OP_RETURN and when trying to fee bump, the OP_RETURN gets replaced by something else. Raising an error seems like the right thing to do regardless of what happens here?

Haven't done a full re-review, but is cbc9a4a1bcf70de19798e5a387fcef7897715086 something we should address in a separate PR? This behavior is a mistake on the user behalf I would imagine, but having the `CNoDestination` get replaced with something else seems bad for meta protocols. I can imagine a transaction that attempts to commit to a proof in an `OP_RETURN` and when trying to fee bump, the `OP_RETURN` gets replaced by something else. Raising an error seems like the right thing to do regardless of what happens here?
Eunovo commented 2026-11-24 12:11:03 +00:00 (Migrated from github.com)
Reply to https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-7126751401, opened https://github.com/bitcoin/bitcoin/pull/36962 with the first 2 commits.
Eunovo commented 2026-11-24 12:58:49 +00:00 (Migrated from github.com)
Rebased on master now that https://github.com/bitcoin/bitcoin/pull/36835 is merged.
DrahtBot commented 2026-12-03 13:35:23 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35302
No description provided.