|
|
@ -2458,6 +2458,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) |
|
|
|
" \"changePosition\" (numeric, optional, default random) The index of the change output\n" |
|
|
|
" \"changePosition\" (numeric, optional, default random) The index of the change output\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 0=estimate) Set a specific feerate (fee per KB)\n" |
|
|
|
" }\n" |
|
|
|
" }\n" |
|
|
|
" for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n" |
|
|
|
" for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n" |
|
|
|
"\nResult:\n" |
|
|
|
"\nResult:\n" |
|
|
@ -2484,6 +2485,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) |
|
|
|
int changePosition = -1; |
|
|
|
int changePosition = -1; |
|
|
|
bool includeWatching = false; |
|
|
|
bool includeWatching = false; |
|
|
|
bool lockUnspents = false; |
|
|
|
bool lockUnspents = false; |
|
|
|
|
|
|
|
CFeeRate feeRate = CFeeRate(0); |
|
|
|
|
|
|
|
|
|
|
|
if (params.size() > 1) { |
|
|
|
if (params.size() > 1) { |
|
|
|
if (params[1].type() == UniValue::VBOOL) { |
|
|
|
if (params[1].type() == UniValue::VBOOL) { |
|
|
@ -2495,7 +2497,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
UniValue options = params[1]; |
|
|
|
UniValue options = params[1]; |
|
|
|
|
|
|
|
|
|
|
|
RPCTypeCheckObj(options, boost::assign::map_list_of("changeAddress", UniValue::VSTR)("changePosition", UniValue::VNUM)("includeWatching", UniValue::VBOOL)("lockUnspents", UniValue::VBOOL), true, true); |
|
|
|
RPCTypeCheckObj(options, boost::assign::map_list_of("changeAddress", UniValue::VSTR)("changePosition", UniValue::VNUM)("includeWatching", UniValue::VBOOL)("lockUnspents", UniValue::VBOOL)("feeRate", UniValue::VNUM), true, true); |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("changeAddress")) { |
|
|
|
if (options.exists("changeAddress")) { |
|
|
|
CBitcoinAddress address(options["changeAddress"].get_str()); |
|
|
|
CBitcoinAddress address(options["changeAddress"].get_str()); |
|
|
@ -2514,6 +2516,9 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("lockUnspents")) |
|
|
|
if (options.exists("lockUnspents")) |
|
|
|
lockUnspents = options["lockUnspents"].get_bool(); |
|
|
|
lockUnspents = options["lockUnspents"].get_bool(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (options.exists("feeRate")) |
|
|
|
|
|
|
|
feeRate = CFeeRate(options["feeRate"].get_real()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2529,16 +2534,16 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) |
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "changePosition out of bounds"); |
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "changePosition out of bounds"); |
|
|
|
|
|
|
|
|
|
|
|
CMutableTransaction tx(origTx); |
|
|
|
CMutableTransaction tx(origTx); |
|
|
|
CAmount nFee; |
|
|
|
CAmount nFeeOut; |
|
|
|
string strFailReason; |
|
|
|
string strFailReason; |
|
|
|
|
|
|
|
|
|
|
|
if(!pwalletMain->FundTransaction(tx, nFee, changePosition, strFailReason, includeWatching, lockUnspents, changeAddress)) |
|
|
|
if(!pwalletMain->FundTransaction(tx, nFeeOut, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, changeAddress)) |
|
|
|
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason); |
|
|
|
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason); |
|
|
|
|
|
|
|
|
|
|
|
UniValue result(UniValue::VOBJ); |
|
|
|
UniValue result(UniValue::VOBJ); |
|
|
|
result.push_back(Pair("hex", EncodeHexTx(tx))); |
|
|
|
result.push_back(Pair("hex", EncodeHexTx(tx))); |
|
|
|
result.push_back(Pair("changepos", changePosition)); |
|
|
|
result.push_back(Pair("changepos", changePosition)); |
|
|
|
result.push_back(Pair("fee", ValueFromAmount(nFee))); |
|
|
|
result.push_back(Pair("fee", ValueFromAmount(nFeeOut))); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|