{
 "number": 34264,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/34264",
 "title": "fuzz: Extend `spend` coverage",
 "author": "Chand-ra",
 "author_association": "NONE",
 "created_at": "2026-01-12T15:12:26Z",
 "updated_at": "2026-08-07T11:32:14Z",
 "age_days": 248,
 "draft": false,
 "labels": [
  "Needs rebase",
  "Fuzzing"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
 "head_ref": "spend",
 "head_repo": "Chand-ra/bitcoin",
 "head_history": [
  {
   "t": "2026-01-13T16:11:05Z",
   "sha": "6242b127a205678e944dc973cfb4b1ba53041e89"
  },
  {
   "t": "2026-01-22T17:44:58Z",
   "sha": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6"
  }
 ],
 "additions": 63,
 "deletions": 21,
 "changed_files": 1,
 "commit_count": 4,
 "size_bucket": "S",
 "mergeable_state": "dirty",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "concept_ack": [
     {
      "login": "frankomosh",
      "url": "https://github.com/bitcoin/bitcoin/pull/34264#pullrequestreview-4882252030"
     }
    ]
   },
   "conflicts": [
    {
     "number": 35720,
     "title": "ipc: Update libmultiprocess subtree and drop fuzz test workaround",
     "author": "maflcko"
    },
    {
     "number": 35716,
     "title": "wallet: Replace mapWallet and wtxOrdered with a boost::multi_index",
     "author": "achow101"
    }
   ]
  }
 },
 "acks_parsed": {
  "frankomosh": {
   "kind": "concept_ack",
   "hash": null,
   "t": "2026-08-07T11:32:10Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 1,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "brunoerg",
   "frankomosh"
  ]
 },
 "signals": {
  "needs_rebase": true,
  "ci_failed": false,
  "mergeable_state": "dirty",
  "last_author_activity": "2026-01-22T17:44:58Z",
  "last_reviewer_activity": "2026-08-07T11:32:10Z",
  "last_reviewer": "frankomosh",
  "author_silent_days": 237,
  "waiting_on_author_days": 41,
  "days_since_update": 41
 },
 "refs": {
  "mentioned": [
   35790
  ],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [
   {
    "number": 35790,
    "type": "pull",
    "state": "closed",
    "merged": true,
    "merged_at": "2026-08-04",
    "title": "fuzz: populate wallet TXO index in wallet_create_transaction"
   }
  ],
  "conflicts": [
   35720,
   35716
  ]
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "src/wallet/test/fuzz/spend.cpp"
 ],
 "body": "Make the `wallet/spend` fuzz target stateful and extend coverage for several missing methods.",
 "commits": [
  {
   "sha": "51c7cedea3fb620a6693c2a51f36cd2b4cfaf024",
   "date": "2026-01-22T17:31:13Z",
   "message": "fuzz: Refactor `wallet_create_transaction` to support multiple actions\n\nUpdate the `wallet_create_transaction` fuzz target to move the\ntransaction creation logic inside a `CallOneOf` block.\n\nThis refactoring is a structural preparation for stateful fuzzing,\nallowing commits to easily add and interleave other wallet\noperations within the same loop."
  },
  {
   "sha": "2f702af9c921b78ce74d39f9e296c74bbac9ebcf",
   "date": "2026-01-22T17:31:16Z",
   "message": "fuzz: lock inputs to verify correct handling of user-mandated inputs\n\nMove the `CCoinControl` parameter configuration inside the fuzzing\nloop to allow mutation of settings between operations. Additionally,\nintroduce logic to randomly `Select` or `UnSelect` specific available\noutpoints within `coin_control`.\n\nThis allows the fuzzer to simulate scenarios where a user manually\nmandates specific inputs."
  },
  {
   "sha": "37d99b6f9e36d037bf5ec737f027fe89ba27f06d",
   "date": "2026-01-22T17:31:16Z",
   "message": "fuzz: Add coverage for `FundTransaction()`\n\nExtend the target to cover `FundTransaction()`."
  },
  {
   "sha": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
   "date": "2026-01-22T17:31:16Z",
   "message": "fuzz: Add coverage for `ListCoins()`\n\nExtend the fuzz target to cover `ListCoins()`."
  }
 ],
 "timeline": [
  {
   "t": "2026-01-12T18:30:46Z",
   "kind": "comment",
   "who": "brunoerg",
   "assoc": "CONTRIBUTOR",
   "text": "From CI:\n```\n[515/729][5.2s] clang-tidy-21 -p=/home/admin/actions-runner/_work/_temp/build -quiet -load=/tidy-build/libbitcoin-tidy.so /home/admin/actions-runner/_work/_temp/src/test/fuzz/block_index_tree.cpp\n1126 warnings generated.\n+ echo '^^^ \u26a0\ufe0f Failure generated from clang-tidy'\n+ false\n\n[516/729][8.1s] clang-tidy-21 -p=/home/admin/actions-runner/_work/_temp/build -quiet -load=/tidy-build/libbitcoin-tidy.so /home/admin/actions-runner/_work/_temp/src/wallet/test/fuzz/spend.cpp\n/home/admin/actions-runner/_work/_temp/src/wallet/test/fuzz/spend.cpp:125:41: error: unnecessary temporary object created while calling emplace_back [modernize-use-emplace,-warnings-as-errors]\n  125 |                     tx.vin.emplace_back(CTxIn(out));\n      |                                         ^~~~~~   ~\n/home/admin/actions-runner/_work/_temp/src/wallet/test/fuzz/spend.cpp:152:23: error: the value returned by this function should not be disregarded; neglecting it may lead to errors [bugprone-unused-return-value,-warnings-as-errors]\n  152 |                 (void)FundTransaction(*fuzzed_wallet.wallet, tx, recipients, change_pos, lockUnspents, coin_control);\n      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n2392 warnings generated.\n\n[517/729][3.6s] clang-tidy-21 -p=/home/admin/actions-runner/_work/_temp/build -quiet -load=/tidy-build/libbitcoin-tidy.so /home/admin/actions-runner/_work/_temp/src/qt/bitcoinaddressvalidator.cpp\n^^^ \u26a0\ufe0f Failure generated from clang-tidy\nCommand '['docker', 'exec', '88e904189f27a153218451cb9cc2cf6a3600de9821f8b631509e657c4e1d73df', '/home/admin/actions-runner/_work/_temp/ci/test/03_test_script.sh']' returned non-zero exit status 1.\n```"
  },
  {
   "t": "2026-01-13T07:32:20Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "e3619a36d848eaad36d8b64a7f69a6a87f059c21",
   "in_reply_to": null,
   "text": "Could simplify to `tx.vin.emplace_back(out)`"
  },
  {
   "t": "2026-01-13T07:48:35Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "e3619a36d848eaad36d8b64a7f69a6a87f059c21",
   "in_reply_to": null,
   "text": "Also, should `FundTransaction` have wallet lock protection i.e wrap it in LOCK(fuzzed_wallet.wallet -> cs_wallet), as has been done in `ListCoins` ?"
  },
  {
   "t": "2026-01-13T08:08:12Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "e3619a36d848eaad36d8b64a7f69a6a87f059c21",
   "in_reply_to": null,
   "text": "I notice that this logic appears twice. Would it make sense to extract it into a lambda helper at the top of the function?"
  },
  {
   "t": "2026-01-13T08:11:48Z",
   "kind": "review",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "e3619a36d848eaad36d8b64a7f69a6a87f059c21",
   "text": "I think that the variables `int next_locktime` and `CAmount all_values` become dead code after you\u2019ve refactored?\nAlso some inline nits below."
  },
  {
   "t": "2026-01-13T15:43:34Z",
   "kind": "review_comment",
   "who": "Chand-ra",
   "assoc": "NONE",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "e3619a36d848eaad36d8b64a7f69a6a87f059c21",
   "in_reply_to": 2685246201,
   "text": "Not really, `FundTransaction()` [doesn't require](https://github.com/bitcoin/bitcoin/blob/62557c95298d88be8920c1b3b952d07d0aedb1af/src/wallet/spend.h#L233) an exclusive lock unlike `ListCoins()` [does](https://github.com/bitcoin/bitcoin/blob/62557c95298d88be8920c1b3b952d07d0aedb1af/src/wallet/spend.h#L105)."
  },
  {
   "t": "2026-01-13T15:48:20Z",
   "kind": "comment",
   "who": "Chand-ra",
   "assoc": "NONE",
   "text": "[quoted text omitted]\n\nI believe `next_locktime` and `all_values` are still necessary in the [setup loop](https://github.com/bitcoin/bitcoin/blob/62557c95298d88be8920c1b3b952d07d0aedb1af/src/wallet/test/fuzz/spend.cpp#L61). `next_locktime` ensures that we generate unique TXIDs and `all_values` is used to enforce the `MAX_MONEY` cap so we don't overflow the wallet balance during setup."
  },
  {
   "t": "2026-01-13T16:11:05Z",
   "kind": "force_push",
   "who": "Chand-ra",
   "commit": "6242b127a205678e944dc973cfb4b1ba53041e89"
  },
  {
   "t": "2026-01-22T17:44:58Z",
   "kind": "force_push",
   "who": "Chand-ra",
   "commit": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6"
  },
  {
   "t": "2026-08-07T11:00:26Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
   "in_reply_to": null,
   "text": "```suggestion\n\n{\n    LOCK(fuzzed_wallet.wallet->cs_wallet);\n    assert(fuzzed_wallet.wallet->GetTXOs().size() == static_cast<size_t>(next_locktime));\n}\n\n```\n\nYou can add Bruno's suggestion from https://github.com/bitcoin/bitcoin/pull/35790#pullrequestreview-4782030244 to always catch a possible future regression where the TXO index falls out of sync."
  },
  {
   "t": "2026-08-07T11:04:57Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
   "in_reply_to": null,
   "text": "```suggestion\n              auto res_ct{CreateTransaction(*fuzzed_wallet.wallet, recipients, change_pos, coin_control)};\n              if (res_ct) { assert(res_ct->fee >= 0); }\n```\n\nAfter rebase, the `CreateTransaction` can reach success paths, and therefore we can do an assert check on the result."
  },
  {
   "t": "2026-08-07T11:07:58Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
   "in_reply_to": null,
   "text": "```suggestion\n                auto res_ft{FundTransaction(*fuzzed_wallet.wallet, tx, recipients, change_pos, lockUnspents, coin_control)};\n                if (res_ft) { assert(res_ft->fee >= 0); }\n```\n\nSame case here,"
  },
  {
   "t": "2026-08-07T11:20:56Z",
   "kind": "review_comment",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "path": "src/wallet/test/fuzz/spend.cpp",
   "commit": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
   "in_reply_to": null,
   "text": "```suggestion\n                auto coins_by_dest = ListCoins(*fuzzed_wallet.wallet);\n                for (const auto& [dest, outputs] : coins_by_dest) {\n                     for (const auto& output : outputs) {\n                          assert(MoneyRange(output.txout.nValue));\n                     }\n                 }\n```\n\n`ListCoins` requires `cs_wallet` and returned map should be non-empty now. Asserting on the result can help check behavior. For example we can catch mutations that corrupt output values during coin enumeration."
  },
  {
   "t": "2026-08-07T11:32:10Z",
   "kind": "review",
   "who": "frankomosh",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "1876e77f7e80c8aca77ddd06f6e6f70fd2b5b9f6",
   "text": "Concept ACK.\n\nGood coverage on FundTransaction and ListCoins. Please do a rebase to pick #35790, which makes coin selection becomes reachable."
  }
 ],
 "labels_log": [
  {
   "t": "2026-01-12T15:12:29Z",
   "action": "labeled",
   "label": "Fuzzing",
   "who": "DrahtBot"
  },
  {
   "t": "2026-01-12T17:24:38Z",
   "action": "labeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-01-13T17:45:28Z",
   "action": "unlabeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-01-21T14:09:32Z",
   "action": "labeled",
   "label": "Needs rebase",
   "who": "DrahtBot"
  },
  {
   "t": "2026-01-22T19:54:59Z",
   "action": "unlabeled",
   "label": "Needs rebase",
   "who": "DrahtBot"
  },
  {
   "t": "2026-07-14T18:59:59Z",
   "action": "labeled",
   "label": "Needs rebase",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 5507,
 "text_tokens_estimate": 1376,
 "changed_paths": [],
 "files": [],
 "test_lines": null,
 "git": null,
 "input_hash": "b40ef525b8507fbc",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}