Skip to content
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

Add change type option to fundrawtransaction #12194

Merged

Conversation

promag
Copy link
Member

@promag promag commented Jan 15, 2018

Adds a new option change_type to fundrawtransaction RPC. This is useful to override the node -changetype argument.

The new option is exclusive to changeAddress option, setting both raises a RPC error.

See also #11403, #12119.

@promag
Copy link
Member Author

promag commented Jan 15, 2018

Missing tests for the new option.

@instagibbs
Copy link
Member

might be a good candidate for another coincontrol field?

concept ACK

@promag
Copy link
Member Author

promag commented Jan 15, 2018

might be a good candidate for another coincontrol field?

I thought the same, but coin control doesn't sound the best place to put it. Correct me if I'm wrong though.

@promag promag force-pushed the 2018-01-fundrawtransaction-changetype branch from a5e687c to 6596d32 Compare January 15, 2018 17:12
@@ -3015,6 +3015,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
" {\n"
" \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n"
" \"changePosition\" (numeric, optional, default random) The index of the change output\n"
" \"change_type\" (string, optional) The address type to use. Only valid if changeAddress is unspecified. Options are \"legacy\", \"p2sh\", and \"bech32\". Default is set by -changetype.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing , after )

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what you mean.

@jonasschnelli
Copy link
Contributor

Concept ACK.
I agree with @instagibbs that it could/should be a CoinControl member.

@promag promag force-pushed the 2018-01-fundrawtransaction-changetype branch 3 times, most recently from c0e5b8e to f46f06f Compare January 16, 2018 00:20
@promag
Copy link
Member Author

promag commented Jan 16, 2018

Thanks @instagibbs and @jonasschnelli, changed as requested.

@promag promag force-pushed the 2018-01-fundrawtransaction-changetype branch from f46f06f to 4c74a8e Compare January 16, 2018 01:58
@promag
Copy link
Member Author

promag commented Jan 16, 2018

Reference #12177.

@kallewoof
Copy link
Member

Also see #11489

@laanwj laanwj added this to the 0.16.0 milestone Jan 18, 2018
@jonasschnelli
Copy link
Contributor

Needs tests.

@maflcko
Copy link
Member

maflcko commented Jan 18, 2018

I am -0 on this one, I tend to like #12119 more.

@promag
Copy link
Member Author

promag commented Jan 18, 2018

If change type is not explicit defined then it should follow #12119 logic for change type. I can rebase with that pull. WDYT?

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 4c74a8ef93d75e605feece08b150cdbd7260ec82. I think it's nice to be adding the coincontrol/fundraw option, if only to make it explicit that unless you override it (or changeAddress), then the type of change output will depend on global options the wallet was started up with. Notes:

  • This PR will conflict with [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH #12119, but the changes should be compatible (as promag pointed out). I don't have an opinion on which PR should be merged first or rebased on the other.
  • It would be good to add a simple test to exercise the new code.
  • It could be good if other RPCs calling CreateTransaction/SendMoney got a change_type option.

@promag
Copy link
Member Author

promag commented Jan 20, 2018

I don't have an opinion on which PR should be merged first or rebased on the other.

From what I can tell #12119 changes the OUTPUT_TYPE_NONE meaning. For that reason I would merge this one first.

It would be good to add a simple test to exercise the new code.

Will do.

It could be good if other RPCs calling CreateTransaction/SendMoney got a change_type option

Not sure about that though. I think this is useful for a migration period and targets expert users.

@promag promag force-pushed the 2018-01-fundrawtransaction-changetype branch from 4c74a8e to bceb5da Compare January 24, 2018 15:31
@promag
Copy link
Member Author

promag commented Jan 24, 2018

Rebase and added test.

@@ -17,6 +17,7 @@ class CCoinControl
{
public:
CTxDestination destChange;
OutputType change_type;
Copy link
Member

Choose a reason for hiding this comment

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

Probably should add some comments distinguishing use between this and destChange right above.

Had to look up why both are required. (this being useful for non-prescribed destination, but prescribed destination type only)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -3057,6 +3057,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
" {\n"
" \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n"
" \"changePosition\" (numeric, optional, default random) The index of the change output\n"
" \"change_type\" (string, optional) The address type to use. Only valid if changeAddress is unspecified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -changetype.\n"
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe try to avoid additional "address" language for change stuff. "The output type to use for change"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also s/unspecified/not specified.

@promag promag force-pushed the 2018-01-fundrawtransaction-changetype branch from bceb5da to 79985b0 Compare January 24, 2018 15:52
@ryanofsky
Copy link
Contributor

ryanofsky commented Jan 24, 2018

Slightly tested (running & tweaking fundraw test script) ACK 79985b052e8846c11a165ac9eabcc8767c32cbb6. Changes since last review were rebasing after #12119, adding test, adding change_type RPCTypeCheck, adding coincontrol comments.

@instagibbs
Copy link
Member

utACK 79985b0

non-blocking requests

@promag promag force-pushed the 2018-01-fundrawtransaction-changetype branch from 79985b0 to 16f6f59 Compare January 24, 2018 16:01
CTxDestination destChange;
//! Custom change type, ignored if destChange is set, defaults to g_change_type
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the term "change type" seems not precise enough... I would have used change address type.

CTxDestination destChange;
//! Custom change type, ignored if destChange is set, defaults to g_change_type
OutputType change_type;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I guess this should haven been m_change_type?

@jonasschnelli
Copy link
Contributor

utACK 16f6f59

@jonasschnelli jonasschnelli merged commit 16f6f59 into bitcoin:master Jan 24, 2018
jonasschnelli added a commit that referenced this pull request Jan 24, 2018
16f6f59 [qa] Test fundrawtransaction with change_type option (João Barbosa)
536ddeb [rpc] Add change_type option to fundrawtransaction (João Barbosa)
31dbd5a [wallet] Add change type to CCoinControl (João Barbosa)

Pull request description:

  Adds a new option `change_type` to `fundrawtransaction` RPC. This is useful to override the node `-changetype` argument.

  The new option is exclusive to `changeAddress` option, setting both raises a RPC error.

  See also #11403, #12119.

Tree-SHA512: 654686444f6125e37015a62f167064d54ec335701534988447be4687fa5ef9c7980a8a07cc0a03fff6ea6c4c1abf0f77a8843d535c4f3fe0bf93f968a4e676e6
@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.

None yet

8 participants