-
Notifications
You must be signed in to change notification settings - Fork 37.8k
wallet: Change output type globals to members #12408
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
Concept ACK. This seems very good in principle, and moving toward multi-wallet support looks like a rational use case to me. |
804f7ba
to
fab8778
Compare
utACK fab8778. How do you plan to have different types for different wallets? |
Concept ACK |
1 similar comment
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.
Tested ACK fab87781
src/wallet/wallet.cpp
Outdated
return nullptr; | ||
} | ||
|
||
|
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: unnecessary empty line
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.
Sorry. Will keep the white space for now, to not invalidate review.
44ed6d1
to
fa9d869
Compare
Trivially rebased and fixed whitespace-nit. Should be easy to re-ACK if you still have the commit locally. |
re-ACK fa9d869. I also checked that #12424 didn't come back, since this latest commit undoes that. |
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 fa9d869d0beec2e6b87c4b88d7226e78864f9e10
Just a suggestion, but I think switching to m_default_address_type
instead of m_address_type
and GetDefaultAddressType
instead of GetWalletAddressType
(and similarly for change) might be a little more clear and consistent.
src/wallet/wallet.h
Outdated
@@ -808,6 +804,8 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface | |||
|
|||
void SetNull() | |||
{ | |||
m_address_type = OutputType::NONE; |
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.
Is there a reason we can't set these to DEFAULT instead of NONE? Using DEFAULT would seem to be better because it would simplify test and test fixture setup in various places. Or if these do have to be NONE, it would be good to have a comment saying why, since the reason isn't obvious.
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.
I think only address type can be DEFAULT
, there is use case NONE
change type (change_type = g_change_type != OUTPUT_TYPE_NONE ? g_change_type : g_address_type
).
I think the answer would depend on what the use case for per-wallet output types is (assuming there is a use case). If the address/change types for a wallet are supposed to be stable, they should probably be determined from the database, either by being stored explicitly, or by being derived from the wallet version number. In this case the output types should be persistent and controllable by RPC. Alternately, if the output types should just be runtime settings, we could follow sqlite's example and allow specifying per-file options with uri query parameters, for example: |
|
Needs rebase. |
f58ae03
to
efdc392
Compare
Addressed feedback by removing |
efdc392
to
fab8a6f
Compare
utACK fab8a6f |
1 similar comment
utACK fab8a6f |
fab8a6f wallet: Change output type globals to members (MarcoFalke) Pull request description: Output type is used by the wallet when generating addresses or transactions with change, thus it should be a member of `CWallet`. Moreover, in light of multiwallet, it makes sense to prepare for per-wallet attributes instead of for-all-wallets globals. Tree-SHA512: 4fa397cd82522e5bacf4870160a2a0f5e1f2dc046e4b9e2514dee18b187a0e1724d036315f77fa48e48f85533021d5e5525d798160a92d389d75512f3f9e1405
1e46d8a Get rid of ambiguous OutputType::NONE value (Russell Yanofsky) Pull request description: Based on suggestion by @sipa #12119 (comment) After #12119, the NONE output type was overloaded to refer to either an output type that couldn't be parsed, or to an automatic change output mode. This change drops the NONE enum and uses a simple bool to indicate parse failure, and a new CHANGE_AUTO enum to refer the change output type. This change is almost a pure refactoring except it makes RPCs reject empty string ("") address types instead of treating them like they were unset. This simplifies the parsing code a little bit and could prevent RPC usage mistakes. It's noted in the release notes. Follows up #12408 by @MarcoFalke Followups for future PRs: - [ ] Add explicit support for specifying "auto" in `ParseOutputType` as suggested by promag and sipa: #12729 (comment) and #12729 (comment) - [ ] Add wallet `AddressChangeType` method to complement `TransactionChangeType`: #12729 (comment). Tree-SHA512: 8b08b272bcb177a0a9e556dcd965840a7fe601ef83ca97938b879c9b1a33b5b3f96939e1bceef11ba7c644ac21bfd6c1dbc6ca715cd1da4ace50475240e4ee48
1e46d8a Get rid of ambiguous OutputType::NONE value (Russell Yanofsky) Pull request description: Based on suggestion by @sipa bitcoin#12119 (comment) After bitcoin#12119, the NONE output type was overloaded to refer to either an output type that couldn't be parsed, or to an automatic change output mode. This change drops the NONE enum and uses a simple bool to indicate parse failure, and a new CHANGE_AUTO enum to refer the change output type. This change is almost a pure refactoring except it makes RPCs reject empty string ("") address types instead of treating them like they were unset. This simplifies the parsing code a little bit and could prevent RPC usage mistakes. It's noted in the release notes. Follows up bitcoin#12408 by @MarcoFalke Followups for future PRs: - [ ] Add explicit support for specifying "auto" in `ParseOutputType` as suggested by promag and sipa: bitcoin#12729 (comment) and bitcoin#12729 (comment) - [ ] Add wallet `AddressChangeType` method to complement `TransactionChangeType`: bitcoin#12729 (comment). Tree-SHA512: 8b08b272bcb177a0a9e556dcd965840a7fe601ef83ca97938b879c9b1a33b5b3f96939e1bceef11ba7c644ac21bfd6c1dbc6ca715cd1da4ace50475240e4ee48
Output type is used by the wallet when generating addresses or transactions with change, thus it should be a member of
CWallet
.Moreover, in light of multiwallet, it makes sense to prepare for per-wallet attributes instead of for-all-wallets globals.