Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Feb 11, 2018

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.

@randolf
Copy link
Contributor

randolf commented Feb 11, 2018

Concept ACK. This seems very good in principle, and moving toward multi-wallet support looks like a rational use case to me.

@maflcko maflcko force-pushed the Mf1802-walletChangeTypeMember branch from 804f7ba to fab8778 Compare February 11, 2018 02:51
@maflcko maflcko added this to the 0.16.1 milestone Feb 11, 2018
@promag
Copy link
Contributor

promag commented Feb 11, 2018

utACK fab8778.

How do you plan to have different types for different wallets?

@jonasschnelli
Copy link
Contributor

Concept ACK

1 similar comment
@laanwj
Copy link
Member

laanwj commented Feb 12, 2018

Concept ACK

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK fab87781

return nullptr;
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary empty line

Copy link
Member Author

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.

@maflcko maflcko removed this from the 0.16.1 milestone Feb 14, 2018
@maflcko maflcko force-pushed the Mf1802-walletChangeTypeMember branch 2 times, most recently from 44ed6d1 to fa9d869 Compare February 16, 2018 18:57
@maflcko
Copy link
Member Author

maflcko commented Feb 16, 2018

Trivially rebased and fixed whitespace-nit. Should be easy to re-ACK if you still have the commit locally.

@Sjors
Copy link
Member

Sjors commented Feb 20, 2018

re-ACK fa9d869. I also checked that #12424 didn't come back, since this latest commit undoes that.

@instagibbs
Copy link
Member

utACK fa9d869

I echo @promag 's question. Out of scope for now, but would be good to know.

Copy link
Contributor

@ryanofsky ryanofsky left a 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.

@@ -808,6 +804,8 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface

void SetNull()
{
m_address_type = OutputType::NONE;
Copy link
Contributor

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.

Copy link
Contributor

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).

@ryanofsky
Copy link
Contributor

How do you plan to have different types for different wallets?

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: "-wallet=name?addresstype=bech32".

@promag
Copy link
Contributor

promag commented Mar 1, 2018

switching to m_default_address_type instead of m_address_type and GetDefaultAddressType instead of GetWalletAddressType

@ryanofsky 👍

@promag
Copy link
Contributor

promag commented Mar 16, 2018

Needs rebase.

@maflcko maflcko force-pushed the Mf1802-walletChangeTypeMember branch 4 times, most recently from f58ae03 to efdc392 Compare March 17, 2018 20:02
@maflcko
Copy link
Member Author

maflcko commented Mar 17, 2018

Addressed feedback by removing OutputType::DEFAULT.

@maflcko maflcko force-pushed the Mf1802-walletChangeTypeMember branch from efdc392 to fab8a6f Compare March 17, 2018 20:10
@laanwj
Copy link
Member

laanwj commented Mar 19, 2018

utACK fab8a6f

1 similar comment
@instagibbs
Copy link
Member

utACK fab8a6f

@laanwj laanwj merged commit fab8a6f into bitcoin:master Mar 19, 2018
laanwj added a commit that referenced this pull request Mar 19, 2018
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
@maflcko maflcko deleted the Mf1802-walletChangeTypeMember branch March 19, 2018 16:17
laanwj added a commit that referenced this pull request May 3, 2018
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
TheArbitrator pushed a commit to TheArbitrator/dash that referenced this pull request Jun 21, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants