{
 "number": 36597,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36597",
 "title": "wallet: return broadcast errors from CommitTransaction",
 "author": "pseudoramdom",
 "author_association": "MEMBER",
 "created_at": "2026-10-21T21:54:15Z",
 "updated_at": "2026-10-30T15:09:13Z",
 "description_hash": "dac5633897a177ca",
 "age_days": 11,
 "draft": false,
 "labels": [
  "Wallet"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "4e3d1675597173075a7efd9b3905c928b2be8de5",
 "head_ref": "commit-transaction-interface",
 "head_repo": "pseudoramdom/bitcoin",
 "head_history": [],
 "additions": 260,
 "deletions": 116,
 "changed_files": 22,
 "commit_count": 4,
 "size_bucket": "M",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "concept_ack": [
     {
      "login": "w0xlt",
      "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6327592527"
     },
     {
      "login": "Naomi-Gift",
      "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6342169509"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "w0xlt": {
   "kind": "concept_ack",
   "hash": null,
   "t": "2026-10-21T22:06:16Z",
   "stale": false
  },
  "Naomi-Gift": {
   "kind": "concept_ack",
   "hash": "4e3d1675597173075a7efd9b3905c928b2be8de5",
   "t": "2026-10-22T13:38:44Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 2,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "Naomi-Gift",
   "ViniciusCestarii",
   "maflcko",
   "w0xlt"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-23T18:01:13Z",
  "last_reviewer_activity": "2026-10-23T18:56:56Z",
  "last_reviewer": "ViniciusCestarii",
  "author_silent_days": 9,
  "waiting_on_author_days": 9,
  "days_since_update": 2
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "Part of https://github.com/bitcoin-core/gui-qml/issues/1008.\n\nThe QML GUI shows \"Transaction sent\" even when the node rejected the transaction, because `CWallet::CommitTransaction()` only logs the rejection and returns `void`.\nThis PR bubbles up the submission result through `interfaces::Wallet::commitTransaction()` so the GUI can report it.\n\n#### Key changes\n- Introduce `TransactionBroadcastError`, holding a `TransactionError` code and an untranslated message.\n- Commit/Broadcast functions returns `Expected<void, TransactionBroadcastError>`.\n  - Remove `TransactionError::OK`, a success value in an error enum.\n- Add a `SUBMISSION_SKIPPED` code for when the wallet doesn't submit the transaction (broadcasting disabled, abandoned, coinbase, confirmed or conflicted). `SubmitTxMemoryPoolAndRelay()` previously returned `false` in these cases.\n\n#### Note\n- Existing callers (wallet RPCs, Qt widgets, fee bumper) ignore the new result, so their behavior and RPC responses don't change.\n- `commitBumpTransaction()` similarly reports success for a rejected replacement. This will be addressed in a follow-up PR.\n- gui-qml will need to update its `interfaces::Wallet` mock for the new `commitTransaction()` signature.",
 "commits": [
  {
   "sha": "9f1fbcddb339032b9a046ca437595626690872ab",
   "date": "2026-10-21T21:02:32Z",
   "message": "refactor: use Expected for transaction broadcast results\n\nIntroduce TransactionBroadcastError, which holds a TransactionError and\na message. BroadcastTransaction returns\nExpected<void, TransactionBroadcastError>, so the error code and its message\ntravel together. Remove TransactionError::OK.\n\nErrors that had an empty message now carry the generic\nTransactionErrorString text."
  },
  {
   "sha": "9f46840bace07b47f52676bd6d3bc22cc42e6ed5",
   "date": "2026-10-21T21:02:32Z",
   "message": "wallet: report skipped transaction submissions\n\nReturn Expected<void, TransactionBroadcastError> from\nSubmitTxMemoryPoolAndRelay. Wallet-side prechecks (broadcasting\ndisabled, coinbase, abandoned, confirmed or conflicted) return the new\nSUBMISSION_SKIPPED code with a reason; node errors pass through."
  },
  {
   "sha": "744650bc9a6d742f752b485197d04c2e828e114c",
   "date": "2026-10-21T21:02:32Z",
   "message": "wallet: propagate submission errors through commit APIs\n\nReturn the submission result from CWallet::CommitTransaction and\ninterfaces::Wallet::commitTransaction, so callers can tell whether a\nsaved transaction was accepted."
  },
  {
   "sha": "4e3d1675597173075a7efd9b3905c928b2be8de5",
   "date": "2026-10-21T21:21:52Z",
   "message": "test: cover CommitTransaction results\n\nCheck the CommitTransaction result for accepted, already confirmed,\nmax-fee and mempool-minimum rejections, and that a rejected transaction\nstays saved in the wallet.\n\nAlso check the result through interfaces::Wallet::commitTransaction,\nwhich the GUI uses, for skipped and accepted commits."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-21T22:06:16Z",
   "kind": "comment",
   "who": "w0xlt",
   "assoc": "CONTRIBUTOR",
   "text": "Concept ACK",
   "id": "c:6327592527",
   "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6327592527",
   "hash": "e8334cc43879b73c",
   "edited": null
  },
  {
   "t": "2026-10-22T13:38:44Z",
   "kind": "comment",
   "who": "Naomi-Gift",
   "assoc": "NONE",
   "text": "Concept ACK 4e3d1675597173075a7efd9b3905c928b2be8de5\n\nWith -walletbroadcast=0, commitTransaction now returns an error (SUBMISSION_SKIPPED), even though the user chose not to broadcast. Will the QML GUI treat that as \"saved, not broadcast\" rather than as a failure?",
   "id": "c:6342169509",
   "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6342169509",
   "hash": "bff00f9e1a7e1c76",
   "edited": null
  },
  {
   "t": "2026-10-22T17:44:50Z",
   "kind": "comment",
   "who": "pseudoramdom",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nYes, that's the intent. `SUBMISSION_SKIPPED` is a separate code precisely so a caller can differentiate between \"the wallet didn't submit it\" and \"the node rejected it\" and act accordingly.",
   "id": "c:6347331724",
   "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6347331724",
   "hash": "bac7f16daff5e53c",
   "edited": null
  },
  {
   "t": "2026-10-23T15:35:31Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "Can you explain why this would be needed? If the wallet creates a consensus-invalid (permanently invalid) transaction, that seems like a severe bug that should be fixed instead. If the wallet creates a tx which permanently fails the mempool policy, that seems like an equally severe bug that should be fixed instead. If the wallet creates a tx that undershoots the fee, that seems irrelevant and can equally happen when the tx was accepted to the mempool, but then dropped? If the mempool min fee is 0.677 sat/vB, but the user explicitly asked for a tx at `0.1`, it seems like a case that the GUI should not allow or display a warning while creating the tx. Some feedback directly  after the tx was created seems misplaced? If this was needed, the feedback could be done async?",
   "id": "c:6368597702",
   "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6368597702",
   "hash": "29a7fc98cf50903d",
   "edited": null
  },
  {
   "t": "2026-10-23T18:01:13Z",
   "kind": "comment",
   "who": "pseudoramdom",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nThe GUI can import a PSBT that spends the wallet's coins, sign it with the wallet and commit it. Its inputs and fee were chosen elsewhere and none of `createTransaction()`'s checks ran, so a rejection (fee above `-maxtxfee`, a non-standard output, a mempool conflict) isn't a wallet bug and can't be caught at creation. An early rejection with the reason at `commitTransaction()` time seems useful.\n\n[quoted text omitted]\nPartially agree. The GUI should catch this before the user confirms. Currently, it looks like `GetMinimumFeeRate()` only checks `-mintxfee`/`-minrelaytxfee` when the user has set the fee rate manually. Maybe GUI should also check for mempool minimum.\n\n[quoted text omitted]\nA synchronous error when submission fails right away seems more useful than returning `void`, which is what we do today.\nAsync feedback sounds like a good idea. Something the GUI can subscribe to and be notified about (a later eviction). I see it as complementing the sync error rather than replacing it.",
   "id": "c:6371422769",
   "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6371422769",
   "hash": "4c5afbc26bffd0c8",
   "edited": null
  },
  {
   "t": "2026-10-23T18:56:56Z",
   "kind": "comment",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "text": "I ran some mutation testing on the changed files. One surviving mutant seems relevant here:\n\nSurviving mutant\n\n`wallet/interfaces.cpp`: returning success on `MEMPOOL_REJECTED` survives. `CommitTransactionErrors` covers the rejection on `CWallet`, but the interface test `commit_transaction` (the path gui-qml#1008 uses) only covers `SUBMISSION_SKIPPED` and success.\n\n```diff\n-        return m_wallet->CommitTransaction(std::move(tx), /*replaces_txid=*/std::nullopt, /*comment=*/std::nullopt, /*comment_to=*/std::nullopt, messages);\n+        auto result{m_wallet->CommitTransaction(std::move(tx), /*replaces_txid=*/std::nullopt, /*comment=*/std::nullopt, /*comment_to=*/std::nullopt, messages)};\n+        // A transaction rejected by the mempool is still stored in the wallet and will be resubmitted later.\n+        if (!result && result.error().code == node::TransactionError::MEMPOOL_REJECTED) return {};\n+        return result;\n```",
   "id": "c:6372466862",
   "url": "https://github.com/bitcoin/bitcoin/pull/36597#issuecomment-6372466862",
   "hash": "a6f86fff7cde363d",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-21T21:54:20Z",
   "action": "labeled",
   "label": "Wallet",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 5730,
 "text_tokens_estimate": 1432,
 "changed_paths": [
  "src/common/messages.cpp",
  "src/interfaces/chain.h",
  "src/interfaces/node.h",
  "src/interfaces/wallet.h",
  "src/net_processing.cpp",
  "src/net_processing.h",
  "src/node/interfaces.cpp",
  "src/node/transaction.cpp",
  "src/node/transaction.h",
  "src/node/types.h",
  "src/qt/psbtoperationsdialog.cpp",
  "src/qt/walletmodel.cpp",
  "src/rpc/mempool.cpp",
  "src/rpc/util.cpp",
  "src/test/fuzz/kitchen_sink.cpp",
  "src/wallet/feebumper.cpp",
  "src/wallet/interfaces.cpp",
  "src/wallet/rpc/spend.cpp",
  "src/wallet/test/wallet_interfaces_tests.cpp",
  "src/wallet/test/wallet_tests.cpp",
  "src/wallet/wallet.cpp",
  "src/wallet/wallet.h"
 ],
 "files": [
  {
   "path": "src/common/messages.cpp",
   "add": 2,
   "del": 2
  },
  {
   "path": "src/interfaces/chain.h",
   "add": 9,
   "del": 8
  },
  {
   "path": "src/interfaces/node.h",
   "add": 5,
   "del": 3
  },
  {
   "path": "src/interfaces/wallet.h",
   "add": 5,
   "del": 2
  },
  {
   "path": "src/net_processing.cpp",
   "add": 9,
   "del": 5
  },
  {
   "path": "src/net_processing.h",
   "add": 3,
   "del": 3
  },
  {
   "path": "src/node/interfaces.cpp",
   "add": 8,
   "del": 13
  },
  {
   "path": "src/node/transaction.cpp",
   "add": 21,
   "del": 12
  },
  {
   "path": "src/node/transaction.h",
   "add": 8,
   "del": 9
  },
  {
   "path": "src/node/types.h",
   "add": 13,
   "del": 1
  },
  {
   "path": "src/qt/psbtoperationsdialog.cpp",
   "add": 4,
   "del": 6
  },
  {
   "path": "src/qt/walletmodel.cpp",
   "add": 1,
   "del": 1
  },
  {
   "path": "src/rpc/mempool.cpp",
   "add": 12,
   "del": 16
  },
  {
   "path": "src/rpc/util.cpp",
   "add": 2,
   "del": 0
  },
  {
   "path": "src/test/fuzz/kitchen_sink.cpp",
   "add": 1,
   "del": 0
  },
  {
   "path": "src/wallet/feebumper.cpp",
   "add": 1,
   "del": 1
  },
  {
   "path": "src/wallet/interfaces.cpp",
   "add": 3,
   "del": 2
  },
  {
   "path": "src/wallet/rpc/spend.cpp",
   "add": 2,
   "del": 2
  },
  {
   "path": "src/wallet/test/wallet_interfaces_tests.cpp",
   "add": 32,
   "del": 0
  },
  {
   "path": "src/wallet/test/wallet_tests.cpp",
   "add": 77,
   "del": 6
  },
  {
   "path": "src/wallet/wallet.cpp",
   "add": 32,
   "del": 21
  },
  {
   "path": "src/wallet/wallet.h",
   "add": 10,
   "del": 3
  }
 ],
 "test_lines": 116,
 "git": {
  "head": "4e3d1675597173075a7efd9b3905c928b2be8de5",
  "head_matches_backup": true,
  "base": "de96f3ae6d163e97a2cf29bbd7c2bf2d56e11019",
  "patch_id": "f6a8051640e31682",
  "commits": [
   {
    "sha": "9f1fbcddb3",
    "subject": "refactor: use Expected for transaction broadcast results",
    "files": 13,
    "add": 102,
    "del": 86
   },
   {
    "sha": "9f46840bac",
    "subject": "wallet: report skipped transaction submissions",
    "files": 7,
    "add": 64,
    "del": 22
   },
   {
    "sha": "744650bc9a",
    "subject": "wallet: propagate submission errors through commit APIs",
    "files": 8,
    "add": 25,
    "del": 19
   },
   {
    "sha": "4e3d167559",
    "subject": "test: cover CommitTransaction results",
    "files": 2,
    "add": 80,
    "del": 0
   }
  ],
  "patch_truncated": true
 },
 "patch_id": "f6a8051640e31682",
 "input_hash": "0a2c459b2e70391b",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}