Repository navigation
wallet: return broadcast errors from CommitTransaction - #36597
pseudoramdom wants to merge 4 commits into
Conversation
Introduce TransactionBroadcastError, which holds a TransactionError and a message. BroadcastTransaction returns Expected<void, TransactionBroadcastError>, so the error code and its message travel together. Remove TransactionError::OK. Errors that had an empty message now carry the generic TransactionErrorString text.
Return Expected<void, TransactionBroadcastError> from SubmitTxMemoryPoolAndRelay. Wallet-side prechecks (broadcasting disabled, coinbase, abandoned, confirmed or conflicted) return the new SUBMISSION_SKIPPED code with a reason; node errors pass through.
Return the submission result from CWallet::CommitTransaction and interfaces::Wallet::commitTransaction, so callers can tell whether a saved transaction was accepted.
Check the CommitTransaction result for accepted, already confirmed, max-fee and mempool-minimum rejections, and that a rejected transaction stays saved in the wallet. Also check the result through interfaces::Wallet::commitTransaction, which the GUI uses, for skipped and accepted commits.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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. |
|
Concept ACK |
|
Concept ACK 4e3d167 With -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? |
Yes, that's the intent. |
|
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 |
The 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
Partially agree. The GUI should catch this before the user confirms. Currently, it looks like
A synchronous error when submission fails right away seems more useful than returning |
|
I ran some mutation testing on the changed files. One surviving mutant seems relevant here: Surviving mutant
- return m_wallet->CommitTransaction(std::move(tx), /*replaces_txid=*/std::nullopt, /*comment=*/std::nullopt, /*comment_to=*/std::nullopt, messages);
+ auto result{m_wallet->CommitTransaction(std::move(tx), /*replaces_txid=*/std::nullopt, /*comment=*/std::nullopt, /*comment_to=*/std::nullopt, messages)};
+ // A transaction rejected by the mempool is still stored in the wallet and will be resubmitted later.
+ if (!result && result.error().code == node::TransactionError::MEMPOOL_REJECTED) return {};
+ return result; |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
Concept ACK |

Part of bitcoin-core/gui-qml#1008.
The QML GUI shows "Transaction sent" even when the node rejected the transaction, because
CWallet::CommitTransaction()only logs the rejection and returnsvoid.This PR bubbles up the submission result through
interfaces::Wallet::commitTransaction()so the GUI can report it.Key changes
TransactionBroadcastError, holding aTransactionErrorcode and an untranslated message.Expected<void, TransactionBroadcastError>.TransactionError::OK, a success value in an error enum.SUBMISSION_SKIPPEDcode for when the wallet doesn't submit the transaction (broadcasting disabled, abandoned, coinbase, confirmed or conflicted).SubmitTxMemoryPoolAndRelay()previously returnedfalsein these cases.Note
commitBumpTransaction()similarly reports success for a rejected replacement. This will be addressed in a follow-up PR.interfaces::Walletmock for the newcommitTransaction()signature.