fuzz: populate wallet TXO index in wallet_create_transaction #35790

pull frankomosh wants to merge 1 commits into bitcoin:master from frankomosh:fuzz-spend-refresh-txos changing 1 files +1 −0
  1. frankomosh commented at 7:48 AM on July 24, 2026: contributor

    A refactor in #27286 seemingly caused a regression in this harness. Rewiring to m_txos from mapWallet makes the setup loop in wallet_create_transaction, which uses raw mapWallet.emplace(), to no longer see coins. Therefore, GetTXO/GetTXOs probably return empty. To make coin selection possible, this fix calls RefreshTXOsFromTx after each insertion.

    <details> <summary>Coverage diff on select functions</summary>

    diff spend_cov_before.txt spend_cov_after.txt on src/wallet/spend.cpp:

    -  748|      0|  if (auto bnb_result{SelectCoinsBnB(...)}) {
    +  748|  2.14k|  if (auto bnb_result{SelectCoinsBnB(...)}) {
    
    -  761|      0|  if (auto knapsack_result{KnapsackSolver(...)}) {
    +  761|  4.46k|  if (auto knapsack_result{KnapsackSolver(...)}) {
    
    -  766|      0|  if (auto cg_result{CoinGrinder(...)}) {
    +  766|  2.88k|  if (auto cg_result{CoinGrinder(...)}) {
    
    -  774|      0|  if (auto srd_result{SelectCoinsSRD(...)}) {
    +  774|  4.46k|  if (auto srd_result{SelectCoinsSRD(...)}) {
    
    -  845|      0|  auto op_selection_result = AutomaticCoinSelection(...);
    +  845|  1.27k|  auto op_selection_result = AutomaticCoinSelection(...);
    
    -  960|      0|  if (auto res{AttemptSelection(...)}) {
    +  960|  1.36k|  if (auto res{AttemptSelection(...)}) {
    
    - 1484|      0|  auto txr_grouped = CreateTransactionInternal(...);
    + 1484|    380|  auto txr_grouped = CreateTransactionInternal(...);
    

    </details>

  2. fuzz: populate wallet TXO index in wallet_create_transaction
    The setup loop inserts transactions through raw mapWallet.emplace(),
    which does not populate m_txos. Since AvailableCoins and
    FetchSelectedInputs now look up coins through m_txos, coin
    selection is structurally unreachable.
    
    Call RefreshTXOsFromTx after each insertion so the wallet's
    TXO index reflects the inserted outputs.
    1eac6a728b
  3. DrahtBot added the label Fuzzing on Jul 24, 2026
  4. DrahtBot commented at 7:48 AM on July 24, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35790.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK brunoerg

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35716 (wallet: Replace mapWallet and wtxOrdered with a boost::multi_index by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. brunoerg approved
  6. brunoerg commented at 3:14 PM on July 26, 2026: contributor

    code review ACK 1eac6a728bfc3ea6a7b95be6db69cce87e0f046f

    Nice catch! Perhaps in a follow-up we could track the number of inserted outputs and assert that the size of GetTXOs matches it, it would have gotten that.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-31 20:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me