Review report

core: PR #35786

1 minor finding

Findings

Link

[minor] · Keypool top-up can leave a parent’s cached credit stale

gettransaction can omit an output the wallet has since recognized as its own; balances and coin selection are unaffected, and the production impact is unconfirmed.

Location: src/wallet/wallet.cpp:1418 (base).

Details and suggested fix

A keypool top-up can add scripts to the wallet’s cached set, changing whether an output belongs to the wallet. TopUpCallback updates the script cache but does not invalidate cached transaction amounts. If a parent’s credit was cached before a spend triggers a top-up, that credit can remain stale until the parent is re-added or the wallet reloads. gettransaction can then report an amount that omits the output while its details list it. Balances and coin selection are unaffected because they read m_txos, which this path does not refresh. In avoid-reuse wallets, MarkDestinationsDirty may still clear the parent’s cache. Mark wallet transactions with outputs to newly added scripts dirty in TopUpCallback; the comment should also say cached values can change when the wallet’s script set changes, not only on descriptor import. No current production flow that pays a not-yet-derived wallet script was identified, so the frequency of this behavior in production is unconfirmed.


Coverage details