Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getnewaddress", | "getnewaddress", | ||||
"\nReturns a new Bitcoin address for receiving payments.\n" | "\nReturns a new Bitcoin address for receiving payments.\n" | ||||
"If 'label' is specified, it is added to the address book \n" | "If 'label' is specified, it is added to the address book \n" | ||||
"so payments received with the address will be associated with " | "so payments received with the address will be associated with " | ||||
"'label'.\n", | "'label'.\n", | ||||
{ | { | ||||
{"label", RPCArg::Type::STR, true}, | {"label", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ "", | |||||
"The label name for the address to be linked to. If not " | |||||
"provided, the default label \"\" is used. It can also be " | |||||
"set to the empty string \"\" to represent the default " | |||||
"label. The label does not need to exist, it will be " | |||||
"created if there is no label by the given name."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"label\" (string, optional) The label name for the " | |||||
"address to be linked to. If not provided, the default label \"\" " | |||||
"is used. It can also be set to the empty string \"\" to represent " | |||||
"the default label. The label does not need to exist, it will be " | |||||
"created if there is no label by the given name.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"address\" (string) The new bitcoin address\n" | "\"address\" (string) The new bitcoin address\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleRpc("getnewaddress", "")); | HelpExampleRpc("getnewaddress", "")); | ||||
} | } | ||||
// Belt and suspenders check for disabled private keys | // Belt and suspenders check for disabled private keys | ||||
if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | static UniValue setlabel(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{"setlabel", | RPCHelpMan{ | ||||
"setlabel", | |||||
"\nSets the label associated with the given address.\n", | "\nSets the label associated with the given address.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
{"label", RPCArg::Type::STR, false}, | /* default_val */ "", | ||||
"The bitcoin address to be associated with a label."}, | |||||
{"label", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", | |||||
"The label to assign to the address."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"address\" (string, required) The bitcoin address to " | |||||
"be associated with a label.\n" | |||||
"2. \"label\" (string, required) The label to assign to " | |||||
"the address.\n" | |||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("setlabel", | HelpExampleCli("setlabel", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | ||||
HelpExampleRpc( | HelpExampleRpc( | ||||
"setlabel", | "setlabel", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")); | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")); | ||||
} | } | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static UniValue sendtoaddress(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{"sendtoaddress", | RPCHelpMan{ | ||||
"\nSend an amount to a given address.\n", | "sendtoaddress", | ||||
"\nSend an amount to a given address.\n" + | |||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"address", RPCArg::Type::STR, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
{"amount", RPCArg::Type::AMOUNT, false}, | /* default_val */ "", "The bitcoin address to send to."}, | ||||
{"comment", RPCArg::Type::STR, true}, | {"amount", RPCArg::Type::AMOUNT, /* opt */ false, | ||||
{"comment_to", RPCArg::Type::STR, true}, | /* default_val */ "", | ||||
{"subtractfeefromamount", RPCArg::Type::BOOL, true}, | "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"}, | ||||
}} | {"comment", RPCArg::Type::STR, /* opt */ true, | ||||
.ToString() + | /* default_val */ "", | ||||
HelpRequiringPassphrase(pwallet) + | "A comment used to store what the transaction is for.\n" | ||||
"\nArguments:\n" | " This is not part of the " | ||||
"1. \"address\" (string, required) The bitcoin address " | "transaction, just kept in your wallet."}, | ||||
"to send to.\n" | {"comment_to", RPCArg::Type::STR, /* opt */ true, | ||||
"2. \"amount\" (numeric or string, required) The " | /* default_val */ "", | ||||
"amount in " + | "A comment to store the name of the person or " | ||||
CURRENCY_UNIT + | "organization\n" | ||||
" to send. eg 0.1\n" | |||||
"3. \"comment\" (string, optional) A comment used to " | |||||
"store what the transaction is for. \n" | |||||
" This is not part of the transaction, " | |||||
"just kept in your wallet.\n" | |||||
"4. \"comment_to\" (string, optional) A comment to store " | |||||
"the name of the person or organization \n" | |||||
" to which you're sending the " | " to which you're sending the " | ||||
"transaction. This is not part of the \n" | "transaction. This is not part of the \n" | ||||
" transaction, just kept in your " | " transaction, just kept in " | ||||
"wallet.\n" | "your wallet."}, | ||||
"5. subtractfeefromamount (boolean, optional, default=false) The " | {"subtractfeefromamount", RPCArg::Type::BOOL, | ||||
"fee will be deducted from the amount being sent.\n" | /* opt */ true, /* default_val */ "false", | ||||
" The recipient will receive less " | "The fee will be deducted from the amount being sent.\n" | ||||
"bitcoins than you enter in the amount field.\n" | " The recipient will receive " | ||||
"less bitcoins than you enter in the amount field."}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"txid\" (string) The transaction id.\n" | "\"txid\" (string) The transaction id.\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("sendtoaddress", | HelpExampleCli("sendtoaddress", | ||||
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") + | "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") + | ||||
HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" | HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" | ||||
"dd\" 0.1 \"donation\" \"seans " | "dd\" 0.1 \"donation\" \"seans " | ||||
"outpost\"") + | "outpost\"") + | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | static UniValue signmessage(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) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"signmessage", | RPCHelpMan{"signmessage", | ||||
"\nSign a message with the private key of an address", | "\nSign a message with the private key of an address" + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"address", RPCArg::Type::STR, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
{"message", RPCArg::Type::STR, false}, | /* default_val */ "", | ||||
"The bitcoin address to use for the private key."}, | |||||
{"message", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", | |||||
"The message to create a signature of."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
HelpRequiringPassphrase(pwallet) + | |||||
"\n" | |||||
"\nArguments:\n" | |||||
"1. \"address\" (string, required) The bitcoin address to " | |||||
"use for the private key.\n" | |||||
"2. \"message\" (string, required) The message to create a " | |||||
"signature of.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"signature\" (string) The signature of the message " | "\"signature\" (string) The signature of the message " | ||||
"encoded in base 64\n" | "encoded in base 64\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nUnlock the wallet for 30 seconds\n" + | "\nUnlock the wallet for 30 seconds\n" + | ||||
HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + | HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + | ||||
"\nCreate the signature\n" + | "\nCreate the signature\n" + | ||||
HelpExampleCli( | HelpExampleCli( | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | static UniValue getreceivedbyaddress(const Config &config, | ||||
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{ | ||||
"getreceivedbyaddress", | "getreceivedbyaddress", | ||||
"\nReturns the total amount received by the given address in " | "\nReturns the total amount received by the given address in " | ||||
"transactions with at least minconf confirmations.\n", | "transactions with at least minconf confirmations.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, false}, | {"address", RPCArg::Type::STR, /* opt */ false, | ||||
{"minconf", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
"The bitcoin address for transactions."}, | |||||
{"minconf", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "1", | |||||
"Only include transactions confirmed at least this many " | |||||
"times."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"address\" (string, required) The bitcoin address for " | |||||
"transactions.\n" | |||||
"2. minconf (numeric, optional, default=1) Only " | |||||
"include transactions confirmed at least this many times.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"amount (numeric) The total amount in " + | "amount (numeric) The total amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" received at this address.\n" | " received at this address.\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nThe amount from transactions with at least 1 confirmation\n" + | "\nThe amount from transactions with at least 1 confirmation\n" + | ||||
HelpExampleCli("getreceivedbyaddress", | HelpExampleCli("getreceivedbyaddress", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") + | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | static UniValue getreceivedbylabel(const Config &config, | ||||
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{ | ||||
"getreceivedbylabel", | "getreceivedbylabel", | ||||
"\nReturns the total amount received by addresses with <label> " | "\nReturns the total amount received by addresses with <label> " | ||||
"in transactions with at least [minconf] confirmations.\n", | "in transactions with at least [minconf] confirmations.\n", | ||||
{ | { | ||||
{"label", RPCArg::Type::STR, false}, | {"label", RPCArg::Type::STR, /* opt */ false, | ||||
{"minconf", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
"The selected label, may be the default label " | |||||
"using \"\"."}, | |||||
{"minconf", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "1", | |||||
"Only include transactions confirmed at least this " | |||||
"many times."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"label\" (string, required) The selected label, may be " | |||||
"the default label using \"\".\n" | |||||
"2. minconf (numeric, optional, default=1) Only include " | |||||
"transactions confirmed at least this many times.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"amount (numeric) The total amount in " + | "amount (numeric) The total amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" received for this label.\n" | " received for this label.\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nAmount received by the default label with at least 1 " | "\nAmount received by the default label with at least 1 " | ||||
"confirmation\n" + | "confirmation\n" + | ||||
HelpExampleCli("getreceivedbylabel", "\"\"") + | HelpExampleCli("getreceivedbylabel", "\"\"") + | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | if (request.fHelp || (request.params.size() > 3)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"getbalance", | RPCHelpMan{"getbalance", | ||||
"\nReturns the total available balance.\n" | "\nReturns the total available balance.\n" | ||||
"The available balance is what the wallet considers " | "The available balance is what the wallet considers " | ||||
"currently spendable, and is\n" | "currently spendable, and is\n" | ||||
"thus affected by options which limit spendability such " | "thus affected by options which limit spendability such " | ||||
"as -spendzeroconfchange.\n", | "as -spendzeroconfchange.\n", | ||||
{ | { | ||||
{"dummy", RPCArg::Type::STR, true}, | {"dummy", RPCArg::Type::STR, /* opt */ true, | ||||
{"minconf", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
{"include_watchonly", RPCArg::Type::BOOL, true}, | "Remains for backward compatibility. Must be " | ||||
"excluded or set to \"*\"."}, | |||||
{"minconf", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "0", | |||||
"Only include transactions confirmed at least this " | |||||
"many times."}, | |||||
{"include_watchonly", RPCArg::Type::BOOL, | |||||
/* opt */ true, /* default_val */ "false", | |||||
"Also include balance in watch-only addresses (see " | |||||
"'importaddress')"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. (dummy) (string, optional) Remains for " | |||||
"backward compatibility. Must be excluded or set to " | |||||
"\"*\".\n" | |||||
"2. minconf (numeric, optional, default=0) " | |||||
"Only include transactions confirmed at least this many " | |||||
"times.\n" | |||||
"3. include_watchonly (bool, optional, default=false) Also include " | |||||
"balance in watch-only addresses (see 'importaddress')\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"amount (numeric) The total amount in " + | "amount (numeric) The total amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
" received for this wallet.\n" | " received for this wallet.\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nThe total amount in the wallet with 1 or more confirmations\n" + | "\nThe total amount in the wallet with 1 or more confirmations\n" + | ||||
HelpExampleCli("getbalance", "") + | HelpExampleCli("getbalance", "") + | ||||
"\nThe total amount in the wallet at least 6 blocks confirmed\n" + | "\nThe total amount in the wallet at least 6 blocks confirmed\n" + | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static UniValue sendmany(const Config &config, const JSONRPCRequest &request) { | ||||
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{"sendmany", | RPCHelpMan{ | ||||
"sendmany", | |||||
"\nSend multiple times. Amounts are double-precision " | "\nSend multiple times. Amounts are double-precision " | ||||
"floating point numbers.\n", | "floating point numbers." + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"dummy", RPCArg::Type::STR, false, "\"\""}, | {"dummy", RPCArg::Type::STR, /* opt */ false, | ||||
{"amounts", | /* default_val */ "", | ||||
RPCArg::Type::OBJ, | "Must be set to \"\" for backwards compatibility.", | ||||
"\"\""}, | |||||
{ | { | ||||
{"address", RPCArg::Type::AMOUNT, false}, | "amounts", | ||||
RPCArg::Type::OBJ, | |||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json object with addresses and amounts", | |||||
{ | |||||
{"address", RPCArg::Type::AMOUNT, /* opt */ false, | |||||
/* default_val */ "", | |||||
"The bitcoin address is the key, the numeric " | |||||
"amount (can be string) in " + | |||||
CURRENCY_UNIT + " is the value"}, | |||||
}, | }, | ||||
false}, | }, | ||||
{"minconf", RPCArg::Type::NUM, true}, | {"minconf", RPCArg::Type::NUM, /* opt */ true, | ||||
{"comment", RPCArg::Type::STR, true}, | /* default_val */ "1", | ||||
{"subtractfeefrom", | "Only use the balance confirmed at least this many " | ||||
RPCArg::Type::ARR, | "times."}, | ||||
{"comment", RPCArg::Type::STR, /* opt */ true, | |||||
/* default_val */ "", "A comment"}, | |||||
{ | { | ||||
{"address", RPCArg::Type::STR, true}, | "subtractfeefrom", | ||||
RPCArg::Type::ARR, | |||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array with addresses.\n" | |||||
" The fee will be equally " | |||||
"deducted from the amount of each selected address.\n" | |||||
" Those recipients will " | |||||
"receive less bitcoins than you enter in their " | |||||
"corresponding amount field.\n" | |||||
" If no addresses are " | |||||
"specified here, the sender pays the fee.", | |||||
{ | |||||
{"address", RPCArg::Type::STR, /* opt */ true, | |||||
/* default_val */ "", | |||||
"Subtract fee from this address"}, | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
HelpRequiringPassphrase(pwallet) + | |||||
"\n" | |||||
"\nArguments:\n" | |||||
"1. \"dummy\" (string, required) Must be set to \"\" " | |||||
"for backwards compatibility.\n" | |||||
"2. \"amounts\" (string, required) A json object with " | |||||
"addresses and amounts\n" | |||||
" {\n" | |||||
" \"address\":amount (numeric or string) The bitcoin " | |||||
"address is the key, the numeric amount (can be string) in " + | |||||
CURRENCY_UNIT + | |||||
" is the value\n" | |||||
" ,...\n" | |||||
" }\n" | |||||
"3. minconf (numeric, optional, default=1) Only " | |||||
"use the balance confirmed at least this many times.\n" | |||||
"4. \"comment\" (string, optional) A comment\n" | |||||
"5. subtractfeefrom (array, optional) A json array with " | |||||
"addresses.\n" | |||||
" The fee will be equally deducted from " | |||||
"the amount of each selected address.\n" | |||||
" Those recipients will receive less " | |||||
"bitcoins than you enter in their corresponding amount field.\n" | |||||
" If no addresses are specified here, " | |||||
"the sender pays the fee.\n" | |||||
" [\n" | |||||
" \"address\" (string) Subtract fee from this " | |||||
"address\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"txid\" (string) The transaction id for the " | "\"txid\" (string) The transaction id for the " | ||||
"send. Only 1 transaction is created regardless of \n" | "send. Only 1 transaction is created regardless of \n" | ||||
" the number of addresses.\n" | " the number of addresses.\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nSend two amounts to two different addresses:\n" + | "\nSend two amounts to two different addresses:\n" + | ||||
HelpExampleCli("sendmany", | HelpExampleCli("sendmany", | ||||
"\"\" " | "\"\" " | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | static UniValue addmultisigaddress(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() > 3) { | request.params.size() > 3) { | ||||
std::string msg = | std::string msg = | ||||
"addmultisigaddress nrequired [\"key\",...] ( \"label\" )\n" | RPCHelpMan{ | ||||
"\nAdd a nrequired-to-sign multisignature address to the wallet. " | "addmultisigaddress", | ||||
"\nAdd a nrequired-to-sign multisignature address to the " | |||||
"wallet. " | |||||
"Requires a new wallet backup.\n" | "Requires a new wallet backup.\n" | ||||
"Each key is a Bitcoin address or hex-encoded public key.\n" | "Each key is a Bitcoin address or hex-encoded public key.\n" | ||||
"If 'label' is specified (DEPRECATED), assign address to that " | "If 'label' is specified (DEPRECATED), assign address to that " | ||||
"label.\n" | "label.\n", | ||||
{ | |||||
"\nArguments:\n" | {"nrequired", RPCArg::Type::NUM, /* opt */ false, | ||||
"1. nrequired (numeric, required) The number of required " | /* default_val */ "", | ||||
"signatures out of the n keys or addresses.\n" | "The number of required signatures out of the n keys or " | ||||
"2. \"keys\" (string, required) A json array of bitcoin " | "addresses."}, | ||||
"addresses or hex-encoded public keys\n" | { | ||||
" [\n" | "keys", | ||||
" \"address\" (string) bitcoin address or hex-encoded " | RPCArg::Type::ARR, | ||||
"public key\n" | /* opt */ false, | ||||
" ...,\n" | /* default_val */ "", | ||||
" ]\n" | "A json array of bitcoin addresses or hex-encoded " | ||||
"3. \"label\" (string, optional) A label to " | "public keys", | ||||
"assign the addresses to.\n" | { | ||||
{"key", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", | |||||
"bitcoin address or hex-encoded public key"}, | |||||
}, | |||||
}, | |||||
{"label", RPCArg::Type::STR, /* opt */ true, | |||||
/* default_val */ "", | |||||
"A label to assign the addresses to."}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"address\":\"multisigaddress\", (string) The value of the " | " \"address\":\"multisigaddress\", (string) The value of the " | ||||
"new multisig address.\n" | "new multisig address.\n" | ||||
" \"redeemScript\":\"script\" (string) The string value " | " \"redeemScript\":\"script\" (string) The string value " | ||||
"of the hex-encoded redemption script.\n" | "of the hex-encoded redemption script.\n" | ||||
"}\n" | "}\n" | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | static UniValue listreceivedbyaddress(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() > 4) { | if (request.fHelp || request.params.size() > 4) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"listreceivedbyaddress", | RPCHelpMan{ | ||||
"listreceivedbyaddress", | |||||
"\nList balances by receiving address.\n", | "\nList balances by receiving address.\n", | ||||
{ | { | ||||
{"minconf", RPCArg::Type::NUM, true}, | {"minconf", RPCArg::Type::NUM, /* opt */ true, | ||||
{"include_empty", RPCArg::Type::BOOL, true}, | /* default_val */ "1", | ||||
{"include_watchonly", RPCArg::Type::BOOL, true}, | "The minimum number of confirmations before payments are " | ||||
{"address_filter", RPCArg::Type::STR, true}, | "included."}, | ||||
{"include_empty", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Whether to include addresses that haven't received any " | |||||
"payments."}, | |||||
{"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Whether to include watch-only addresses (see " | |||||
"'importaddress')."}, | |||||
{"address_filter", RPCArg::Type::STR, /* opt */ true, | |||||
/* default_val */ "", | |||||
"If present, only return information on this address."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. minconf (numeric, optional, default=1) The minimum " | |||||
"number of confirmations before payments are included.\n" | |||||
"2. include_empty (bool, optional, default=false) Whether to " | |||||
"include addresses that haven't received any payments.\n" | |||||
"3. include_watchonly (bool, optional, default=false) Whether to " | |||||
"include watch-only addresses (see 'importaddress').\n" | |||||
"4. address_filter (string, optional) If present, only return " | |||||
"information on this address.\n" | |||||
"\nResult:\n" | "\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" | ||||
" \"address\" : \"receivingaddress\", (string) The receiving " | " \"address\" : \"receivingaddress\", (string) The receiving " | ||||
"address\n" | "address\n" | ||||
" \"amount\" : x.xxx, (numeric) The total " | " \"amount\" : x.xxx, (numeric) The total " | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | 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{"listreceivedbylabel", | RPCHelpMan{"listreceivedbylabel", | ||||
"\nList received transactions by label.\n", | "\nList received transactions by label.\n", | ||||
{ | { | ||||
{"minconf", RPCArg::Type::NUM, true}, | {"minconf", RPCArg::Type::NUM, /* opt */ true, | ||||
{"include_empty", RPCArg::Type::BOOL, true}, | /* default_val */ "1", | ||||
{"include_watchonly", RPCArg::Type::BOOL, true}, | "The minimum number of confirmations before " | ||||
"payments are included."}, | |||||
{"include_empty", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Whether to include labels that haven't received " | |||||
"any payments."}, | |||||
{"include_watchonly", RPCArg::Type::BOOL, | |||||
/* opt */ true, /* default_val */ "false", | |||||
"Whether to include watch-only addresses (see " | |||||
"'importaddress')."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. minconf (numeric, optional, default=1) The minimum " | |||||
"number of confirmations before payments are included.\n" | |||||
"2. include_empty (bool, optional, default=false) Whether to " | |||||
"include labels that haven't received any payments.\n" | |||||
"3. include_watchonly (bool, optional, default=false) Whether to " | |||||
"include watch-only addresses (see 'importaddress').\n" | |||||
"\nResult:\n" | "\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 amount " | ||||
"received by addresses with this label\n" | "received by addresses with this label\n" | ||||
" \"confirmations\" : n, (numeric) The number of " | " \"confirmations\" : n, (numeric) The number of " | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | 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, true}, | {"label", RPCArg::Type::STR, /* opt */ true, | ||||
{"count", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
{"skip", RPCArg::Type::NUM, true}, | "If set, should be a valid label name to return only " | ||||
{"include_watchonly", RPCArg::Type::BOOL, true}, | "incoming transactions\n" | ||||
" with the specified label, or \"*\" to " | |||||
"disable filtering and return all transactions."}, | |||||
{"count", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "10", | |||||
"The number of transactions to return"}, | |||||
{"skip", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "0", | |||||
"The number of transactions to skip"}, | |||||
{"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Include transactions to watch-only addresses (see " | |||||
"'importaddress')"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"label\" (string, optional) If set, should be a valid " | |||||
"label name to return only incoming transactions with the " | |||||
"specified label, or \"*\" to disable filtering and return all " | |||||
"transactions.\n" | |||||
"2. count (numeric, optional, default=10) The number of " | |||||
"transactions to return\n" | |||||
"3. skip (numeric, optional, default=0) The number of " | |||||
"transactions to skip\n" | |||||
"4. include_watchonly (bool, optional, default=false) Include " | |||||
"transactions to watch-only addresses (see 'importaddress')\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"address\":\"address\", (string) The bitcoin address of " | " \"address\":\"address\", (string) The bitcoin address of " | ||||
"the transaction.\n" | "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 " + | ||||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 4) { | ||||
"\nGet all transactions in blocks since block [blockhash], or " | "\nGet all transactions in blocks since block [blockhash], or " | ||||
"all transactions if omitted.\n" | "all 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 the wallet which were removed are returned in the " | "affecting the wallet which were removed are returned in the " | ||||
"\"removed\" array.\n", | "\"removed\" array.\n", | ||||
{ | { | ||||
{"blockhash", RPCArg::Type::STR, true}, | {"blockhash", RPCArg::Type::STR, /* opt */ true, | ||||
{"target_confirmations", RPCArg::Type::NUM, true}, | /* default_val */ "", | ||||
{"include_watchonly", RPCArg::Type::BOOL, true}, | "The block hash to list transactions since"}, | ||||
{"include_removed", RPCArg::Type::BOOL, true}, | {"target_confirmations", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "1", | |||||
"Return the nth block hash from the main chain. e.g. 1 " | |||||
"would mean the best block hash. Note: this is not used " | |||||
"as a filter, but only affects [lastblock] in the return " | |||||
"value"}, | |||||
{"include_watchonly", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Include transactions to watch-only addresses (see " | |||||
"'importaddress')"}, | |||||
{"include_removed", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "true", | |||||
"Show transactions that were removed due to a reorg in " | |||||
"the \"removed\" array\n" | |||||
" " | |||||
" (not guaranteed to work on pruned nodes)"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"blockhash\" (string, optional) The block hash to " | |||||
"list transactions since\n" | |||||
"2. target_confirmations: (numeric, optional, default=1) Return " | |||||
"the nth block hash from the main chain. e.g. 1 would mean the " | |||||
"best block hash. Note: this is not used as a filter, but only " | |||||
"affects [lastblock] in the return value\n" | |||||
"3. include_watchonly: (bool, optional, default=false) " | |||||
"Include transactions to watch-only addresses (see " | |||||
"'importaddress')\n" | |||||
"4. include_removed: (bool, optional, default=true) Show " | |||||
"transactions that were removed due to a reorg in the \"removed\" " | |||||
"array\n" | |||||
" (not " | |||||
"guaranteed to work on pruned nodes)\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"transactions\": [\n" | " \"transactions\": [\n" | ||||
" \"address\":\"address\", (string) The bitcoin address of " | " \"address\":\"address\", (string) The bitcoin address of " | ||||
"the transaction. Not present for move transactions (category = " | "the transaction. Not present for move transactions (category = " | ||||
"move).\n" | "move).\n" | ||||
" \"category\":\"send|receive\", (string) The transaction " | " \"category\":\"send|receive\", (string) The transaction " | ||||
"category. 'send' has negative amounts, 'receive' has positive " | "category. 'send' has negative amounts, 'receive' has positive " | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | static UniValue gettransaction(const Config &config, | ||||
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{"gettransaction", | RPCHelpMan{"gettransaction", | ||||
"\nGet detailed information about in-wallet transaction " | "\nGet detailed information about in-wallet transaction " | ||||
"<txid>\n", | "<txid>\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR, false}, | {"txid", RPCArg::Type::STR, /* opt */ false, | ||||
{"include_watchonly", RPCArg::Type::BOOL, true}, | /* default_val */ "", "The transaction id"}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, | |||||
/* opt */ true, /* default_val */ "false", | |||||
"Whether to include watch-only addresses in " | |||||
"balance calculation and details[]"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"txid\" (string, required) The transaction " | |||||
"id\n" | |||||
"2. \"include_watchonly\" (bool, optional, default=false) " | |||||
"Whether to include watch-only addresses in balance calculation " | |||||
"and details[]\n" | |||||
"\nResult:\n" | "\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 + | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"descendants as abandoned which will allow\n" | "descendants 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 \"stuck\" or evicted transactions.\n" | "replace \"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 and are not currently in the mempool.\n" | "in a block 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, false}, | {"txid", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "The transaction id"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"txid\" (string, required) The transaction id\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084" | HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084" | ||||
"e2115b9345e16c5cf302fc80e9d5f" | "e2115b9345e16c5cf302fc80e9d5f" | ||||
"bf5d48d\"") + | "bf5d48d\"") + | ||||
HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084" | HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084" | ||||
"e2115b9345e16c5cf302fc80e9d5f" | "e2115b9345e16c5cf302fc80e9d5f" | ||||
"bf5d48d\"")); | "bf5d48d\"")); | ||||
Show All 27 Lines | static UniValue backupwallet(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) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"backupwallet", | RPCHelpMan{ | ||||
"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, false}, | {"destination", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The destination directory or file"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | "\nExamples:\n" + HelpExampleCli("backupwallet", "\"backup.dat\"") + | ||||
"1. \"destination\" (string) The destination directory or file\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("backupwallet", "\"backup.dat\"") + | |||||
HelpExampleRpc("backupwallet", "\"backup.dat\"")); | HelpExampleRpc("backupwallet", "\"backup.dat\"")); | ||||
} | } | ||||
// 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(); | ||||
Show All 14 Lines | static UniValue keypoolrefill(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) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"keypoolrefill", | RPCHelpMan{"keypoolrefill", | ||||
"\nFills the keypool.", | "\nFills the keypool." + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | |||||
{ | { | ||||
{"newsize", RPCArg::Type::NUM, true}, | {"newsize", RPCArg::Type::NUM, /* opt */ true, | ||||
/* default_val */ "100", "The new keypool size"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
HelpRequiringPassphrase(pwallet) + | "\nExamples:\n" + HelpExampleCli("keypoolrefill", "") + | ||||
"\n" | |||||
"\nArguments\n" | |||||
"1. newsize (numeric, optional, default=100) " | |||||
"The new keypool size\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("keypoolrefill", "") + | |||||
HelpExampleRpc("keypoolrefill", "")); | HelpExampleRpc("keypoolrefill", "")); | ||||
} | } | ||||
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"); | ||||
} | } | ||||
Show All 33 Lines | static UniValue walletpassphrase(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 (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{"walletpassphrase", | RPCHelpMan{ | ||||
"walletpassphrase", | |||||
"\nStores the wallet decryption key in memory for " | "\nStores the wallet decryption key in memory for " | ||||
"'timeout' seconds.\n" | "'timeout' seconds.\n" | ||||
"This is needed prior to performing transactions " | "This is needed prior to performing transactions " | ||||
"related to private keys such as sending bitcoins\n", | "related to private keys such as sending bitcoins\n", | ||||
{ | { | ||||
{"passphrase", RPCArg::Type::STR, false}, | {"passphrase", RPCArg::Type::STR, /* opt */ false, | ||||
{"timeout", RPCArg::Type::NUM, false}, | /* default_val */ "", "The wallet passphrase"}, | ||||
{"timeout", RPCArg::Type::NUM, /* opt */ false, | |||||
/* default_val */ "", | |||||
"The time to keep the decryption key in seconds; capped " | |||||
"at 100000000 (~3 years)."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"passphrase\" (string, required) The wallet passphrase\n" | |||||
"2. timeout (numeric, required) The time to keep the " | |||||
"decryption key in seconds; capped at 100000000 (~3 years).\n" | |||||
"\nNote:\n" | "\nNote:\n" | ||||
"Issuing the walletpassphrase command while the wallet is already " | "Issuing the walletpassphrase command while the wallet is already " | ||||
"unlocked will set a new unlock\n" | "unlocked will set a new unlock\n" | ||||
"time that overrides the old one.\n" | "time that overrides the old one.\n" | ||||
"\nExamples:\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" + | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static UniValue walletpassphrasechange(const Config &config, | ||||
} | } | ||||
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{"walletpassphrasechange", | RPCHelpMan{"walletpassphrasechange", | ||||
"\nChanges the wallet passphrase from 'oldpassphrase' " | "\nChanges the wallet passphrase from 'oldpassphrase' " | ||||
"to 'newpassphrase'.\n", | "to 'newpassphrase'.\n", | ||||
{ | { | ||||
{"oldpassphrase", RPCArg::Type::STR, false}, | {"oldpassphrase", RPCArg::Type::STR, /* opt */ false, | ||||
{"newpassphrase", RPCArg::Type::STR, false}, | /* default_val */ "", "The current passphrase"}, | ||||
{"newpassphrase", RPCArg::Type::STR, /* opt */ false, | |||||
/* default_val */ "", "The new passphrase"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"oldpassphrase\" (string) The current passphrase\n" | |||||
"2. \"newpassphrase\" (string) The new passphrase\n" | |||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("walletpassphrasechange", | HelpExampleCli("walletpassphrasechange", | ||||
"\"old one\" \"new one\"") + | "\"old one\" \"new one\"") + | ||||
HelpExampleRpc("walletpassphrasechange", | HelpExampleRpc("walletpassphrasechange", | ||||
"\"old one\", \"new one\"")); | "\"old one\", \"new one\"")); | ||||
} | } | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | static UniValue encryptwallet(const Config &config, | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (!pwallet->IsCrypted() && | if (!pwallet->IsCrypted() && | ||||
(request.fHelp || request.params.size() != 1)) { | (request.fHelp || request.params.size() != 1)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"encryptwallet", | RPCHelpMan{ | ||||
"encryptwallet", | |||||
"\nEncrypts the wallet with 'passphrase'. This is for " | "\nEncrypts the wallet with 'passphrase'. This is for " | ||||
"first time encryption.\n" | "first time encryption.\n" | ||||
"After this, any calls that interact with private keys " | "After this, any calls that interact with private keys " | ||||
"such as sending or signing \n" | "such as sending or signing \n" | ||||
"will require the passphrase to be set prior the making " | "will require the passphrase to be set prior the making " | ||||
"these calls.\n" | "these calls.\n" | ||||
"Use the walletpassphrase call for this, and then " | "Use the walletpassphrase call for this, and then " | ||||
"walletlock call.\n" | "walletlock call.\n" | ||||
"If the wallet is already encrypted, use the " | "If the wallet is already encrypted, use the " | ||||
"walletpassphrasechange call.\n", | "walletpassphrasechange call.\n", | ||||
{ | { | ||||
{"passphrase", RPCArg::Type::STR, false}, | {"passphrase", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | |||||
"The pass phrase to encrypt the wallet with. It must be " | |||||
"at least 1 character, but should be long."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"passphrase\" (string) The pass phrase to encrypt the " | |||||
"wallet with. It must be at least 1 character, but should be " | |||||
"long.\n" | |||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\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 59 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"A locked transaction output will not be chosen by automatic " | "A locked transaction output will not be chosen by automatic " | ||||
"coin selection, when spending bitcoins.\n" | "coin selection, when spending bitcoins.\n" | ||||
"Locks are stored in memory only. Nodes start with zero locked " | "Locks are stored in memory only. Nodes start with zero locked " | ||||
"outputs, and the locked output list\n" | "outputs, and the locked output list\n" | ||||
"is always cleared (by virtue of process exit) when a node " | "is always cleared (by virtue of process exit) when a node " | ||||
"stops or fails.\n" | "stops or fails.\n" | ||||
"Also see the listunspent call\n", | "Also see the listunspent call\n", | ||||
{ | { | ||||
{"unlock", RPCArg::Type::BOOL, false}, | {"unlock", RPCArg::Type::BOOL, /* opt */ false, | ||||
{"transactions", | /* default_val */ "", | ||||
"Whether to unlock (true) or lock (false) the specified " | |||||
"transactions"}, | |||||
{ | |||||
"transactions", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of objects. Each object the txid " | |||||
"(string) vout (numeric)", | |||||
{ | { | ||||
{"", | |||||
RPCArg::Type::OBJ, | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | "", | ||||
{"vout", RPCArg::Type::NUM, false}, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The transaction id"}, | |||||
{"vout", RPCArg::Type::NUM, /* opt */ false, | |||||
/* default_val */ "", "The output number"}, | |||||
}, | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
true}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. unlock (boolean, required) Whether to unlock (true) " | |||||
"or lock (false) the specified transactions\n" | |||||
"2. \"transactions\" (string, optional) A json array of objects. " | |||||
"Each object the txid (string) vout (numeric)\n" | |||||
" [ (json array of json objects)\n" | |||||
" {\n" | |||||
" \"txid\":\"id\", (string) The transaction id\n" | |||||
" \"vout\": n (numeric) The output number\n" | |||||
" }\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"true|false (boolean) Whether the command was successful or " | "true|false (boolean) Whether the command was successful or " | ||||
"not\n" | "not\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nList the unspent transactions\n" + | "\nList the unspent transactions\n" + | ||||
HelpExampleCli("listunspent", "") + | HelpExampleCli("listunspent", "") + | ||||
"\nLock an unspent transaction\n" + | "\nLock an unspent transaction\n" + | ||||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | static UniValue settxfee(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 1) { | request.params.size() > 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"settxfee", | "settxfee", | ||||
"\nSet the transaction fee per kB for this wallet. Overrides " | "\nSet the transaction fee per kB for this wallet. Overrides " | ||||
"the global -paytxfee command line parameter.\n", | "the global -paytxfee command line parameter.\n", | ||||
{ | { | ||||
{"amount", RPCArg::Type::AMOUNT, false}, | {"amount", RPCArg::Type::AMOUNT, /* opt */ false, | ||||
/* default_val */ "", | |||||
"The transaction fee in " + CURRENCY_UNIT + "/kB"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. amount (numeric or string, required) The transaction " | |||||
"fee in " + | |||||
CURRENCY_UNIT + | |||||
"/kB\n" | |||||
"\nResult\n" | "\nResult\n" | ||||
"true|false (boolean) Returns true if successful\n" | "true|false (boolean) Returns true if successful\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("settxfee", "0.00001") + | HelpExampleCli("settxfee", "0.00001") + | ||||
HelpExampleRpc("settxfee", "0.00001")); | HelpExampleRpc("settxfee", "0.00001")); | ||||
} | } | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"loadwallet", | RPCHelpMan{"loadwallet", | ||||
"\nLoads a wallet from a wallet file or directory." | "\nLoads a wallet from a wallet file or directory." | ||||
"\nNote that all wallet command-line options used when " | "\nNote that all wallet command-line options used when " | ||||
"starting bitcoind will be" | "starting bitcoind will be" | ||||
"\napplied to the new wallet (eg -zapwallettxes, " | "\napplied to the new wallet (eg -zapwallettxes, " | ||||
"upgradewallet, rescan, etc).\n", | "upgradewallet, rescan, etc).\n", | ||||
{ | { | ||||
{"filename", RPCArg::Type::STR, false}, | {"filename", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", | |||||
"The wallet directory or .dat file."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"filename\" (string, required) The wallet directory or " | |||||
".dat file.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"name\" : <wallet_name>, (string) The wallet name if " | " \"name\" : <wallet_name>, (string) The wallet name if " | ||||
"loaded successfully.\n" | "loaded successfully.\n" | ||||
" \"warning\" : <warning>, (string) Warning message if " | " \"warning\" : <warning>, (string) Warning message if " | ||||
"wallet was not loaded cleanly.\n" | "wallet was not loaded cleanly.\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
static UniValue createwallet(const Config &config, | static UniValue createwallet(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"createwallet", | RPCHelpMan{"createwallet", | ||||
"\nCreates and loads a new wallet.\n", | "\nCreates and loads a new wallet.\n", | ||||
{ | { | ||||
{"wallet_name", RPCArg::Type::STR, false}, | {"wallet_name", RPCArg::Type::STR, /* opt */ false, | ||||
{"disable_private_keys", RPCArg::Type::BOOL, true}, | /* default_val */ "", | ||||
{"blank", RPCArg::Type::BOOL, true}, | "The name for the new wallet. If this is a path, " | ||||
"the wallet will be created at the path location."}, | |||||
{"disable_private_keys", RPCArg::Type::BOOL, | |||||
/* opt */ true, /* default_val */ "false", | |||||
"Disable the possibility of private keys (only " | |||||
"watchonlys are possible in this mode)."}, | |||||
{"blank", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"Create a blank wallet. A blank wallet has no keys " | |||||
"or HD seed. One can be set using sethdseed.\n"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"wallet_name\" (string, required) The name for the new " | |||||
"wallet. If this is a path, the wallet will be created at the path " | |||||
"location.\n" | |||||
"2. disable_private_keys (boolean, optional, default: false) " | |||||
"Disable the possibility of private keys (only watchonlys are " | |||||
"possible in this mode).\n" | |||||
"3. blank (boolean, optional, default: false) Create a blank " | |||||
"wallet. A blank wallet has no keys or HD seed. One can be set " | |||||
"using sethdseed.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"name\" : <wallet_name>, (string) The wallet name if " | " \"name\" : <wallet_name>, (string) The wallet name if " | ||||
"created successfully. If the wallet was created using a full " | "created successfully. If the wallet was created using a full " | ||||
"path, the wallet_name will be the full path.\n" | "path, the wallet_name will be the full path.\n" | ||||
" \"warning\" : <warning>, (string) Warning message if " | " \"warning\" : <warning>, (string) Warning message if " | ||||
"wallet was not loaded cleanly.\n" | "wallet was not loaded cleanly.\n" | ||||
"}\n" | "}\n" | ||||
▲ Show 20 Lines • Show All 51 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() + | .ToString() + | ||||
"\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, /* opt */ true, | ||||
{"include_unsafe", RPCArg::Type::BOOL, 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, | ||||
{"minimumAmount", RPCArg::Type::AMOUNT, true}, | /* default_val */ "", | ||||
{"maximumAmount", RPCArg::Type::AMOUNT, true}, | "JSON with query options", | ||||
{"maximumCount", RPCArg::Type::NUM, true}, | { | ||||
{"minimumSumAmount", RPCArg::Type::AMOUNT, true}, | {"minimumAmount", RPCArg::Type::AMOUNT, /* opt */ true, | ||||
/* default_val */ "0", | |||||
"Minimum value of each UTXO in " + CURRENCY_UNIT + | |||||
""}, | |||||
{"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() + | .ToString() + | ||||
"\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, | ||||
{"vout_index", RPCArg::Type::NUM, 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, | |||||
/* opt */ true, /* default_val */ "", | |||||
"The zero-based output index, before a " | |||||
"change output is added."}, | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
true, | |||||
"options"}, | "options"}, | ||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\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, /* opt */ false, | |||||
/* default_val */ "", "The transaction hex string"}, | |||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | "prevtxs", | ||||
{"prevtxs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of previous dependent transaction " | |||||
"outputs", | |||||
{ | { | ||||
{"", | |||||
RPCArg::Type::OBJ, | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | "", | ||||
{"vout", RPCArg::Type::NUM, false}, | RPCArg::Type::OBJ, | ||||
{"scriptPubKey", RPCArg::Type::STR_HEX, false}, | /* opt */ false, | ||||
{"redeemScript", RPCArg::Type::STR_HEX, false}, | /* default_val */ "", | ||||
{"amount", RPCArg::Type::AMOUNT, false}, | "", | ||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The transaction id"}, | |||||
{"vout", RPCArg::Type::NUM, /* opt */ 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\""}, | ||||
}} | |||||
.ToString() + | |||||
"\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() + | .ToString() + | ||||
"\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() + | .ToString() + | ||||
"\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 191 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() + | .ToString() + | ||||
"\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() + | .ToString() + | ||||
"\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() + | .ToString() + | ||||
"\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", "") + | }} | ||||
.ToString() + | |||||
"\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 111 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"}, | |||||
}} | |||||
.ToString() + | |||||
"\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 48 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, | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | "", | ||||
{"vout", RPCArg::Type::NUM, false}, | RPCArg::Type::OBJ, | ||||
{"sequence", RPCArg::Type::NUM, true}, | /* opt */ false, | ||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"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, | |||||
{ | { | ||||
{"address", RPCArg::Type::AMOUNT, true}, | "", | ||||
}, | |||||
true}, | |||||
{"", | |||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"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 + ""}, | |||||
}, | |||||
}, | |||||
{ | { | ||||
{"data", RPCArg::Type::STR_HEX, true}, | "", | ||||
RPCArg::Type::OBJ, | |||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"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() + | .ToString() + | ||||
"\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 110 Lines • Show Last 20 Lines |