Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"setlabel", | "setlabel", | ||||
"Sets the label associated with the given address.\n", | "Sets the label associated with the given address.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The bitcoin address to be associated with a label."}, | "The bitcoin address to be associated with a label."}, | ||||
{"label", RPCArg::Type::STR, RPCArg::Optional::NO, | {"label", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The label to assign to the address."}, | "The label to assign to the address."}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("setlabel", | HelpExampleCli("setlabel", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | ||||
HelpExampleRpc( | HelpExampleRpc( | ||||
"setlabel", | "setlabel", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")}, | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | static UniValue getunconfirmedbalance(const Config &config, | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getunconfirmedbalance", | "getunconfirmedbalance", | ||||
"DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n", | "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NUM, "", "The balance"}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// 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(); | ||||
▲ Show 20 Lines • Show All 1,270 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"or evicted transactions.\n" | "or evicted transactions.\n" | ||||
"It only works on transactions which are not included in a block and " | "It only works on transactions which are not included in a block and " | ||||
"are not currently in the mempool.\n" | "are not currently in the mempool.\n" | ||||
"It has no effect on transactions which are already abandoned.\n", | "It has no effect on transactions which are already abandoned.\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The transaction id"}, | "The transaction id"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("abandontransaction", | RPCExamples{HelpExampleCli("abandontransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\"") + | "5cf302fc80e9d5fbf5d48d\"") + | ||||
HelpExampleRpc("abandontransaction", | HelpExampleRpc("abandontransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\"")}, | "5cf302fc80e9d5fbf5d48d\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
Show All 31 Lines | static UniValue backupwallet(const Config &config, | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"backupwallet", | "backupwallet", | ||||
"Safely copies current wallet file to destination, which can be a " | "Safely copies current wallet file to destination, which can be a " | ||||
"directory or a path with filename.\n", | "directory or a path with filename.\n", | ||||
{ | { | ||||
{"destination", RPCArg::Type::STR, RPCArg::Optional::NO, | {"destination", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The destination directory or file"}, | "The destination directory or file"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("backupwallet", "\"backup.dat\"") + | RPCExamples{HelpExampleCli("backupwallet", "\"backup.dat\"") + | ||||
HelpExampleRpc("backupwallet", "\"backup.dat\"")}, | HelpExampleRpc("backupwallet", "\"backup.dat\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// 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(); | ||||
Show All 19 Lines | static UniValue keypoolrefill(const Config &config, | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"keypoolrefill", | "keypoolrefill", | ||||
"Fills the keypool." + HelpRequiringPassphrase(pwallet) + "\n", | "Fills the keypool." + HelpRequiringPassphrase(pwallet) + "\n", | ||||
{ | { | ||||
{"newsize", RPCArg::Type::NUM, /* default */ "100", | {"newsize", RPCArg::Type::NUM, /* default */ "100", | ||||
"The new keypool size"}, | "The new keypool size"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("keypoolrefill", "") + | RPCExamples{HelpExampleCli("keypoolrefill", "") + | ||||
HelpExampleRpc("keypoolrefill", "")}, | HelpExampleRpc("keypoolrefill", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
if (pwallet->IsLegacy() && | if (pwallet->IsLegacy() && | ||||
pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"time that overrides the old one.\n", | "time that overrides the old one.\n", | ||||
{ | { | ||||
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | {"passphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The wallet passphrase"}, | "The wallet passphrase"}, | ||||
{"timeout", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"timeout", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"The time to keep the decryption key in seconds; capped at " | "The time to keep the decryption key in seconds; capped at " | ||||
"100000000 (~3 years)."}, | "100000000 (~3 years)."}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{ | RPCExamples{ | ||||
"\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")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Changes the wallet passphrase from 'oldpassphrase' to " | "Changes the wallet passphrase from 'oldpassphrase' to " | ||||
"'newpassphrase'.\n", | "'newpassphrase'.\n", | ||||
{ | { | ||||
{"oldpassphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | {"oldpassphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The current passphrase"}, | "The current passphrase"}, | ||||
{"newpassphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | {"newpassphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The new passphrase"}, | "The new passphrase"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("walletpassphrasechange", | RPCExamples{HelpExampleCli("walletpassphrasechange", | ||||
"\"old one\" \"new one\"") + | "\"old one\" \"new one\"") + | ||||
HelpExampleRpc("walletpassphrasechange", | HelpExampleRpc("walletpassphrasechange", | ||||
"\"old one\", \"new one\"")}, | "\"old one\", \"new one\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static UniValue walletlock(const Config &config, | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"walletlock", | "walletlock", | ||||
"Removes the wallet encryption key from memory, locking the wallet.\n" | "Removes the wallet encryption key from memory, locking the wallet.\n" | ||||
"After calling this method, you will need to call walletpassphrase " | "After calling this method, you will need to call walletpassphrase " | ||||
"again\n" | "again\n" | ||||
"before being able to call any methods which require the wallet to be " | "before being able to call any methods which require the wallet to be " | ||||
"unlocked.\n", | "unlocked.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{ | RPCExamples{ | ||||
"\nSet the passphrase for 2 minutes to perform a transaction\n" + | "\nSet the passphrase for 2 minutes to perform a transaction\n" + | ||||
HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + | HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + | ||||
"\nPerform a send (requires passphrase set)\n" + | "\nPerform a send (requires passphrase set)\n" + | ||||
HelpExampleCli("sendtoaddress", | HelpExampleCli("sendtoaddress", | ||||
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") + | "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") + | ||||
"\nClear the passphrase since we are done before 2 minutes is " | "\nClear the passphrase since we are done before 2 minutes is " | ||||
"up\n" + | "up\n" + | ||||
Show All 35 Lines | RPCHelpMan{ | ||||
"Use the walletpassphrase call for this, and then walletlock call.\n" | "Use the walletpassphrase call for this, and then walletlock call.\n" | ||||
"If the wallet is already encrypted, use the walletpassphrasechange " | "If the wallet is already encrypted, use the walletpassphrasechange " | ||||
"call.\n", | "call.\n", | ||||
{ | { | ||||
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | {"passphrase", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The pass phrase to encrypt the wallet with. It must be at least " | "The pass phrase to encrypt the wallet with. It must be at least " | ||||
"1 character, but should be long."}, | "1 character, but should be long."}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::STR, "", | ||||
"A string with further instructions"}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\nEncrypt your wallet\n" + | "\nEncrypt your wallet\n" + | ||||
HelpExampleCli("encryptwallet", "\"my pass phrase\"") + | HelpExampleCli("encryptwallet", "\"my pass phrase\"") + | ||||
"\nNow set the passphrase to use the wallet, such as for signing " | "\nNow set the passphrase to use the wallet, such as for signing " | ||||
"or sending bitcoin\n" + | "or sending bitcoin\n" + | ||||
HelpExampleCli("walletpassphrase", "\"my pass phrase\"") + | HelpExampleCli("walletpassphrase", "\"my pass phrase\"") + | ||||
"\nNow we can do something like sign\n" + | "\nNow we can do something like sign\n" + | ||||
HelpExampleCli("signmessage", "\"address\" \"test message\"") + | HelpExampleCli("signmessage", "\"address\" \"test message\"") + | ||||
▲ Show 20 Lines • Show All 854 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Unloads the wallet referenced by the request endpoint otherwise " | "Unloads the wallet referenced by the request endpoint otherwise " | ||||
"unloads the wallet specified in the argument.\n" | "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, | {"wallet_name", RPCArg::Type::STR, | ||||
/* default */ "the wallet name from the RPC request", | /* default */ "the wallet name from the RPC request", | ||||
"The name of the wallet to unload."}, | "The name of the wallet to unload."}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("unloadwallet", "wallet_name") + | RPCExamples{HelpExampleCli("unloadwallet", "wallet_name") + | ||||
HelpExampleRpc("unloadwallet", "wallet_name")}, | HelpExampleRpc("unloadwallet", "wallet_name")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
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()) { | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"output is reused/dirty (sent to an address that was " | "output is reused/dirty (sent to an address that was " | ||||
"previously spent from)"}, | "previously spent from)"}, | ||||
{RPCResult::Type::STR, "desc", | {RPCResult::Type::STR, "desc", | ||||
"(only when solvable) A descriptor for spending this " | "(only when solvable) A descriptor for spending this " | ||||
"output"}, | "output"}, | ||||
{RPCResult::Type::BOOL, "safe", | {RPCResult::Type::BOOL, "safe", | ||||
"Whether this output is considered safe to spend. " | "Whether this output is considered safe to spend. " | ||||
"Unconfirmed transactions\n" | "Unconfirmed transactions\n" | ||||
" from outside keys and " | "from outside keys and unconfirmed replacement " | ||||
"unconfirmed replacement transactions are considered " | "transactions are considered unsafe\n" | ||||
"unsafe\n" | |||||
"and are not eligible for spending by fundrawtransaction " | "and are not eligible for spending by fundrawtransaction " | ||||
"and sendtoaddress."}, | "and sendtoaddress."}, | ||||
}}, | }}, | ||||
}}, | }}, | ||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("listunspent", "") + | HelpExampleCli("listunspent", "") + | ||||
HelpExampleCli("listunspent", | HelpExampleCli("listunspent", | ||||
"6 9999999 " | "6 9999999 " | ||||
▲ Show 20 Lines • Show All 1,105 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
" keypool will be used until it has " | " keypool will be used until it has " | ||||
"been depleted."}, | "been depleted."}, | ||||
{"seed", RPCArg::Type::STR, /* default */ "random seed", | {"seed", RPCArg::Type::STR, /* default */ "random seed", | ||||
"The WIF private key to use as the new HD seed.\n" | "The WIF private key to use as the new HD seed.\n" | ||||
" The seed value can be retrieved " | " The seed value can be retrieved " | ||||
"using the dumpwallet command. It is the private key marked " | "using the dumpwallet command. It is the private key marked " | ||||
"hdseed=1"}, | "hdseed=1"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("sethdseed", "") + | RPCExamples{HelpExampleCli("sethdseed", "") + | ||||
HelpExampleCli("sethdseed", "false") + | HelpExampleCli("sethdseed", "false") + | ||||
HelpExampleCli("sethdseed", "true \"wifkey\"") + | HelpExampleCli("sethdseed", "true \"wifkey\"") + | ||||
HelpExampleRpc("sethdseed", "true, \"wifkey\"")}, | HelpExampleRpc("sethdseed", "true, \"wifkey\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LegacyScriptPubKeyMan &spk_man = | LegacyScriptPubKeyMan &spk_man = | ||||
▲ Show 20 Lines • Show All 343 Lines • ▼ Show 20 Lines | RPCHelpMan{"upgradewallet", | ||||
"\nUpgrade the wallet. Upgrades to the latest version if no " | "\nUpgrade the wallet. Upgrades to the latest version if no " | ||||
"version number is specified\n" | "version number is specified\n" | ||||
"New keys may be generated and a new wallet backup will need to " | "New keys may be generated and a new wallet backup will need to " | ||||
"be made.", | "be made.", | ||||
{{"version", RPCArg::Type::NUM, | {{"version", RPCArg::Type::NUM, | ||||
/* default */ strprintf("%d", FEATURE_LATEST), | /* default */ strprintf("%d", FEATURE_LATEST), | ||||
"The version number to upgrade to. Default is the latest " | "The version number to upgrade to. Default is the latest " | ||||
"wallet version"}}, | "wallet version"}}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("upgradewallet", "200300") + | RPCExamples{HelpExampleCli("upgradewallet", "200300") + | ||||
HelpExampleRpc("upgradewallet", "200300")}} | HelpExampleRpc("upgradewallet", "200300")}} | ||||
.Check(request); | .Check(request); | ||||
RPCTypeCheck(request.params, {UniValue::VNUM}, true); | RPCTypeCheck(request.params, {UniValue::VNUM}, true); | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |