2 suggestions
Optional improvements
[suggestion] · Null-coin-control test leaves coin membership unchecked
The regression test exercises the null call but would also pass a fix that drops all unconfirmed outputs or skips the intended non-TRUC filtering.
Location: src/wallet/test/spend_tests.cpp:88 (head).
Details and suggested fix
BOOST_CHECK_NO_THROW evaluates the call, so it remains useful as a crash reproducer, but it discards the returned coins. The existing unconfirmed v2 output should be available: it spends an owned confirmed parent and satisfies the default zero-confirmation-change trust rules. Keep the created transaction and assert that COutPoint{txid, 0} appears in AvailableCoins(*wallet).All(). Adding an owned unconfirmed v3 transaction spending another mature coinbase and asserting that its output is excluded would also distinguish the chosen non-TRUC semantics from simply bypassing the version filter for null coin control. That exclusion case only needs wallet mempool state, since the null/non-TRUC branch does not query transaction ancestry.
[suggestion] · Direct fuzz call leaves TRUC result invariants unchecked
With unsafe inputs enabled, the new fuzz fixture could check TRUC output membership and the single-transaction restriction, but discarding the result leaves those invariants unchecked.
Location: src/wallet/test/fuzz/spend.cpp:108 (head).
Details and suggested fix
Keep the selected coin-control pointer and returned CoinsResult. When params.check_version_trucness is true, inspect each depth-zero output through GetWalletTx(output.outpoint.hash): non-TRUC requests must return no v3 outputs, while TRUC requests must return only v3 outputs from at most one txid. These assertions would catch removing the version skip or returning outputs from multiple unconfirmed TRUC transactions. The early-return paths preserve these invariants because they return before deferred v3 outputs are added. The synthesized transactions have no inputs and are untrusted, so the null-coin-control case currently filters all their unconfirmed outputs as unsafe and makes these checks vacuous. Their wallet-only mempool states also do not exercise rejection for real ancestors or existing children.