{
 "number": 36284,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36284",
 "title": "wallet: don't double discard output groups with avoidpartialspends",
 "author": "fjahr",
 "author_association": "MEMBER",
 "created_at": "2026-09-17T08:19:30Z",
 "updated_at": "2026-09-17T08:19:47Z",
 "age_days": 0,
 "draft": false,
 "labels": [
  "Wallet"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "20307f0ac0e17c6e478e2e11318dc7a9b18fc5d1",
 "head_ref": "2026-09-double-discard",
 "head_repo": "fjahr/bitcoin",
 "head_history": [],
 "additions": 29,
 "deletions": 1,
 "changed_files": 2,
 "commit_count": 1,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {},
   "conflicts": []
  }
 },
 "acks_parsed": {},
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": []
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-09-16T22:48:54Z",
  "last_reviewer_activity": null,
  "last_reviewer": null,
  "author_silent_days": 0,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "With `-avoidpartialspends` or `-avoid_reuse`, `GroupOutputs` puts every positive-value output into both the mixed and the positive-only map and runs `push_output_groups` on each, so a group rejected by the eligibility filters lands in `discarded_groups` twice. `AutomaticCoinSelection` then subtracts it twice and could fail with an insufficient funds error even when there would be enough confirmed coins to cover the payment.\n\nNot a problem in a default wallet but it can happen with `sendtoaddress` from an `avoid_reuse` wallet, or with `-avoidpartialspends=1`.\n\nThe simplest possible fix is to record discards only from the mixed map pass, which contains every output anyway. Also adds a test that reproduces the issue.",
 "commits": [
  {
   "sha": "20307f0ac0e17c6e478e2e11318dc7a9b18fc5d1",
   "date": "2026-09-16T22:48:54Z",
   "message": "wallet: don't double count discarded output groups with avoidpartialspends"
  }
 ],
 "timeline": [],
 "labels_log": [
  {
   "t": "2026-09-17T08:19:34Z",
   "action": "labeled",
   "label": "Wallet",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 864,
 "text_tokens_estimate": 216,
 "changed_paths": [
  "src/wallet/spend.cpp",
  "test/functional/wallet_create_tx.py"
 ],
 "files": [
  {
   "path": "src/wallet/spend.cpp",
   "add": 2,
   "del": 1
  },
  {
   "path": "test/functional/wallet_create_tx.py",
   "add": 27,
   "del": 0
  }
 ],
 "test_lines": 27,
 "git": {
  "head": "20307f0ac0e17c6e478e2e11318dc7a9b18fc5d1",
  "head_matches_backup": true,
  "base": "b8215855437288cac95c7fd5d41104c73c0f3495",
  "commits": [
   {
    "sha": "20307f0ac0",
    "subject": "wallet: don't double count discarded output groups with avoidpartialspends",
    "files": 2,
    "add": 29,
    "del": 1
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "0df06f17bcdb0d32",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}