New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wallet: Remove return value from CommitTransaction #17154
Conversation
77d8b78
to
25edffb
Compare
Slightly tend to NACK. What is this needed for? Effectively, a gui user will send the transaction twice (spending different coins), losing all their funds. |
Currently the function returns a bool, which is always
I could change this PR to maintain the current behaviour (not return success to |
I am pretty sure it was intentional. At least that was my understanding, see #9302 (comment) To sum up, the wallet is only allowed to do one of the following:
A wallet is not allowed to create a tx, sign it and add it to the wallet, so that it will be rebroadcast later, but |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
In that case, |
Fine with me |
25edffb
to
13c2cc4
Compare
Reviewer hint: use --ignore-all-space git diff option for review.
13c2cc4
to
d3e6e19
Compare
This PR now just changes Also rebased on master. |
d3e6e19
to
5021b8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK 5021b8a
5021b8a
to
1f490c9
Compare
Addressed @achow101 's review comment (thanks!) |
ACK 1f490c9 |
Concept ACK. |
CommitTransaction returns a bool to indicate success, but since commit b3a7410 it only returns true, even if the transaction was not successfully broadcast. This commit changes CommitTransaction() to return void. All dead code in `if (!CommitTransaction())` branches has been removed.
1f490c9
to
23fe401
Compare
The `state` return argument has not been set since commit 611291c. Remove it (and the one place that it's used in a calling function).
23fe401
to
9e95931
Compare
Concept ACK |
ACK 9e95931 |
9e95931 [wallet] Remove `state` argument from CWallet::CommitTransaction (John Newbery) d1734f9 [wallet] Remove return value from CommitTransaction() (John Newbery) b6f486a [wallet] Add doxygen comment to CWallet::CommitTransaction() (John Newbery) 8bba91b [wallet] Fix whitespace in CWallet::CommitTransaction() (John Newbery) Pull request description: `CommitTransaction()` returns a bool to indicate success, but since commit b3a7410 (#9302) it only returns true, even if the transaction was not successfully broadcast. This commit changes CommitTransaction() to return void. All dead code in `if (!CommitTransaction())` branches has been removed. Two additional commits fix up the idiosyncratic whitespace in `CommitTransaction` and add a doxygen comment for the function. ACKs for top commit: laanwj: ACK 9e95931 Tree-SHA512: a55a2c20369a45222fc0e02d0891495655a926e71c4f52cb72624768dd7b9c1dca716ea67d38420afb90f40c6e0fd448caa60c18fd693bb10ecb110b641820e6
Hmmm -- sorry for a posthumous comment here, but this patch confuses me a little. It seems the better change would be to continue to have CommitTransaction return a success value/reject reason. What's the recommended pattern following this change for checking the status of a committed transaction? What if a transaction is rejected for consensus reasons, and won't be in the wallet? As a wallet rpc implementer, I want to be able to detect a failed committransaction and then undo some prior steps... |
This PR didn't change any behaviour. It removed a return value that was not used by any calling code. See #9302 for why the RPC code was changed. |
And the TODO that this should, is still in the code: // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure. |
Contributions are welcome. If you want to suggest a PR to return failure information from |
Instead of creating a transaction that is consensus-invalid and then returning a failure and removing the tx again, I'd prefer if the consensus-invalid transaction was not created by the wallet in the first place. Or if that is not possible, the wallet should have checked consensus-validity before storing it in the wallet.dat |
@MarcoFalke well I don't disagree it's better to never be wrong in the first place! But the committransaction also seems to be able to fail for mere policy reasons too, right? @jnewbery My original question was, in light of this patch, if there is actually a recommended handling for transactions which may err, what's the "proper handling" to recover the relevant information here? I'd be happy to make a PR which makes the changes but I don't really fully understand what we want functionality wise from CommitTransaction. |
Yes. I think you are arguing that the functionality to check the tx should happen in
I think we don't have a recommendation to recover from such errors. The best we can do right now is manual fixups: |
I think the most critical thing in I think adding a call to ATMP with |
…ansaction() Summary: bitcoin/bitcoin@b6f486a note: the first commit (bitcoin/bitcoin@8bba91b) didn't really apply to us. --- Depends on D7111 Partial backport of Core [[bitcoin/bitcoin#17154 | PR17154]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7112
…on() Summary: CommitTransaction returns a bool to indicate success, but since commit b3a7410 it only returns true, even if the transaction was not successfully broadcast. This commit changes CommitTransaction() to return void. All dead code in `if (!CommitTransaction())` branches has been removed. bitcoin/bitcoin@d1734f9 --- Depends on D7112 Partial backport of Core [[bitcoin/bitcoin#17154 | PR17154]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7113
…mmitTransaction Summary: The `state` return argument has not been set since commit 611291c198. Remove it (and the one place that it's used in a calling function). bitcoin/bitcoin@9e95931 --- Depends on D7113 Concludes backport of Core [[bitcoin/bitcoin#17154 | PR17154]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7114
CommitTransaction()
returns a bool to indicate success, but since commitb3a7410 (#9302) it only returns true, even if the transaction was not
successfully broadcast. This commit changes CommitTransaction() to return
void.
All dead code in
if (!CommitTransaction())
branches has been removed.Two additional commits fix up the idiosyncratic whitespace in
CommitTransaction
and add a doxygen comment for the function.