mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:11:37 +00:00
Silent Payments: Sending (take 2) #35302
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35302
Loading…
Reference in a new issue
No description provided.
Delete branch "implement-bip352-sending"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
PaymentDestinationis added to containCTxDestinationorSilentPaymentsDestinationadd_to_wallet=FalseThe 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.
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:
util::Resultfor fee bumping methods by rustaceanrob)original_change_indexoutput without a destination by Eunovo)-Wunusedby fanquake)WalletBatchwrite failures by achow101)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++, andfunc(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"]→ Preferassert_greater_than(self.wallet.getbalances()["mine"]["trusted"], 0).2026-12-03 14:42:53
Concept ACK 03c835d
in
e3ef349ad5: any reason why the coin_control instance got moved up?in
e3ef349ad5: for functions starting withIs, I'd usually expect to return a boolean value. maybe rename with usingEnsureas a prefix instead?in
e3ef349ad5: could slightly simplify by usingstd::any_ofinstead (returns a bool instead of an iterator)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).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.@theStack I'll attend to your reviews when I rebase on https://github.com/bitcoin/bitcoin/pull/35301
Done.
Removed.
Done.
Done.
Reverted.
🚧 At least one of the CI tasks failed.
Task
lint: https://github.com/bitcoin/bitcoin/actions/runs/27090770600/job/79953877713LLM 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.
🐙 This pull request conflicts with the target branch and needs rebase.
Reviewed only the last testing commit partially 989d354 "tests: add sending functional tests".
In 989d3548c6933a4bc31b82a6f950029440e1d232 "tests: add sending functional tests"
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 989d354 "tests: add sending functional tests"
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"
github.com/bitcoin/bitcoin@d84fc352cb/src/wallet/rpc/spend.cpp (L1003-L1006)🚧 At least one of the CI tasks failed.
Task
Windows native, fuzz, VS: https://github.com/bitcoin/bitcoin/actions/runs/28226175984/job/83618564020LLM reason (✨ experimental): CI failed because the fuzz RPC target errored out:
scantxforsilentpaymentsRPC command is missing fromrpc.cpp’sRPC_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.
Done
Done
Added new tests for bumpfee with the outputs replaced.
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".
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: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"
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 theassert_equal(X, Y)utility function from the testing framework.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"
Similar to the equality:
s/assert X <= Y/assert_greater_than(Y, X)It seems a bit overkill to create a Context Manager class for this one test function. I think the current
setup-cleanupcode is better for this caseWill fix when I rebase.
Done.
Done.
Done.
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.
Changed the code to use the generator context manager pattern.
CI failure seems unrelated.
🐙 This pull request conflicts with the target branch and needs rebase.
Fixed.
🐙 This pull request conflicts with the target branch and needs rebase.
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
bumpfeepreserve 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
WriteTxMetadatafails butEraseSpRecipientssucceeds, 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
AssertAn SP
CRecipientpassed withoutm_silent_paymentscan 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 reportspermalink
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.
The
Windows native, VSfailure in CI is reproducible on MSVC and directly related tosrc/qt/walletmodel.cpp:457: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 in9fa43b5af6(UnlockContext(UnlockContext&&) = delete;). GCC and Clang elide the temporary, but MSVC strictly enforces the standard requirement here.Initializing
sp_ctxvia an immediately-invoked lambda avoids the move constructor requirement entirely through guaranteed copy elision:Alternatively, move semantics could be restored to
UnlockContextinsrc/qt/walletmodel.hby makingrelocknon-const and transferring ownership withrelock(std::exchange(other.relock, false)).A few subtle edge cases around descriptor key derivation, RBF state persistence, and coin selection diverge across the branch.
In
src/wallet/spend.cpp,IsInputForSharedSecretDerivationassumes any Taproot output whereinternal_key != NUMS_His eligible. For descriptors where the wallet only owns a leaf key (tr(unspendable_key, pk(leaf))), this returnstrue, butCreateSilentPaymentsOutputssubsequently fails withMissing the private key of silent payments eligible input COutPoint(...)whenGetPrivKeyForSilentPaymentscannot tweak the missing internal key. On thePUBKEYHASHbranch,IsInputForSharedSecretDerivationalso assumes unresolvable inputs are compressed ifprovider->GetPubKeyfails.This causes an inconsistency between
sendandsendall.AvailableCoinsskips all Taproot coins with script path spend data, causingsendallwithout inputs to fail with an error instructing the user to choose coins viainputs. If those coins are supplied tosend, line 382 explicitly rejects them withFound script data for ... Only key path spends are allowed. If supplied tosendall, the transaction succeeds when the wallet owns both keys becausesendall's input path bypassesHasTaprootScriptPath.In
src/wallet/feebumper.cpp:460,CommitTransactioncallsEraseSpRecipients(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_txintostring_values["replaced_by_txid"]usingGetHash().ToString()insrc/wallet/transaction.honly persists until the transaction is bumped. Once replaced,m_replaced_by_txidbecomes the new transaction id. On the next wallet load,key == "replaced_by_txid"sees the replacement txid rather thanGetHash(), leavingm_is_sp_txasfalse. Combined withEraseSpRecipients, a replaced transaction loses its silent payments identity entirely across restarts.In
AttemptSelectionSP(spend.cpp:1058), anchor candidates are restricted topositive_group. At high fee rates, a small eligible coin (such as a 1,000 sat P2WPKH UTXO) can haveeffective_value <= 0and land innegative_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 withINSUFFICIENT_FUNDS. Additionally, when subtracting fees from outputs, candidates are sorted byeffective_valuewhile target reduction uses nominal value.Concept ACK
Concept ACK, have lots of opinions on approach.
It seems
a01dc8e712could potentially be split out into a small PR. I think it is a simple and big readability improvement. Perhaps09127c62b1also could be split off.The BIP allows for multiple outputs to the same recipient, which is particularly good for privacy:
Can we remove this and only check for duplicate
CTxDestinationinParseOutputs? AFICT use ofsetinsendallis 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
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
IsValidmethod as well. The need for this in part stems from the coin control field being a plainCTxDestination/PaymentDestination, but I think it should be anoptionalthere to express the intent. Anulloptimplies the change will be generated. This removes the overloaded meaning of theCTxNoDestinationto mean either invalid or needs an address.Suggested diff with optional change dest
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
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
There is no way to make RBF fully backward compatible, so I think we should fail as loudly as possible IMO
cc @theStack @murchandamus
And if we do go this route, this can be simpler with:
🚧 At least one of the CI tasks failed.
Task
i686, no IPC: https://github.com/bitcoin/bitcoin/actions/runs/38374955165/job/115220901904LLM reason (✨ experimental): CI failed during compilation: GCC 15’s
-Wmaybe-uninitializedwarning inprevector.hwas 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.
Done
Done.
Changed to use
std::tieThis is the intended behaviour.
sendandsendall(with inputs selected) now follow the same rules.The persisted SP recipients information is only useful for bumping the transaction. This can only happen before it is confirmed.
m_is_sp_txis only useful before the transaction is bumped.AttemptSelectionSPhas been updated to use the "negative" group.GetSelectionValue()is now used in place ofeffective_valuefor sorting the eligible groups.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):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
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 awpkhutxo,CheckSilentPaymentsInputpasses becauseproviderexists, andAttemptSelectionSPtreats it as eligible sinceinternal_key != NUMS_H. If coin selection picks that taproot utxo,sendaborts withMissing the private key...even though thewpkhcoin alone could fund the tx.Should
AvailableCoins(orCheckSilentPaymentsInput) check if the provider can actually resolve the key first, so coin selection falls back to thewpkhutxo instead of failing the send?This function seems like it could introduce surface for bugs. In the case of
scriptChangefor instance, thescriptChangevariable 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 ofscriptChange, I would recommend swapping for anoptionalsimilar to what was done elsewhere in the PR. It has the nice effect of showing if the change isnulloptwhen we expect a script for a newCTxOut, then the error is thrown in that same line.The proposed change to
CreateTransactionInternalintroduces an empty error return on custom change failure paths.In
CreateTransactionInternal,bilingual_str erroris only assigned when keypool reservation fails under theelsebranch. Underif (coin_control.destChange),errorremains default-constructed. IfdestChangeis a silent payments destination,destChange->GetStaticScript()returnsstd::nullopt. Ifchange_amount > 0andscriptChangeis not populated, executingif (!scriptChange) return util::Error{error};returns an empty string, yielding{"code": -4, "message": ""}via RPC. The failure path withcoin_control.destChangeset cannot reuseerrorand requires an explicit diagnostic.Inlining
dest.GetStaticScript().value_or(GetScriptForDestination(WitnessV1Taproot{}))acrossfeebumper.cpp,GetSerializeSizeForRecipient,IsDust, andchange_prototype_txoutduplicates the BIP352 v0 output structure across multiple wallet subsystems. It also necessitates the ad-hoc ternarysp_changesolely to re-create the dummy taproot output forchange_prototype_txout. A centralized sizing helper keeps the size assumption encapsulated, while unassigned change scripts can be guarded directly at the pointscriptChangeis resolved.A simple "you did not set the error in the nullopt case" would've sufficed.
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.Fair enough, just wanted to flag the empty error on
destChange.The purpose of
GetDummyTxOutis 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 thescriptChangelogic, but left the other code as is.Thanks for pointing this out. I have updated the rules in
CheckSilentPaymentsInputto exclude eligible coins with missing private keys.Done.
Done.
Wait, shouldn't this filter on
selection_amount(output) <= 0instead ofoutput.GetEffectiveValue() <= 0? Underm_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. CheckingGetEffectiveValue() <= 0prematurely drops valid anchors and aborts with "No silent payment eligible inputs were found" even when the wallet has sufficient funds to cover the send.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.
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() <= 0discards this sole anchor and aborts with "No silent payment eligible inputs were found", failing a funded transaction.Core's coin selection already defines
GetSelectionAmount()asm_subtract_fee_outputs ? m_value : effective_value(coinselection.cpp:865). Filtering anchors onselection_amount(output) <= 0aligns with this convention without an ad-hoc flag.We don't want to spend negative effective value coins even if they are the only eligible coins.
concept ACK
Reviewing this soon
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
Can't an anchor with negative effective value still be used when
m_subtract_fee_outputsis 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 checkselection_amount(output) <= 0instead?🐙 This pull request conflicts with the target branch and needs rebase.
tACK
41f9f48a2bPayments 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
Rebased on master:
git range-diff master 41f9f48 d5f146eRe-tested against
d5f146e.Filtering unresolvable keys in
AvailableCoinsviaCheckSilentPaymentsInputresolves the fallback cleanly. Coin selection now drops the leaf-only Taproot coin (tr(pub, pk(priv))) and picks thewpkhUTXO instead of failing the spend.Also verified
feebumper.cppwhen change drops below dust. Collapsing the k counter keeps indexes contiguous so BIP-352 scanners don't abort early.Passes
wallet_silentpayments_sending.pyandspend_tests. Tested ACKd5f146e.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)
I've taken out the special coin-selection logic. The transaction creation process now fails if no eligible coins are selected.
Did another review pass mostly focused on simplifying the tests
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
We could also test an uncompressed P2PKH is allowed as an input but does not contribute to the shared secret derivation
If this file included
make_sp_addrfrom the head commit thenwallet_backwards_compatibilityandwallet_silentpayments_sendingcould both use itIt looks like these are overriding optional arguments that can be passed directly
This and a few other places look like
find_vout_for_addressinutilself.sp_addr_1is astralready sodo_sendcould just take a dictionary of{self.sp_addr: 5}directlyThe fee bumping and checking for confirmations comes up a few times. They could be a few small functions.
Suggested diff
These are essentially doing the same thing, they could potentially be integrated into one function
Suggested diff
Some other cases to potentially cover:
psbtbumpfeeis an error for SP outputs and a transaction paying to a regular address can be bumped to an SP address.🐙 This pull request conflicts with the target branch and needs rebase.
reACK
6cbb0ea9dcSince
41f9f48athe only non-test change is the removal ofSelectCoinsForSilentPayments, as davidgumberg suggested. Its tests went with it: thecoinselector_testscases,test_prefer_eligible_inputsand theadd_inputs=Truehalf oftest_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
Could you please clarify whether this is expected: after restoring a backup made before an SP payment,
bumpfeecan add inputs without recomputing the recipient output, causing standard BIP352 scanning to miss the payment?Does
bumpfeeneed 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 populatesmapWalletviaAddToWalletIfInvolvingMewithout settingm_rbf_needs_sp_outputs.Because external P2TR outputs are indistinguishable on-chain from standard Taproot sends,
bumpfeetreats 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 viaoutputs=[{...}].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.
Done.
Done.
Done.
Done.
Done.
Done.
Done.
Done.
Done,
Done.
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.I reverted the decision to make
CCoinCointrol::destChangeanstd::optional, because it creates 2 values (instead of just 1 on master) thatCreateTransactionInternalinterprets as no custom change:std::nulloptandCNoDestinationBy setting
destChangetoPaymentDestination(CNoDestination())by default,CreateTransactionInternalonly checks that case and decides whether to generate a change address.I also slightly adjusted the
PaymentDestinationAPI to reduce the code required by users of the API.🐙 This pull request conflicts with the target branch and needs rebase.
Haven't done a full re-review, but is
cbc9a4a1bcsomething we should address in a separate PR? This behavior is a mistake on the user behalf I would imagine, but having theCNoDestinationget replaced with something else seems bad for meta protocols. I can imagine a transaction that attempts to commit to a proof in anOP_RETURNand when trying to fee bump, theOP_RETURNgets replaced by something else. Raising an error seems like the right thing to do regardless of what happens here?Reply to https://github.com/bitcoin/bitcoin/pull/35302#issuecomment-7126751401, opened https://github.com/bitcoin/bitcoin/pull/36962 with the first 2 commits.
Rebased on master now that https://github.com/bitcoin/bitcoin/pull/36835 is merged.
🐙 This pull request conflicts with the target branch and needs rebase.