-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: Consume ReserveDestination on successful CreateTransaction #16208
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: Consume ReserveDestination on successful CreateTransaction #16208
Conversation
|
Maybe just ditch |
|
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. |
Even with this change this happens even when creating the transaction fails: ret = reservekey.GetReservedKey(vchPubKey, true);
LearnRelatedScripts(vchPubKey, change_type); // will call AddCScript
So IIUC it should always keep the key. |
|
@promag AFAICT there is no case, except maybe mempool chain limits being busted, where keys will be burned. I'm not sure what you're saying with respect to |
|
I mean that once |
|
@promag That's not the case though. There are a number of reasons why a valid transaction is unable to be made, after the key is reserved. Insufficient fee, transaction too large, etc. This results in additional burned keys. |
| Needs rebase |
b535a06 to
5819967
Compare
|
rebased |
5819967 to
e18a67d
Compare
achow101
left a comment
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.
Concept ACK. I think this is a reasonable assumption.
Please update the OP and commit messages to use the new naming.
src/wallet/wallet.cpp
Outdated
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.
This change should be in the previous commit.
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.
done
src/wallet/wallet.h
Outdated
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.
nit: should be reserve an address.
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.
done
e18a67d to
e10e1e8
Compare
|
fixed and updated OP/description as per @achow101 suggestions |
|
ACK e10e1e8 Reviewed the diff |
|
utACK e10e1e8 |
|
Looks good. I initially thought this includes "createrawtransaction" which I think should be stateless,... but Concept ACK. |
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.
utACK e10e1e8
I think my one comment is not merge-blocking
| * ReserveDestination is used to reserve an address. It is passed around | ||
| * during the CreateTransaction/CommitTransaction procedure. | ||
| * ReserveDestination is used to reserve an address. | ||
| * It is currently only used inside of CreateTransaction. |
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.
Not quite true, it is still used in GetNewChangeDestination() which is called by the getrawchangeaddress RPC
…Transaction e10e1e8 Restrict lifetime of ReserveDestination to CWallet::CreateTransaction (Gregory Sanders) d9ff862 CreateTransaction calls KeepDestination on ReserveDestination before success (Gregory Sanders) Pull request description: The typical usage pattern of `ReserveDestination` is to explicitly `KeepDestination`, or `ReturnDestination` when it's detected it will not be used. Implementers such as myself may fail to complete this pattern, and could result in key re-use: #15557 (comment) Since ReserveDestination is currently only used directly in the `CreateTransaction`/`CommitTransaction` flow(or fee bumping where it's just used in `CreateTransaction`), I instead make the assumption that if a transaction is returned by `CreateTransaction` it's highly likely that it will be accepted by the caller, and the `ReserveDestination` kept. This simplifies the API as well. There are very few cases where this would not be the case which may result in keys being burned. Those failure cases appear to be: `CommitTransaction` failing to get the transaction into the mempool Belt and suspenders check in `WalletModel::prepareTransaction` Alternative to #15796 ACKs for top commit: achow101: ACK e10e1e8 Reviewed the diff stevenroose: utACK e10e1e8 meshcollider: utACK e10e1e8 Tree-SHA512: 78d047a00f39ab41cfa297052cc1e9c224d5f47d3d2299face650d71827635de077ac33fb4ab9f7dc6fc5a27f4a68415a1bc9ca33a3cb09a78f4f15b2a48411b
No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed.
|
Should this have release notes? IIUC before this change, if you created a transaction in the GUI and pressed "Cancel" instead of "Yes" in the confirmation dialog, it would previously not affect the change keypool, but now it will remove the key from the pool and mark it used. |
|
@ryanofsky Forgot this case in OP. Considering it's unlikely(?) to be an automated process I don't think it necessitates release notes but that is just my estimation. |
|
Sure, could just add the Needs release note tag for consideration when there is a release. |
4d94916 Get rid of PendingWalletTx class. (Russell Yanofsky) Pull request description: No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from #16208 recently removed the destructor code that would return an unused key if the transaction wasn't committed. This is just cleanup, there's no change in behavior. ACKs for top commit: ariard: utACK 4d94916. Successfully built both `bitcoind` and `bitcoin-qt`. `PendingWalletTx` was only a wrapper to enforce call to `ReturnDestination` if `CommitTransaction` doesn't `KeepDestination` before. promag: ACK 4d94916, refactor looks good to me. meshcollider: utACK 4d94916 Tree-SHA512: f3f93d2f2f5d8f1e7810d609d881c1b1cbbaa8629f483f4293e20b3210292605e947bc4903fde9d2d8736277ca3bd6de182f7eac1e13515d5a327f2ebc130839
4d94916 Get rid of PendingWalletTx class. (Russell Yanofsky) Pull request description: No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin#16208 recently removed the destructor code that would return an unused key if the transaction wasn't committed. This is just cleanup, there's no change in behavior. ACKs for top commit: ariard: utACK 4d94916. Successfully built both `bitcoind` and `bitcoin-qt`. `PendingWalletTx` was only a wrapper to enforce call to `ReturnDestination` if `CommitTransaction` doesn't `KeepDestination` before. promag: ACK 4d94916, refactor looks good to me. meshcollider: utACK 4d94916 Tree-SHA512: f3f93d2f2f5d8f1e7810d609d881c1b1cbbaa8629f483f4293e20b3210292605e947bc4903fde9d2d8736277ca3bd6de182f7eac1e13515d5a327f2ebc130839
… CreateTransaction e10e1e8 Restrict lifetime of ReserveDestination to CWallet::CreateTransaction (Gregory Sanders) d9ff862 CreateTransaction calls KeepDestination on ReserveDestination before success (Gregory Sanders) Pull request description: The typical usage pattern of `ReserveDestination` is to explicitly `KeepDestination`, or `ReturnDestination` when it's detected it will not be used. Implementers such as myself may fail to complete this pattern, and could result in key re-use: bitcoin#15557 (comment) Since ReserveDestination is currently only used directly in the `CreateTransaction`/`CommitTransaction` flow(or fee bumping where it's just used in `CreateTransaction`), I instead make the assumption that if a transaction is returned by `CreateTransaction` it's highly likely that it will be accepted by the caller, and the `ReserveDestination` kept. This simplifies the API as well. There are very few cases where this would not be the case which may result in keys being burned. Those failure cases appear to be: `CommitTransaction` failing to get the transaction into the mempool Belt and suspenders check in `WalletModel::prepareTransaction` Alternative to bitcoin#15796 ACKs for top commit: achow101: ACK e10e1e8 Reviewed the diff stevenroose: utACK e10e1e8 meshcollider: utACK e10e1e8 Tree-SHA512: 78d047a00f39ab41cfa297052cc1e9c224d5f47d3d2299face650d71827635de077ac33fb4ab9f7dc6fc5a27f4a68415a1bc9ca33a3cb09a78f4f15b2a48411b
No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed.
No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed.
No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin/bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed.
No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed.
…veDestination before success Summary: bitcoin/bitcoin@d9ff862 --- Partial backport of Core [[bitcoin/bitcoin#16208 | PR16208]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6800
Summary: No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8db043e9b7c113e07faf408f337c1b732d from bitcoin/bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed. bitcoin/bitcoin@4d94916 --- Backport of Core [[bitcoin/bitcoin#16415 | PR16415]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6804
619685e Get rid of PendingWalletTx class. (Russell Yanofsky) Pull request description: No reason for this class to exist if it doesn't have any code to run in the destructor. d3edeaa from bitcoin/bitcoin#16208 recently removed the destructor code that would return an unused key if the transaction wasn't committed. This is just cleanup, there's no change in behavior. ACKs for top commit: ariard: utACK 619685e. Successfully built both `bitcoind` and `bitcoin-qt`. `PendingWalletTx` was only a wrapper to enforce call to `ReturnDestination` if `CommitTransaction` doesn't `KeepDestination` before. promag: ACK 619685e, refactor looks good to me. meshcollider: utACK 619685e Tree-SHA512: f3f93d2f2f5d8f1e7810d609d881c1b1cbbaa8629f483f4293e20b3210292605e947bc4903fde9d2d8736277ca3bd6de182f7eac1e13515d5a327f2ebc130839
No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin/bitcoin#16208 recently removed code destructor code that would return an unused key if the transaction wasn't committed.
4d94916 Get rid of PendingWalletTx class. (Russell Yanofsky) Pull request description: No reason for this class to exist if it doesn't have any code to run in the destructor. e10e1e8 from bitcoin/bitcoin#16208 recently removed the destructor code that would return an unused key if the transaction wasn't committed. This is just cleanup, there's no change in behavior. ACKs for top commit: ariard: utACK 4d94916. Successfully built both `bitcoind` and `bitcoin-qt`. `PendingWalletTx` was only a wrapper to enforce call to `ReturnDestination` if `CommitTransaction` doesn't `KeepDestination` before. promag: ACK 4d94916, refactor looks good to me. meshcollider: utACK 4d94916 Tree-SHA512: f3f93d2f2f5d8f1e7810d609d881c1b1cbbaa8629f483f4293e20b3210292605e947bc4903fde9d2d8736277ca3bd6de182f7eac1e13515d5a327f2ebc130839
The typical usage pattern of
ReserveDestinationis to explicitlyKeepDestination, orReturnDestinationwhen it's detected it will not be used.Implementers such as myself may fail to complete this pattern, and could result in key re-use: #15557 (comment)
Since ReserveDestination is currently only used directly in the
CreateTransaction/CommitTransactionflow(or fee bumping where it's just used inCreateTransaction), I instead make the assumption that if a transaction is returned byCreateTransactionit's highly likely that it will be accepted by the caller, and theReserveDestinationkept. This simplifies the API as well. There are very few cases where this would not be the case which may result in keys being burned.Those failure cases appear to be:
CommitTransactionfailing to get the transaction into the mempoolBelt and suspenders check in
WalletModel::prepareTransactionAlternative to #15796