Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 3,238 Lines • ▼ Show 20 Lines | static UniValue unloadwallet(const Config &config, | ||||
if (request.fHelp || request.params.size() > 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"unloadwallet", | "unloadwallet", | ||||
"Unloads the wallet referenced by the request endpoint " | "Unloads the wallet referenced by the request endpoint " | ||||
"otherwise unloads the wallet specified in the argument.\n" | "otherwise unloads the wallet specified in the argument.\n" | ||||
"Specifying the wallet name on a wallet endpoint is invalid.", | "Specifying the wallet name on a wallet endpoint is invalid.", | ||||
{ | { | ||||
{"wallet_name", RPCArg::Type::STR, true}, | {"wallet_name", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", "The name of the wallet to unload."}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | "\nExamples:\n" + HelpExampleCli("unloadwallet", "wallet_name") + | ||||
"1. \"wallet_name\" (string, optional) The name of the wallet " | |||||
"to unload.\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("unloadwallet", "wallet_name") + | |||||
HelpExampleRpc("unloadwallet", "wallet_name")); | HelpExampleRpc("unloadwallet", "wallet_name")); | ||||
} | } | ||||
std::string wallet_name; | std::string wallet_name; | ||||
if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) { | if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) { | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Cannot unload the requested wallet"); | "Cannot unload the requested wallet"); | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 5) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"listunspent", | "listunspent", | ||||
"\nReturns array of unspent transaction outputs\n" | "\nReturns array of unspent transaction outputs\n" | ||||
"with between minconf and maxconf (inclusive) confirmations.\n" | "with between minconf and maxconf (inclusive) confirmations.\n" | ||||
"Optionally filter to only include txouts paid to specified " | "Optionally filter to only include txouts paid to specified " | ||||
"addresses.\n", | "addresses.\n", | ||||
{ | { | ||||
{"minconf", RPCArg::Type::NUM, true}, | {"minconf", RPCArg::Type::NUM, /* opt */ true, | ||||
{"maxconf", RPCArg::Type::NUM, true}, | /* default_val */ "1", | ||||
{"addresses", | "The minimum confirmations to filter"}, | ||||
{"maxconf", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "9999999", | |||||
"The maximum confirmations to filter"}, | |||||
{ | |||||
"addresses", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of bitcoin addresses to filter", | |||||
{ | { | ||||
{"address", RPCArg::Type::STR, true}, | {"address", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", "bitcoin address"}, | |||||
}, | }, | ||||
true}, | }, | ||||
{"include_unsafe", RPCArg::Type::BOOL, true}, | {"include_unsafe", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "true", | |||||
"Include outputs that are not safe to spend\n" | |||||
" See description of \"safe\" attribute " | |||||
"below."}, | |||||
{"query_options", | {"query_options", | ||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"JSON with query options", | |||||
{ | { | ||||
{"minimumAmount", RPCArg::Type::AMOUNT, true}, | {"minimumAmount", RPCArg::Type::AMOUNT, /* opt */ true, | ||||
{"maximumAmount", RPCArg::Type::AMOUNT, true}, | /* default_val */ "0", | ||||
{"maximumCount", RPCArg::Type::NUM, true}, | "Minimum value of each UTXO in " + CURRENCY_UNIT + | ||||
{"minimumSumAmount", RPCArg::Type::AMOUNT, true}, | ""}, | ||||
{"maximumAmount", RPCArg::Type::AMOUNT, /* opt */ true, | |||||
/* default_val */ "unlimited", | |||||
"Maximum value of each UTXO in " + CURRENCY_UNIT + | |||||
""}, | |||||
{"maximumCount", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "unlimited", | |||||
"Maximum number of UTXOs"}, | |||||
{"minimumSumAmount", RPCArg::Type::AMOUNT, | |||||
/* opt */ true, /* default_val */ "unlimited", | |||||
"Minimum sum value of all UTXOs in " + CURRENCY_UNIT + | |||||
""}, | |||||
}, | }, | ||||
true, | |||||
"query_options"}, | "query_options"}, | ||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. minconf (numeric, optional, default=1) The minimum " | |||||
"confirmations to filter\n" | |||||
"2. maxconf (numeric, optional, default=9999999) The " | |||||
"maximum confirmations to filter\n" | |||||
"3. \"addresses\" (string, optional) A json array of bitcoin " | |||||
"addresses to filter\n" | |||||
" [\n" | |||||
" \"address\" (string) bitcoin address\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"4. include_unsafe (bool, optional, default=true) Include outputs " | |||||
"that are not safe to spend\n" | |||||
" See description of \"safe\" attribute below.\n" | |||||
"5. query_options (json, optional) JSON with query options\n" | |||||
" {\n" | |||||
" \"minimumAmount\" (numeric or string, default=0) Minimum " | |||||
"value of each UTXO in " + | |||||
CURRENCY_UNIT + | |||||
"\n" | |||||
" \"maximumAmount\" (numeric or string, default=unlimited) " | |||||
"Maximum value of each UTXO in " + | |||||
CURRENCY_UNIT + | |||||
"\n" | |||||
" \"maximumCount\" (numeric or string, default=unlimited) " | |||||
"Maximum number of UTXOs\n" | |||||
" \"minimumSumAmount\" (numeric or string, default=unlimited) " | |||||
"Minimum sum value of all UTXOs in " + | |||||
CURRENCY_UNIT + | |||||
"\n" | |||||
" }\n" | |||||
"\nResult\n" | "\nResult\n" | ||||
"[ (array of json object)\n" | "[ (array of json object)\n" | ||||
" {\n" | " {\n" | ||||
" \"txid\" : \"txid\", (string) the transaction id \n" | " \"txid\" : \"txid\", (string) the transaction id \n" | ||||
" \"vout\" : n, (numeric) the vout value\n" | " \"vout\" : n, (numeric) the vout value\n" | ||||
" \"address\" : \"address\", (string) the bitcoin address\n" | " \"address\" : \"address\", (string) the bitcoin address\n" | ||||
" \"label\" : \"label\", (string) The associated label, " | " \"label\" : \"label\", (string) The associated label, " | ||||
"or \"\" for the default label\n" | "or \"\" for the default label\n" | ||||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"P2SH scripts must be\n" | "P2SH 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 " | "You can see whether this is the case by checking the " | ||||
"\"solvable\" field in the listunspent output.\n" | "\"solvable\" 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", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", | |||||
"The hex string of the raw transaction"}, | |||||
{"options", | {"options", | ||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"for backward compatibility: passing in a true instead of " | |||||
"an object will result in {\"includeWatching\":true}", | |||||
{ | |||||
{"changeAddress", RPCArg::Type::STR, /* opt */ true, | |||||
/* default_val */ "pool address", | |||||
"The bitcoin address to receive the change"}, | |||||
{"changePosition", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "", | |||||
"The index of the change output"}, | |||||
{"includeWatching", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Also select inputs which are watch only"}, | |||||
{"lockUnspents", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Lock selected unspent outputs"}, | |||||
{"feeRate", RPCArg::Type::AMOUNT, /* opt */ true, | |||||
/* default_val */ | |||||
"not set: makes wallet determine the fee", | |||||
"Set a specific fee rate in " + CURRENCY_UNIT + | |||||
"/kB"}, | |||||
{ | { | ||||
{"changeAddress", RPCArg::Type::STR, true}, | "subtractFeeFromOutputs", | ||||
{"changePosition", RPCArg::Type::NUM, true}, | |||||
{"includeWatching", RPCArg::Type::BOOL, true}, | |||||
{"lockUnspents", RPCArg::Type::BOOL, true}, | |||||
{"feeRate", RPCArg::Type::AMOUNT, true}, | |||||
{"subtractFeeFromOutputs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of integers.\n" | |||||
" The fee will be " | |||||
"equally deducted from the amount of each " | |||||
"specified output.\n" | |||||
" The outputs are " | |||||
"specified by their zero-based index, before any " | |||||
"change output is added.\n" | |||||
" Those recipients " | |||||
"will receive less bitcoins than you enter in " | |||||
"their corresponding amount field.\n" | |||||
" If no outputs are " | |||||
"specified here, the sender pays the fee.", | |||||
{ | { | ||||
{"vout_index", RPCArg::Type::NUM, true}, | {"vout_index", RPCArg::Type::NUM, | ||||
/* opt */ true, /* default_val */ "", | |||||
"The zero-based output index, before a " | |||||
"change output is added."}, | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
true, | |||||
"options"}, | "options"}, | ||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. \"hexstring\" (string, required) The hex string of " | |||||
"the raw transaction\n" | |||||
"2. options (object, optional)\n" | |||||
" {\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" | |||||
" \"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" | |||||
" \"subtractFeeFromOutputs\" (array, optional) A json array of " | |||||
"integers.\n" | |||||
" The fee will be equally deducted " | |||||
"from the amount of each specified output.\n" | |||||
" The outputs are specified by their " | |||||
"zero-based index, before any change output is added.\n" | |||||
" Those recipients will receive less " | |||||
"bitcoins than you enter in their corresponding amount field.\n" | |||||
" If no outputs are specified here, " | |||||
"the sender pays the fee.\n" | |||||
" [vout_index,...]\n" | |||||
" }\n" | |||||
" for backward compatibility: passing in a " | |||||
"true instead of an object will result in " | |||||
"{\"includeWatching\":true}\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"hex\": \"value\", (string) The resulting raw " | " \"hex\": \"value\", (string) The resulting raw " | ||||
"transaction (hex-encoded string)\n" | "transaction (hex-encoded string)\n" | ||||
" \"fee\": n, (numeric) Fee in " + | " \"fee\": n, (numeric) Fee in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" the resulting transaction pays\n" | " the resulting transaction pays\n" | ||||
" \"changepos\": n (numeric) The position of the added " | " \"changepos\": n (numeric) The position of the added " | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"signrawtransactionwithwallet", | "signrawtransactionwithwallet", | ||||
"\nSign inputs for raw transaction (serialized, hex-encoded).\n" | "\nSign inputs for raw transaction (serialized, hex-encoded).\n" | ||||
"The second optional argument (may be null) is an array of " | "The second optional argument (may be null) is an array of " | ||||
"previous transaction outputs that\n" | "previous transaction outputs that\n" | ||||
"this transaction depends on but may not yet be in the block " | "this transaction depends on but may not yet be in the block " | ||||
"chain.\n", | "chain.\n" + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR, /* opt */ false, | ||||
{"prevtxs", | /* default_val */ "", "The transaction hex string"}, | ||||
{ | |||||
"prevtxs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of previous dependent transaction " | |||||
"outputs", | |||||
{ | { | ||||
{"", | { | ||||
"", | |||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | {"txid", RPCArg::Type::STR_HEX, | ||||
{"vout", RPCArg::Type::NUM, false}, | /* opt */ false, /* default_val */ "", | ||||
{"scriptPubKey", RPCArg::Type::STR_HEX, false}, | "The transaction id"}, | ||||
{"redeemScript", RPCArg::Type::STR_HEX, false}, | {"vout", RPCArg::Type::NUM, /* opt */ false, | ||||
{"amount", RPCArg::Type::AMOUNT, false}, | /* default_val */ "", "The output number"}, | ||||
{"scriptPubKey", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"script key"}, | |||||
{"redeemScript", RPCArg::Type::STR_HEX, | |||||
/* opt */ true, /* default_val */ "", | |||||
"(required for P2SH"}, | |||||
{"amount", RPCArg::Type::AMOUNT, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The amount spent"}, | |||||
}, | }, | ||||
false}, | |||||
}, | }, | ||||
true}, | }, | ||||
{"sighashtype", RPCArg::Type::STR, true}, | }, | ||||
}} | {"sighashtype", RPCArg::Type::STR, /* opt */ true, | ||||
.ToString() + | /* default_val */ "ALL|FORKID", | ||||
HelpRequiringPassphrase(pwallet) + | "The signature hash type. Must be one of\n" | ||||
"\n" | |||||
"\nArguments:\n" | |||||
"1. \"hexstring\" (string, required) The " | |||||
"transaction hex string\n" | |||||
"2. \"prevtxs\" (string, optional) An json " | |||||
"array of previous dependent transaction outputs\n" | |||||
" [ (json array of json objects, " | |||||
"or 'null' if none provided)\n" | |||||
" {\n" | |||||
" \"txid\":\"id\", (string, required) The " | |||||
"transaction id\n" | |||||
" \"vout\":n, (numeric, required) The " | |||||
"output number\n" | |||||
" \"scriptPubKey\": \"hex\", (string, required) script " | |||||
"key\n" | |||||
" \"redeemScript\": \"hex\", (string, required for " | |||||
"P2SH) redeem script\n" | |||||
" \"amount\": value (numeric, required) The " | |||||
"amount spent\n" | |||||
" }\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"3. \"sighashtype\" (string, optional, " | |||||
"default=ALL|FORKID) The signature hash type. Must be one of\n" | |||||
" \"ALL|FORKID\"\n" | " \"ALL|FORKID\"\n" | ||||
" \"NONE|FORKID\"\n" | " \"NONE|FORKID\"\n" | ||||
" \"SINGLE|FORKID\"\n" | " \"SINGLE|FORKID\"\n" | ||||
" \"ALL|FORKID|ANYONECANPAY\"\n" | " \"ALL|FORKID|ANYONECANPAY\"\n" | ||||
" \"NONE|FORKID|ANYONECANPAY\"\n" | " \"NONE|FORKID|ANYONECANPAY\"\n" | ||||
" \"SINGLE|FORKID|ANYONECANPAY\"\n" | " \"SINGLE|FORKID|ANYONECANPAY\""}, | ||||
}} | |||||
.ToStringWithArgs() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"hex\" : \"value\", (string) The hex-encoded " | " \"hex\" : \"value\", (string) The hex-encoded " | ||||
"raw transaction with signature(s)\n" | "raw transaction with signature(s)\n" | ||||
" \"complete\" : true|false, (boolean) If the " | " \"complete\" : true|false, (boolean) If the " | ||||
"transaction has a complete set of signatures\n" | "transaction has a complete set of signatures\n" | ||||
" \"errors\" : [ (json array of objects) " | " \"errors\" : [ (json array of objects) " | ||||
"Script verification errors (if there are any)\n" | "Script verification errors (if there are any)\n" | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | UniValue generate(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"generate", | RPCHelpMan{"generate", | ||||
"\nMine up to nblocks blocks immediately (before the " | "\nMine up to nblocks blocks immediately (before the " | ||||
"RPC call returns) to an address in the wallet.\n", | "RPC call returns) to an address in the wallet.\n", | ||||
{ | { | ||||
{"nblocks", RPCArg::Type::NUM, false}, | {"nblocks", RPCArg::Type::NUM, /* opt */ false, | ||||
{"maxtries", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
"How many blocks are generated immediately."}, | |||||
{"maxtries", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "", | |||||
"How many iterations to try (default = 1000000)."}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. nblocks (numeric, required) How many blocks are generated " | |||||
"immediately.\n" | |||||
"2. maxtries (numeric, optional) How many iterations to try " | |||||
"(default = 1000000).\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[ blockhashes ] (array) hashes of blocks generated\n" | "[ blockhashes ] (array) hashes of blocks generated\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nGenerate 11 blocks\n" + | "\nGenerate 11 blocks\n" + | ||||
HelpExampleCli("generate", "11")); | HelpExampleCli("generate", "11")); | ||||
} | } | ||||
int num_generate = request.params[0].get_int(); | int num_generate = request.params[0].get_int(); | ||||
Show All 30 Lines | UniValue rescanblockchain(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
if (request.fHelp || request.params.size() > 2) { | if (request.fHelp || request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"rescanblockchain", | RPCHelpMan{"rescanblockchain", | ||||
"\nRescan the local blockchain for wallet related " | "\nRescan the local blockchain for wallet related " | ||||
"transactions.\n", | "transactions.\n", | ||||
{ | { | ||||
{"start_height", RPCArg::Type::NUM, true}, | {"start_height", RPCArg::Type::NUM, /* opt */ true, | ||||
{"stop_height", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
"block height where the rescan should start"}, | |||||
{"stop_height", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "", | |||||
"the last block height that should be scanned"}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. \"start_height\" (numeric, optional) block height where the " | |||||
"rescan should start\n" | |||||
"2. \"stop_height\" (numeric, optional) the last block height " | |||||
"that should be scanned\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"start_height\" (numeric) The block height where the " | " \"start_height\" (numeric) The block height where the " | ||||
"rescan has started. If omitted, rescan started from the genesis " | "rescan has started. If omitted, rescan started from the genesis " | ||||
"block.\n" | "block.\n" | ||||
" \"stop_height\" (numeric) The height of the last rescanned " | " \"stop_height\" (numeric) The height of the last rescanned " | ||||
"block. If omitted, rescan stopped at the chain tip.\n" | "block. If omitted, rescan stopped at the chain tip.\n" | ||||
"}\n" | "}\n" | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | UniValue getaddressinfo(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"getaddressinfo", | RPCHelpMan{"getaddressinfo", | ||||
"\nReturn information about the given bitcoin address. " | "\nReturn information about the given bitcoin address. " | ||||
"Some information requires the address\n" | "Some information requires the address\n" | ||||
"to be in the wallet.\n", | "to be in the wallet.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | |||||
"The bitcoin address to get the information of."}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. \"address\" (string, required) The bitcoin " | |||||
"address to get the information of.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"address\" : \"address\", (string) The bitcoin address " | " \"address\" : \"address\", (string) The bitcoin address " | ||||
"validated\n" | "validated\n" | ||||
" \"scriptPubKey\" : \"hex\", (string) The hex-encoded " | " \"scriptPubKey\" : \"hex\", (string) The hex-encoded " | ||||
"scriptPubKey generated by the address\n" | "scriptPubKey generated by the address\n" | ||||
" \"ismine\" : true|false, (boolean) If the address is " | " \"ismine\" : true|false, (boolean) If the address is " | ||||
"yours or not\n" | "yours or not\n" | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | UniValue getaddressesbylabel(const Config &config, | ||||
} | } | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"getaddressesbylabel", | RPCHelpMan{"getaddressesbylabel", | ||||
"\nReturns the list of addresses assigned the specified " | "\nReturns the list of addresses assigned the specified " | ||||
"label.\n", | "label.\n", | ||||
{ | { | ||||
{"label", RPCArg::Type::STR, false}, | {"label", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The label."}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. \"label\" (string, required) The label.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{ (json object with addresses as keys)\n" | "{ (json object with addresses as keys)\n" | ||||
" \"address\": { (json object with information about address)\n" | " \"address\": { (json object with information about address)\n" | ||||
" \"purpose\": \"string\" (string) Purpose of address " | " \"purpose\": \"string\" (string) Purpose of address " | ||||
"(\"send\" for sending address, \"receive\" for receiving " | "(\"send\" for sending address, \"receive\" for receiving " | ||||
"address)\n" | "address)\n" | ||||
" },...\n" | " },...\n" | ||||
"}\n" | "}\n" | ||||
Show All 32 Lines | UniValue listlabels(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
if (request.fHelp || request.params.size() > 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"listlabels", | RPCHelpMan{"listlabels", | ||||
"\nReturns the list of all labels, or labels that are " | "\nReturns the list of all labels, or labels that are " | ||||
"assigned to addresses with a specific purpose.\n", | "assigned to addresses with a specific purpose.\n", | ||||
{ | { | ||||
{"purpose", RPCArg::Type::STR, true}, | {"purpose", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | |||||
"Address purpose to list labels for " | |||||
"('send','receive'). An empty string is the same " | |||||
"as not providing this argument."}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. \"purpose\" (string, optional) Address purpose to list " | |||||
"labels for ('send','receive'). An empty string is the same as not " | |||||
"providing this argument.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[ (json array of string)\n" | "[ (json array of string)\n" | ||||
" \"label\", (string) Label name\n" | " \"label\", (string) Label name\n" | ||||
" ...\n" | " ...\n" | ||||
"]\n" | "]\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nList all labels\n" + | "\nList all labels\n" + | ||||
HelpExampleCli("listlabels", "") + | HelpExampleCli("listlabels", "") + | ||||
Show All 33 Lines | static UniValue sethdseed(const Config &config, const JSONRPCRequest &request) { | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() > 2) { | if (request.fHelp || request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"sethdseed", | RPCHelpMan{ | ||||
"sethdseed", | |||||
"\nSet or generate a new HD wallet seed. Non-HD wallets " | "\nSet or generate a new HD wallet seed. Non-HD wallets " | ||||
"will not be upgraded to being a HD wallet. Wallets " | "will not be upgraded to being a HD wallet. Wallets " | ||||
"that are already\n" | "that are already\n" | ||||
"HD will have a new HD seed set so that new keys added " | "HD will have a new HD seed set so that new keys added " | ||||
"to the keypool will be derived from this new seed.\n" | "to the keypool will be derived from this new seed.\n" | ||||
"\nNote that you will need to MAKE A NEW BACKUP of your " | "\nNote that you will need to MAKE A NEW BACKUP of your " | ||||
"wallet after setting the HD wallet seed.\n", | "wallet after setting the HD wallet seed.\n" + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"newkeypool", RPCArg::Type::BOOL, true}, | {"newkeypool", RPCArg::Type::BOOL, /* opt */ true, | ||||
{"seed", RPCArg::Type::STR, true}, | /* default_val */ "true", | ||||
}} | |||||
.ToString() + | |||||
HelpRequiringPassphrase(pwallet) + | |||||
"\nArguments:\n" | |||||
"1. \"newkeypool\" (boolean, optional, default=true) " | |||||
"Whether to flush old unused addresses, including change " | "Whether to flush old unused addresses, including change " | ||||
"addresses, from the keypool and regenerate it.\n" | "addresses, from the keypool and regenerate it.\n" | ||||
" If true, the next address from " | " If true, the next address " | ||||
"getnewaddress and change address from getrawchangeaddress will be " | "from getnewaddress and change address from " | ||||
"from this new seed.\n" | "getrawchangeaddress will be from this new seed.\n" | ||||
" If false, addresses (including " | " If false, addresses " | ||||
"change addresses if the wallet already had HD Chain Split " | "(including change addresses if the wallet already had HD " | ||||
"enabled) from the existing\n" | "Chain Split enabled) from the existing\n" | ||||
" keypool will be used until it has " | " keypool will be used until " | ||||
"been depleted.\n" | "it has been depleted."}, | ||||
"2. \"seed\" (string, optional) The WIF private key " | {"seed", RPCArg::Type::STR, /* opt */ true, | ||||
"to use as the new HD seed; if not provided a random seed will be " | /* default_val */ "", | ||||
"used.\n" | "The WIF private key to use as the new HD seed; if not " | ||||
" The seed value can be retrieved " | "provided a random seed will be used.\n" | ||||
"using the dumpwallet command. It is the private key marked " | " The seed value can be " | ||||
"hdseed=1\n" | "retrieved using the dumpwallet command. It is the " | ||||
"\nExamples:\n" + | "private key marked hdseed=1"}, | ||||
HelpExampleCli("sethdseed", "") + | }} | ||||
.ToStringWithArgs() + | |||||
"\nExamples:\n" + HelpExampleCli("sethdseed", "") + | |||||
HelpExampleCli("sethdseed", "false") + | HelpExampleCli("sethdseed", "false") + | ||||
HelpExampleCli("sethdseed", "true \"wifkey\"") + | HelpExampleCli("sethdseed", "true \"wifkey\"") + | ||||
HelpExampleRpc("sethdseed", "true, \"wifkey\"")); | HelpExampleRpc("sethdseed", "true, \"wifkey\"")); | ||||
} | } | ||||
if (IsInitialBlockDownload()) { | if (IsInitialBlockDownload()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_CLIENT_IN_INITIAL_DOWNLOAD, | RPC_CLIENT_IN_INITIAL_DOWNLOAD, | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | static UniValue walletprocesspsbt(const Config &config, | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 4) { | request.params.size() > 4) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"walletprocesspsbt", | RPCHelpMan{ | ||||
"walletprocesspsbt", | |||||
"\nUpdate a PSBT with input information from our wallet " | "\nUpdate a PSBT with input information from our wallet " | ||||
"and then sign inputs that we can sign for.\n", | "and then sign inputs that we can sign for." + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"psbt", RPCArg::Type::STR, false}, | {"psbt", RPCArg::Type::STR, /* opt */ false, | ||||
{"sign", RPCArg::Type::BOOL, true}, | /* default_val */ "", "The transaction base64 string"}, | ||||
{"sighashtype", RPCArg::Type::STR, true}, | {"sign", RPCArg::Type::BOOL, /* opt */ true, | ||||
{"bip32derivs", RPCArg::Type::BOOL, true}, | /* default_val */ "true", | ||||
}} | "Also sign the transaction when updating"}, | ||||
.ToString() + | {"sighashtype", RPCArg::Type::STR, /* opt */ true, | ||||
HelpRequiringPassphrase(pwallet) + | /* default_val */ "ALL|FORKID", | ||||
"\n" | "The signature hash type to sign with if not specified by " | ||||
"the PSBT. Must be one of\n" | |||||
"\nArguments:\n" | |||||
"1. \"psbt\" (string, required) The " | |||||
"transaction base64 string\n" | |||||
"2. sign (boolean, optional, " | |||||
"default=true) Also sign the transaction when updating\n" | |||||
"3. \"sighashtype\" (string, optional, " | |||||
"default=ALL|FORKID) The signature hash type to sign with if not " | |||||
"specified by the PSBT. Must be one of\n" | |||||
" \"ALL|FORKID\"\n" | " \"ALL|FORKID\"\n" | ||||
" \"NONE|FORKID\"\n" | " \"NONE|FORKID\"\n" | ||||
" \"SINGLE|FORKID\"\n" | " \"SINGLE|FORKID\"\n" | ||||
" \"ALL|FORKID|ANYONECANPAY\"\n" | " \"ALL|FORKID|ANYONECANPAY\"\n" | ||||
" \"NONE|FORKID|ANYONECANPAY\"\n" | " \"NONE|FORKID|ANYONECANPAY\"\n" | ||||
" \"SINGLE|FORKID|ANYONECANPAY\"\n" | " \"SINGLE|FORKID|ANYONECANPAY\""}, | ||||
"4. bip32derivs (boolean, optional, " | {"bip32derivs", RPCArg::Type::BOOL, /* opt */ true, | ||||
"default=false) If true, includes the BIP 32 derivation paths for " | /* default_val */ "false", | ||||
"public keys if we know them\n" | "If true, includes the BIP 32 derivation paths for public " | ||||
"keys if we know them"}, | |||||
}} | |||||
.ToStringWithArgs() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"psbt\" : \"value\", (string) The base64-encoded " | " \"psbt\" : \"value\", (string) The base64-encoded " | ||||
"partially signed transaction\n" | "partially signed transaction\n" | ||||
" \"complete\" : true|false, (boolean) If the transaction has a " | " \"complete\" : true|false, (boolean) If the transaction has a " | ||||
"complete set of signatures\n" | "complete set of signatures\n" | ||||
" ]\n" | " ]\n" | ||||
"}\n" | "}\n" | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | static UniValue walletcreatefundedpsbt(const Config &config, | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
request.params.size() > 5) { | request.params.size() > 5) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"walletcreatefundedpsbt", | RPCHelpMan{ | ||||
"walletcreatefundedpsbt", | |||||
"\nCreates and funds a transaction in the Partially " | "\nCreates and funds a transaction in the Partially " | ||||
"Signed Transaction format. Inputs will be added if " | "Signed Transaction format. Inputs will be added if " | ||||
"supplied inputs are not enough\n" | "supplied inputs are not enough\n" | ||||
"Implements the Creator and Updater roles.\n", | "Implements the Creator and Updater roles.\n", | ||||
{ | { | ||||
{"inputs", | { | ||||
"inputs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json array of json objects", | |||||
{ | |||||
{ | { | ||||
{"", | "", | ||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | {"txid", RPCArg::Type::STR_HEX, | ||||
{"vout", RPCArg::Type::NUM, false}, | /* opt */ false, /* default_val */ "", | ||||
{"sequence", RPCArg::Type::NUM, true}, | "The transaction id"}, | ||||
{"vout", RPCArg::Type::NUM, /* opt */ false, | |||||
/* default_val */ "", "The output number"}, | |||||
{"sequence", RPCArg::Type::NUM, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The sequence number"}, | |||||
}, | |||||
}, | }, | ||||
false}, | |||||
}, | }, | ||||
false}, | }, | ||||
{"outputs", | { | ||||
"outputs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"a json array with outputs (key-value pairs).\n" | |||||
"For compatibility reasons, a dictionary, which holds " | |||||
"the key-value pairs directly, is also\n" | |||||
" accepted as second " | |||||
"parameter.", | |||||
{ | |||||
{ | { | ||||
{"", | "", | ||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | { | ||||
{"address", RPCArg::Type::AMOUNT, true}, | {"address", RPCArg::Type::AMOUNT, | ||||
/* opt */ true, /* default_val */ "", | |||||
"A key-value pair. The key (string) is " | |||||
"the bitcoin address, the value (float or " | |||||
"string) is the amount in " + | |||||
CURRENCY_UNIT + ""}, | |||||
}, | |||||
}, | }, | ||||
true}, | { | ||||
{"", | "", | ||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | { | ||||
{"data", RPCArg::Type::STR_HEX, true}, | {"data", RPCArg::Type::STR_HEX, | ||||
/* opt */ true, /* default_val */ "", | |||||
"A key-value pair. The key must be " | |||||
"\"data\", the value is hex-encoded data"}, | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
false}, | }, | ||||
{"locktime", RPCArg::Type::NUM, true}, | {"locktime", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "0", | |||||
"Raw locktime. Non-0 value also locktime-activates " | |||||
"inputs\n" | |||||
" Allows this transaction to " | |||||
"be replaced by a transaction with higher fees. If " | |||||
"provided, it is an error if explicit sequence numbers " | |||||
"are incompatible."}, | |||||
{"options", | {"options", | ||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"changeAddress", RPCArg::Type::STR_HEX, | |||||
/* opt */ true, /* default_val */ "pool address", | |||||
"The bitcoin address to receive the change"}, | |||||
{"changePosition", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "random", | |||||
"The index of the change output"}, | |||||
{"includeWatching", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Also select inputs which are watch only"}, | |||||
{"lockUnspents", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Lock selected unspent outputs"}, | |||||
{"feeRate", RPCArg::Type::AMOUNT, /* opt */ true, | |||||
/* default_val */ | |||||
"not set: makes wallet determine the fee", | |||||
"Set a specific fee rate in " + CURRENCY_UNIT + | |||||
"/kB"}, | |||||
{ | { | ||||
{"changeAddress", RPCArg::Type::STR, true}, | "subtractFeeFromOutputs", | ||||
{"changePosition", RPCArg::Type::NUM, true}, | |||||
{"includeWatching", RPCArg::Type::BOOL, true}, | |||||
{"lockUnspents", RPCArg::Type::BOOL, true}, | |||||
{"feeRate", RPCArg::Type::AMOUNT, true}, | |||||
{"subtractFeeFromOutputs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of integers.\n" | |||||
" The fee will be " | |||||
"equally deducted from the amount of each " | |||||
"specified output.\n" | |||||
" The outputs are " | |||||
"specified by their zero-based index, before any " | |||||
"change output is added.\n" | |||||
" Those recipients " | |||||
"will receive less bitcoins than you enter in " | |||||
"their corresponding amount field.\n" | |||||
" If no outputs are " | |||||
"specified here, the sender pays the fee.", | |||||
{ | { | ||||
{"int", RPCArg::Type::NUM, true}, | {"vout_index", RPCArg::Type::NUM, | ||||
/* opt */ true, /* default_val */ "", ""}, | |||||
}, | }, | ||||
true, | |||||
"options"}, | |||||
}, | }, | ||||
true}, | }, | ||||
{"bip32derivs", RPCArg::Type::BOOL, true}, | "options"}, | ||||
{"bip32derivs", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"If true, includes the BIP 32 derivation paths for public " | |||||
"keys if we know them"}, | |||||
}} | }} | ||||
.ToString() + | .ToStringWithArgs() + | ||||
"\nArguments:\n" | |||||
"1. \"inputs\" (array, required) A json array of " | |||||
"json objects\n" | |||||
" [\n" | |||||
" {\n" | |||||
" \"txid\":\"id\", (string, required) The transaction " | |||||
"id\n" | |||||
" \"vout\":n, (numeric, required) The output " | |||||
"number\n" | |||||
" \"sequence\":n (numeric, optional) The sequence " | |||||
"number\n" | |||||
" } \n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"2. \"outputs\" (array, required) a json array with " | |||||
"outputs (key-value pairs)\n" | |||||
" [\n" | |||||
" {\n" | |||||
" \"address\": x.xxx, (obj, optional) A key-value pair. " | |||||
"The key (string) is the bitcoin address, the value (float or " | |||||
"string) is the amount in " + | |||||
CURRENCY_UNIT + | |||||
"\n" | |||||
" },\n" | |||||
" {\n" | |||||
" \"data\": \"hex\" (obj, optional) A key-value pair. " | |||||
"The key must be \"data\", the value is hex-encoded data\n" | |||||
" }\n" | |||||
" ,... More key-value pairs of the above " | |||||
"form. For compatibility reasons, a dictionary, which holds the " | |||||
"key-value pairs directly, is also\n" | |||||
" accepted as second parameter.\n" | |||||
" ]\n" | |||||
"3. locktime (numeric, optional, default=0) Raw " | |||||
"locktime. Non-0 value also locktime-activates inputs\n" | |||||
"4. options (object, optional)\n" | |||||
" {\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" | |||||
" \"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" | |||||
" \"subtractFeeFromOutputs\" (array, optional) A json array of " | |||||
"integers.\n" | |||||
" The fee will be equally deducted " | |||||
"from the amount of each specified output.\n" | |||||
" The outputs are specified by their " | |||||
"zero-based index, before any change output is added.\n" | |||||
" Those recipients will receive less " | |||||
"bitcoins than you enter in their corresponding amount field.\n" | |||||
" If no outputs are specified here, " | |||||
"the sender pays the fee.\n" | |||||
" [vout_index,...]\n" | |||||
" }\n" | |||||
"5. bip32derivs (boolean, optional, " | |||||
"default=false) If true, includes the BIP 32 derivation paths for " | |||||
"public keys if we know them\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"psbt\": \"value\", (string) The resulting raw " | " \"psbt\": \"value\", (string) The resulting raw " | ||||
"transaction (base64-encoded string)\n" | "transaction (base64-encoded string)\n" | ||||
" \"fee\": n, (numeric) Fee in " + | " \"fee\": n, (numeric) Fee in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" the resulting transaction pays\n" | " the resulting transaction pays\n" | ||||
" \"changepos\": n (numeric) The position of the added " | " \"changepos\": n (numeric) The position of the added " | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |