Provider refusals
write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.
2 major findings · 4 minor findings · 1 suggestion
Earlier concerns neither republished nor resolved: 1 minor finding · 5 suggestions. See the Run archive for their assessments.
Findings
[major] · Rebuilt conflicted outputs abort balance queries
Rebuilding TXOs, or newly owning an output of a block-conflicted transaction, can put negative-depth outputs in m_txos and abort bitcoind on the next balance query.
Location: src/wallet/wallet.cpp:4629 (head).
Details and suggested fix
Consider an owned output with no confirmed spender whose creating transaction is block-conflicted, such as change from a transaction whose replacement confirmed. An authenticated client can reinsert that output by removing an unrelated wallet transaction with removeprunedfunds, which requires -deprecatedrpc=removeprunedfunds and rebuilds both TXO maps. A successful importdescriptors or keypoolrefill can also insert a previously unowned output of an existing conflicted transaction. Fresh insertion checks only IsSpent(outpoint, 1), so the output enters m_txos despite its creating transaction's negative depth. GetBalance then reaches the fatal Assert(tx_depth >= 0), including in release builds. An ordinary refresh of an already indexed unusable output does not trigger this. PruneSpentTXOs handles the conflict state, but only during chain attachment; rescanning an already-conflicted transaction does not repair membership because MarkConflicted returns UNCHANGED at the same conflict depth. Restarting repairs the partition. Include the creating transaction's block-conflicted state in the insertion predicate, as pruning already does, and add a regression that confirms a replacement, rebuilds or imports the affected output, and calls getbalances.
[major] · Disconnected spends leave usable inputs in the unusable map
After a confirmed spend is disconnected and then abandoned or conflicted through another input, genuinely unspent wallet coins can remain missing from balances, listunspent, and automatic coin selection until restart.
Location: src/wallet/wallet.cpp:4702 (head).
Details and suggested fix
When spender A confirms, AddToWallet moves its wallet input X to m_unusable_txos. Disconnection does call AddToWallet's inactive-input restoration loop, but MaybeMarkTXOUsable uses IsSpent(X) with min_depth=0. The now-inactive, non-abandoned A still counts as a spender when it has no mempool conflict, so it blocks restoration of its own input. Once A leaves the mempool and is abandoned, or becomes block-conflicted through a different input Y without X being spent by the winner, IsSpent(X) becomes false. However, RecursiveUpdateTxState maintains A's outputs and dirties input accounting without moving X back. Balance and coin-selection iteration therefore omit X even though it is spendable. The base's single map did not require this restoration, and restarting reconstructs the correct membership. Base membership on definite unusability: a confirmed spender, using IsSpent(outpoint, 1), or a block-conflicted creating transaction. Apply that predicate consistently to restoration and spender-state changes while respecting other confirmed spenders. Add a no-reload regression covering confirmation, disconnection, mempool removal, and abandonment, plus conflict through another input.
[minor] · From-me upgrades depend on transaction insertion order
Child-before-parent wallet histories can persist false from-me flags during upgrade or rebuild and can misclassify transactions during migration.
Location: src/wallet/walletdb.cpp:1090 (head).
Details and suggested fix
IsFromMe checks GetTXO for each input, but the upgrade skips indexing records lacking m_from_me and then interleaves ownership lookup with indexing in wtxOrdered order. That is insertion order, not dependency order: a child paying an existing wallet address can precede a parent discovered by a later import or rescan, and importprunedfunds also permits this order. The child is then persisted with m_from_me=false. RefreshAllTXOs after RemoveTxs clears both maps has the same problem. Migration now also classifies transactions while rebuilding the index, whereas the base populated all owned outputs before classification. A child spending a private-key-owned input and paying only a watched script can consequently be removed from the main wallet, leaving its parent apparently unspent; migration instead fails if neither wallet claims it. Incorrect flags also affect fee/amount reporting and TXO coin-eligibility metadata. A reload with all flags present skips the upgrade. CachedTxIsTrusted currently tests optional engagement, so its early exit does not consume this false value. No real wallet with this ordering was examined, so production prevalence is unconfirmed. Build the complete owned-output index first, then compute and persist m_from_me and update its TXO copies. Populate that index before migration classification as well.
[minor] · Watch-only migration copies the main wallet's from-me flag
Migrated watch-only transactions inherit another wallet's persisted from-me flag, which can make gettransaction report the entire output value as a fee.
Location: src/wallet/wallet.cpp:4048 (head).
Details and suggested fix
ApplyMigrationData assigns wtx->m_from_me from the main wallet's ownership view. It computes watchonly_from_me separately, but uses that value only for inclusion before serializing the unchanged transaction into copy_wtx. Serialization now carries m_from_me, so LoadToWallet builds the watch-only TXOs with the main wallet's flag and WriteFullTx persists it. For a main-wallet payment to a watched address with no watch-only inputs, the copy has from-me=true but zero debit. PushTxAmountAndFee therefore reports a positive fee equal to GetValueOut() and amount equal to credit minus GetValueOut(), in gettransaction and raw transaction entries. A watch-only spend with change to the main wallet can have the reverse mismatch, omitting its fee and using incorrect coin-eligibility metadata. Reloading with all flags present does not recompute them, although re-syncing the transaction or refreshing that wallet's TXOs can repair them. Set copy_wtx.m_from_me = watchonly_from_me before LoadToWallet, and test accounting in both migrated wallets after reload.
[minor] · Transaction upgrades write before the corruption guard
The from-me upgrade and relocated reordering can rewrite an already-corrupt wallet using an incomplete transaction set before LoadWallet checks whether upgrades are safe.
Location: src/wallet/walletdb.cpp:1088 (head).
Details and suggested fix
LoadRecords records individual errors and continues loading other records. LoadTxRecords then writes every transaction's metadata when any record lacks m_from_me and runs ReorderTransactions when ordering metadata is missing, without requiring a successful aggregate load result. LoadWallet's guard against rewriting a corrupt wallet runs afterwards. For example, if a parent record fails to deserialize, its readable old-format children can be written with m_from_me=false before the wallet ultimately fails to load. Repairing the corrupt record later does not itself invalidate those persisted flags. Base ran ReorderTransactions after the guard; the narrower existing coinbase-abandon writes do not protect these new rewrites. Keep the required in-memory initialization during loading, but defer durable metadata upgrades and reordering until LoadWallet has established that the aggregate result is LOAD_OK.
[minor] · Synced test wallets leak their notification handlers
CreateSyncedWallet now creates a wallet-handler-proxy ownership cycle, but its unit-test callers only drop their shared pointers, leaving the wallets and handlers allocated.
Location: src/wallet/test/util.cpp:26 (head).
Details and suggested fix
CreateNew attaches chain notifications and stores their handler in the wallet. NotificationsHandlerImpl owns a NotificationsProxy whose shared notification pointer owns the wallet, so releasing the caller's shared_ptr cannot invoke the wallet deleter. ListCoinsTestingSetup only calls wallet.reset(), and SubtractFee and wallet_duplicated_preset_inputs_test let their local pointers expire. The local WalletContext does not disconnect these handlers either. Use TestUnloadWallet(std::move(wallet)) for these callers before fixture teardown: it drains notifications, resets m_chain_notifications_handler to break the cycle, and waits for deletion. Release cs_wallet before calling it, including in the duplicated-input test, because draining callbacks while holding that lock can deadlock.
Optional improvements
[suggestion] · The from-me shortcut tests optional engagement
Negating m_from_me tests whether the optional is empty, so incoming mempool transactions with a stored false value lose the intended early rejection and reach parent lookups.
Location: src/wallet/receive.cpp:213 (head).
Details and suggested fix
Base tested the boolean returned by CachedTxIsFromMe. Here m_from_me is std::optional<bool>, and both transaction insertion and loading initialize it, so !wtx->m_from_me is false even when the contained value is false. With spend-zero-conf-change enabled, those transactions proceed into the input loop. The later ownership checks still reject foreign inputs, preserving the trust decision but losing the shortcut. Read the contained value explicitly, for example with !*Assert(wtx->m_from_me), and retain the all-inputs-owned checks. Apply this alongside the ordering and migration fixes for stale from-me values, since this condition will then start consuming those values.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: Migration loses spenders recorded before their parents (earlier report)
- [suggestion]: The upgrade fixture never checks from-me accounting (earlier report)
- [suggestion]: The coin-listing fixture overwrites the notification state it tests (earlier report)
- [suggestion]: Migration writes retained transaction metadata twice (earlier report)
- [suggestion]: TXO move helpers return unused and inconsistently ordered iterators (earlier report)
- [suggestion]: RefreshAllTXOs carries an unused caller-batch branch (earlier report)