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
Add change type option to fundrawtransaction #12194
Conversation
Missing tests for the new option. |
might be a good candidate for another coincontrol field? concept ACK |
I thought the same, but coin control doesn't sound the best place to put it. Correct me if I'm wrong though. |
a5e687c
to
6596d32
Compare
src/wallet/rpcwallet.cpp
Outdated
@@ -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" |
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: missing ,
after )
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.
Not sure what you mean.
Concept ACK. |
c0e5b8e
to
f46f06f
Compare
Thanks @instagibbs and @jonasschnelli, changed as requested. |
f46f06f
to
4c74a8e
Compare
Reference #12177. |
Also see #11489 |
Needs tests. |
I am -0 on this one, I tend to like #12119 more. |
If change type is not explicit defined then it should follow #12119 logic for change type. I can rebase with that pull. WDYT? |
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 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.
From what I can tell #12119 changes the
Will do.
Not sure about that though. I think this is useful for a migration period and targets expert users. |
4c74a8e
to
bceb5da
Compare
Rebase and added test. |
src/wallet/coincontrol.h
Outdated
@@ -17,6 +17,7 @@ class CCoinControl | |||
{ | |||
public: | |||
CTxDestination destChange; | |||
OutputType change_type; |
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.
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)
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.
Done.
src/wallet/rpcwallet.cpp
Outdated
@@ -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" |
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: maybe try to avoid additional "address" language for change stuff. "The output type to use for change"
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.
Done.
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.
Also s/unspecified/not specified.
bceb5da
to
79985b0
Compare
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. |
utACK 79985b0 non-blocking requests |
79985b0
to
16f6f59
Compare
CTxDestination destChange; | ||
//! Custom change type, ignored if destChange is set, defaults to g_change_type |
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: 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; |
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: I guess this should haven been m_change_type
?
utACK 16f6f59 |
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
Adds a new option
change_type
tofundrawtransaction
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.