-
Notifications
You must be signed in to change notification settings - Fork 38.8k
wallet: Replace use of purpose strings with an enum #27217
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
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
maflcko
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.
nits
87f8f8b to
44a2ae1
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.
This is a nice change, and I started reviewing 44a2ae100b600bc9c9f4c956223fab3b1948ea8d, but it looks like there are a lot of functions taking optional<AddressPurpose> values that should more properly take AddressPurpose values for simplicity and better type checking. (Basically NotifyAddressBookChanged and all the functions it calls). I think this might stem from not having separate SetAddressBook and UpdateAddressBook functions, so I want to look into this before reviewing more of the PR. (Having separate functions could help because Set function could make purpose a required parameter, while the Update function could let it be it optional).
|
I made some changes to this in a branch that could be adopted https://github.com/ryanofsky/bitcoin/commits/review.27217.1-edit
|
44a2ae1 to
db521d3
Compare
I've adopted these changes. |
ryanofsky
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.
Code review ACK db521d3e89b23046f73410a875bb9660178e3842. Thanks for adopting suggested changes. I left some new suggestions, but they are not important and can be ignored.
I think this PR should be straightforward for others to review now, and nice because it should demystify the purpose field and wallet address book as a whole.
src/interfaces/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.
In commit "wallet: Replace use of purpose strings with an enum" (db521d3e89b23046f73410a875bb9660178e3842)
Note for reviewers: in a few places in this PR, struct order or argument order is changed so the AddressPurpose field follows IsMine or IsChange fields. This is done because the fields hold overlapping information, and in most cases new code should rely on the other fields instead of AddressPurpose.
src/wallet/rpc/addresses.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.
In commit "wallet: Replace use of purpose strings with an enum" (db521d3e89b23046f73410a875bb9660178e3842)
Note for reviewers: this is preserving previous behavior. Default value for CAddressBook::purpose field previously was "unknown" when a purpose was not recorded, and now it is null which is translated to "unknown"
a797f99 to
0d18142
Compare
ryanofsky
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.
Code review ACK 0d18142f595b43070bd07b608d43c9ed9b37cdcc. Suggested a few comment/whitespace tweaks, but this is also fine as-is.
0d18142 to
a48010f
Compare
ryanofsky
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.
Code review ACK a48010f1fd6d8a430b8234789ac3c91ec9d06972. Just comment and whitespace changes since last review
aureleoules
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.
ACK a48010f1fd6d8a430b8234789ac3c91ec9d06972, looks good to me.
a48010f to
98821a7
Compare
ryanofsky
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.
Code review ACK 98821a7aca88ac9401786e848899866b71446460. Just suggested changes since last review, the main one being changing translateTransactionType to use a switch statement.
This had 3 reviews before, so it would be nice to have reacks and hopefully merge this soon.
murchandamus
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.
ACK 98821a7aca88ac9401786e848899866b71446460
98821a7 to
635c50a
Compare
|
ACK 635c50a |
|
reACK 635c50a but appears to need rebase |
Move isminetype and isminefilter there this commit, add WalletPurpose type next commit.
Instead of storing and passing around fixed strings for the purpose of an address, use an enum. This also rationalizes the CAddressBookData struct, documenting all fields and making them public, and simplifying the representation to avoid bugs like bitcoin#26761 (comment) and make it not possible to invalid address data like change addresses with labels. Co-authored-by: Ryan Ofsky <[email protected]>
635c50a to
18fc71a
Compare
|
reACK 18fc71a |
| Q_ARG(QString, strLabel), | ||
| Q_ARG(bool, isMine), | ||
| Q_ARG(QString, strPurpose), | ||
| Q_ARG(wallet::AddressPurpose, purpose), |
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 appears to trigger this assert when executing "getnewaddress" from the Console:
Assertion failed: (invoked), function NotifyAddressBookChanged, file walletmodel.cpp, line 392.
debug.log shows this error message:
GUI: QMetaMethod::invoke: Unable to handle unregistered datatype 'wallet::AddressPurpose'
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.
Thanks, opened an issue here to follow up: bitcoin-core/gui#725.
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.
Fixed in bitcoin-core/gui#726.
a45b544 qt: Register `wallet::AddressPurpose` type (Hennadii Stepanov) Pull request description: This PR is a follow up of bitcoin/bitcoin#27217. Fixes #725. ACKs for top commit: achow101: ACK a45b544 furszy: Tested ACK a45b544 Tree-SHA512: c670f4bf56442613d3fe038b0ba21acfcd4c69aa5340072e9a77d83f5fab1bf2facd87a9e1f42d88f496d277b27b79e7090444d59a9b9e71f3b486e171daa669
a45b544 qt: Register `wallet::AddressPurpose` type (Hennadii Stepanov) Pull request description: This PR is a follow up of bitcoin#27217. Fixes bitcoin#725. ACKs for top commit: achow101: ACK a45b544 furszy: Tested ACK a45b544 Tree-SHA512: c670f4bf56442613d3fe038b0ba21acfcd4c69aa5340072e9a77d83f5fab1bf2facd87a9e1f42d88f496d277b27b79e7090444d59a9b9e71f3b486e171daa669
Instead of storing and passing around fixed strings for the purpose of an address, use an enum.