wallet: fix migration with watch-only transactions

bitcoin/bitcoin: PR #36825

1 suggestion

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

Optional improvements

Link

[suggestion] · DbTxnListener requires no-op callbacks for unused events

No current registrant omits a callback, but handling empty callbacks centrally would remove the explicit no-op requirement and the associated std::bad_function_call trap.

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

Details and suggested fix

DbTxnListener has no callback defaults, RegisterTxnListener checks only that a transaction is active, and TxnCommit and TxnAbort invoke the callbacks unconditionally. Both RemoveTxs and DescriptorScriptPubKeyMan::Encrypt therefore supply an explicit no-op on_abort. A new registration supplying only .on_commit would compile but throw on its first successful database abort, reproducing the pattern fixed here. Guard each invocation with a presence check, such as if (listener.on_abort) listener.on_abort();, and do the same for on_commit. This makes an unused event harmless without changing either registrant's commit-time memory updates.


Coverage details

Earlier concerns

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