-
Notifications
You must be signed in to change notification settings - Fork 1.2k
bitcoin#9680: Unify CWalletTx construction #3680
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
Conversation
Construct CWalletTx objects in CWallet::CommitTransaction, instead of having callers do it. This ensures CWalletTx objects are constructed in a uniform way and all fields are set. This also makes it possible to avoid confusing and wasteful CWalletTx copies in bitcoin#9381 There is no change in behavior.
No change in behavior in the normal case. But buggy mapWallet lookups with invalid txids will now throw exceptions instead of inserting dummy entries into the map, and potentially causing segfaults and other failures. This also makes it a compiler error to use the mapWallet[hash] syntax which could create dummy entries.
da944ca
to
ceece04
Compare
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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.
ACK
@@ -1035,7 +1035,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface | |||
CAmount GetNormalizedAnonymizedBalance() const; | |||
CAmount GetDenominatedBalance(bool unconfirmed=false) const; | |||
|
|||
bool GetBudgetSystemCollateralTX(CTransactionRef tx, uint256 hash, CAmount amount, const COutPoint& outpoint=COutPoint()/*defaults null*/); | |||
bool GetBudgetSystemCollateralTX(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint=COutPoint()/*defaults null*/); |
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.
What's the point of making this a reference reference?
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.
std::shared_ptr
reference -> https://github.com/dashpay/dash/blob/develop/src/primitives/transaction.h#L345
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, changes look good. Please update spreadsheet when merged: https://docs.google.com/spreadsheets/d/1DnKxat0S0H62CJOzXpKGPXTa8hgoVOjGYZzoClmGSB8/edit?usp=sharing
Also, please avoid mixing dash changes in the same commit as backport when possible. When it's in the same file, and it's clear what's happening, that's cool, but the changes to the privatesend code/governance code here should be done in a separate commit imo to enable an easier review of the main part of the backport
* Fix extra line break in CommitTransaction log message Introduced in #3680 ebe7e80#diff-b2bb174788c7409b671c46ccc86034bdR4113 * doc: Fix `quorum sign` help * doc: Add `getdata` to quorum commands list help * doc: Drop "P2WSH" from signrawtransactionwithkey help * trivial: Replace "push_back(Pair(..))" with "pushKV" * trivial: Reorder wallet cmd-line options * git: Add macos debug simbols to .gitignore * trivial: Fix typos and whitespaces, drop unused stuff
* [wallet] Construct CWalletTx objects in CommitTransaction Construct CWalletTx objects in CWallet::CommitTransaction, instead of having callers do it. This ensures CWalletTx objects are constructed in a uniform way and all fields are set. This also makes it possible to avoid confusing and wasteful CWalletTx copies in bitcoin#9381 There is no change in behavior. * [wallet] Get rid of CWalletTx default constructor No change in behavior in the normal case. But buggy mapWallet lookups with invalid txids will now throw exceptions instead of inserting dummy entries into the map, and potentially causing segfaults and other failures. This also makes it a compiler error to use the mapWallet[hash] syntax which could create dummy entries. * Apply suggestions from code review Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: Russell Yanofsky <russ@yanofsky.org> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
* Fix extra line break in CommitTransaction log message Introduced in dashpay#3680 dashpay@ebe7e80#diff-b2bb174788c7409b671c46ccc86034bdR4113 * doc: Fix `quorum sign` help * doc: Add `getdata` to quorum commands list help * doc: Drop "P2WSH" from signrawtransactionwithkey help * trivial: Replace "push_back(Pair(..))" with "pushKV" * trivial: Reorder wallet cmd-line options * git: Add macos debug simbols to .gitignore * trivial: Fix typos and whitespaces, drop unused stuff
Backport bitcoin#9680