Browse Source

[rpc] Add change_type option to fundrawtransaction

0.16
João Barbosa 7 years ago
parent
commit
536ddeb173
  1. 12
      src/wallet/rpcwallet.cpp

12
src/wallet/rpcwallet.cpp

@ -3057,6 +3057,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
" {\n" " {\n"
" \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\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" " \"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" " \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n"
" \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\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" " \"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)}, {"changeAddress", UniValueType(UniValue::VSTR)},
{"changePosition", UniValueType(UniValue::VNUM)}, {"changePosition", UniValueType(UniValue::VNUM)},
{"change_type", UniValueType(UniValue::VSTR)},
{"includeWatching", UniValueType(UniValue::VBOOL)}, {"includeWatching", UniValueType(UniValue::VBOOL)},
{"lockUnspents", UniValueType(UniValue::VBOOL)}, {"lockUnspents", UniValueType(UniValue::VBOOL)},
{"reserveChangeKey", UniValueType(UniValue::VBOOL)}, // DEPRECATED (and ignored), should be removed in 0.16 or so. {"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")) if (options.exists("changePosition"))
changePosition = options["changePosition"].get_int(); 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")) if (options.exists("includeWatching"))
coinControl.fAllowWatchOnly = options["includeWatching"].get_bool(); coinControl.fAllowWatchOnly = options["includeWatching"].get_bool();

Loading…
Cancel
Save