Review report

bitcoin/bitcoin: PR #36154

2 minor findings · 3 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Unrelated PSBT paths multiply derivation work under wallet locks

Processing a crafted PSBT with derivations enabled can force millions of EC derivations for unrelated keys while holding wallet locks, including synchronously during GUI loading.

Location: src/wallet/scriptpubkeyman.cpp:1523 (head).

Details and suggested fix

Once a descriptor contributes, DerivesKeyInPSBT derives every matching claimed unhardened suffix before comparing public keys. A sender who knows the wallet fingerprint and account path can attach distinct unrelated public keys with roughly 250-step paths to a UTXO-less input, then include an owned output to activate the scan. The input loop skips that input, but the new eligibility scan visits its records before reaching the genuine output match. Each approximately 1 KB record can therefore cause about 250 derivations. The depth-255 cap and the 32 MiB RPC-body or 100 MiB GUI-file limits still permit millions in aggregate. This requires an RPC client to process the file or a user to open it, not merely a P2P message. The scan holds cs_wallet and cs_desc_man; GUI loading waits for it before showing the dialog. Wall-clock duration was not measured, and no state is persisted, so waiting or restarting recovers. Restrict derivation checks to public keys this descriptor actually produced, including both parities for x-only keys, while retaining derive-and-compare to reject forged origins. Add a regression ensuring unrelated long-path records do not multiply derivation work.


Link

[minor] · Global-xpub filtering accepts or rejects entire origin groups

When distinct xpubs share an explicit origin, one eligible key can publish ineligible peers, while one depth mismatch can suppress eligible peers.

Location: src/wallet/scriptpubkeyman.cpp:1552 (head).

Details and suggested fix

GetExtPubKeysWithOrigins groups distinct keys by origin, but AddGlobalXpubs filters each group as a unit. For example, consider wsh(multi(2,[00000000]xpubA/0/*,[00000000]xprvB/0/*h)) with depth-zero roots in a private-key-enabled wallet. Import accepts partial private-key coverage with a warning, and B's private key permits hardened expansion. Both roots share the empty-path origin and pass the depth check. B's hardened wildcard caches individual children, so its accessor falls back to the root. During an unsigned update, A's matching child makes DerivesKeyInPSBT retain both roots, publishing B even though it derives no listed key through unhardened steps. Conversely, any depth mismatch removes the entire group, including eligible keys. Check depth and derivation separately for each CExtPubKey, then remove empty groups. Add mixed-eligibility and mixed-depth regressions. No current workflow placing distinct keys under one origin was identified, so production impact is unconfirmed.


Optional improvements

Link

[suggestion] · Several PSBT routes offer no account-xpub publication control

The send, sendall, psbtbumpfee and GUI paths force derivations on, so users cannot suppress eligible account xpubs when sharing their resulting PSBTs.

Location: src/wallet/scriptpubkeyman.cpp:1502 (head).

Details and suggested fix

Publication deliberately includes single-key accounts, but it is tied to bip32_derivs, which these callers hard-code to true. An owned output alone also activates it: opening a counterparty's PSBT that only pays this wallet adds the eligible receiving-account xpub, and GUI Copy or Save exports the updated object. Sharing that PSBT exposes account-address derivability, beyond the transaction-specific pubkey and path previously added. Add a separate global-xpub publication control that these RPC and GUI paths honor, so users can retain per-key derivations without exporting account xpubs. If always-on publication is intentional instead, explicitly document the forced-on routes and receive-only trigger alongside the current RPC opt-out guidance. Do not simply exclude output-only contributions: the split-change fixture needs an internal descriptor to publish through change even when it owns no input.


Link

[suggestion] · The release note implies bip32derivs=false can remove existing xpubs

In walletprocesspsbt, bip32derivs=false prevents new global xpubs but preserves those already present, so reprocessing does not redact account metadata.

Location: doc/release-notes-36154.md:9 (head).

Details and suggested fix

The phrase "leaves the field out" can suggest that reprocessing a PSBT with bip32derivs=false removes its global xpubs. The flag only skips AddGlobalXpubs; serialization still writes every existing m_xpubs record. A user who creates a PSBT with defaults and then reprocesses it with false can therefore share the account xpubs despite expecting them to be absent. Clarify that false prevents the wallet from adding extended public keys and derivation paths, but does not remove existing global xpubs. To avoid adding them in the first place, disable the flag when creating the PSBT as well.


Link

[suggestion] · External-signer signing bypasses global-xpub filling

Direct walletprocesspsbt signing through the external-signer override sends a prefilled PSBT to the device without adding missing global xpubs.

Location: src/wallet/scriptpubkeyman.cpp:1502 (head).

Details and suggested fix

walletprocesspsbt defaults to sign=true and makes one CWallet::FillPSBT call. For descriptors handled by ExternalSignerScriptPubKeyMan, that branch bypasses the base implementation containing AddGlobalXpubs. A PSBT from an older Core or another coordinator can already contain the required derivation paths but no global xpubs, so it reaches the device without the multisig metadata this PR supplies. Unlike this direct route, wallet creation, send, and GUI processing perform an unsigned fill first. Calling walletprocesspsbt with sign=false first is a workaround. Add an unsigned wallet-level fill before external signing in this RPC, respecting the requested derivation flag. Do it before any signer SPKM runs, so later managers, including the change descriptor, contribute before the first device call. No test or documented workflow importing multisig descriptors into an external-signer wallet was found, so practical impact is unconfirmed.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.