Add iswitness parameter to decode- and fundrawtransaction RPCs
This commit is contained in:
@@ -2812,9 +2812,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
|
||||
throw std::runtime_error(
|
||||
"fundrawtransaction \"hexstring\" ( options )\n"
|
||||
"fundrawtransaction \"hexstring\" ( options iswitness )\n"
|
||||
"\nAdd inputs to a transaction until it has enough in value to meet its out value.\n"
|
||||
"This will not modify existing inputs, and will add at most one change output to the outputs.\n"
|
||||
"No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n"
|
||||
@@ -2849,6 +2849,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
" \"CONSERVATIVE\"\n"
|
||||
" }\n"
|
||||
" for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n"
|
||||
"3. iswitness (boolean, optional) Whether the transaction hex is a serialized witness transaction \n"
|
||||
" If iswitness is not present, heuristic tests will be used in decoding\n"
|
||||
|
||||
"\nResult:\n"
|
||||
"{\n"
|
||||
" \"hex\": \"value\", (string) The resulting raw transaction (hex-encoded string)\n"
|
||||
@@ -2881,7 +2884,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
coinControl.fAllowWatchOnly = request.params[1].get_bool();
|
||||
}
|
||||
else {
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ, UniValue::VBOOL});
|
||||
|
||||
UniValue options = request.params[1];
|
||||
|
||||
@@ -2949,8 +2952,11 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
|
||||
// parse hex string from parameter
|
||||
CMutableTransaction tx;
|
||||
if (!DecodeHexTx(tx, request.params[0].get_str(), true))
|
||||
bool try_witness = request.params[2].isNull() ? true : request.params[2].get_bool();
|
||||
bool try_no_witness = request.params[2].isNull() ? true : !request.params[2].get_bool();
|
||||
if (!DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
||||
}
|
||||
|
||||
if (tx.vout.size() == 0)
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "TX must have at least one output");
|
||||
@@ -3183,7 +3189,7 @@ extern UniValue importmulti(const JSONRPCRequest& request);
|
||||
static const CRPCCommand commands[] =
|
||||
{ // category name actor (function) argNames
|
||||
// --------------------- ------------------------ ----------------------- ----------
|
||||
{ "rawtransactions", "fundrawtransaction", &fundrawtransaction, {"hexstring","options"} },
|
||||
{ "rawtransactions", "fundrawtransaction", &fundrawtransaction, {"hexstring","options","iswitness"} },
|
||||
{ "hidden", "resendwallettransactions", &resendwallettransactions, {} },
|
||||
{ "wallet", "abandontransaction", &abandontransaction, {"txid"} },
|
||||
{ "wallet", "abortrescan", &abortrescan, {} },
|
||||
|
||||
Reference in New Issue
Block a user