[rpc] Add change_type option to fundrawtransaction
This commit is contained in:
parent
31dbd5af48
commit
536ddeb173
1 changed files with 12 additions and 0 deletions
|
@ -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 output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -changetype.\n"
|
||||
" \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n"
|
||||
" \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n"
|
||||
" \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific fee rate in " + CURRENCY_UNIT + "/kB\n"
|
||||
|
@ -3122,6 +3123,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
|||
{
|
||||
{"changeAddress", UniValueType(UniValue::VSTR)},
|
||||
{"changePosition", UniValueType(UniValue::VNUM)},
|
||||
{"change_type", UniValueType(UniValue::VSTR)},
|
||||
{"includeWatching", UniValueType(UniValue::VBOOL)},
|
||||
{"lockUnspents", UniValueType(UniValue::VBOOL)},
|
||||
{"reserveChangeKey", UniValueType(UniValue::VBOOL)}, // DEPRECATED (and ignored), should be removed in 0.16 or so.
|
||||
|
@ -3146,6 +3148,16 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
|||
if (options.exists("changePosition"))
|
||||
changePosition = options["changePosition"].get_int();
|
||||
|
||||
if (options.exists("change_type")) {
|
||||
if (options.exists("changeAddress")) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify both changeAddress and address_type options");
|
||||
}
|
||||
coinControl.change_type = ParseOutputType(options["change_type"].get_str(), coinControl.change_type);
|
||||
if (coinControl.change_type == OUTPUT_TYPE_NONE) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown change type '%s'", options["change_type"].get_str()));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.exists("includeWatching"))
|
||||
coinControl.fAllowWatchOnly = options["includeWatching"].get_bool();
|
||||
|
||||
|
|
Loading…
Reference in a new issue