Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show All 20 Lines | |||||
#include <util/bip32.h> | #include <util/bip32.h> | ||||
#include <util/error.h> | #include <util/error.h> | ||||
#include <util/message.h> // For MessageSign() | #include <util/message.h> // For MessageSign() | ||||
#include <util/moneystr.h> | #include <util/moneystr.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <util/url.h> | #include <util/url.h> | ||||
#include <util/vector.h> | |||||
#include <wallet/coincontrol.h> | #include <wallet/coincontrol.h> | ||||
#include <wallet/rpcwallet.h> | #include <wallet/rpcwallet.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
#include <wallet/walletdb.h> | #include <wallet/walletdb.h> | ||||
#include <wallet/walletutil.h> | #include <wallet/walletutil.h> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"the default label \"\" is used. It can also be set to the empty " | "the default label \"\" is used. It can also be set to the empty " | ||||
"string \"\" to represent the default label. The label does not " | "string \"\" to represent the default label. The label does not " | ||||
"need to exist, it will be created if there is no label by the " | "need to exist, it will be created if there is no label by the " | ||||
"given name."}, | "given name."}, | ||||
{"address_type", RPCArg::Type::STR, | {"address_type", RPCArg::Type::STR, | ||||
/* default */ "set by -addresstype", | /* default */ "set by -addresstype", | ||||
"The address type to use. Options are \"legacy\"."}, | "The address type to use. Options are \"legacy\"."}, | ||||
}, | }, | ||||
RPCResult{"\"address\" (string) The new bitcoin address\n"}, | RPCResult{RPCResult::Type::STR, "address", "The new bitcoin address"}, | ||||
RPCExamples{HelpExampleCli("getnewaddress", "") + | RPCExamples{HelpExampleCli("getnewaddress", "") + | ||||
HelpExampleRpc("getnewaddress", "")}, | HelpExampleRpc("getnewaddress", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
if (!pwallet->CanGetAddresses()) { | if (!pwallet->CanGetAddresses()) { | ||||
Show All 34 Lines | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getrawchangeaddress", | "getrawchangeaddress", | ||||
"Returns a new Bitcoin address, for receiving change.\n" | "Returns a new Bitcoin address, for receiving change.\n" | ||||
"This is for use with raw transactions, NOT normal use.\n", | "This is for use with raw transactions, NOT normal use.\n", | ||||
{}, | {}, | ||||
RPCResult{"\"address\" (string) The address\n"}, | RPCResult{RPCResult::Type::STR, "address", "The address"}, | ||||
RPCExamples{HelpExampleCli("getrawchangeaddress", "") + | RPCExamples{HelpExampleCli("getrawchangeaddress", "") + | ||||
HelpExampleRpc("getrawchangeaddress", "")}, | HelpExampleRpc("getrawchangeaddress", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
if (!pwallet->CanGetAddresses(true)) { | if (!pwallet->CanGetAddresses(true)) { | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"less bitcoins than you enter in the amount field."}, | "less bitcoins than you enter in the amount field."}, | ||||
{"avoid_reuse", RPCArg::Type::BOOL, | {"avoid_reuse", RPCArg::Type::BOOL, | ||||
/* default */ "true", | /* default */ "true", | ||||
"(only available if avoid_reuse wallet flag is set) Avoid " | "(only available if avoid_reuse wallet flag is set) Avoid " | ||||
"spending from dirty addresses; addresses are considered\n" | "spending from dirty addresses; addresses are considered\n" | ||||
" dirty if they have previously " | " dirty if they have previously " | ||||
"been used in a transaction."}, | "been used in a transaction."}, | ||||
}, | }, | ||||
RPCResult{"\"txid\" (string) The transaction id.\n"}, | RPCResult{RPCResult::Type::STR_HEX, "txid", "The transaction id."}, | ||||
RPCExamples{ | RPCExamples{ | ||||
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\"") + | ||||
HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44" | HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44" | ||||
"Jvaydd\" 0.1 \"\" \"\" true") + | "Jvaydd\" 0.1 \"\" \"\" true") + | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | static UniValue listaddressgroupings(const Config &config, | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"listaddressgroupings", | "listaddressgroupings", | ||||
"Lists groups of addresses which have had their common ownership\n" | "Lists groups of addresses which have had their common ownership\n" | ||||
"made public by common use as inputs or as the resulting change\n" | "made public by common use as inputs or as the resulting change\n" | ||||
"in past transactions\n", | "in past transactions\n", | ||||
{}, | {}, | ||||
RPCResult{"[\n" | RPCResult{RPCResult::Type::ARR, | ||||
" [\n" | "", | ||||
" [\n" | "", | ||||
" \"address\", (string) The bitcoin address\n" | { | ||||
" amount, (numeric) The amount in " + | {RPCResult::Type::ARR, | ||||
CURRENCY_UNIT + | "", | ||||
"\n" | "", | ||||
" \"label\" (string, optional) The label\n" | { | ||||
" ]\n" | {RPCResult::Type::ARR, | ||||
" ,...\n" | "", | ||||
" ]\n" | "", | ||||
" ,...\n" | { | ||||
"]\n"}, | {RPCResult::Type::STR, "address", | ||||
"The bitcoin address"}, | |||||
{RPCResult::Type::STR_AMOUNT, "amount", | |||||
"The amount in " + CURRENCY_UNIT}, | |||||
{RPCResult::Type::STR, "label", | |||||
/* optional */ true, "The label"}, | |||||
}}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("listaddressgroupings", "") + | RPCExamples{HelpExampleCli("listaddressgroupings", "") + | ||||
HelpExampleRpc("listaddressgroupings", "")}, | HelpExampleRpc("listaddressgroupings", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
Show All 37 Lines | RPCHelpMan{ | ||||
"Sign a message with the private key of an address" + | "Sign a message with the private key of an address" + | ||||
HelpRequiringPassphrase(pwallet) + "\n", | HelpRequiringPassphrase(pwallet) + "\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The bitcoin address to use for the private key."}, | "The bitcoin address to use for the private key."}, | ||||
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, | {"message", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The message to create a signature of."}, | "The message to create a signature of."}, | ||||
}, | }, | ||||
RPCResult{"\"signature\" (string) The signature of the " | RPCResult{RPCResult::Type::STR, "signature", | ||||
"message encoded in base 64\n"}, | "The signature of the message encoded in base 64"}, | ||||
RPCExamples{ | RPCExamples{ | ||||
"\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( | ||||
"signmessage", | "signmessage", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + | ||||
"\nVerify the signature\n" + | "\nVerify the signature\n" + | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Returns the total amount received by the given address in " | "Returns 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, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The bitcoin address for transactions."}, | "The bitcoin address for transactions."}, | ||||
{"minconf", RPCArg::Type::NUM, /* default */ "1", | {"minconf", RPCArg::Type::NUM, /* default */ "1", | ||||
"Only include transactions confirmed at least this many times."}, | "Only include transactions confirmed at least this many times."}, | ||||
}, | }, | ||||
RPCResult{"amount (numeric) The total amount in " + CURRENCY_UNIT + | RPCResult{RPCResult::Type::STR_AMOUNT, "amount", | ||||
" received at this address.\n"}, | "The total amount in " + CURRENCY_UNIT + | ||||
" received at this address."}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\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\"") + | ||||
"\nThe amount including unconfirmed transactions, zero " | "\nThe amount including unconfirmed transactions, zero " | ||||
"confirmations\n" + | "confirmations\n" + | ||||
HelpExampleCli("getreceivedbyaddress", | HelpExampleCli("getreceivedbyaddress", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") + | ||||
Show All 30 Lines | RPCHelpMan{ | ||||
"Returns the total amount received by addresses with <label> in " | "Returns the total amount received by addresses with <label> in " | ||||
"transactions with at least [minconf] confirmations.\n", | "transactions with at least [minconf] confirmations.\n", | ||||
{ | { | ||||
{"label", RPCArg::Type::STR, RPCArg::Optional::NO, | {"label", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The selected label, may be the default label using \"\"."}, | "The selected label, may be the default label using \"\"."}, | ||||
{"minconf", RPCArg::Type::NUM, /* default */ "1", | {"minconf", RPCArg::Type::NUM, /* default */ "1", | ||||
"Only include transactions confirmed at least this many times."}, | "Only include transactions confirmed at least this many times."}, | ||||
}, | }, | ||||
RPCResult{"amount (numeric) The total amount in " + | RPCResult{RPCResult::Type::STR_AMOUNT, "amount", | ||||
CURRENCY_UNIT + " received for this label.\n"}, | "The total amount in " + CURRENCY_UNIT + | ||||
" received for this label."}, | |||||
RPCExamples{"\nAmount received by the default label with at least 1 " | RPCExamples{"\nAmount received by the default label with at least 1 " | ||||
"confirmation\n" + | "confirmation\n" + | ||||
HelpExampleCli("getreceivedbylabel", "\"\"") + | HelpExampleCli("getreceivedbylabel", "\"\"") + | ||||
"\nAmount received at the tabby label including " | "\nAmount received at the tabby label including " | ||||
"unconfirmed amounts with zero confirmations\n" + | "unconfirmed amounts with zero confirmations\n" + | ||||
HelpExampleCli("getreceivedbylabel", "\"tabby\" 0") + | HelpExampleCli("getreceivedbylabel", "\"tabby\" 0") + | ||||
"\nThe amount with at least 6 confirmations\n" + | "\nThe amount with at least 6 confirmations\n" + | ||||
HelpExampleCli("getreceivedbylabel", "\"tabby\" 6") + | HelpExampleCli("getreceivedbylabel", "\"tabby\" 6") + | ||||
Show All 39 Lines | RPCHelpMan{ | ||||
"Also include balance in watch-only addresses (see " | "Also include balance in watch-only addresses (see " | ||||
"'importaddress')"}, | "'importaddress')"}, | ||||
{"avoid_reuse", RPCArg::Type::BOOL, | {"avoid_reuse", RPCArg::Type::BOOL, | ||||
/* default */ "true", | /* default */ "true", | ||||
"(only available if avoid_reuse wallet flag is set) Do not " | "(only available if avoid_reuse wallet flag is set) Do not " | ||||
"include balance in dirty outputs; addresses are considered dirty " | "include balance in dirty outputs; addresses are considered dirty " | ||||
"if they have previously been used in a transaction."}, | "if they have previously been used in a transaction."}, | ||||
}, | }, | ||||
RPCResult{"amount (numeric) The total amount in " + | RPCResult{RPCResult::Type::STR_AMOUNT, "amount", | ||||
CURRENCY_UNIT + " received for this wallet.\n"}, | "The total amount in " + CURRENCY_UNIT + | ||||
" received for this wallet."}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\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" + | ||||
HelpExampleCli("getbalance", "\"*\" 6") + "\nAs a JSON-RPC call\n" + | HelpExampleCli("getbalance", "\"*\" 6") + "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("getbalance", "\"*\", 6")}, | HelpExampleRpc("getbalance", "\"*\", 6")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
" If no addresses are specified " | " If no addresses are specified " | ||||
"here, the sender pays the fee.", | "here, the sender pays the fee.", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | {"address", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | ||||
"Subtract fee from this address"}, | "Subtract fee from this address"}, | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{RPCResult::Type::STR_HEX, "txid", | ||||
"\"txid\" (string) The transaction id for the " | "The transaction id for the send. Only 1 transaction is " | ||||
"send. Only 1 transaction is created regardless of \n" | "created regardless of the number of addresses."}, | ||||
" the number of addresses.\n"}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\nSend two amounts to two different addresses:\n" + | "\nSend two amounts to two different addresses:\n" + | ||||
HelpExampleCli( | HelpExampleCli( | ||||
"sendmany", | "sendmany", | ||||
"\"\" " | "\"\" " | ||||
"\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | "\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | ||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") + | "\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") + | ||||
"\nSend two amounts to two different addresses setting the " | "\nSend two amounts to two different addresses setting the " | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{ | { | ||||
{"key", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | {"key", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | ||||
"bitcoin address or hex-encoded public key"}, | "bitcoin address or hex-encoded public key"}, | ||||
}, | }, | ||||
}, | }, | ||||
{"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, | {"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, | ||||
"A label to assign the addresses to."}, | "A label to assign the addresses to."}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"address\":\"multisigaddress\", (string) The value of " | "", | ||||
"the new multisig address.\n" | "", | ||||
" \"redeemScript\":\"script\" (string) The string " | { | ||||
"value of the hex-encoded redemption script.\n" | {RPCResult::Type::STR, "address", | ||||
" \"descriptor\":\"descriptor\" (string) The descriptor " | "The value of the new multisig address"}, | ||||
"for this multisig\n" | {RPCResult::Type::STR_HEX, "redeemScript", | ||||
"}\n"}, | "The string value of the hex-encoded redemption script"}, | ||||
{RPCResult::Type::STR, "descriptor", | |||||
"The descriptor for this multisig"}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\nAdd a multisig address from 2 addresses\n" + | "\nAdd a multisig address from 2 addresses\n" + | ||||
HelpExampleCli("addmultisigaddress", | HelpExampleCli("addmultisigaddress", | ||||
"2 " | "2 " | ||||
"\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\"," | "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\"," | ||||
"\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + | "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("addmultisigaddress", | HelpExampleRpc("addmultisigaddress", | ||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{"include_watchonly", RPCArg::Type::BOOL, | {"include_watchonly", RPCArg::Type::BOOL, | ||||
/* default */ "true for watch-only wallets, otherwise false", | /* default */ "true for watch-only wallets, otherwise false", | ||||
"Whether to include watch-only addresses (see 'importaddress')."}, | "Whether to include watch-only addresses (see 'importaddress')."}, | ||||
{"address_filter", RPCArg::Type::STR, | {"address_filter", RPCArg::Type::STR, | ||||
RPCArg::Optional::OMITTED_NAMED_ARG, | RPCArg::Optional::OMITTED_NAMED_ARG, | ||||
"If present, only return information on this address."}, | "If present, only return information on this address."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"[\n" | RPCResult::Type::ARR, | ||||
" {\n" | "", | ||||
" \"involvesWatchonly\" : true, (bool) Only returns true " | "", | ||||
"if imported addresses were involved in transaction\n" | { | ||||
" \"address\" : \"receivingaddress\", (string) The receiving " | {RPCResult::Type::OBJ, | ||||
"address\n" | "", | ||||
" \"amount\" : x.xxx, (numeric) The total " | "", | ||||
"amount in " + | { | ||||
CURRENCY_UNIT + | {RPCResult::Type::BOOL, "involvesWatchonly", | ||||
" received by the address\n" | "Only returns true if imported addresses were involved " | ||||
" \"confirmations\" : n, (numeric) The number of " | "in transaction"}, | ||||
"confirmations of the most recent transaction included\n" | {RPCResult::Type::STR, "address", "The receiving address"}, | ||||
" \"label\" : \"label\", (string) The label of " | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
"the receiving address. The default label is \"\".\n" | "The total amount in " + CURRENCY_UNIT + | ||||
" \"txids\": [\n" | " received by the address"}, | ||||
" \"txid\", (string) The ids of " | {RPCResult::Type::NUM, "confirmations", | ||||
"transactions received with the address \n" | "The number of confirmations of the most recent " | ||||
" ...\n" | "transaction included"}, | ||||
" ]\n" | {RPCResult::Type::STR, "label", | ||||
" }\n" | "The label of the receiving address. The default label " | ||||
" ,...\n" | "is \"\""}, | ||||
"]\n"}, | {RPCResult::Type::ARR, | ||||
"txids", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::STR_HEX, "txid", | |||||
"The ids of transactions received with the address"}, | |||||
}}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("listreceivedbyaddress", "") + | HelpExampleCli("listreceivedbyaddress", "") + | ||||
HelpExampleCli("listreceivedbyaddress", "6 true") + | HelpExampleCli("listreceivedbyaddress", "6 true") + | ||||
HelpExampleRpc("listreceivedbyaddress", "6, true, true") + | HelpExampleRpc("listreceivedbyaddress", "6, true, true") + | ||||
HelpExampleRpc( | HelpExampleRpc( | ||||
"listreceivedbyaddress", | "listreceivedbyaddress", | ||||
"6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")}, | "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")}, | ||||
} | } | ||||
Show All 25 Lines | RPCHelpMan{ | ||||
"The minimum number of confirmations before payments are " | "The minimum number of confirmations before payments are " | ||||
"included."}, | "included."}, | ||||
{"include_empty", RPCArg::Type::BOOL, /* default */ "false", | {"include_empty", RPCArg::Type::BOOL, /* default */ "false", | ||||
"Whether to include labels that haven't received any payments."}, | "Whether to include labels that haven't received any payments."}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, | {"include_watchonly", RPCArg::Type::BOOL, | ||||
/* default */ "true for watch-only wallets, otherwise false", | /* default */ "true for watch-only wallets, otherwise false", | ||||
"Whether to include watch-only addresses (see 'importaddress')."}, | "Whether to include watch-only addresses (see 'importaddress')."}, | ||||
}, | }, | ||||
RPCResult{"[\n" | RPCResult{ | ||||
" {\n" | RPCResult::Type::ARR, | ||||
" \"involvesWatchonly\" : true, (bool) Only returns " | "", | ||||
"true if imported addresses were involved in transaction\n" | "", | ||||
" \"amount\" : x.xxx, (numeric) The total " | { | ||||
"amount received by addresses with this label\n" | {RPCResult::Type::OBJ, | ||||
" \"confirmations\" : n, (numeric) The number of " | "", | ||||
"confirmations of the most recent transaction included\n" | "", | ||||
" \"label\" : \"label\" (string) The label of " | { | ||||
"the receiving address. The default label is \"\".\n" | {RPCResult::Type::BOOL, "involvesWatchonly", | ||||
" }\n" | "Only returns true if imported addresses were involved " | ||||
" ,...\n" | "in transaction"}, | ||||
"]\n"}, | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
"The total amount received by addresses with this label"}, | |||||
{RPCResult::Type::NUM, "confirmations", | |||||
"The number of confirmations of the most recent " | |||||
"transaction included"}, | |||||
{RPCResult::Type::STR, "label", | |||||
"The label of the receiving address. The default label " | |||||
"is \"\""}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("listreceivedbylabel", "") + | RPCExamples{HelpExampleCli("listreceivedbylabel", "") + | ||||
HelpExampleCli("listreceivedbylabel", "6 true") + | HelpExampleCli("listreceivedbylabel", "6 true") + | ||||
HelpExampleRpc("listreceivedbylabel", "6, true, true")}, | HelpExampleRpc("listreceivedbylabel", "6, true, true")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { | ||||
if (fLong) { | if (fLong) { | ||||
WalletTxToJSON(pwallet->chain(), wtx, entry); | WalletTxToJSON(pwallet->chain(), wtx, entry); | ||||
} | } | ||||
ret.push_back(entry); | ret.push_back(entry); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static const std::string TransactionDescriptionString() { | static const std::vector<RPCResult> TransactionDescriptionString() { | ||||
return " \"confirmations\": n, (numeric) The " | return { | ||||
"number of confirmations for the transaction. Negative " | {RPCResult::Type::NUM, "confirmations", | ||||
"The number of confirmations for the transaction. Negative " | |||||
"confirmations means the\n" | "confirmations means the\n" | ||||
" transaction " | "transaction conflicted that many blocks ago."}, | ||||
"conflicted that many blocks ago.\n" | {RPCResult::Type::BOOL, "generated", | ||||
" \"generated\": xxx, (bool) Only " | "Only present if transaction only input is a coinbase one."}, | ||||
"present if transaction only input is a coinbase one.\n" | {RPCResult::Type::BOOL, "trusted", | ||||
" \"trusted\": xxx, (bool) Only " | "Only present if we consider transaction to be trusted and so safe to " | ||||
"present if we consider transaction to be trusted and so safe to " | "spend from."}, | ||||
"spend from.\n" | {RPCResult::Type::STR_HEX, "blockhash", | ||||
" \"blockhash\": \"hashvalue\", (string) The " | "The block hash containing the transaction."}, | ||||
"block hash containing the transaction.\n" | {RPCResult::Type::NUM, "blockheight", | ||||
" \"blockheight\": n, (numeric) The " | "The block height containing the transaction."}, | ||||
"block height containing the transaction.\n" | {RPCResult::Type::NUM, "blockindex", | ||||
" \"blockindex\": n, (numeric) The " | "The index of the transaction in the block that includes it."}, | ||||
"index of the transaction in the block that includes it.\n" | {RPCResult::Type::NUM_TIME, "blocktime", | ||||
" \"blocktime\": xxx, (numeric) The " | "The block time expressed in " + UNIX_EPOCH_TIME + "."}, | ||||
"block time expressed in " + | {RPCResult::Type::STR_HEX, "txid", "The transaction id."}, | ||||
UNIX_EPOCH_TIME + | {RPCResult::Type::ARR, | ||||
".\n" | "walletconflicts", | ||||
" \"txid\": \"transactionid\", (string) The " | "Conflicting transaction ids.", | ||||
"transaction id.\n" | { | ||||
" \"walletconflicts\": [ (array) " | {RPCResult::Type::STR_HEX, "txid", "The transaction id."}, | ||||
"Conflicting transaction ids.\n" | }}, | ||||
" \"txid\", (string) The " | {RPCResult::Type::NUM_TIME, "time", | ||||
"transaction id.\n" | "The transaction time expressed in " + UNIX_EPOCH_TIME + "."}, | ||||
" ...\n" | {RPCResult::Type::NUM_TIME, "timereceived", | ||||
" ],\n" | "The time received expressed in " + UNIX_EPOCH_TIME + "."}, | ||||
" \"time\": xxx, (numeric) The " | {RPCResult::Type::STR, "comment", | ||||
"transaction time expressed in " + | "If a comment is associated with the transaction, only present if not " | ||||
UNIX_EPOCH_TIME + | "empty."}, | ||||
".\n" | }; | ||||
" \"timereceived\": xxx, (numeric) The " | |||||
"time received expressed in " + | |||||
UNIX_EPOCH_TIME + | |||||
".\n" | |||||
" \"comment\": \"...\", (string) If a " | |||||
"comment is associated with the transaction, only present if not " | |||||
"empty.\n"; | |||||
} | } | ||||
UniValue listtransactions(const Config &config, const JSONRPCRequest &request) { | UniValue listtransactions(const Config &config, const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
const CWallet *const pwallet = wallet.get(); | const CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
Show All 15 Lines | RPCHelpMan{ | ||||
{"skip", RPCArg::Type::NUM, /* default */ "0", | {"skip", RPCArg::Type::NUM, /* default */ "0", | ||||
"The number of transactions to skip"}, | "The number of transactions to skip"}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, | {"include_watchonly", RPCArg::Type::BOOL, | ||||
/* default */ "true for watch-only wallets, otherwise false", | /* default */ "true for watch-only wallets, otherwise false", | ||||
"Include transactions to watch-only addresses (see " | "Include transactions to watch-only addresses (see " | ||||
"'importaddress')"}, | "'importaddress')"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"[\n" | RPCResult::Type::ARR, | ||||
" {\n" | "", | ||||
" \"involvesWatchonly\": xxx, (bool) Only returns true if " | "", | ||||
"imported addresses were involved in transaction.\n" | { | ||||
" \"address\":\"address\", (string) The bitcoin address of " | {RPCResult::Type::OBJ, "", "", | ||||
"the transaction.\n" | Cat(Cat<std::vector<RPCResult>>( | ||||
" \"category\": (string) The transaction " | { | ||||
"category.\n" | {RPCResult::Type::BOOL, "involvesWatchonly", | ||||
"Only returns true if imported addresses were " | |||||
"involved in transaction."}, | |||||
{RPCResult::Type::STR, "address", | |||||
"The bitcoin address of the transaction."}, | |||||
{RPCResult::Type::STR, "category", | |||||
"The transaction category.\n" | |||||
" \"send\" Transactions sent.\n" | "\"send\" Transactions sent.\n" | ||||
" \"receive\" Non-coinbase " | "\"receive\" Non-coinbase " | ||||
"transactions received.\n" | "transactions received.\n" | ||||
" \"generate\" Coinbase transactions " | "\"generate\" Coinbase transactions " | ||||
"received with more than 100 confirmations.\n" | "received with more than 100 confirmations.\n" | ||||
" \"immature\" Coinbase transactions " | "\"immature\" Coinbase transactions " | ||||
"received with 100 or fewer confirmations.\n" | "received with 100 or fewer confirmations.\n" | ||||
" \"orphan\" Orphaned coinbase " | "\"orphan\" Orphaned coinbase " | ||||
"transactions received.\n" | "transactions received."}, | ||||
" \"amount\": x.xxx, (numeric) The amount in " + | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
CURRENCY_UNIT + | "The amount in " + CURRENCY_UNIT + | ||||
". This is negative for the 'send' category, and is positive\n" | ". This is negative for the 'send' category, " | ||||
" for all other categories\n" | "and is positive\n" | ||||
" \"label\": \"label\", (string) A comment for the " | "for all other categories"}, | ||||
"address/transaction, if any\n" | {RPCResult::Type::STR, "label", | ||||
" \"vout\": n, (numeric) the vout value\n" | "A comment for the address/transaction, if any"}, | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee " | {RPCResult::Type::NUM, "vout", "the vout value"}, | ||||
"in " + | {RPCResult::Type::STR_AMOUNT, "fee", | ||||
CURRENCY_UNIT + | "The amount of the fee in " + CURRENCY_UNIT + | ||||
". This is negative and only available for the \n" | ". This is negative and only available for " | ||||
" 'send' category of " | |||||
"transactions.\n" + | |||||
TransactionDescriptionString() + | |||||
" \"abandoned\": xxx (bool) 'true' if the transaction " | |||||
"has been abandoned (inputs are respendable). Only available for " | |||||
"the \n" | "the\n" | ||||
" 'send' category of " | "'send' category of transactions."}, | ||||
"transactions.\n" | }, | ||||
" }\n" | TransactionDescriptionString()), | ||||
"]\n"}, | { | ||||
{RPCResult::Type::BOOL, "abandoned", | |||||
"'true' if the transaction has been abandoned " | |||||
"(inputs are respendable). Only available for the \n" | |||||
"'send' category of transactions."}, | |||||
})}, | |||||
}}, | |||||
RPCExamples{"\nList the most recent 10 transactions in the systems\n" + | RPCExamples{"\nList the most recent 10 transactions in the systems\n" + | ||||
HelpExampleCli("listtransactions", "") + | HelpExampleCli("listtransactions", "") + | ||||
"\nList transactions 100 to 120\n" + | "\nList transactions 100 to 120\n" + | ||||
HelpExampleCli("listtransactions", "\"*\" 20 100") + | HelpExampleCli("listtransactions", "\"*\" 20 100") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("listtransactions", "\"*\", 20, 100")}, | HelpExampleRpc("listtransactions", "\"*\", 20, 100")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"'importaddress')"}, | "'importaddress')"}, | ||||
{"include_removed", RPCArg::Type::BOOL, /* default */ "true", | {"include_removed", RPCArg::Type::BOOL, /* default */ "true", | ||||
"Show transactions that were removed due to a reorg in the " | "Show transactions that were removed due to a reorg in the " | ||||
"\"removed\" array\n" | "\"removed\" array\n" | ||||
" (not " | " (not " | ||||
"guaranteed to work on pruned nodes)"}, | "guaranteed to work on pruned nodes)"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"transactions\": [\n" | "", | ||||
" \"involvesWatchonly\": xxx, (bool) Only returns true if " | "", | ||||
"imported addresses were involved in transaction.\n" | { | ||||
" \"address\":\"address\", (string) The bitcoin address of " | {RPCResult::Type::ARR, | ||||
"the transaction.\n" | "transactions", | ||||
" \"category\": (string) The transaction " | "", | ||||
"category.\n" | { | ||||
" \"send\" Transactions sent.\n" | {RPCResult::Type::OBJ, "", "", | ||||
Cat(Cat<std::vector<RPCResult>>( | |||||
{ | |||||
{RPCResult::Type::BOOL, "involvesWatchonly", | |||||
"Only returns true if imported addresses " | |||||
"were involved in transaction."}, | |||||
{RPCResult::Type::STR, "address", | |||||
"The bitcoin address of the transaction."}, | |||||
{RPCResult::Type::STR, "category", | |||||
"The transaction category.\n" | |||||
"\"send\" Transactions " | |||||
"sent.\n" | |||||
" \"receive\" Non-coinbase " | "\"receive\" Non-coinbase " | ||||
"transactions received.\n" | "transactions received.\n" | ||||
" \"generate\" Coinbase transactions " | "\"generate\" Coinbase " | ||||
"received with more than 100 confirmations.\n" | "transactions received with more than 100 " | ||||
" \"immature\" Coinbase transactions " | "confirmations.\n" | ||||
"received with 100 or fewer confirmations.\n" | "\"immature\" Coinbase " | ||||
" \"orphan\" Orphaned coinbase " | "transactions received with 100 or fewer " | ||||
"transactions received.\n" | "confirmations.\n" | ||||
" \"amount\": x.xxx, (numeric) The amount in " + | "\"orphan\" Orphaned " | ||||
CURRENCY_UNIT + | "coinbase transactions received."}, | ||||
". This is negative for the 'send' category, and is positive\n" | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
" for all other " | "The amount in " + CURRENCY_UNIT + | ||||
"categories\n" | ". This is negative for the 'send' " | ||||
" \"vout\" : n, (numeric) the vout value\n" | "category, and is positive\n" | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee " | "for all other categories"}, | ||||
"in " + | {RPCResult::Type::NUM, "vout", | ||||
CURRENCY_UNIT + | "the vout value"}, | ||||
". This is negative and only available for the 'send' category of " | {RPCResult::Type::STR_AMOUNT, "fee", | ||||
"transactions.\n" + | "The amount of the fee in " + CURRENCY_UNIT + | ||||
TransactionDescriptionString() + | ". This is negative and only available " | ||||
" \"abandoned\": xxx, (bool) 'true' if the transaction " | "for the\n" | ||||
"has been abandoned (inputs are respendable). Only available for " | "'send' category of transactions."}, | ||||
"the 'send' category of transactions.\n" | }, | ||||
" \"comment\": \"...\", (string) If a comment is " | TransactionDescriptionString()), | ||||
"associated with the transaction.\n" | { | ||||
" \"label\" : \"label\" (string) A comment for the " | {RPCResult::Type::BOOL, "abandoned", | ||||
"address/transaction, if any\n" | "'true' if the transaction has been abandoned " | ||||
" \"to\": \"...\", (string) If a comment to is " | "(inputs are respendable). Only available for " | ||||
"associated with the transaction.\n" | "the \n" | ||||
" ],\n" | "'send' category of transactions."}, | ||||
" \"removed\": [\n" | {RPCResult::Type::STR, "comment", | ||||
"If a comment is associated with the " | |||||
"transaction."}, | |||||
{RPCResult::Type::STR, "label", | |||||
"A comment for the address/transaction, if any"}, | |||||
{RPCResult::Type::STR, "to", | |||||
"If a comment to is associated with the " | |||||
"transaction."}, | |||||
})}, | |||||
}}, | |||||
{RPCResult::Type::ARR, | |||||
"removed", | |||||
" <structure is the same as \"transactions\" above, only " | "<structure is the same as \"transactions\" above, only " | ||||
"present if include_removed=true>\n" | "present if include_removed=true>\n" | ||||
" Note: transactions that were re-added in the active chain " | "Note: transactions that were re-added in the active chain " | ||||
"will appear as-is in this array, and may thus have a positive " | "will appear as-is in this array, and may thus have a " | ||||
"confirmation count.\n" | "positive confirmation count.", | ||||
" ],\n" | { | ||||
" \"lastblock\": \"lastblockhash\" (string) The hash of the " | {RPCResult::Type::ELISION, "", ""}, | ||||
"block (target_confirmations-1) from the best block on the main " | }}, | ||||
"chain. This is typically used to feed back into listsinceblock " | {RPCResult::Type::STR_HEX, "lastblock", | ||||
"the next time you call it. So you would generally use a " | "The hash of the block (target_confirmations-1) from the best " | ||||
"target_confirmations of say 6, so you will be continually " | "block on the main chain. This is typically used to feed back " | ||||
"re-notified of transactions until they've reached 6 confirmations " | "into listsinceblock the next time you call it. So you would " | ||||
"plus any new ones\n" | "generally use a target_confirmations of say 6, so you will " | ||||
"}\n"}, | "be continually re-notified of transactions until they've " | ||||
"reached 6 confirmations plus any new ones"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("listsinceblock", "") + | RPCExamples{HelpExampleCli("listsinceblock", "") + | ||||
HelpExampleCli("listsinceblock", | HelpExampleCli("listsinceblock", | ||||
"\"000000000000000bacf66f7497b7dc45ef753ee9a" | "\"000000000000000bacf66f7497b7dc45ef753ee9a" | ||||
"7d38571037cdb1a57f663ad\" 6") + | "7d38571037cdb1a57f663ad\" 6") + | ||||
HelpExampleRpc("listsinceblock", | HelpExampleRpc("listsinceblock", | ||||
"\"000000000000000bacf66f7497b7dc45ef753ee9a" | "\"000000000000000bacf66f7497b7dc45ef753ee9a" | ||||
"7d38571037cdb1a57f663ad\", 6")}, | "7d38571037cdb1a57f663ad\", 6")}, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
/* default */ "true for watch-only wallets, otherwise false", | /* default */ "true for watch-only wallets, otherwise false", | ||||
"Whether to include watch-only addresses in balance calculation " | "Whether to include watch-only addresses in balance calculation " | ||||
"and details[]"}, | "and details[]"}, | ||||
{"verbose", RPCArg::Type::BOOL, /* default */ "false", | {"verbose", RPCArg::Type::BOOL, /* default */ "false", | ||||
"Whether to include a `decoded` field containing the decoded " | "Whether to include a `decoded` field containing the decoded " | ||||
"transaction (equivalent to RPC decoderawtransaction)"}, | "transaction (equivalent to RPC decoderawtransaction)"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, "", "", | ||||
" \"amount\" : x.xxx, (numeric) The transaction amount " | Cat(Cat<std::vector<RPCResult>>( | ||||
"in " + | { | ||||
CURRENCY_UNIT + | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
"\n" | "The amount in " + CURRENCY_UNIT}, | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee " | {RPCResult::Type::STR_AMOUNT, "fee", | ||||
"in " + | "The amount of the fee in " + CURRENCY_UNIT + | ||||
CURRENCY_UNIT + | |||||
". This is negative and only available for the \n" | ". This is negative and only available for the\n" | ||||
" 'send' category of transactions.\n" + | "'send' category of transactions."}, | ||||
TransactionDescriptionString() + | }, | ||||
+" \"details\" : [\n" | TransactionDescriptionString()), | ||||
" {\n" | { | ||||
" \"involvesWatchonly\": xxx, (bool) Only returns " | {RPCResult::Type::ARR, | ||||
"true if imported addresses were involved in transaction.\n" | "details", | ||||
" \"address\" : \"address\", (string) The bitcoin " | "", | ||||
"address involved in the transaction\n" | { | ||||
" \"category\" : (string) The " | {RPCResult::Type::OBJ, | ||||
"transaction category.\n" | "", | ||||
" \"send\" Transactions " | "", | ||||
"sent.\n" | { | ||||
{RPCResult::Type::BOOL, "involvesWatchonly", | |||||
"Only returns true if imported addresses were " | |||||
"involved in transaction."}, | |||||
{RPCResult::Type::STR, "address", | |||||
"The bitcoin address involved in the " | |||||
"transaction."}, | |||||
{RPCResult::Type::STR, "category", | |||||
"The transaction category.\n" | |||||
"\"send\" Transactions sent.\n" | |||||
" \"receive\" Non-coinbase " | "\"receive\" Non-coinbase " | ||||
"transactions received.\n" | "transactions received.\n" | ||||
" \"generate\" Coinbase " | "\"generate\" Coinbase " | ||||
"transactions received with more than 100 confirmations.\n" | "transactions received with more than 100 " | ||||
"confirmations.\n" | |||||
" \"immature\" Coinbase " | "\"immature\" Coinbase " | ||||
"transactions received with 100 or fewer confirmations.\n" | "transactions received with 100 or fewer " | ||||
"confirmations.\n" | |||||
" \"orphan\" Orphaned coinbase " | "\"orphan\" Orphaned coinbase " | ||||
"transactions received.\n" | "transactions received."}, | ||||
" \"amount\" : x.xxx, (numeric) The amount " | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
"in " + | "The amount in " + CURRENCY_UNIT}, | ||||
CURRENCY_UNIT + | {RPCResult::Type::STR, "label", | ||||
"\n" | "A comment for the address/transaction, if any"}, | ||||
" \"label\" : \"label\", (string) A comment " | {RPCResult::Type::NUM, "vout", "the vout value"}, | ||||
"for the address/transaction, if any\n" | {RPCResult::Type::STR_AMOUNT, "fee", | ||||
" \"vout\" : n, (numeric) the vout " | "The amount of the fee in " + CURRENCY_UNIT + | ||||
"value\n" | ". This is negative and only available for " | ||||
" \"fee\": x.xxx, (numeric) The amount " | "the \n" | ||||
"of the fee in " + | "'send' category of transactions."}, | ||||
CURRENCY_UNIT + | {RPCResult::Type::BOOL, "abandoned", | ||||
". This is negative and only available for the \n" | "'true' if the transaction has been abandoned " | ||||
" 'send' category of " | "(inputs are respendable). Only available for " | ||||
"transactions.\n" | "the \n" | ||||
" \"abandoned\": xxx (bool) 'true' if the " | "'send' category of transactions."}, | ||||
"transaction has been abandoned (inputs are respendable). Only " | }}, | ||||
"available for the \n" | }}, | ||||
" 'send' category of " | {RPCResult::Type::STR_HEX, "hex", | ||||
"transactions.\n" | "Raw data for transaction"}, | ||||
" }\n" | {RPCResult::Type::OBJ, | ||||
" ,...\n" | "decoded", | ||||
" ],\n" | "Optional, the decoded transaction (only present when " | ||||
" \"hex\" : \"data\" (string) Raw data for transaction\n" | "`verbose` is passed)", | ||||
" \"decoded\" : transaction (json object) Optional, the " | { | ||||
"decoded transaction (only present when `verbose` is passed), " | {RPCResult::Type::ELISION, "", | ||||
"equivalent to the\n" | "Equivalent to the RPC decoderawtransaction method, " | ||||
" RPC " | "or the RPC getrawtransaction method when `verbose` " | ||||
"decoderawtransaction method, or the RPC getrawtransaction method " | "is passed."}, | ||||
"when `verbose` is passed.\n" | }}, | ||||
"}\n"}, | })}, | ||||
RPCExamples{HelpExampleCli("gettransaction", | RPCExamples{HelpExampleCli("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\"") + | "5cf302fc80e9d5fbf5d48d\"") + | ||||
HelpExampleCli("gettransaction", | HelpExampleCli("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\" true") + | "5cf302fc80e9d5fbf5d48d\" true") + | ||||
HelpExampleCli("gettransaction", | HelpExampleCli("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
▲ Show 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
RPCArg::Optional::NO, "The transaction id"}, | RPCArg::Optional::NO, "The transaction id"}, | ||||
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"The output number"}, | "The output number"}, | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
RPCResult{"true|false (boolean) Whether the command was successful " | RPCResult{RPCResult::Type::BOOL, "", | ||||
"or not\n"}, | "Whether the command was successful or not"}, | ||||
RPCExamples{ | RPCExamples{ | ||||
"\nList the unspent transactions\n" + | "\nList the unspent transactions\n" + | ||||
HelpExampleCli("listunspent", "") + | HelpExampleCli("listunspent", "") + | ||||
"\nLock an unspent transaction\n" + | "\nLock an unspent transaction\n" + | ||||
HelpExampleCli("lockunspent", "false " | HelpExampleCli("lockunspent", "false " | ||||
"\"[{\\\"txid\\\":" | "\"[{\\\"txid\\\":" | ||||
"\\\"a08e6907dbbd3d809776dbfc5d82e371" | "\\\"a08e6907dbbd3d809776dbfc5d82e371" | ||||
"b764ed838b5655e72f463568df1aadf0\\\"" | "b764ed838b5655e72f463568df1aadf0\\\"" | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | static UniValue listlockunspent(const Config &config, | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"listlockunspent", | "listlockunspent", | ||||
"Returns list of temporarily unspendable outputs.\n" | "Returns list of temporarily unspendable outputs.\n" | ||||
"See the lockunspent call to lock and unlock transactions for " | "See the lockunspent call to lock and unlock transactions for " | ||||
"spending.\n", | "spending.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{RPCResult::Type::ARR, | ||||
"[\n" | "", | ||||
" {\n" | "", | ||||
" \"txid\" : \"transactionid\", (string) The transaction id " | { | ||||
"locked\n" | {RPCResult::Type::OBJ, | ||||
" \"vout\" : n (numeric) The vout value\n" | "", | ||||
" }\n" | "", | ||||
" ,...\n" | { | ||||
"]\n"}, | {RPCResult::Type::STR_HEX, "txid", | ||||
"The transaction id locked"}, | |||||
{RPCResult::Type::NUM, "vout", "The vout value"}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\nList the unspent transactions\n" + | "\nList the unspent transactions\n" + | ||||
HelpExampleCli("listunspent", "") + | HelpExampleCli("listunspent", "") + | ||||
"\nLock an unspent transaction\n" + | "\nLock an unspent transaction\n" + | ||||
HelpExampleCli("lockunspent", "false " | HelpExampleCli("lockunspent", "false " | ||||
"\"[{\\\"txid\\\":" | "\"[{\\\"txid\\\":" | ||||
"\\\"a08e6907dbbd3d809776dbfc5d82e371" | "\\\"a08e6907dbbd3d809776dbfc5d82e371" | ||||
"b764ed838b5655e72f463568df1aadf0\\\"" | "b764ed838b5655e72f463568df1aadf0\\\"" | ||||
Show All 39 Lines | static UniValue settxfee(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"settxfee", | "settxfee", | ||||
"Set the transaction fee per kB for this wallet. Overrides the " | "Set the transaction fee per kB for this wallet. Overrides the " | ||||
"global -paytxfee command line parameter.\n", | "global -paytxfee command line parameter.\n", | ||||
{ | { | ||||
{"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, | {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, | ||||
"The transaction fee in " + CURRENCY_UNIT + "/kB"}, | "The transaction fee in " + CURRENCY_UNIT + "/kB"}, | ||||
}, | }, | ||||
RPCResult{"true|false (boolean) Returns true if successful\n"}, | RPCResult{RPCResult::Type::BOOL, "", "Returns true if successful"}, | ||||
RPCExamples{HelpExampleCli("settxfee", "0.00001") + | RPCExamples{HelpExampleCli("settxfee", "0.00001") + | ||||
HelpExampleRpc("settxfee", "0.00001")}, | HelpExampleRpc("settxfee", "0.00001")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
Amount nAmount = AmountFromValue(request.params[0]); | Amount nAmount = AmountFromValue(request.params[0]); | ||||
Show All 24 Lines | if (!EnsureWalletIsAvailable(rpc_wallet.get(), request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
CWallet &wallet = *rpc_wallet; | CWallet &wallet = *rpc_wallet; | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getbalances", | "getbalances", | ||||
"Returns an object with all balances in " + CURRENCY_UNIT + ".\n", | "Returns an object with all balances in " + CURRENCY_UNIT + ".\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{RPCResult::Type::OBJ, | ||||
"{\n" | "", | ||||
" \"mine\": { (object) balances from " | "", | ||||
"outputs that the wallet can sign\n" | { | ||||
" \"trusted\": xxx (numeric) trusted balance " | {RPCResult::Type::OBJ, | ||||
"(outputs created by the wallet or confirmed outputs)\n" | "mine", | ||||
" \"untrusted_pending\": xxx (numeric) untrusted " | "balances from outputs that the wallet can sign", | ||||
"pending balance (outputs created by others that are in the " | { | ||||
"mempool)\n" | {RPCResult::Type::STR_AMOUNT, "trusted", | ||||
" \"immature\": xxx (numeric) balance from " | "trusted balance (outputs created by the wallet or " | ||||
"immature coinbase outputs\n" | "confirmed outputs)"}, | ||||
" \"used\": xxx (numeric) (only present if " | {RPCResult::Type::STR_AMOUNT, "untrusted_pending", | ||||
"avoid_reuse is set) balance from coins sent to addresses that " | "untrusted pending balance (outputs created by " | ||||
"were previously spent from (potentially privacy violating)\n" | "others that are in the mempool)"}, | ||||
" },\n" | {RPCResult::Type::STR_AMOUNT, "immature", | ||||
" \"watchonly\": { (object) watchonly " | "balance from immature coinbase outputs"}, | ||||
"balances (not present if wallet does not watch anything)\n" | {RPCResult::Type::STR_AMOUNT, "used", | ||||
" \"trusted\": xxx (numeric) trusted balance " | "(only present if avoid_reuse is set) balance from " | ||||
"(outputs created by the wallet or confirmed outputs)\n" | "coins sent to addresses that were previously " | ||||
" \"untrusted_pending\": xxx (numeric) untrusted " | "spent from (potentially privacy violating)"}, | ||||
"pending balance (outputs created by others that are in the " | }}, | ||||
"mempool)\n" | {RPCResult::Type::OBJ, | ||||
" \"immature\": xxx (numeric) balance from " | "watchonly", | ||||
"immature coinbase outputs\n" | "watchonly balances (not present if wallet does not " | ||||
" },\n" | "watch anything)", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR_AMOUNT, "trusted", | |||||
"trusted balance (outputs created by the wallet or " | |||||
"confirmed outputs)"}, | |||||
{RPCResult::Type::STR_AMOUNT, "untrusted_pending", | |||||
"untrusted pending balance (outputs created by " | |||||
"others that are in the mempool)"}, | |||||
{RPCResult::Type::STR_AMOUNT, "immature", | |||||
"balance from immature coinbase outputs"}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getbalances", "") + | RPCExamples{HelpExampleCli("getbalances", "") + | ||||
HelpExampleRpc("getbalances", "")}, | HelpExampleRpc("getbalances", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
wallet.BlockUntilSyncedToCurrentChain(); | wallet.BlockUntilSyncedToCurrentChain(); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getwalletinfo", | "getwalletinfo", | ||||
"Returns an object containing various wallet state info.\n", | "Returns an object containing various wallet state info.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"walletname\": xxxxx, (string) the wallet name\n" | "", | ||||
" \"walletversion\": xxxxx, (numeric) the wallet " | "", | ||||
"version\n" | {{ | ||||
" \"balance\": xxxxxxx, (numeric) DEPRECATED. " | {RPCResult::Type::STR, "walletname", "the wallet name"}, | ||||
"Identical to getbalances().mine.trusted\n" | {RPCResult::Type::NUM, "walletversion", "the wallet version"}, | ||||
" \"unconfirmed_balance\": xxx, (numeric) DEPRECATED. " | {RPCResult::Type::STR_AMOUNT, "balance", | ||||
"Identical to getbalances().mine.untrusted_pending\n" | "DEPRECATED. Identical to getbalances().mine.trusted"}, | ||||
" \"immature_balance\": xxxxxx, (numeric) DEPRECATED. " | {RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", | ||||
"Identical to getbalances().mine.immature\n" | "DEPRECATED. Identical to " | ||||
" \"txcount\": xxxxxxx, (numeric) the total number " | "getbalances().mine.untrusted_pending"}, | ||||
"of transactions in the wallet\n" | {RPCResult::Type::STR_AMOUNT, "immature_balance", | ||||
" \"keypoololdest\": xxxxxx, (numeric) the " + | "DEPRECATED. Identical to getbalances().mine.immature"}, | ||||
UNIX_EPOCH_TIME + | {RPCResult::Type::NUM, "txcount", | ||||
" of the oldest pre-generated key in the key pool\n" | "the total number of transactions in the wallet"}, | ||||
" \"keypoolsize\": xxxx, (numeric) how many new keys " | {RPCResult::Type::NUM_TIME, "keypoololdest", | ||||
"are pre-generated (only counts external keys)\n" | "the " + UNIX_EPOCH_TIME + | ||||
" \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys " | " of the oldest pre-generated key in the key pool"}, | ||||
"are pre-generated for internal use (used for change outputs, only " | {RPCResult::Type::NUM, "keypoolsize", | ||||
"appears if the wallet is using this feature, otherwise external " | "how many new keys are pre-generated (only counts external " | ||||
"keys are used)\n" | "keys)"}, | ||||
" \"unlocked_until\": ttt, (numeric) the " + | {RPCResult::Type::NUM, "keypoolsize_hd_internal", | ||||
UNIX_EPOCH_TIME + | "how many new keys are pre-generated for internal use (used " | ||||
" until which the wallet is unlocked for transfers, or 0 if the " | "for change outputs, only appears if the wallet is using this " | ||||
"wallet is locked\n" | "feature, otherwise external keys are used)"}, | ||||
" \"paytxfee\": x.xxxx, (numeric) the transaction " | {RPCResult::Type::NUM_TIME, "unlocked_until", | ||||
"fee configuration, set in " + | "the " + UNIX_EPOCH_TIME + | ||||
CURRENCY_UNIT + | " until which the wallet is unlocked for transfers, or 0 " | ||||
"/kB\n" | "if the wallet is locked"}, | ||||
" \"hdseedid\": \"<hash160>\" (string, optional) the " | {RPCResult::Type::STR_AMOUNT, "paytxfee", | ||||
"Hash160 of the HD seed (only present when HD is enabled)\n" | "the transaction fee configuration, set in " + CURRENCY_UNIT + | ||||
" \"private_keys_enabled\": true|false (boolean) false if " | "/kB"}, | ||||
"privatekeys are disabled for this wallet (enforced watch-only " | {RPCResult::Type::STR_HEX, "hdseedid", /* optional */ true, | ||||
"wallet)\n" | "the Hash160 of the HD seed (only present when HD is " | ||||
" \"scanning\": (json object) current " | "enabled)"}, | ||||
"scanning details, or false if no scan is in progress\n" | {RPCResult::Type::BOOL, "private_keys_enabled", | ||||
" {\n" | "false if privatekeys are disabled for this wallet (enforced " | ||||
" \"duration\" : xxxx (numeric) elapsed seconds " | "watch-only wallet)"}, | ||||
"since scan start\n" | {RPCResult::Type::OBJ, | ||||
" \"progress\" : x.xxxx, (numeric) scanning " | "scanning", | ||||
"progress percentage [0.0, 1.0]\n" | "current scanning details, or false if no scan is in progress", | ||||
" }\n" | { | ||||
" \"avoid_reuse\": true|false (boolean) whether this " | {RPCResult::Type::NUM, "duration", | ||||
"wallet tracks clean/dirty coins in terms of reuse\n" | "elapsed seconds since scan start"}, | ||||
"}\n"}, | {RPCResult::Type::NUM, "progress", | ||||
"scanning progress percentage [0.0, 1.0]"}, | |||||
}}, | |||||
{RPCResult::Type::BOOL, "avoid_reuse", | |||||
"whether this wallet tracks clean/dirty coins in terms of " | |||||
"reuse"}, | |||||
}}, | |||||
}, | |||||
RPCExamples{HelpExampleCli("getwalletinfo", "") + | RPCExamples{HelpExampleCli("getwalletinfo", "") + | ||||
HelpExampleRpc("getwalletinfo", "")}, | HelpExampleRpc("getwalletinfo", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
static UniValue listwalletdir(const Config &config, | static UniValue listwalletdir(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"listwalletdir", | "listwalletdir", | ||||
"Returns a list of wallets in the wallet directory.\n", | "Returns a list of wallets in the wallet directory.\n", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"wallets\" : [ (json array of objects)\n" | "", | ||||
" {\n" | "", | ||||
" \"name\" : \"name\" (string) The wallet name\n" | { | ||||
" }\n" | {RPCResult::Type::ARR, | ||||
" ,...\n" | "wallets", | ||||
" ]\n" | "", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::OBJ, | |||||
"", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::STR, "name", "The wallet name"}, | |||||
}}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("listwalletdir", "") + | RPCExamples{HelpExampleCli("listwalletdir", "") + | ||||
HelpExampleRpc("listwalletdir", "")}, | HelpExampleRpc("listwalletdir", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
UniValue wallets(UniValue::VARR); | UniValue wallets(UniValue::VARR); | ||||
for (const auto &path : ListWalletDir()) { | for (const auto &path : ListWalletDir()) { | ||||
UniValue wallet(UniValue::VOBJ); | UniValue wallet(UniValue::VOBJ); | ||||
wallet.pushKV("name", path.string()); | wallet.pushKV("name", path.string()); | ||||
wallets.push_back(wallet); | wallets.push_back(wallet); | ||||
} | } | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("wallets", wallets); | result.pushKV("wallets", wallets); | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue listwallets(const Config &config, | static UniValue listwallets(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"listwallets", | "listwallets", | ||||
"Returns a list of currently loaded wallets.\n" | "Returns a list of currently loaded wallets.\n" | ||||
"For full information on the wallet, use \"getwalletinfo\"\n", | "For full information on the wallet, use \"getwalletinfo\"\n", | ||||
{}, | {}, | ||||
RPCResult{"[ (json array of strings)\n" | RPCResult{RPCResult::Type::ARR, | ||||
" \"walletname\" (string) the wallet name\n" | "", | ||||
" ...\n" | "", | ||||
"]\n"}, | { | ||||
{RPCResult::Type::STR, "walletname", "the wallet name"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("listwallets", "") + | RPCExamples{HelpExampleCli("listwallets", "") + | ||||
HelpExampleRpc("listwallets", "")}, | HelpExampleRpc("listwallets", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
UniValue obj(UniValue::VARR); | UniValue obj(UniValue::VARR); | ||||
for (const std::shared_ptr<CWallet> &wallet : GetWallets()) { | for (const std::shared_ptr<CWallet> &wallet : GetWallets()) { | ||||
Show All 16 Lines | RPCHelpMan{ | ||||
"Loads a wallet from a wallet file or directory." | "Loads a wallet from a wallet file or directory." | ||||
"\nNote that all wallet command-line options used when starting " | "\nNote that all wallet command-line options used when starting " | ||||
"bitcoind will be" | "bitcoind will be" | ||||
"\napplied to the new wallet (eg -zapwallettxes, rescan, etc).\n", | "\napplied to the new wallet (eg -zapwallettxes, rescan, etc).\n", | ||||
{ | { | ||||
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, | {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The wallet directory or .dat file."}, | "The wallet directory or .dat file."}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"name\" : <wallet_name>, (string) The wallet " | "", | ||||
"name if loaded successfully.\n" | "", | ||||
" \"warning\" : <warning>, (string) Warning " | { | ||||
"message if wallet was not loaded cleanly.\n" | {RPCResult::Type::STR, "name", | ||||
"}\n"}, | "The wallet name if loaded successfully."}, | ||||
{RPCResult::Type::STR, "warning", | |||||
"Warning message if wallet was not loaded cleanly."}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("loadwallet", "\"test.dat\"") + | RPCExamples{HelpExampleCli("loadwallet", "\"test.dat\"") + | ||||
HelpExampleRpc("loadwallet", "\"test.dat\"")}, | HelpExampleRpc("loadwallet", "\"test.dat\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
const CChainParams &chainParams = config.GetChainParams(); | const CChainParams &chainParams = config.GetChainParams(); | ||||
WalletLocation location(request.params[0].get_str()); | WalletLocation location(request.params[0].get_str()); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Change the state of the given wallet flag for a wallet.\n", | "Change the state of the given wallet flag for a wallet.\n", | ||||
{ | { | ||||
{"flag", RPCArg::Type::STR, RPCArg::Optional::NO, | {"flag", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The name of the flag to change. Current available flags: " + | "The name of the flag to change. Current available flags: " + | ||||
flags}, | flags}, | ||||
{"value", RPCArg::Type::BOOL, /* default */ "true", | {"value", RPCArg::Type::BOOL, /* default */ "true", | ||||
"The new state."}, | "The new state."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{RPCResult::Type::OBJ, | ||||
"{\n" | "", | ||||
" \"flag_name\": string (string) The name of the flag that " | "", | ||||
"was modified\n" | { | ||||
" \"flag_state\": bool (bool) The new state of the flag\n" | {RPCResult::Type::STR, "flag_name", | ||||
" \"warnings\": string (string) Any warnings associated with " | "The name of the flag that was modified"}, | ||||
"the change\n" | {RPCResult::Type::BOOL, "flag_state", | ||||
"}\n"}, | "The new state of the flag"}, | ||||
{RPCResult::Type::STR, "warnings", | |||||
"Any warnings associated with the change"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("setwalletflag", "avoid_reuse") + | RPCExamples{HelpExampleCli("setwalletflag", "avoid_reuse") + | ||||
HelpExampleRpc("setwalletflag", "\"avoid_reuse\"")}, | HelpExampleRpc("setwalletflag", "\"avoid_reuse\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
std::string flag_str = request.params[0].get_str(); | std::string flag_str = request.params[0].get_str(); | ||||
bool value = request.params[1].isNull() || request.params[1].get_bool(); | bool value = request.params[1].isNull() || request.params[1].get_bool(); | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Create a blank wallet. A blank wallet has no keys or HD seed. " | "Create a blank wallet. A blank wallet has no keys or HD seed. " | ||||
"One can be set using sethdseed."}, | "One can be set using sethdseed."}, | ||||
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | {"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED, | ||||
"Encrypt the wallet with this passphrase."}, | "Encrypt the wallet with this passphrase."}, | ||||
{"avoid_reuse", RPCArg::Type::BOOL, /* default */ "false", | {"avoid_reuse", RPCArg::Type::BOOL, /* default */ "false", | ||||
"Keep track of coin reuse, and treat dirty and clean coins " | "Keep track of coin reuse, and treat dirty and clean coins " | ||||
"differently with privacy considerations in mind."}, | "differently with privacy considerations in mind."}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"name\" : <wallet_name>, (string) The wallet " | "", | ||||
"name if created successfully. If the wallet was created " | "", | ||||
"using a full path, the wallet_name will be the full path.\n" | { | ||||
" \"warning\" : <warning>, (string) Warning " | {RPCResult::Type::STR, "name", | ||||
"message if wallet was not loaded cleanly.\n" | "The wallet name if created successfully. If the wallet " | ||||
"}\n"}, | "was created using a full path, the wallet_name will be " | ||||
"the full path."}, | |||||
{RPCResult::Type::STR, "warning", | |||||
"Warning message if wallet was not loaded cleanly."}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("createwallet", "\"testwallet\"") + | RPCExamples{HelpExampleCli("createwallet", "\"testwallet\"") + | ||||
HelpExampleRpc("createwallet", "\"testwallet\"")}, | HelpExampleRpc("createwallet", "\"testwallet\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
uint64_t flags = 0; | uint64_t flags = 0; | ||||
if (!request.params[1].isNull() && request.params[1].get_bool()) { | if (!request.params[1].isNull() && request.params[1].get_bool()) { | ||||
flags |= WALLET_FLAG_DISABLE_PRIVATE_KEYS; | flags |= WALLET_FLAG_DISABLE_PRIVATE_KEYS; | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Maximum number of UTXOs"}, | "Maximum number of UTXOs"}, | ||||
{"minimumSumAmount", RPCArg::Type::AMOUNT, | {"minimumSumAmount", RPCArg::Type::AMOUNT, | ||||
/* default */ "unlimited", | /* default */ "unlimited", | ||||
"Minimum sum value of all UTXOs in " + CURRENCY_UNIT + ""}, | "Minimum sum value of all UTXOs in " + CURRENCY_UNIT + ""}, | ||||
}, | }, | ||||
"query_options"}, | "query_options"}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"[ (array of json object)\n" | RPCResult::Type::ARR, | ||||
" {\n" | "", | ||||
" \"txid\" : \"txid\", (string) the transaction id\n" | "", | ||||
" \"vout\" : n, (numeric) the vout value\n" | { | ||||
" \"address\" : \"address\", (string) the bitcoin address\n" | {RPCResult::Type::OBJ, | ||||
" \"label\" : \"label\", (string) The associated label, or " | "", | ||||
"\"\" for the default label\n" | "", | ||||
" \"scriptPubKey\" : \"key\", (string) the script key\n" | { | ||||
" \"amount\" : x.xxx, (numeric) the transaction output " | {RPCResult::Type::STR_HEX, "txid", "the transaction id"}, | ||||
"amount in " + | {RPCResult::Type::NUM, "vout", "the vout value"}, | ||||
CURRENCY_UNIT + | {RPCResult::Type::STR, "address", "the bitcoin address"}, | ||||
"\n" | {RPCResult::Type::STR, "label", | ||||
" \"confirmations\" : n, (numeric) The number of " | "The associated label, or \"\" for the default label"}, | ||||
"confirmations\n" | {RPCResult::Type::STR, "scriptPubKey", "the script key"}, | ||||
" \"redeemScript\" : n (string) The redeemScript if " | {RPCResult::Type::STR_AMOUNT, "amount", | ||||
"scriptPubKey is P2SH\n" | "the transaction output amount in " + CURRENCY_UNIT}, | ||||
" \"spendable\" : xxx, (bool) Whether we have the " | {RPCResult::Type::NUM, "confirmations", | ||||
"private keys to spend this output\n" | "The number of confirmations"}, | ||||
" \"solvable\" : xxx, (bool) Whether we know how to " | {RPCResult::Type::STR_HEX, "redeemScript", | ||||
"spend this output, ignoring the lack of keys\n" | "The redeemScript if scriptPubKey is P2SH"}, | ||||
" \"reused\" : xxx, (bool) (only present if " | {RPCResult::Type::BOOL, "spendable", | ||||
"avoid_reuse is set) Whether this output is reused/dirty (sent to " | "Whether we have the private keys to spend this output"}, | ||||
"an address that was previously spent from)\n" | {RPCResult::Type::BOOL, "solvable", | ||||
" \"desc\" : xxx, (string, only when solvable) A " | "Whether we know how to spend this output, ignoring the " | ||||
"descriptor for spending this output\n" | "lack of keys"}, | ||||
" \"safe\" : xxx (bool) Whether this output is " | {RPCResult::Type::BOOL, "reused", | ||||
"considered safe to spend. Unconfirmed transactions\n" | "(only present if avoid_reuse is set) Whether this " | ||||
" from outside keys are considered " | "output is reused/dirty (sent to an address that was " | ||||
"unsafe and are not eligible for spending by\n" | "previously spent from)"}, | ||||
" fundrawtransaction and " | {RPCResult::Type::STR, "desc", | ||||
"sendtoaddress.\n" | "(only when solvable) A descriptor for spending this " | ||||
" }\n" | "output"}, | ||||
" ,...\n" | {RPCResult::Type::BOOL, "safe", | ||||
"]\n"}, | "Whether this output is considered safe to spend. " | ||||
"Unconfirmed transactions\n" | |||||
" from outside keys and " | |||||
"unconfirmed replacement transactions are considered " | |||||
"unsafe\n" | |||||
"and are not eligible for spending by fundrawtransaction " | |||||
"and sendtoaddress."}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("listunspent", "") + | HelpExampleCli("listunspent", "") + | ||||
HelpExampleCli("listunspent", | HelpExampleCli("listunspent", | ||||
"6 9999999 " | "6 9999999 " | ||||
"\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\"," | "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\"," | ||||
"\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") + | "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") + | ||||
HelpExampleRpc("listunspent", | HelpExampleRpc("listunspent", | ||||
"6, 9999999 " | "6, 9999999 " | ||||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
RPCArg::Optional::OMITTED, | RPCArg::Optional::OMITTED, | ||||
"The zero-based output index, before a change output " | "The zero-based output index, before a change output " | ||||
"is added."}, | "is added."}, | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
"options"}, | "options"}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{ | ||||
" \"hex\": \"value\", (string) The resulting raw " | RPCResult::Type::OBJ, | ||||
"transaction (hex-encoded string)\n" | "", | ||||
" \"fee\": n, (numeric) Fee in " + | "", | ||||
CURRENCY_UNIT + | { | ||||
" the resulting transaction pays\n" | {RPCResult::Type::STR_HEX, "hex", | ||||
" \"changepos\": n (numeric) The position of the " | "The resulting raw transaction (hex-encoded string)"}, | ||||
"added change output, or -1\n" | {RPCResult::Type::STR_AMOUNT, "fee", | ||||
"}\n"}, | "Fee in " + CURRENCY_UNIT + " the resulting transaction pays"}, | ||||
{RPCResult::Type::NUM, "changepos", | |||||
"The position of the added change output, or -1"}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\nCreate a transaction with no inputs\n" + | "\nCreate a transaction with no inputs\n" + | ||||
HelpExampleCli("createrawtransaction", | HelpExampleCli("createrawtransaction", | ||||
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") + | "\"[]\" \"{\\\"myaddress\\\":0.01}\"") + | ||||
"\nAdd sufficient unsigned inputs to meet the output value\n" + | "\nAdd sufficient unsigned inputs to meet the output value\n" + | ||||
HelpExampleCli("fundrawtransaction", "\"rawtransactionhex\"") + | HelpExampleCli("fundrawtransaction", "\"rawtransactionhex\"") + | ||||
"\nSign the transaction\n" + | "\nSign the transaction\n" + | ||||
HelpExampleCli("signrawtransactionwithwallet", | HelpExampleCli("signrawtransactionwithwallet", | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"The signature hash type. Must be one of\n" | "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\""}, | " \"SINGLE|FORKID|ANYONECANPAY\""}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{ | ||||
" \"hex\" : \"value\", (string) The hex-encoded " | RPCResult::Type::OBJ, | ||||
"raw transaction with signature(s)\n" | "", | ||||
" \"complete\" : true|false, (boolean) If the " | "", | ||||
"transaction has a complete set of signatures\n" | { | ||||
" \"errors\" : [ (json array of objects) " | {RPCResult::Type::STR_HEX, "hex", | ||||
"Script verification errors (if there are any)\n" | "The hex-encoded raw transaction with signature(s)"}, | ||||
" {\n" | {RPCResult::Type::BOOL, "complete", | ||||
" \"txid\" : \"hash\", (string) The hash of the " | "If the transaction has a complete set of signatures"}, | ||||
"referenced, previous transaction\n" | {RPCResult::Type::ARR, | ||||
" \"vout\" : n, (numeric) The index of " | "errors", | ||||
"the output to spent and used as input\n" | "Script verification errors (if there are any)", | ||||
" \"scriptSig\" : \"hex\", (string) The hex-encoded " | { | ||||
"signature script\n" | {RPCResult::Type::OBJ, | ||||
" \"sequence\" : n, (numeric) Script sequence " | "", | ||||
"number\n" | "", | ||||
" \"error\" : \"text\" (string) Verification or " | { | ||||
"signing error related to the input\n" | {RPCResult::Type::STR_HEX, "txid", | ||||
" }\n" | "The hash of the referenced, previous transaction"}, | ||||
" ,...\n" | {RPCResult::Type::NUM, "vout", | ||||
" ]\n" | "The index of the output to spent and used as " | ||||
"}\n"}, | "input"}, | ||||
{RPCResult::Type::STR_HEX, "scriptSig", | |||||
"The hex-encoded signature script"}, | |||||
{RPCResult::Type::NUM, "sequence", | |||||
"Script sequence number"}, | |||||
{RPCResult::Type::STR, "error", | |||||
"Verification or signing error related to the " | |||||
"input"}, | |||||
}}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | ||||
HelpExampleRpc("signrawtransactionwithwallet", "\"myhex\"")}, | HelpExampleRpc("signrawtransactionwithwallet", "\"myhex\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
RPCTypeCheck(request.params, | RPCTypeCheck(request.params, | ||||
{UniValue::VSTR, UniValue::VARR, UniValue::VSTR}, true); | {UniValue::VSTR, UniValue::VARR, UniValue::VSTR}, true); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Note: Use \"getwalletinfo\" to query the scanning progress.\n", | "Note: Use \"getwalletinfo\" to query the scanning progress.\n", | ||||
{ | { | ||||
{"start_height", RPCArg::Type::NUM, /* default */ "0", | {"start_height", RPCArg::Type::NUM, /* default */ "0", | ||||
"block height where the rescan should start"}, | "block height where the rescan should start"}, | ||||
{"stop_height", RPCArg::Type::NUM, | {"stop_height", RPCArg::Type::NUM, | ||||
RPCArg::Optional::OMITTED_NAMED_ARG, | RPCArg::Optional::OMITTED_NAMED_ARG, | ||||
"the last block height that should be scanned"}, | "the last block height that should be scanned"}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{ | ||||
" \"start_height\" (numeric) The block height where the " | RPCResult::Type::OBJ, | ||||
"rescan started (the requested height or 0\n" | "", | ||||
" \"stop_height\" (numeric) The height of the last " | "", | ||||
"rescanned block. May be null in rare cases if there was a " | { | ||||
"reorg and the call didn't scan any blocks because they were " | {RPCResult::Type::NUM, "start_height", | ||||
"already scanned in the background.\n" | "The block height where the rescan started (the requested " | ||||
"}\n"}, | "height or 0)"}, | ||||
{RPCResult::Type::NUM, "stop_height", | |||||
"The height of the last rescanned block. May be null in rare " | |||||
"cases if there was a reorg and the call didn't scan any " | |||||
"blocks because they were already scanned in the background."}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("rescanblockchain", "100000 120000") + | RPCExamples{HelpExampleCli("rescanblockchain", "100000 120000") + | ||||
HelpExampleRpc("rescanblockchain", "100000, 120000")}, | HelpExampleRpc("rescanblockchain", "100000, 120000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
WalletRescanReserver reserver(*pwallet); | WalletRescanReserver reserver(*pwallet); | ||||
if (!reserver.reserve()) { | if (!reserver.reserve()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"\nReturn information about the given bitcoin address.\n" | "\nReturn information about the given bitcoin address.\n" | ||||
"Some of the information will only be present if the address is in the " | "Some of the information will only be present if the address is in the " | ||||
"active wallet.\n", | "active wallet.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The bitcoin address for which to get information."}, | "The bitcoin address for which to get information."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | RPCResult::Type::OBJ, | ||||
" \"address\" : \"address\", (string) The bitcoin " | "", | ||||
"address validated.\n" | "", | ||||
" \"scriptPubKey\" : \"hex\", (string) The " | { | ||||
"hex-encoded scriptPubKey generated by the address.\n" | {RPCResult::Type::STR, "address", | ||||
" \"ismine\" : true|false, (boolean) If the address " | "The bitcoin address validated."}, | ||||
"is yours.\n" | {RPCResult::Type::STR_HEX, "scriptPubKey", | ||||
" \"iswatchonly\" : true|false, (boolean) If the address " | "The hex-encoded scriptPubKey generated by the address."}, | ||||
"is watchonly.\n" | {RPCResult::Type::BOOL, "ismine", "If the address is yours."}, | ||||
" \"solvable\" : true|false, (boolean) If we know how " | {RPCResult::Type::BOOL, "iswatchonly", | ||||
"to spend coins sent to this address, ignoring the possible lack " | "If the address is watchonly."}, | ||||
"of private keys.\n" | {RPCResult::Type::BOOL, "solvable", | ||||
" \"desc\" : \"desc\", (string, optional) A " | "If we know how to spend coins sent to this address, ignoring " | ||||
"descriptor for spending coins sent to this address (only when " | "the possible lack of private keys."}, | ||||
"solvable).\n" | {RPCResult::Type::STR, "desc", /* optional */ true, | ||||
" \"isscript\" : true|false, (boolean) If the key is a " | "A descriptor for spending coins sent to this address (only " | ||||
"script.\n" | "when solvable)."}, | ||||
" \"ischange\" : true|false, (boolean) If the address " | {RPCResult::Type::BOOL, "isscript", "If the key is a script."}, | ||||
"was used for change output.\n" | {RPCResult::Type::BOOL, "ischange", | ||||
" \"script\" : \"type\" (string, optional) The " | "If the address was used for change output."}, | ||||
"output script type. Only if isscript is true and the redeemscript " | {RPCResult::Type::STR, "script", /* optional */ true, | ||||
"is known. Possible\n" | "The output script type. Only if isscript is true and the " | ||||
" types: " | "redeemscript is known. Possible\n" | ||||
"nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata\n" | |||||
" \"hex\" : \"hex\", (string, optional) The " | |||||
"redeemscript for the p2sh address.\n" | |||||
" \"pubkeys\" (array, optional) Array " | |||||
"of pubkeys associated with the known redeemscript (only if script " | |||||
"is multisig).\n" | |||||
" [\n" | |||||
" \"pubkey\" (string)\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
" \"sigsrequired\" : xxxxx (numeric, optional) The " | |||||
"number of signatures required to spend multisig output (only if " | |||||
"script is multisig).\n" | |||||
" \"pubkey\" : \"publickeyhex\", (string, optional) The " | |||||
"hex value of the raw public key for single-key addresses " | |||||
"(possibly embedded in P2SH).\n" | |||||
" \"embedded\" : {...}, (object, optional) " | |||||
"Information about the address embedded in P2SH, if " | |||||
"relevant and known. Includes all\n" | |||||
" " | " " | ||||
"getaddressinfo output fields for the embedded address, excluding " | "types: nonstandard, pubkey, pubkeyhash, scripthash, " | ||||
"metadata (timestamp, hdkeypath,\n" | "multisig, nulldata."}, | ||||
{RPCResult::Type::STR_HEX, "hex", /* optional */ true, | |||||
"The redeemscript for the p2sh address."}, | |||||
{RPCResult::Type::ARR, | |||||
"pubkeys", | |||||
/* optional */ true, | |||||
"Array of pubkeys associated with the known redeemscript " | |||||
"(only if script is multisig).", | |||||
{ | |||||
{RPCResult::Type::STR, "pubkey", ""}, | |||||
}}, | |||||
{RPCResult::Type::NUM, "sigsrequired", /* optional */ true, | |||||
"The number of signatures required to spend multisig output " | |||||
"(only if script is multisig)."}, | |||||
{RPCResult::Type::STR_HEX, "pubkey", /* optional */ true, | |||||
"The hex value of the raw public key for single-key addresses " | |||||
"(possibly embedded in P2SH)."}, | |||||
{RPCResult::Type::OBJ, | |||||
"embedded", | |||||
/* optional */ true, | |||||
"Information about the address embedded in P2SH, if " | |||||
"relevant and known.", | |||||
{ | |||||
{RPCResult::Type::ELISION, "", | |||||
"Includes all\n" | |||||
" " | " " | ||||
"hdseedid) and relation to the wallet (ismine, iswatchonly).\n" | " getaddressinfo output fields for the embedded address, " | ||||
" \"iscompressed\" : true|false, (boolean, optional) If " | "excluding metadata (timestamp, hdkeypath,\n" | ||||
"the pubkey is compressed.\n" | "hdseedid) and relation to the wallet (ismine, " | ||||
" \"label\" : \"label\" (string) The label " | "iswatchonly)."}, | ||||
"associated with the address. Defaults to \"\". Equivalent to the " | }}, | ||||
"label name in the labels array below.\n" | {RPCResult::Type::BOOL, "iscompressed", /* optional */ true, | ||||
" \"timestamp\" : timestamp, (number, optional) The " | "If the pubkey is compressed."}, | ||||
"creation time of the key, if available, expressed in " + | {RPCResult::Type::STR, "label", | ||||
UNIX_EPOCH_TIME + | "DEPRECATED. The label associated with the address. Defaults " | ||||
".\n" | "to \"\". Replaced by the labels array below."}, | ||||
" \"hdkeypath\" : \"keypath\" (string, optional) The " | {RPCResult::Type::NUM_TIME, "timestamp", /* optional */ true, | ||||
"HD keypath, if the key is HD and available.\n" | "The creation time of the key, if available, expressed in " + | ||||
" \"hdseedid\" : \"<hash160>\" (string, optional) The " | UNIX_EPOCH_TIME + "."}, | ||||
"Hash160 of the HD seed.\n" | {RPCResult::Type::STR, "hdkeypath", /* optional */ true, | ||||
" \"hdmasterfingerprint\" : \"<hash160>\" (string, optional) The " | "The HD keypath, if the key is HD and available."}, | ||||
"fingerprint of the master key.\n" | {RPCResult::Type::STR_HEX, "hdseedid", /* optional */ true, | ||||
" \"labels\" (json object) An array of " | "The Hash160 of the HD seed."}, | ||||
"labels associated with the address. Currently limited to one " | {RPCResult::Type::STR_HEX, "hdmasterfingerprint", | ||||
"label but returned\n" | /* optional */ true, "The fingerprint of the master key."}, | ||||
" as an array to " | {RPCResult::Type::ARR, | ||||
"keep the API stable if multiple labels are enabled in the " | "labels", | ||||
"future.\n" | "Array of labels associated with the address. Currently " | ||||
" [\n" | "limited to one label but returned\n" | ||||
" \"label name\" (string) The label name. Defaults to \"\". " | "as an array to keep the API stable if multiple labels are " | ||||
"Equivalent to the label field above.\n\n" | "enabled in the future.", | ||||
{ | |||||
{RPCResult::Type::STR, "label name", | |||||
"The label name. Defaults to \"\"."}, | |||||
{RPCResult::Type::OBJ, | |||||
"", | |||||
" DEPRECATED, will be removed in a future version. To " | "DEPRECATED, will be removed in a future version. To " | ||||
"re-enable, launch bitcoind with `-deprecatedrpc=labelspurpose`:\n" | "re-enable, launch bitcoind with " | ||||
" { (json object of label data)\n" | "`-deprecatedrpc=labelspurpose`", | ||||
" \"name\" : \"label name\" (string) The label name. " | { | ||||
"Defaults to \"\". Equivalent to the label field above.\n" | {RPCResult::Type::STR, "name", | ||||
" \"purpose\" : \"purpose\" (string) The purpose of the " | "The label name. Defaults to \"\"."}, | ||||
"associated address (send or receive).\n" | {RPCResult::Type::STR, "purpose", | ||||
" },...\n" | "The purpose of the associated address (send or " | ||||
" ]\n" | "receive)."}, | ||||
"}\n"}, | }}, | ||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) + | RPCExamples{HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) + | ||||
HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS)}, | HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS)}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | UniValue getaddressesbylabel(const Config &config, | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getaddressesbylabel", | "getaddressesbylabel", | ||||
"Returns the list of addresses assigned the specified label.\n", | "Returns the list of addresses assigned the specified label.\n", | ||||
{ | { | ||||
{"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The label."}, | {"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The label."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{RPCResult::Type::OBJ_DYN, | ||||
"{ (json object with addresses as keys)\n" | "", | ||||
" \"address\": { (json object with information about address)\n" | "json object with addresses as keys", | ||||
" \"purpose\": \"string\" (string) Purpose of address " | { | ||||
"(\"send\" for sending address, \"receive\" for receiving " | {RPCResult::Type::OBJ, | ||||
"address)\n" | "address", | ||||
" },...\n" | "json object with information about address", | ||||
"}\n"}, | { | ||||
{RPCResult::Type::STR, "purpose", | |||||
"Purpose of address (\"send\" for sending address, " | |||||
"\"receive\" for receiving address)"}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("getaddressesbylabel", "\"tabby\"") + | RPCExamples{HelpExampleCli("getaddressesbylabel", "\"tabby\"") + | ||||
HelpExampleRpc("getaddressesbylabel", "\"tabby\"")}, | HelpExampleRpc("getaddressesbylabel", "\"tabby\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
std::string label = LabelFromValue(request.params[0]); | std::string label = LabelFromValue(request.params[0]); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"listlabels", | "listlabels", | ||||
"Returns the list of all labels, or labels that are assigned to " | "Returns the list of all labels, or labels that are assigned to " | ||||
"addresses with a specific purpose.\n", | "addresses with a specific purpose.\n", | ||||
{ | { | ||||
{"purpose", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, | {"purpose", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, | ||||
"Address purpose to list labels for ('send','receive'). An empty " | "Address purpose to list labels for ('send','receive'). An empty " | ||||
"string is the same as not providing this argument."}, | "string is the same as not providing this argument."}, | ||||
}, | }, | ||||
RPCResult{"[ (json array of string)\n" | RPCResult{RPCResult::Type::ARR, | ||||
" \"label\", (string) Label name\n" | "", | ||||
" ...\n" | "", | ||||
"]\n"}, | { | ||||
{RPCResult::Type::STR, "label", "Label name"}, | |||||
}}, | |||||
RPCExamples{"\nList all labels\n" + HelpExampleCli("listlabels", "") + | RPCExamples{"\nList all labels\n" + HelpExampleCli("listlabels", "") + | ||||
"\nList labels that have receiving addresses\n" + | "\nList labels that have receiving addresses\n" + | ||||
HelpExampleCli("listlabels", "receive") + | HelpExampleCli("listlabels", "receive") + | ||||
"\nList labels that have sending addresses\n" + | "\nList labels that have sending addresses\n" + | ||||
HelpExampleCli("listlabels", "send") + | HelpExampleCli("listlabels", "send") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("listlabels", "receive")}, | HelpExampleRpc("listlabels", "receive")}, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
" \"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\""}, | " \"SINGLE|FORKID|ANYONECANPAY\""}, | ||||
{"bip32derivs", RPCArg::Type::BOOL, /* default */ "true", | {"bip32derivs", RPCArg::Type::BOOL, /* default */ "true", | ||||
"Includes the BIP 32 derivation paths for public keys if we know " | "Includes the BIP 32 derivation paths for public keys if we know " | ||||
"them"}, | "them"}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{RPCResult::Type::OBJ, | ||||
" \"psbt\" : \"value\", (string) The " | "", | ||||
"base64-encoded partially signed transaction\n" | "", | ||||
" \"complete\" : true|false, (boolean) If the transaction " | { | ||||
"has a complete set of signatures\n" | {RPCResult::Type::STR, "psbt", | ||||
" ]\n" | "The base64-encoded partially signed transaction"}, | ||||
"}\n"}, | {RPCResult::Type::BOOL, "complete", | ||||
"If the transaction has a complete set of signatures"}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("walletprocesspsbt", "\"psbt\"")}, | RPCExamples{HelpExampleCli("walletprocesspsbt", "\"psbt\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
RPCTypeCheck(request.params, | RPCTypeCheck(request.params, | ||||
{UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR}); | {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR}); | ||||
// Unserialize the transaction | // Unserialize the transaction | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
"options"}, | "options"}, | ||||
{"bip32derivs", RPCArg::Type::BOOL, /* default */ "true", | {"bip32derivs", RPCArg::Type::BOOL, /* default */ "true", | ||||
"Includes the BIP 32 derivation paths for public keys if we know " | "Includes the BIP 32 derivation paths for public keys if we know " | ||||
"them"}, | "them"}, | ||||
}, | }, | ||||
RPCResult{"{\n" | RPCResult{ | ||||
" \"psbt\": \"value\", (string) The resulting raw " | RPCResult::Type::OBJ, | ||||
"transaction (base64-encoded string)\n" | "", | ||||
" \"fee\": n, (numeric) Fee in " + | "", | ||||
CURRENCY_UNIT + | { | ||||
" the resulting transaction pays\n" | {RPCResult::Type::STR, "psbt", | ||||
" \"changepos\": n (numeric) The position of the " | "The resulting raw transaction (base64-encoded string)"}, | ||||
"added change output, or -1\n" | {RPCResult::Type::STR_AMOUNT, "fee", | ||||
"}\n"}, | "Fee in " + CURRENCY_UNIT + " the resulting transaction pays"}, | ||||
{RPCResult::Type::NUM, "changepos", | |||||
"The position of the added change output, or -1"}, | |||||
}}, | |||||
RPCExamples{ | RPCExamples{ | ||||
"\nCreate a transaction with no inputs\n" + | "\nCreate a transaction with no inputs\n" + | ||||
HelpExampleCli("walletcreatefundedpsbt", | HelpExampleCli("walletcreatefundedpsbt", | ||||
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | ||||
"\"[{\\\"data\\\":\\\"00010203\\\"}]\"")}, | "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |