Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 1,178 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
{"key", RPCArg::Type::STR, /* opt */ false, | {"key", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"bitcoin address or hex-encoded public key"}, | "bitcoin address or hex-encoded public key"}, | ||||
}, | }, | ||||
}, | }, | ||||
{"label", RPCArg::Type::STR, /* opt */ true, | {"label", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"A label to assign the addresses to."}, | "A label to assign the addresses to."}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{"{\n" | ||||
"\nResult:\n" | " \"address\":\"multisigaddress\", (string) The " | ||||
"{\n" | "value of the new multisig address.\n" | ||||
" \"address\":\"multisigaddress\", (string) The value of the " | " \"redeemScript\":\"script\" (string) The " | ||||
"new multisig address.\n" | "string value of the hex-encoded redemption script.\n" | ||||
" \"redeemScript\":\"script\" (string) The string value " | "}\n"}, | ||||
"of the hex-encoded redemption script.\n" | RPCExamples{ | ||||
"}\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 a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("addmultisigaddress", | HelpExampleRpc( | ||||
"addmultisigaddress", | |||||
"2, " | "2, " | ||||
"\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\"," | "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\"," | ||||
"\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\""); | "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")}, | ||||
} | |||||
.ToStringWithResultsAndExamples(); | |||||
throw std::runtime_error(msg); | throw std::runtime_error(msg); | ||||
} | } | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
std::string label; | std::string label; | ||||
if (!request.params[2].isNull()) { | if (!request.params[2].isNull()) { | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | static UniValue listreceivedbyaddress(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() > 4) { | if (request.fHelp || request.params.size() > 4) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"listreceivedbyaddress", | "listreceivedbyaddress", | ||||
"\nList balances by receiving address.\n", | "\nList balances by receiving address.\n", | ||||
{ | { | ||||
{"minconf", RPCArg::Type::NUM, /* opt */ true, | {"minconf", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "1", | /* default_val */ "1", | ||||
"The minimum number of confirmations before payments are " | "The minimum number of confirmations before payments are " | ||||
"included."}, | "included."}, | ||||
{"include_empty", RPCArg::Type::BOOL, /* opt */ true, | {"include_empty", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "false", | /* default_val */ "false", | ||||
"Whether to include addresses that haven't received any " | "Whether to include addresses that haven't received any " | ||||
"payments."}, | "payments."}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | {"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "false", | /* default_val */ "false", | ||||
"Whether to include watch-only addresses (see " | "Whether to include watch-only addresses (see " | ||||
"'importaddress')."}, | "'importaddress')."}, | ||||
{"address_filter", RPCArg::Type::STR, /* opt */ true, | {"address_filter", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"If present, only return information on this address."}, | "If present, only return information on this address."}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{ | ||||
"\nResult:\n" | |||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"involvesWatchonly\" : true, (bool) Only returned if " | " \"involvesWatchonly\" : true, (bool) Only returned " | ||||
"imported addresses were involved in transaction\n" | "if imported addresses were involved in transaction\n" | ||||
" \"address\" : \"receivingaddress\", (string) The receiving " | " \"address\" : \"receivingaddress\", (string) The " | ||||
"address\n" | "receiving address\n" | ||||
" \"amount\" : x.xxx, (numeric) The total " | " \"amount\" : x.xxx, (numeric) The total " | ||||
"amount in " + | "amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" received by the address\n" | " received by the address\n" | ||||
" \"confirmations\" : n, (numeric) The number of " | " \"confirmations\" : n, (numeric) The number " | ||||
"confirmations of the most recent transaction included\n" | "of confirmations of the most recent transaction included\n" | ||||
" \"label\" : \"label\", (string) The label of " | " \"label\" : \"label\", (string) The label " | ||||
"the receiving address. The default label is \"\".\n" | "of the receiving address. The default label is \"\".\n" | ||||
" \"txids\": [\n" | " \"txids\": [\n" | ||||
" \"txid\", (string) The ids of " | " \"txid\", (string) The ids of " | ||||
"transactions received with the address \n" | "transactions received with the address \n" | ||||
" ...\n" | " ...\n" | ||||
" ]\n" | " ]\n" | ||||
" }\n" | " }\n" | ||||
" ,...\n" | " ,...\n" | ||||
"]\n" | "]\n"}, | ||||
RPCExamples{ | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("listreceivedbyaddress", "") + | HelpExampleCli("listreceivedbyaddress", "") + | ||||
HelpExampleCli("listreceivedbyaddress", "6 true") + | HelpExampleCli("listreceivedbyaddress", "6 true") + | ||||
HelpExampleRpc("listreceivedbyaddress", "6, true, true") + | HelpExampleRpc("listreceivedbyaddress", "6, true, true") + | ||||
HelpExampleRpc( | HelpExampleRpc( | ||||
"listreceivedbyaddress", | "listreceivedbyaddress", | ||||
"6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")); | "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
return ListReceived(config, *locked_chain, pwallet, request.params, false); | return ListReceived(config, *locked_chain, pwallet, request.params, false); | ||||
} | } | ||||
static UniValue listreceivedbylabel(const Config &config, | static UniValue listreceivedbylabel(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() > 3) { | if (request.fHelp || request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{"listreceivedbylabel", | "listreceivedbylabel", | ||||
"\nList received transactions by label.\n", | "\nList received transactions by label.\n", | ||||
{ | { | ||||
{"minconf", RPCArg::Type::NUM, /* opt */ true, | {"minconf", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "1", | /* default_val */ "1", | ||||
"The minimum number of confirmations before " | "The minimum number of confirmations before " | ||||
"payments are included."}, | "payments are included."}, | ||||
{"include_empty", RPCArg::Type::BOOL, /* opt */ true, | {"include_empty", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "false", | /* default_val */ "false", | ||||
"Whether to include labels that haven't received " | "Whether to include labels that haven't received " | ||||
"any payments."}, | "any payments."}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, | {"include_watchonly", RPCArg::Type::BOOL, | ||||
/* opt */ true, /* default_val */ "false", | /* opt */ true, /* default_val */ "false", | ||||
"Whether to include watch-only addresses (see " | "Whether to include watch-only addresses (see " | ||||
"'importaddress')."}, | "'importaddress')."}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{ | ||||
"\nResult:\n" | |||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"involvesWatchonly\" : true, (bool) Only returned if " | " \"involvesWatchonly\" : true, (bool) Only returned if " | ||||
"imported addresses were involved in transaction\n" | "imported addresses were involved in transaction\n" | ||||
" \"amount\" : x.xxx, (numeric) The total amount " | " \"amount\" : x.xxx, (numeric) The total " | ||||
"received by addresses with this label\n" | "amount received by addresses with this label\n" | ||||
" \"confirmations\" : n, (numeric) The number of " | " \"confirmations\" : n, (numeric) The number of " | ||||
"confirmations of the most recent transaction included\n" | "confirmations of the most recent transaction included\n" | ||||
" \"label\" : \"label\" (string) The label of the " | " \"label\" : \"label\" (string) The label of the " | ||||
"receiving address. The default label is \"\".\n" | "receiving address. The default label is \"\".\n" | ||||
" }\n" | " }\n" | ||||
" ,...\n" | " ,...\n" | ||||
"]\n" | "]\n"}, | ||||
RPCExamples{HelpExampleCli("listreceivedbylabel", "") + | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("listreceivedbylabel", "") + | |||||
HelpExampleCli("listreceivedbylabel", "6 true") + | HelpExampleCli("listreceivedbylabel", "6 true") + | ||||
HelpExampleRpc("listreceivedbylabel", "6, true, true")); | HelpExampleRpc("listreceivedbylabel", "6, true, true")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | UniValue listtransactions(const Config &config, const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() > 4) { | if (request.fHelp || request.params.size() > 4) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"listtransactions", | "listtransactions", | ||||
"\nIf a label name is provided, this will return only incoming " | "\nIf a label name is provided, this will return only incoming " | ||||
"transactions paying to addresses with the specified label.\n" | "transactions paying to addresses with the specified label.\n" | ||||
"\nReturns up to 'count' most recent transactions skipping the " | "\nReturns up to 'count' most recent transactions skipping the " | ||||
"first 'from' transactions.\n", | "first 'from' transactions.\n", | ||||
{ | { | ||||
{"label", RPCArg::Type::STR, /* opt */ true, | {"label", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"If set, should be a valid label name to return only " | "If set, should be a valid label name to return only incoming " | ||||
"incoming transactions with the specified label, or \"*\" " | "transactions with the specified label, or \"*\" to disable " | ||||
"to " | "filtering and return all transactions."}, | ||||
"disable filtering and return all transactions."}, | |||||
{"count", RPCArg::Type::NUM, /* opt */ true, | {"count", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "10", | /* default_val */ "10", | ||||
"The number of transactions to return"}, | "The number of transactions to return"}, | ||||
{"skip", RPCArg::Type::NUM, /* opt */ true, | {"skip", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "0", | /* default_val */ "0", "The number of transactions to skip"}, | ||||
"The number of transactions to skip"}, | |||||
{"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | {"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "false", | /* default_val */ "false", | ||||
"Include transactions to watch-only addresses (see " | "Include transactions to watch-only addresses (see " | ||||
"'importaddress')"}, | "'importaddress')"}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{ | ||||
"\nResult:\n" | |||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"address\":\"address\", (string) The bitcoin address of " | " \"address\":\"address\", (string) The bitcoin address " | ||||
"the transaction.\n" | "of the transaction.\n" | ||||
" \"category\":\"send|receive\", (string) The transaction " | " \"category\":\"send|receive\", (string) The transaction " | ||||
"category.\n" | "category.\n" | ||||
" \"amount\": x.xxx, (numeric) The amount in " + | " \"amount\": x.xxx, (numeric) The amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
". This is negative for the 'send' category, and is positive\n" | ". This is negative for the 'send' category, and is positive\n" | ||||
" for the 'receive' " | " for the 'receive' " | ||||
"category,\n" | "category,\n" | ||||
" \"label\": \"label\", (string) A comment for the " | " \"label\": \"label\", (string) A comment for the " | ||||
"address/transaction, if any\n" | "address/transaction, if any\n" | ||||
" \"vout\": n, (numeric) the vout value\n" | " \"vout\": n, (numeric) the vout value\n" | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee " | " \"fee\": x.xxx, (numeric) The amount of the " | ||||
"in " + | "fee in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
". This is negative and only available for the \n" | ". This is negative and only available for the \n" | ||||
" 'send' category of " | " 'send' category of " | ||||
"transactions.\n" | "transactions.\n" | ||||
" \"confirmations\": n, (numeric) The number of " | " \"confirmations\": n, (numeric) The number of " | ||||
"confirmations for the transaction. Negative confirmations " | "confirmations for the transaction. Negative confirmations " | ||||
"indicate the\n" | "indicate the\n" | ||||
" transaction conflicts " | " transaction " | ||||
"with the block chain\n" | "conflicts with the block chain\n" | ||||
" \"trusted\": xxx, (bool) Whether we consider the " | " \"trusted\": xxx, (bool) Whether we consider " | ||||
"outputs of this unconfirmed transaction safe to spend.\n" | "the outputs of this unconfirmed transaction safe to spend.\n" | ||||
" \"blockhash\": \"hashvalue\", (string) The block hash " | " \"blockhash\": \"hashvalue\", (string) The block hash " | ||||
"containing the transaction.\n" | "containing the transaction.\n" | ||||
" \"blockindex\": n, (numeric) The index of the " | " \"blockindex\": n, (numeric) The index of the " | ||||
"transaction in the block that includes it.\n" | "transaction in the block that includes it.\n" | ||||
" \"blocktime\": xxx, (numeric) The block time in " | " \"blocktime\": xxx, (numeric) The block time in " | ||||
"seconds since epoch (1 Jan 1970 GMT).\n" | "seconds since epoch (1 Jan 1970 GMT).\n" | ||||
" \"txid\": \"transactionid\", (string) The transaction id.\n" | " \"txid\": \"transactionid\", (string) The transaction " | ||||
" \"time\": xxx, (numeric) The transaction time in " | "id.\n" | ||||
"seconds since epoch (midnight Jan 1 1970 GMT).\n" | " \"time\": xxx, (numeric) The transaction " | ||||
" \"timereceived\": xxx, (numeric) The time received in " | "time in seconds since epoch (midnight Jan 1 1970 GMT).\n" | ||||
"seconds since epoch (midnight Jan 1 1970 GMT).\n" | " \"timereceived\": xxx, (numeric) The time received " | ||||
"in seconds since epoch (midnight Jan 1 1970 GMT).\n" | |||||
" \"comment\": \"...\", (string) If a comment is " | " \"comment\": \"...\", (string) If a comment is " | ||||
"associated with the transaction.\n" | "associated with the transaction.\n" | ||||
" \"abandoned\": xxx (bool) 'true' if the transaction " | " \"abandoned\": xxx (bool) 'true' if the " | ||||
"has been abandoned (inputs are respendable). Only available for " | "transaction has been abandoned (inputs are respendable). Only " | ||||
"the \n" | "available for the \n" | ||||
" 'send' category of " | " 'send' category of " | ||||
"transactions.\n" | "transactions.\n" | ||||
" }\n" | " }\n" | ||||
"]\n" | "]\n"}, | ||||
RPCExamples{ | |||||
"\nExamples:\n" | |||||
"\nList the most recent 10 transactions in the systems\n" + | "\nList the most recent 10 transactions in the systems\n" + | ||||
HelpExampleCli("listtransactions", "") + | HelpExampleCli("listtransactions", "") + | ||||
"\nList transactions 100 to 120\n" + | "\nList transactions 100 to 120\n" + | ||||
HelpExampleCli("listtransactions", "\"*\" 20 100") + | HelpExampleCli("listtransactions", "\"*\" 20 100") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("listtransactions", "\"*\", 20, 100")); | HelpExampleRpc("listtransactions", "\"*\", 20, 100")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static UniValue listsinceblock(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() > 4) { | if (request.fHelp || request.params.size() > 4) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"listsinceblock", | "listsinceblock", | ||||
"\nGet all transactions in blocks since block [blockhash], or " | "\nGet all transactions in blocks since block [blockhash], or all " | ||||
"all transactions if omitted.\n" | "transactions if omitted.\n" | ||||
"If \"blockhash\" is no longer a part of the main chain, " | "If \"blockhash\" is no longer a part of the main chain, " | ||||
"transactions from the fork point onward are included.\n" | "transactions from the fork point onward are included.\n" | ||||
"Additionally, if include_removed is set, transactions " | "Additionally, if include_removed is set, transactions affecting " | ||||
"affecting the wallet which were removed are returned in the " | "the wallet which were removed are returned in the \"removed\" " | ||||
"\"removed\" array.\n", | "array.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR, /* opt */ true, | {"blockhash", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"The block hash to list transactions since"}, | "The block hash to list transactions since"}, | ||||
{"target_confirmations", RPCArg::Type::NUM, /* opt */ true, | {"target_confirmations", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "1", | /* default_val */ "1", | ||||
"Return the nth block hash from the main chain. e.g. 1 " | "Return the nth block hash from the main chain. e.g. 1 " | ||||
"would mean the best block hash. Note: this is not used " | "would mean the best block hash. Note: this is not used " | ||||
"as a filter, but only affects [lastblock] in the return " | "as a filter, but only affects [lastblock] in the return " | ||||
"value"}, | "value"}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | {"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "false", | /* default_val */ "false", | ||||
"Include transactions to watch-only addresses (see " | "Include transactions to watch-only addresses (see " | ||||
"'importaddress')"}, | "'importaddress')"}, | ||||
{"include_removed", RPCArg::Type::BOOL, /* opt */ true, | {"include_removed", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "true", | /* default_val */ "true", | ||||
"Show transactions that were removed due to a reorg in " | "Show transactions that were removed due to a reorg in " | ||||
"the \"removed\" array\n" | "the \"removed\" array\n" | ||||
" " | " " | ||||
" (not guaranteed to work on pruned nodes)"}, | " (not guaranteed to work on pruned nodes)"}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{ | ||||
"\nResult:\n" | |||||
"{\n" | "{\n" | ||||
" \"transactions\": [\n" | " \"transactions\": [\n" | ||||
" \"address\":\"address\", (string) The bitcoin address of " | " \"address\":\"address\", (string) The bitcoin address " | ||||
"the transaction. Not present for move transactions (category = " | "of the transaction. Not present for move transactions " | ||||
"move).\n" | "(category = move).\n" | ||||
" \"category\":\"send|receive\", (string) The transaction " | " \"category\":\"send|receive\", (string) The " | ||||
"category. 'send' has negative amounts, 'receive' has positive " | "transaction category. 'send' has negative amounts, 'receive' " | ||||
"amounts.\n" | "has positive amounts.\n" | ||||
" \"amount\": x.xxx, (numeric) The amount in " + | " \"amount\": x.xxx, (numeric) The amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
". This is negative for the 'send' category, and for the 'move' " | ". This is negative for the 'send' category, and for the " | ||||
"category for moves \n" | "'move' category for moves \n" | ||||
" outbound. It is " | " outbound. It is " | ||||
"positive for the 'receive' category, and for the 'move' category " | "positive for the 'receive' category, and for the 'move' " | ||||
"for inbound funds.\n" | "category for inbound funds.\n" | ||||
" \"vout\" : n, (numeric) the vout value\n" | " \"vout\" : n, (numeric) the vout value\n" | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee " | " \"fee\": x.xxx, (numeric) The amount of the " | ||||
"in " + | "fee in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
". This is negative and only available for the 'send' category of " | ". This is negative and only available for the 'send' category " | ||||
"transactions.\n" | "of transactions.\n" | ||||
" \"confirmations\": n, (numeric) The number of " | " \"confirmations\": n, (numeric) The number of " | ||||
"confirmations for the transaction. Available for 'send' and " | "confirmations for the transaction. Available for 'send' and " | ||||
"'receive' category of transactions.\n" | "'receive' category of transactions.\n" | ||||
" When it's < 0, it means " | " When it's < 0, it " | ||||
"the transaction conflicted that many blocks ago.\n" | "means the transaction conflicted that many blocks ago.\n" | ||||
" \"blockhash\": \"hashvalue\", (string) The block hash " | " \"blockhash\": \"hashvalue\", (string) The block hash " | ||||
"containing the transaction. Available for 'send' and 'receive' " | "containing the transaction. Available for 'send' and " | ||||
"category of transactions.\n" | "'receive' category of transactions.\n" | ||||
" \"blockindex\": n, (numeric) The index of the " | " \"blockindex\": n, (numeric) The index of the " | ||||
"transaction in the block that includes it. Available for 'send' " | "transaction in the block that includes it. Available for " | ||||
"and 'receive' category of transactions.\n" | "'send' and 'receive' category of transactions.\n" | ||||
" \"blocktime\": xxx, (numeric) The block time in " | " \"blocktime\": xxx, (numeric) The block time in " | ||||
"seconds since epoch (1 Jan 1970 GMT).\n" | "seconds since epoch (1 Jan 1970 GMT).\n" | ||||
" \"txid\": \"transactionid\", (string) The transaction id. " | " \"txid\": \"transactionid\", (string) The transaction " | ||||
"Available for 'send' and 'receive' category of transactions.\n" | "id. Available for 'send' and 'receive' category of " | ||||
" \"time\": xxx, (numeric) The transaction time in " | "transactions.\n" | ||||
"seconds since epoch (Jan 1 1970 GMT).\n" | " \"time\": xxx, (numeric) The transaction " | ||||
" \"timereceived\": xxx, (numeric) The time received in " | "time in seconds since epoch (Jan 1 1970 GMT).\n" | ||||
"seconds since epoch (Jan 1 1970 GMT). Available for 'send' and " | " \"timereceived\": xxx, (numeric) The time received " | ||||
"'receive' category of transactions.\n" | "in seconds since epoch (Jan 1 1970 GMT). Available for 'send' " | ||||
" \"abandoned\": xxx, (bool) 'true' if the transaction " | "and 'receive' category of transactions.\n" | ||||
"has been abandoned (inputs are respendable). Only available for " | " \"abandoned\": xxx, (bool) 'true' if the " | ||||
"the 'send' category of transactions.\n" | "transaction has been abandoned (inputs are respendable). Only " | ||||
"available for the 'send' category of transactions.\n" | |||||
" \"comment\": \"...\", (string) If a comment is " | " \"comment\": \"...\", (string) If a comment is " | ||||
"associated with the transaction.\n" | "associated with the transaction.\n" | ||||
" \"label\" : \"label\" (string) A comment for the " | " \"label\" : \"label\" (string) A comment for the " | ||||
"address/transaction, if any\n" | "address/transaction, if any\n" | ||||
" \"to\": \"...\", (string) If a comment to is " | " \"to\": \"...\", (string) If a comment to is " | ||||
"associated with the transaction.\n" | "associated with the transaction.\n" | ||||
" ],\n" | " ],\n" | ||||
" \"removed\": [\n" | " \"removed\": [\n" | ||||
" <structure is the same as \"transactions\" above, only " | " <structure is the same as \"transactions\" above, only " | ||||
"present if include_removed=true>\n" | "present if include_removed=true>\n" | ||||
" Note: transactions that were re-added in the active chain " | " Note: transactions that were re-added in the active chain " | ||||
"will appear as-is in this array, and may thus have a positive " | "will appear as-is in this array, and may thus have a positive " | ||||
"confirmation count.\n" | "confirmation count.\n" | ||||
" ],\n" | " ],\n" | ||||
" \"lastblock\": \"lastblockhash\" (string) The hash of the " | " \"lastblock\": \"lastblockhash\" (string) The hash of " | ||||
"block (target_confirmations-1) from the best block on the main " | "the block (target_confirmations-1) from the best block on the " | ||||
"chain. This is typically used to feed back into listsinceblock " | "main chain. This is typically used to feed back into " | ||||
"the next time you call it. So you would generally use a " | "listsinceblock the next time you call it. So you would " | ||||
"target_confirmations of say 6, so you will be continually " | "generally use a target_confirmations of say 6, so you will be " | ||||
"re-notified of transactions until they've reached 6 confirmations " | "continually re-notified of transactions until they've reached " | ||||
"plus any new ones\n" | "6 confirmations plus any new ones\n" | ||||
"}\n" | "}\n"}, | ||||
"\nExamples:\n" + | RPCExamples{HelpExampleCli("listsinceblock", "") + | ||||
HelpExampleCli("listsinceblock", "") + | HelpExampleCli("listsinceblock", | ||||
HelpExampleCli("listsinceblock", "\"000000000000000bacf66f7497b7dc4" | "\"000000000000000bacf66f7497b7dc4" | ||||
"5ef753ee9a7d38571037cdb1a57f663ad" | "5ef753ee9a7d38571037cdb1a57f663ad" | ||||
"\" 6") + | "\" 6") + | ||||
HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc4" | HelpExampleRpc("listsinceblock", | ||||
"\"000000000000000bacf66f7497b7dc4" | |||||
"5ef753ee9a7d38571037cdb1a57f663ad" | "5ef753ee9a7d38571037cdb1a57f663ad" | ||||
"\", 6")); | "\", 6")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | static UniValue gettransaction(const Config &config, | ||||
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() < 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{ | ||||
RPCHelpMan{"gettransaction", | "gettransaction", | ||||
"\nGet detailed information about in-wallet transaction " | "\nGet detailed information about in-wallet transaction " | ||||
"<txid>\n", | "<txid>\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR, /* opt */ false, | {"txid", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The transaction id"}, | /* default_val */ "", "The transaction id"}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, | {"include_watchonly", RPCArg::Type::BOOL, | ||||
/* opt */ true, /* default_val */ "false", | /* opt */ true, /* default_val */ "false", | ||||
"Whether to include watch-only addresses in " | "Whether to include watch-only addresses in " | ||||
"balance calculation and details[]"}, | "balance calculation and details[]"}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{ | ||||
"\nResult:\n" | |||||
"{\n" | "{\n" | ||||
" \"amount\" : x.xxx, (numeric) The transaction amount " | " \"amount\" : x.xxx, (numeric) The transaction amount " | ||||
"in " + | "in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee in " + | " \"fee\": x.xxx, (numeric) The amount of the fee " | ||||
"in " + | |||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
". This is negative and only available for the \n" | ". This is negative and only available for the \n" | ||||
" 'send' category of transactions.\n" | " 'send' category of " | ||||
"transactions.\n" | |||||
" \"confirmations\" : n, (numeric) The number of " | " \"confirmations\" : n, (numeric) The number of " | ||||
"confirmations\n" | "confirmations\n" | ||||
" \"blockhash\" : \"hash\", (string) The block hash\n" | " \"blockhash\" : \"hash\", (string) The block hash\n" | ||||
" \"blockindex\" : xx, (numeric) The index of the " | " \"blockindex\" : xx, (numeric) The index of the " | ||||
"transaction in the block that includes it\n" | "transaction in the block that includes it\n" | ||||
" \"blocktime\" : ttt, (numeric) The time in seconds since " | " \"blocktime\" : ttt, (numeric) The time in seconds " | ||||
"epoch (1 Jan 1970 GMT)\n" | "since epoch (1 Jan 1970 GMT)\n" | ||||
" \"txid\" : \"transactionid\", (string) The transaction id.\n" | " \"txid\" : \"transactionid\", (string) The transaction " | ||||
" \"time\" : ttt, (numeric) The transaction time in " | "id.\n" | ||||
"seconds since epoch (1 Jan 1970 GMT)\n" | " \"time\" : ttt, (numeric) The transaction time " | ||||
"in seconds since epoch (1 Jan 1970 GMT)\n" | |||||
" \"timereceived\" : ttt, (numeric) The time received in " | " \"timereceived\" : ttt, (numeric) The time received in " | ||||
"seconds since epoch (1 Jan 1970 GMT)\n" | "seconds since epoch (1 Jan 1970 GMT)\n" | ||||
" \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether " | " \"bip125-replaceable\": \"yes|no|unknown\", (string) " | ||||
"this transaction could be replaced due to BIP125 " | "Whether this transaction could be replaced due to BIP125 " | ||||
"(replace-by-fee);\n" | "(replace-by-fee);\n" | ||||
" may be unknown " | " may be " | ||||
"for unconfirmed transactions not in the mempool\n" | "unknown for unconfirmed transactions not in the mempool\n" | ||||
" \"details\" : [\n" | " \"details\" : [\n" | ||||
" {\n" | " {\n" | ||||
" \"address\" : \"address\", (string) The bitcoin " | " \"address\" : \"address\", (string) The " | ||||
"address involved in the transaction\n" | "bitcoin address involved in the transaction\n" | ||||
" \"category\" : \"send|receive\", (string) The category, " | " \"category\" : \"send|receive\", (string) The " | ||||
"either 'send' or 'receive'\n" | "category, either 'send' or 'receive'\n" | ||||
" \"amount\" : x.xxx, (numeric) The amount " | " \"amount\" : x.xxx, (numeric) The " | ||||
"in " + | "amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"label\" : \"label\", " | " \"label\" : \"label\", (string) A comment " | ||||
"(string) A comment for the address/transaction, " | "for the address/transaction, if any\n" | ||||
"if any\n" | " \"vout\" : n, (numeric) the vout " | ||||
" \"vout\" : n, " | "value\n" | ||||
"(numeric) the vout value\n" | " \"fee\": x.xxx, (numeric) The " | ||||
" \"fee\": x.xxx, " | "amount of the fee in " + | ||||
"(numeric) The amount of the fee in " + | |||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
". This is negative and only available for the \n" | ". This is negative and only available for the \n" | ||||
" 'send' category of " | " 'send' category of " | ||||
"transactions.\n" | "transactions.\n" | ||||
" \"abandoned\": xxx (bool) 'true' if the " | " \"abandoned\": xxx (bool) 'true' if " | ||||
"transaction has been abandoned (inputs are respendable). Only " | "the transaction has been abandoned (inputs are respendable). " | ||||
"available for the \n" | "Only available for the \n" | ||||
" 'send' category of " | " 'send' category of " | ||||
"transactions.\n" | "transactions.\n" | ||||
" }\n" | " }\n" | ||||
" ,...\n" | " ,...\n" | ||||
" ],\n" | " ],\n" | ||||
" \"hex\" : \"data\" (string) Raw data for transaction\n" | " \"hex\" : \"data\" (string) Raw data for " | ||||
"}\n" | "transaction\n" | ||||
"}\n"}, | |||||
"\nExamples:\n" + | RPCExamples{HelpExampleCli("gettransaction", | ||||
HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e211" | "\"1075db55d416d3ca199f55b6084e211" | ||||
"5b9345e16c5cf302fc80e9d5fbf5d48d" | "5b9345e16c5cf302fc80e9d5fbf5d48d" | ||||
"\"") + | "\"") + | ||||
HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e211" | HelpExampleCli("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e211" | |||||
"5b9345e16c5cf302fc80e9d5fbf5d48d" | "5b9345e16c5cf302fc80e9d5fbf5d48d" | ||||
"\" true") + | "\" true") + | ||||
HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e211" | HelpExampleRpc("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e211" | |||||
"5b9345e16c5cf302fc80e9d5fbf5d48d" | "5b9345e16c5cf302fc80e9d5fbf5d48d" | ||||
"\"")); | "\"")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static UniValue abandontransaction(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{"abandontransaction", | "abandontransaction", | ||||
"\nMark in-wallet transaction <txid> as abandoned\n" | "\nMark in-wallet transaction <txid> as abandoned\n" | ||||
"This will mark this transaction and all its in-wallet " | "This will mark this transaction and all its in-wallet descendants " | ||||
"descendants as abandoned which will allow\n" | "as abandoned which will allow\n" | ||||
"for their inputs to be respent. It can be used to " | "for their inputs to be respent. It can be used to replace " | ||||
"replace \"stuck\" or evicted transactions.\n" | "\"stuck\" or evicted transactions.\n" | ||||
"It only works on transactions which are not included " | "It only works on transactions which are not included in a block " | ||||
"in a block and are not currently in the mempool.\n" | "and are not currently in the mempool.\n" | ||||
"It has no effect on transactions which are already " | "It has no effect on transactions which are already abandoned.\n", | ||||
"abandoned.\n", | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, | {"txid", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "The transaction id"}, | /* default_val */ "", "The transaction id"}, | ||||
}} | }, | ||||
.ToString() + | RPCResults{}, | ||||
"\nResult:\n" | RPCExamples{HelpExampleCli("abandontransaction", | ||||
"\nExamples:\n" + | "\"1075db55d416d3ca199f55b6084" | ||||
HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084" | |||||
"e2115b9345e16c5cf302fc80e9d5f" | "e2115b9345e16c5cf302fc80e9d5f" | ||||
"bf5d48d\"") + | "bf5d48d\"") + | ||||
HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084" | HelpExampleRpc("abandontransaction", | ||||
"\"1075db55d416d3ca199f55b6084" | |||||
"e2115b9345e16c5cf302fc80e9d5f" | "e2115b9345e16c5cf302fc80e9d5f" | ||||
"bf5d48d\"")); | "bf5d48d\"")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
Show All 18 Lines | static UniValue backupwallet(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"backupwallet", | "backupwallet", | ||||
"\nSafely copies current wallet file to destination, " | "\nSafely copies current wallet file to destination, " | ||||
"which can be a directory or a path with filename.\n", | "which can be a directory or a path with filename.\n", | ||||
{ | { | ||||
{"destination", RPCArg::Type::STR, /* opt */ false, | {"destination", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The destination directory or file"}, | /* default_val */ "", "The destination directory or file"}, | ||||
}} | }, | ||||
.ToString() + | RPCResults{}, | ||||
"\nExamples:\n" + HelpExampleCli("backupwallet", "\"backup.dat\"") + | RPCExamples{HelpExampleCli("backupwallet", "\"backup.dat\"") + | ||||
HelpExampleRpc("backupwallet", "\"backup.dat\"")); | HelpExampleRpc("backupwallet", "\"backup.dat\"")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
// 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(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
Show All 11 Lines | static UniValue keypoolrefill(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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() > 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{"keypoolrefill", | "keypoolrefill", | ||||
"\nFills the keypool." + | "\nFills the keypool." + HelpRequiringPassphrase(pwallet) + "\n", | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"newsize", RPCArg::Type::NUM, /* opt */ true, | {"newsize", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "100", "The new keypool size"}, | /* default_val */ "100", "The new keypool size"}, | ||||
}} | }, | ||||
.ToString() + | RPCResults{}, | ||||
"\nExamples:\n" + HelpExampleCli("keypoolrefill", "") + | RPCExamples{HelpExampleCli("keypoolrefill", "") + | ||||
HelpExampleRpc("keypoolrefill", "")); | HelpExampleRpc("keypoolrefill", "")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Error: Private keys are disabled for this wallet"); | "Error: Private keys are disabled for this wallet"); | ||||
} | } | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
Show All 31 Lines | static UniValue walletpassphrase(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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 (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) { | if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"walletpassphrase", | "walletpassphrase", | ||||
"\nStores the wallet decryption key in memory for " | "\nStores the wallet decryption key in memory for 'timeout' " | ||||
"'timeout' seconds.\n" | "seconds.\n" | ||||
"This is needed prior to performing transactions " | "This is needed prior to performing transactions related to " | ||||
"related to private keys such as sending bitcoins\n", | "private keys such as sending bitcoins\n" | ||||
"\nNote:\n" | |||||
"Issuing the walletpassphrase command while the wallet is already " | |||||
"unlocked will set a new unlock\n" | |||||
"time that overrides the old one.\n", | |||||
{ | { | ||||
{"passphrase", RPCArg::Type::STR, /* opt */ false, | {"passphrase", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The wallet passphrase"}, | /* default_val */ "", "The wallet passphrase"}, | ||||
{"timeout", RPCArg::Type::NUM, /* opt */ false, | {"timeout", RPCArg::Type::NUM, /* opt */ false, | ||||
/* default_val */ "", | /* default_val */ "", | ||||
"The time to keep the decryption key in seconds; capped " | "The time to keep the decryption key in seconds; capped " | ||||
"at 100000000 (~3 years)."}, | "at 100000000 (~3 years)."}, | ||||
}} | }, | ||||
.ToString() + | RPCResults{}, | ||||
"\nNote:\n" | RPCExamples{ | ||||
"Issuing the walletpassphrase command while the wallet is already " | |||||
"unlocked will set a new unlock\n" | |||||
"time that overrides the old one.\n" | |||||
"\nExamples:\n" | |||||
"\nUnlock the wallet for 60 seconds\n" + | "\nUnlock the wallet for 60 seconds\n" + | ||||
HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60") + | HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60") + | ||||
"\nLock the wallet again (before 60 seconds)\n" + | "\nLock the wallet again (before 60 seconds)\n" + | ||||
HelpExampleCli("walletlock", "") + "\nAs a JSON-RPC call\n" + | HelpExampleCli("walletlock", "") + "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60")); | HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
if (request.fHelp) { | if (request.fHelp) { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | static UniValue walletpassphrasechange(const Config &config, | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(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 (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) { | if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{"walletpassphrasechange", | "walletpassphrasechange", | ||||
"\nChanges the wallet passphrase from 'oldpassphrase' " | "\nChanges the wallet passphrase from 'oldpassphrase' to " | ||||
"to 'newpassphrase'.\n", | "'newpassphrase'.\n", | ||||
{ | { | ||||
{"oldpassphrase", RPCArg::Type::STR, /* opt */ false, | {"oldpassphrase", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The current passphrase"}, | /* default_val */ "", "The current passphrase"}, | ||||
{"newpassphrase", RPCArg::Type::STR, /* opt */ false, | {"newpassphrase", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The new passphrase"}, | /* default_val */ "", "The new passphrase"}, | ||||
}} | }, | ||||
.ToString() + | RPCResults{}, | ||||
"\nExamples:\n" + | RPCExamples{HelpExampleCli("walletpassphrasechange", | ||||
HelpExampleCli("walletpassphrasechange", | |||||
"\"old one\" \"new one\"") + | "\"old one\" \"new one\"") + | ||||
HelpExampleRpc("walletpassphrasechange", | HelpExampleRpc("walletpassphrasechange", | ||||
"\"old one\", \"new one\"")); | "\"old one\", \"new one\"")}, | ||||
} | |||||
.ToStringWithResultsAndExamples()); | |||||
} | } | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
if (request.fHelp) { | if (request.fHelp) { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,454 Lines • Show Last 20 Lines |