Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 1,408 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"address\":\"multisigaddress\", (string) The value of the " | " \"address\":\"multisigaddress\", (string) The value of the " | ||||
"new multisig address.\n" | "new multisig address.\n" | ||||
" \"redeemScript\":\"script\" (string) The string value " | " \"redeemScript\":\"script\" (string) The string value " | ||||
"of the hex-encoded redemption script.\n" | "of the hex-encoded redemption script.\n" | ||||
"}\n" | "}\n" | ||||
"\nResult (DEPRECATED. To see this result in v0.19.6 instead, " | |||||
"please start bitcoind with -deprecatedrpc=addmultisigaddress).\n" | |||||
" clients should transition to the new output api before " | |||||
"upgrading to v0.20.\n" | |||||
"\"address\" (string) A bitcoin address " | |||||
"associated with the keys.\n" | |||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nAdd a multisig address from 2 addresses\n" + | "\nAdd a multisig address from 2 addresses\n" + | ||||
HelpExampleCli("addmultisigaddress", | HelpExampleCli("addmultisigaddress", | ||||
"2 " | "2 " | ||||
"\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\"," | "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\"," | ||||
"\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + | "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + | ||||
"\nAs json rpc call\n" + | "\nAs json rpc call\n" + | ||||
Show All 33 Lines | static UniValue addmultisigaddress(const Config &config, | ||||
CScript inner = CreateMultisigRedeemscript(required, pubkeys); | CScript inner = CreateMultisigRedeemscript(required, pubkeys); | ||||
pwallet->AddCScript(inner); | pwallet->AddCScript(inner); | ||||
CTxDestination dest = | CTxDestination dest = | ||||
pwallet->AddAndGetDestinationForScript(inner, output_type); | pwallet->AddAndGetDestinationForScript(inner, output_type); | ||||
pwallet->SetAddressBook(dest, label, "send"); | pwallet->SetAddressBook(dest, label, "send"); | ||||
// Return old style interface | |||||
if (IsDeprecatedRPCEnabled(gArgs, "addmultisigaddress")) { | |||||
return EncodeDestination(dest, config); | |||||
} | |||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("address", EncodeDestination(dest, config)); | result.pushKV("address", EncodeDestination(dest, config)); | ||||
result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); | result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); | ||||
return result; | return result; | ||||
} | } | ||||
struct tallyitem { | struct tallyitem { | ||||
Amount nAmount; | Amount nAmount; | ||||
▲ Show 20 Lines • Show All 2,137 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"\nAdd inputs to a transaction until it has enough in value to " | "\nAdd inputs to a transaction until it has enough in value to " | ||||
"meet its out value.\n" | "meet its out value.\n" | ||||
"This will not modify existing inputs, and will add at most one " | "This will not modify existing inputs, and will add at most one " | ||||
"change output to the outputs.\n" | "change output to the outputs.\n" | ||||
"No existing outputs will be modified unless " | "No existing outputs will be modified unless " | ||||
"\"subtractFeeFromOutputs\" is specified.\n" | "\"subtractFeeFromOutputs\" is specified.\n" | ||||
"Note that inputs which were signed may need to be resigned after " | "Note that inputs which were signed may need to be resigned after " | ||||
"completion since in/outputs have been added.\n" | "completion since in/outputs have been added.\n" | ||||
"The inputs added will not be signed, use signrawtransaction for " | "The inputs added will not be signed, use " | ||||
"signrawtransactionwithkey or signrawtransactionwithwallet for " | |||||
"that.\n" | "that.\n" | ||||
"Note that all existing inputs must have their previous output " | "Note that all existing inputs must have their previous output " | ||||
"transaction be in the wallet.\n" | "transaction be in the wallet.\n" | ||||
"Note that all inputs selected must be of standard form and P2SH " | "Note that all inputs selected must be of standard form and P2SH " | ||||
"scripts must be\n" | "scripts must be\n" | ||||
"in the wallet using importaddress or addmultisigaddress (to " | "in the wallet using importaddress or addmultisigaddress (to " | ||||
"calculate fees).\n" | "calculate fees).\n" | ||||
"You can see whether this is the case by checking the \"solvable\" " | "You can see whether this is the case by checking the \"solvable\" " | ||||
"field in the listunspent output.\n" | "field in the listunspent output.\n" | ||||
"Only pay-to-pubkey, multisig, and P2SH versions thereof are " | "Only pay-to-pubkey, multisig, and P2SH versions thereof are " | ||||
"currently supported for watch-only\n" | "currently supported for watch-only\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"hexstring\" (string, required) The hex string of " | "1. \"hexstring\" (string, required) The hex string of " | ||||
"the raw transaction\n" | "the raw transaction\n" | ||||
"2. options (object, optional)\n" | "2. options (object, optional)\n" | ||||
" {\n" | " {\n" | ||||
" \"changeAddress\" (string, optional, default pool " | " \"changeAddress\" (string, optional, default pool " | ||||
"address) The bitcoin address to receive the change\n" | "address) The bitcoin address to receive the change\n" | ||||
" \"changePosition\" (numeric, optional, default " | " \"changePosition\" (numeric, optional, default " | ||||
"random) The index of the change output\n" | "random) The index of the change output\n" | ||||
" \"includeWatching\" (boolean, optional, default " | " \"includeWatching\" (boolean, optional, default " | ||||
"false) Also select inputs which are watch only\n" | "false) Also select inputs which are watch only\n" | ||||
" \"lockUnspents\" (boolean, optional, default " | " \"lockUnspents\" (boolean, optional, default " | ||||
"false) Lock selected unspent outputs\n" | "false) Lock selected unspent outputs\n" | ||||
" \"reserveChangeKey\" (boolean, optional) " | |||||
"DEPRECATED. Reserves the change output key from the keypool\n" | |||||
" \"feeRate\" (numeric, optional, default not " | " \"feeRate\" (numeric, optional, default not " | ||||
"set: makes wallet determine the fee) Set a specific fee rate in " + | "set: makes wallet determine the fee) Set a specific fee rate in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"/kB\n" | "/kB\n" | ||||
" \"subtractFeeFromOutputs\" (array, optional) A json array of " | " \"subtractFeeFromOutputs\" (array, optional) A json array of " | ||||
"integers.\n" | "integers.\n" | ||||
" The fee will be equally deducted " | " The fee will be equally deducted " | ||||
"from the amount of each specified output.\n" | "from the amount of each specified output.\n" | ||||
Show All 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nCreate a transaction with no inputs\n" + | "\nCreate a transaction with no inputs\n" + | ||||
HelpExampleCli("createrawtransaction", | HelpExampleCli("createrawtransaction", | ||||
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") + | "\"[]\" \"{\\\"myaddress\\\":0.01}\"") + | ||||
"\nAdd sufficient unsigned inputs to meet the output value\n" + | "\nAdd sufficient unsigned inputs to meet the output value\n" + | ||||
HelpExampleCli("fundrawtransaction", "\"rawtransactionhex\"") + | HelpExampleCli("fundrawtransaction", "\"rawtransactionhex\"") + | ||||
"\nSign the transaction\n" + | "\nSign the transaction\n" + | ||||
HelpExampleCli("signrawtransaction", "\"fundedtransactionhex\"") + | HelpExampleCli("signrawtransactionwithwallet", | ||||
"\"fundedtransactionhex\"") + | |||||
"\nSend the transaction\n" + | "\nSend the transaction\n" + | ||||
HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")); | HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")); | ||||
} | } | ||||
RPCTypeCheck(request.params, {UniValue::VSTR}); | RPCTypeCheck(request.params, {UniValue::VSTR}); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
CCoinControl coinControl; | CCoinControl coinControl; | ||||
int changePosition = -1; | int changePosition = -1; | ||||
bool lockUnspents = false; | bool lockUnspents = false; | ||||
// DEPRECATED, should be removed in 0.20 | |||||
bool reserveChangeKey = false; | |||||
UniValue subtractFeeFromOutputs; | UniValue subtractFeeFromOutputs; | ||||
std::set<int> setSubtractFeeFromOutputs; | std::set<int> setSubtractFeeFromOutputs; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
if (request.params[1].type() == UniValue::VBOOL) { | if (request.params[1].type() == UniValue::VBOOL) { | ||||
// backward compatibility bool only fallback | // backward compatibility bool only fallback | ||||
coinControl.fAllowWatchOnly = request.params[1].get_bool(); | coinControl.fAllowWatchOnly = request.params[1].get_bool(); | ||||
} else { | } else { | ||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ}); | RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ}); | ||||
UniValue options = request.params[1]; | UniValue options = request.params[1]; | ||||
RPCTypeCheckObj( | RPCTypeCheckObj( | ||||
options, | options, | ||||
{ | { | ||||
{"changeAddress", UniValueType(UniValue::VSTR)}, | {"changeAddress", UniValueType(UniValue::VSTR)}, | ||||
{"changePosition", UniValueType(UniValue::VNUM)}, | {"changePosition", UniValueType(UniValue::VNUM)}, | ||||
{"includeWatching", UniValueType(UniValue::VBOOL)}, | {"includeWatching", UniValueType(UniValue::VBOOL)}, | ||||
{"lockUnspents", UniValueType(UniValue::VBOOL)}, | {"lockUnspents", UniValueType(UniValue::VBOOL)}, | ||||
// DEPRECATED, should be removed in 0.20 | |||||
{"reserveChangeKey", UniValueType(UniValue::VBOOL)}, | |||||
// will be checked below | // will be checked below | ||||
{"feeRate", UniValueType()}, | {"feeRate", UniValueType()}, | ||||
{"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, | {"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, | ||||
}, | }, | ||||
true, true); | true, true); | ||||
if (options.exists("changeAddress")) { | if (options.exists("changeAddress")) { | ||||
CTxDestination dest = | CTxDestination dest = | ||||
Show All 17 Lines | if (!request.params[1].isNull()) { | ||||
coinControl.fAllowWatchOnly = | coinControl.fAllowWatchOnly = | ||||
options["includeWatching"].get_bool(); | options["includeWatching"].get_bool(); | ||||
} | } | ||||
if (options.exists("lockUnspents")) { | if (options.exists("lockUnspents")) { | ||||
lockUnspents = options["lockUnspents"].get_bool(); | lockUnspents = options["lockUnspents"].get_bool(); | ||||
} | } | ||||
// DEPRECATED, should be removed in v0.20 | |||||
if (options.exists("reserveChangeKey")) { | |||||
if (!IsDeprecatedRPCEnabled(gArgs, "fundrawtransaction")) { | |||||
throw JSONRPCError( | |||||
RPC_METHOD_DEPRECATED, | |||||
"fundrawtransaction -reserveChangeKey is deprecated " | |||||
"and will be fully removed in v0.20. To use the " | |||||
"-reserveChangeKey option in v0.19, restart bitcoind " | |||||
"with -deprecatedrpc=fundrawtransaction.\nProjects " | |||||
"should transition to expecting change addresses " | |||||
"removed from the keypool before upgrading to v0.20"); | |||||
} else { | |||||
reserveChangeKey = options["reserveChangeKey"].get_bool(); | |||||
} | |||||
} | |||||
if (options.exists("feeRate")) { | if (options.exists("feeRate")) { | ||||
coinControl.m_feerate = | coinControl.m_feerate = | ||||
CFeeRate(AmountFromValue(options["feeRate"])); | CFeeRate(AmountFromValue(options["feeRate"])); | ||||
coinControl.fOverrideFeeRate = true; | coinControl.fOverrideFeeRate = true; | ||||
} | } | ||||
if (options.exists("subtractFeeFromOutputs")) { | if (options.exists("subtractFeeFromOutputs")) { | ||||
subtractFeeFromOutputs = | subtractFeeFromOutputs = | ||||
Show All 39 Lines | for (size_t idx = 0; idx < subtractFeeFromOutputs.size(); idx++) { | ||||
setSubtractFeeFromOutputs.insert(pos); | setSubtractFeeFromOutputs.insert(pos); | ||||
} | } | ||||
Amount nFeeOut; | Amount nFeeOut; | ||||
std::string strFailReason; | std::string strFailReason; | ||||
if (!pwallet->FundTransaction(tx, nFeeOut, changePosition, strFailReason, | if (!pwallet->FundTransaction(tx, nFeeOut, changePosition, strFailReason, | ||||
lockUnspents, setSubtractFeeFromOutputs, | lockUnspents, setSubtractFeeFromOutputs, | ||||
coinControl, reserveChangeKey)) { | coinControl)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); | throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); | ||||
} | } | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("hex", EncodeHexTx(CTransaction(tx))); | result.pushKV("hex", EncodeHexTx(CTransaction(tx))); | ||||
result.pushKV("changepos", changePosition); | result.pushKV("changepos", changePosition); | ||||
result.pushKV("fee", ValueFromAmount(nFeeOut)); | result.pushKV("fee", ValueFromAmount(nFeeOut)); | ||||
▲ Show 20 Lines • Show All 523 Lines • Show Last 20 Lines |