Review report

bitcoin/bitcoin: PR #35294

Provider refusals

write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.

1 major finding · 1 minor finding · 1 suggestion

Findings

Link

[major] · Loading child-first coinbase records can abort the node

If a confirmed spender was inserted before its coinbase parent, loading against chain data without those confirmations reaches the spender before refreshing it and aborts the node during recursive abandonment.

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

Details and suggested fix

nOrderPos records insertion order, not transaction dependencies. The owner can use importprunedfunds to import a confirmed spender before its coinbase parent, provided each transaction has a wallet-owned output and a proof in the tracked chain. On a later load where the coinbase block is inactive, such as after chain-data replacement, this reverse loop refreshes the coinbase first and immediately abandons it. The reconstructed spend index leads AbandonTransaction to the child, which still has its deserialized TxStateConfirmed state, triggering assert(!wtx.isConfirmed()) before any rescan can repair it. Base refreshed every record before the separate abandonment pass. Refresh all transaction states first, then abandon inactive coinbases in a second pass, and cover child-first insertion in a regression test. No real wallet with this insertion order was identified. The root abandonment is written before the assertion, so restarting may make progress, but durability of that write before the abort is unestablished.


Link

[minor] · Live-chain refresh can leave coinbases above the tracked tip

During runtime wallet loading, a stored coinbase activated at least two blocks above the tip snapshot can acquire negative depth, allowing a GUI read to abort the node before queued notifications catch up.

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

Details and suggested fix

AttachChain snapshots the tip before this loop, but each updateState call checks the live active chain under a separate cs_main lock. If a previously recorded coinbase block becomes active at snapshot height plus two or more before its lookup, the transaction remains confirmed above GetLastBlockHeight(). This can occur when loading or restoring a mining wallet while the node catches up. The held cs_wallet delays block notifications, and the rescan stops at the tracked height. After attachment returns, GUI balance/status reads do not wait for notification delivery and can reach GetTxBlocksToMaturity with negative depth, triggering its assertion. Notifications repair the discrepancy as they advance the wallet height. Base had a narrower related window during notification replay; this loop extends it to the per-transaction refresh interval. Make the refresh consistent with the tracked snapshot, taking care not to abandon coinbases merely because their confirmations lie above it. No GUI poll was traced inside this window, so an actual production occurrence remains unconfirmed.


Optional improvements

Link

[suggestion] · Regression test does not advance the chain during wallet loading

The test loads the wallet on a stationary chain and reconnects the missing-block peer afterwards, so its final state checks do not exercise the missed-block race described by the comment.

Location: test/functional/wallet_chain_reprocess.py:58 (head).

Details and suggested fix

start_node(0) waits for getmempoolinfo.loaded, which initialization sets after block import and mempool loading. Automatic connections are disabled, and the earlier peer connections use addnode onetry, so node 0 remains isolated after restarting. The synchronous loadwallet at line 58 therefore completes before reconnection at line 63. The assertions establish rollback and eventual confirmation after ordinary catch-up, not movement between transaction-record loading and notification registration. The target wallet's only coinbase also predates the clean restart and stays active, leaving inactive-coinbase abandonment untested. Add a deterministic regression, for example a wallet unit test that connects blocks between loading transaction records and attaching the chain, then checks the resulting transaction states against the tracked tip. At minimum, correct the comment so it does not claim concurrency coverage.


Coverage details