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.
Missing tests for the new option.
might be a good candidate for another coincontrol field?
concept ACK
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.
3014 | @@ -3015,6 +3015,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) 3015 | " {\n" 3016 | " \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n" 3017 | " \"changePosition\" (numeric, optional, default random) The index of the change output\n" 3018 | + " \"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"
nit: missing , after )
Not sure what you mean.
Concept ACK. I agree with @instagibbs that it could/should be a CoinControl member.
Thanks @instagibbs and @jonasschnelli, changed as requested.
Needs tests.
I am -0 on this one, I tend to like #12119 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:
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.
Rebase and added test.
16 | @@ -17,6 +17,7 @@ class CCoinControl 17 | { 18 | public: 19 | CTxDestination destChange; 20 | + OutputType change_type;
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)
Done.
3056 | @@ -3057,6 +3057,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) 3057 | " {\n" 3058 | " \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n" 3059 | " \"changePosition\" (numeric, optional, default random) The index of the change output\n" 3060 | + " \"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"
nit: maybe try to avoid additional "address" language for change stuff. "The output type to use for change"
Done.
Also s/unspecified/not specified.
utACK https://github.com/bitcoin/bitcoin/pull/12194/commits/79985b052e8846c11a165ac9eabcc8767c32cbb6
non-blocking requests
15 | @@ -16,7 +16,10 @@ 16 | class CCoinControl 17 | { 18 | public: 19 | + //! Custom change destination, if not set an address is generated 20 | CTxDestination destChange; 21 | + //! Custom change type, ignored if destChange is set, defaults to g_change_type
nit: the term "change type" seems not precise enough... I would have used change address type.
15 | @@ -16,7 +16,10 @@ 16 | class CCoinControl 17 | { 18 | public: 19 | + //! Custom change destination, if not set an address is generated 20 | CTxDestination destChange; 21 | + //! Custom change type, ignored if destChange is set, defaults to g_change_type 22 | + OutputType change_type;
nit: I guess this should haven been m_change_type?
utACK 16f6f59dc