Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
HelpExampleCli("getlabeladdress", "\"\"") + | HelpExampleCli("getlabeladdress", "\"\"") + | ||||
HelpExampleCli("getlabeladdress", "\"mylabel\"") + | HelpExampleCli("getlabeladdress", "\"mylabel\"") + | ||||
HelpExampleRpc("getlabeladdress", "\"mylabel\"")); | HelpExampleRpc("getlabeladdress", "\"mylabel\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
// Parse the label first so we don't generate a key if there's an error | // Parse the label first so we don't generate a key if there's an error | ||||
std::string label = LabelFromValue(request.params[0]); | std::string label = LabelFromValue(request.params[0]); | ||||
bool force = request.strMethod == "getaccountaddress" ? true : false; | bool force = request.strMethod == "getaccountaddress"; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
force = request.params[1].get_bool(); | force = request.params[1].get_bool(); | ||||
} | } | ||||
bool label_found = false; | bool label_found = false; | ||||
for (const std::pair<CTxDestination, CAddressBookData> &item : | for (const std::pair<CTxDestination, CAddressBookData> &item : | ||||
pwallet->mapAddressBook) { | pwallet->mapAddressBook) { | ||||
if (item.second.name == label) { | if (item.second.name == label) { | ||||
▲ Show 20 Lines • Show All 723 Lines • ▼ Show 20 Lines | static UniValue getbalance(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() > 3) { | if (request.fHelp || | ||||
(request.params.size() > 3 && | |||||
IsDeprecatedRPCEnabled(gArgs, "accounts")) || | |||||
(request.params.size() != 0 && | |||||
!IsDeprecatedRPCEnabled(gArgs, "accounts"))) { | |||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getbalance ( \"account\" minconf include_watchonly )\n" | "getbalance ( \"account\" minconf include_watchonly )\n" | ||||
"\nIf account is not specified, returns the server's total " | "\nIf account is not specified, returns the server's total " | ||||
"available balance.\n" | "available balance.\n" | ||||
"The available balance is what the wallet considers currently " | "The available balance is what the wallet considers currently " | ||||
"spendable,\n" | "spendable,\n" | ||||
"and is thus affected by options which limit spendability such as " | "and is thus affected by options which limit spendability such as " | ||||
"-spendzeroconfchange.\n" | "-spendzeroconfchange.\n" | ||||
"If account is specified (DEPRECATED), returns the balance in the " | "If account is specified (DEPRECATED), returns the balance in the " | ||||
"account.\n" | "account.\n" | ||||
"Note that the account \"\" is not the same as leaving the " | "Note that the account \"\" is not the same as leaving the " | ||||
"parameter out.\n" | "parameter out.\n" | ||||
"The server total may be different to the balance in the default " | "The server total may be different to the balance in the default " | ||||
"\"\" account.\n" | "\"\" account.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"account\" (string, optional) DEPRECATED. The account " | "1. \"account\" (string, optional) DEPRECATED. This " | ||||
"argument will be removed in v0.21. \n" | |||||
" To use this deprecated argument, start " | |||||
"bitcoind with -deprecatedrpc=accounts. The account " | |||||
"string may be given as a\n" | "string may be given as a\n" | ||||
" specific account name to find the balance " | " specific account name to find the balance " | ||||
"associated with wallet keys in\n" | "associated with wallet keys in\n" | ||||
" a named account, or as the empty string " | " a named account, or as the empty string " | ||||
"(\"\") to find the balance\n" | "(\"\") to find the balance\n" | ||||
" associated with wallet keys not in any named " | " associated with wallet keys not in any named " | ||||
"account, or as \"*\" to find\n" | "account, or as \"*\" to find\n" | ||||
" the balance associated with all wallet keys " | " the balance associated with all wallet keys " | ||||
"regardless of account.\n" | "regardless of account.\n" | ||||
" When this option is specified, it calculates " | " When this option is specified, it calculates " | ||||
"the balance in a different\n" | "the balance in a different\n" | ||||
" way than when it is not specified, and which " | " way than when it is not specified, and which " | ||||
"can count spends twice when\n" | "can count spends twice when\n" | ||||
" there are conflicting pending transactions " | " there are conflicting pending transactions " | ||||
"temporarily resulting in low\n" | "temporarily resulting in low\n" | ||||
" or even negative balances.\n" | " or even negative balances.\n" | ||||
" In general, account balance calculation is " | " In general, account balance calculation is " | ||||
"not considered reliable and\n" | "not considered reliable and\n" | ||||
" has resulted in confusing outcomes, so it is " | " has resulted in confusing outcomes, so it is " | ||||
"recommended to avoid passing\n" | "recommended to avoid passing\n" | ||||
" this argument.\n" | " this argument.\n" | ||||
"2. minconf (numeric, optional, default=1) Only include " | "2. minconf (numeric, optional, default=1) DEPRECATED. " | ||||
"transactions confirmed at least this many times.\n" | "Only valid when an account is specified. This argument will be " | ||||
"3. include_watchonly (bool, optional, default=false) Also include " | "removed in V0.21. To use this deprecated argument, start bitcoind " | ||||
"balance in watch-only addresses (see 'importaddress')\n" | "with -deprecatedrpc=accounts. Only include transactions confirmed " | ||||
"at least this many times.\n" | |||||
"3. include_watchonly (bool, optional, default=false) DEPRECATED. " | |||||
"Only valid when an account is specified. This argument will be " | |||||
"removed in V0.21. To use this deprecated argument, start bitcoind " | |||||
"with -deprecatedrpc=accounts. 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 account.\n" | " received for this account.\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" + | ||||
HelpExampleCli("getbalance", "\"*\" 6") + "\nAs a json rpc call\n" + | HelpExampleCli("getbalance", "\"*\" 6") + "\nAs a json rpc call\n" + | ||||
HelpExampleRpc("getbalance", "\"*\", 6")); | HelpExampleRpc("getbalance", "\"*\", 6")); | ||||
} | } | ||||
// 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(); | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | |||||
const UniValue &account_value = request.params[0]; | const UniValue &account_value = request.params[0]; | ||||
const UniValue &minconf = request.params[1]; | const UniValue &minconf = request.params[1]; | ||||
const UniValue &include_watchonly = request.params[2]; | const UniValue &include_watchonly = request.params[2]; | ||||
if (account_value.isNull()) { | if (account_value.isNull()) { | ||||
if (!minconf.isNull()) { | if (!minconf.isNull()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError( | ||||
"getbalance minconf option is only currently " | RPC_INVALID_PARAMETER, | ||||
"supported if an account is specified"); | "getbalance minconf option is only currently supported if " | ||||
"an account is specified"); | |||||
} | } | ||||
if (!include_watchonly.isNull()) { | if (!include_watchonly.isNull()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"getbalance include_watchonly option is only currently " | "getbalance include_watchonly option is only currently " | ||||
"supported if an account is specified"); | "supported if an account is specified"); | ||||
} | } | ||||
return ValueFromAmount(pwallet->GetBalance()); | return ValueFromAmount(pwallet->GetBalance()); | ||||
} | } | ||||
const std::string &account_param = account_value.get_str(); | const std::string &account_param = account_value.get_str(); | ||||
const std::string *account = | const std::string *account = | ||||
account_param != "*" ? &account_param : nullptr; | account_param != "*" ? &account_param : nullptr; | ||||
int nMinDepth = 1; | int nMinDepth = 1; | ||||
if (!minconf.isNull()) { | if (!minconf.isNull()) { | ||||
nMinDepth = minconf.get_int(); | nMinDepth = minconf.get_int(); | ||||
} | } | ||||
isminefilter filter = ISMINE_SPENDABLE; | isminefilter filter = ISMINE_SPENDABLE; | ||||
if (!include_watchonly.isNull() && include_watchonly.get_bool()) { | if (!include_watchonly.isNull() && include_watchonly.get_bool()) { | ||||
filter = filter | ISMINE_WATCH_ONLY; | filter = filter | ISMINE_WATCH_ONLY; | ||||
} | } | ||||
return ValueFromAmount( | return ValueFromAmount( | ||||
pwallet->GetLegacyBalance(filter, nMinDepth, account)); | pwallet->GetLegacyBalance(filter, nMinDepth, account)); | ||||
} | } | ||||
return ValueFromAmount(pwallet->GetBalance()); | |||||
} | |||||
static UniValue getunconfirmedbalance(const Config &config, | static UniValue getunconfirmedbalance(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | |||||
static UniValue sendmany(const Config &config, const JSONRPCRequest &request) { | static UniValue sendmany(const Config &config, const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() < 2 || | std::string help_text; | ||||
request.params.size() > 5) { | if (!IsDeprecatedRPCEnabled(gArgs, "accounts")) { | ||||
throw std::runtime_error( | help_text = | ||||
"sendmany \"fromaccount\" {\"address\":amount,...} ( minconf " | "sendmany \"fromaccount\" {\"address\":amount,...} ( minconf " | ||||
"\"comment\" [\"address\",...] )\n" | "\"comment\" [\"address\",...] )\n" | ||||
"\nSend multiple times. Amounts are double-precision floating " | "\nSend multiple times. Amounts are double-precision floating " | ||||
"point numbers.\n" | |||||
"Note that the \"fromaccount\" argument has been removed in V0.20. " | |||||
"To use this RPC with a \"fromaccount\" argument, restart\n" | |||||
"bitcoind with -deprecatedrpc=accounts\n" + | |||||
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" | |||||
"\"txid\" (string) The transaction id for the " | |||||
"send. Only 1 transaction is created regardless of \n" | |||||
" the number of addresses.\n" | |||||
"\nExamples:\n" | |||||
"\nSend two amounts to two different addresses:\n" + | |||||
HelpExampleCli("sendmany", | |||||
"\"\" " | |||||
"\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | |||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}" | |||||
"\"") + | |||||
"\nSend two amounts to two different addresses setting the " | |||||
"confirmation and comment:\n" + | |||||
HelpExampleCli("sendmany", | |||||
"\"\" " | |||||
"\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | |||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" " | |||||
"6 \"testing\"") + | |||||
"\nSend two amounts to two different addresses, subtract fee from " | |||||
"amount:\n" + | |||||
HelpExampleCli("sendmany", | |||||
"\"\" " | |||||
"\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | |||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" " | |||||
"1 \"\" " | |||||
"\"[\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\"," | |||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") + | |||||
"\nAs a json rpc call\n" + | |||||
HelpExampleRpc("sendmany", | |||||
"\"\", " | |||||
"\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | |||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"," | |||||
" 6, \"testing\""); | |||||
} else { | |||||
help_text = | |||||
"sendmany \"\" \"fromaccount\" {\"address\":amount,...} ( " | |||||
"minconf \"comment\" [\"address\",...])\n" | |||||
"\nSend multiple times. Amounts are double-precision floating " | |||||
"point numbers." + | "point numbers." + | ||||
HelpRequiringPassphrase(pwallet) + | HelpRequiringPassphrase(pwallet) + | ||||
"\n" | "\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"fromaccount\" (string, required) DEPRECATED. The " | "1. \"fromaccount\" (string, required) DEPRECATED. The " | ||||
"account to send the funds from. Should be \"\" for the default " | "account to send the funds from. Should be \"\" for the default " | ||||
"account\n" | "account\n" | ||||
"2. \"amounts\" (string, required) A json object with " | "2. \"amounts\" (string, required) A json object with " | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (!IsDeprecatedRPCEnabled(gArgs, "accounts")) { | ||||
"1 \"\" " | "1 \"\" " | ||||
"\"[\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\"," | "\"[\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\"," | ||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") + | "\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") + | ||||
"\nAs a json rpc call\n" + | "\nAs a json rpc call\n" + | ||||
HelpExampleRpc("sendmany", | HelpExampleRpc("sendmany", | ||||
"\"\", " | "\"\", " | ||||
"\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | "\"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01," | ||||
"\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"," | "\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"," | ||||
" 6, \"testing\"")); | " 6, \"testing\""); | ||||
} | |||||
if (request.fHelp || request.params.size() < 2 || | |||||
request.params.size() > 5) { | |||||
throw std::runtime_error(help_text); | |||||
} | } | ||||
// 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(); | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
if (pwallet->GetBroadcastTransactions() && !g_connman) { | if (pwallet->GetBroadcastTransactions() && !g_connman) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_CLIENT_P2P_DISABLED, | RPC_CLIENT_P2P_DISABLED, | ||||
"Error: Peer-to-peer functionality missing or disabled"); | "Error: Peer-to-peer functionality missing or disabled"); | ||||
} | } | ||||
if (!IsDeprecatedRPCEnabled(gArgs, "accounts") && | |||||
!request.params[0].get_str().empty()) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"Dummy value must be set to \"\""); | |||||
} | |||||
std::string strAccount = LabelFromValue(request.params[0]); | std::string strAccount = LabelFromValue(request.params[0]); | ||||
UniValue sendTo = request.params[1].get_obj(); | UniValue sendTo = request.params[1].get_obj(); | ||||
int nMinDepth = 1; | int nMinDepth = 1; | ||||
if (!request.params[2].isNull()) { | if (!request.params[2].isNull()) { | ||||
nMinDepth = request.params[2].get_int(); | nMinDepth = request.params[2].get_int(); | ||||
} | } | ||||
mapValue_t mapValue; | mapValue_t mapValue; | ||||
▲ Show 20 Lines • Show All 510 Lines • ▼ Show 20 Lines | static void ListTransactions(CWallet *const pwallet, const CWalletTx &wtx, | ||||
if ((!listSent.empty() || nFee != Amount::zero()) && | if ((!listSent.empty() || nFee != Amount::zero()) && | ||||
(fAllAccounts || strAccount == strSentAccount)) { | (fAllAccounts || strAccount == strSentAccount)) { | ||||
for (const COutputEntry &s : listSent) { | for (const COutputEntry &s : listSent) { | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
if (involvesWatchonly || | if (involvesWatchonly || | ||||
(::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) { | (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) { | ||||
entry.pushKV("involvesWatchonly", true); | entry.pushKV("involvesWatchonly", true); | ||||
} | } | ||||
if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | |||||
entry.pushKV("account", strSentAccount); | entry.pushKV("account", strSentAccount); | ||||
} | |||||
MaybePushAddress(entry, s.destination); | MaybePushAddress(entry, s.destination); | ||||
entry.pushKV("category", "send"); | entry.pushKV("category", "send"); | ||||
entry.pushKV("amount", ValueFromAmount(-s.amount)); | entry.pushKV("amount", ValueFromAmount(-s.amount)); | ||||
if (pwallet->mapAddressBook.count(s.destination)) { | if (pwallet->mapAddressBook.count(s.destination)) { | ||||
entry.pushKV("label", | entry.pushKV("label", | ||||
pwallet->mapAddressBook[s.destination].name); | pwallet->mapAddressBook[s.destination].name); | ||||
} | } | ||||
entry.pushKV("vout", s.vout); | entry.pushKV("vout", s.vout); | ||||
Show All 14 Lines | if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { | ||||
account = pwallet->mapAddressBook[r.destination].name; | account = pwallet->mapAddressBook[r.destination].name; | ||||
} | } | ||||
if (fAllAccounts || (account == strAccount)) { | if (fAllAccounts || (account == strAccount)) { | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
if (involvesWatchonly || | if (involvesWatchonly || | ||||
(::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) { | (::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) { | ||||
entry.pushKV("involvesWatchonly", true); | entry.pushKV("involvesWatchonly", true); | ||||
} | } | ||||
if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | |||||
entry.pushKV("account", account); | entry.pushKV("account", account); | ||||
} | |||||
MaybePushAddress(entry, r.destination); | MaybePushAddress(entry, r.destination); | ||||
if (wtx.IsCoinBase()) { | if (wtx.IsCoinBase()) { | ||||
if (wtx.GetDepthInMainChain() < 1) { | if (wtx.GetDepthInMainChain() < 1) { | ||||
entry.pushKV("category", "orphan"); | entry.pushKV("category", "orphan"); | ||||
} else if (wtx.IsImmatureCoinBase()) { | } else if (wtx.IsImmatureCoinBase()) { | ||||
entry.pushKV("category", "immature"); | entry.pushKV("category", "immature"); | ||||
} else { | } else { | ||||
entry.pushKV("category", "generate"); | entry.pushKV("category", "generate"); | ||||
Show All 20 Lines | static void AcentryToJSON(const CAccountingEntry &acentry, | ||||
bool fAllAccounts = (strAccount == std::string("*")); | bool fAllAccounts = (strAccount == std::string("*")); | ||||
if (fAllAccounts || acentry.strAccount == strAccount) { | if (fAllAccounts || acentry.strAccount == strAccount) { | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
entry.pushKV("account", acentry.strAccount); | entry.pushKV("account", acentry.strAccount); | ||||
entry.pushKV("category", "move"); | entry.pushKV("category", "move"); | ||||
entry.pushKV("time", acentry.nTime); | entry.pushKV("time", acentry.nTime); | ||||
entry.pushKV("amount", ValueFromAmount(acentry.nCreditDebit)); | entry.pushKV("amount", ValueFromAmount(acentry.nCreditDebit)); | ||||
if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | |||||
entry.pushKV("otheraccount", acentry.strOtherAccount); | entry.pushKV("otheraccount", acentry.strOtherAccount); | ||||
} | |||||
entry.pushKV("comment", acentry.strComment); | entry.pushKV("comment", acentry.strComment); | ||||
ret.push_back(entry); | ret.push_back(entry); | ||||
} | } | ||||
} | } | ||||
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); | ||||
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) { | std::string help_text{}; | ||||
throw std::runtime_error( | if (!IsDeprecatedRPCEnabled(gArgs, "accounts")) { | ||||
help_text = | |||||
"listtransactions (dummy count skip include_watchonly)\n" | |||||
"\nReturns up to 'count' most recent transactions skipping the " | |||||
"first 'from' transactions for account 'account'.\n" | |||||
"Note that the \"account\" argument and \"otheraccount\" return " | |||||
"value have been removed in V0.20. To use this RPC with an " | |||||
"\"account\" argument, restart\n" | |||||
"bitcoind with -deprecatedrpc=accounts\n" | |||||
"\nArguments:\n" | |||||
"1. \"dummy\" (string, optional) If set, should be \"*\" for " | |||||
"backwards compatibility.\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" | |||||
"[\n" | |||||
" {\n" | |||||
" \"address\":\"address\", (string) The bitcoin address of " | |||||
"the transaction.\n" | |||||
" \"category\":\"send|receive\", (string) The transaction " | |||||
"category.\n" | |||||
" \"amount\": x.xxx, (numeric) The amount in " + | |||||
CURRENCY_UNIT + | |||||
". This is negative for the 'send' category, and is positive\n" | |||||
" for the 'receive' " | |||||
"category,\n" | |||||
" \"label\": \"label\", (string) A comment for the " | |||||
"address/transaction, if any\n" | |||||
" \"vout\": n, (numeric) the vout value\n" | |||||
" \"fee\": x.xxx, (numeric) The amount of the fee " | |||||
"in " + | |||||
CURRENCY_UNIT + | |||||
". This is negative and only available for the \n" | |||||
" 'send' category of " | |||||
"transactions.\n" | |||||
" \"confirmations\": n, (numeric) The number of " | |||||
"confirmations for the transaction. Negative confirmations " | |||||
"indicate the\n" | |||||
" transaction conflicts " | |||||
"with the block chain\n" | |||||
" \"trusted\": xxx, (bool) Whether we consider the " | |||||
"outputs of this unconfirmed transaction safe to spend.\n" | |||||
" \"blockhash\": \"hashvalue\", (string) The block hash " | |||||
"containing the transaction.\n" | |||||
" \"blockindex\": n, (numeric) The index of the " | |||||
"transaction in the block that includes it.\n" | |||||
" \"blocktime\": xxx, (numeric) The block time in " | |||||
"seconds since epoch (1 Jan 1970 GMT).\n" | |||||
" \"txid\": \"transactionid\", (string) The transaction id.\n" | |||||
" \"time\": xxx, (numeric) The transaction time in " | |||||
"seconds since epoch (midnight Jan 1 1970 GMT).\n" | |||||
" \"timereceived\": xxx, (numeric) The time received in " | |||||
"seconds since epoch (midnight Jan 1 1970 GMT).\n" | |||||
" \"comment\": \"...\", (string) If a comment is " | |||||
"associated with the transaction.\n" | |||||
" \"abandoned\": xxx (bool) 'true' if the transaction " | |||||
"has been abandoned (inputs are respendable). Only available for " | |||||
"the \n" | |||||
" 'send' category of " | |||||
"transactions.\n" | |||||
" }\n" | |||||
"]\n" | |||||
"\nExamples:\n" | |||||
"\nList the most recent 10 transactions in the systems\n" + | |||||
HelpExampleCli("listtransactions", "") + | |||||
"\nList transactions 100 to 120\n" + | |||||
HelpExampleCli("listtransactions", "\"*\" 20 100") + | |||||
"\nAs a json rpc call\n" + | |||||
HelpExampleRpc("listtransactions", "\"*\", 20, 100"); | |||||
} else { | |||||
help_text = | |||||
"listtransactions ( \"account\" count skip include_watchonly)\n" | "listtransactions ( \"account\" count skip include_watchonly)\n" | ||||
"\nReturns up to 'count' most recent transactions skipping the " | "\nReturns up to 'count' most recent transactions skipping the " | ||||
"first 'from' transactions for account 'account'.\n" | "first 'from' transactions for account 'account'.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"account\" (string, optional) DEPRECATED. The account " | "1. \"account\" (string, optional) DEPRECATED. This argument " | ||||
"name. Should be \"*\".\n" | "will be removed in V0.21. The account name. Should be \"*\".\n" | ||||
"2. count (numeric, optional, default=10) The number of " | "2. count (numeric, optional, default=10) The number of " | ||||
"transactions to return\n" | "transactions to return\n" | ||||
"3. skip (numeric, optional, default=0) The number of " | "3. skip (numeric, optional, default=0) The number of " | ||||
"transactions to skip\n" | "transactions to skip\n" | ||||
"4. include_watchonly (bool, optional, default=false) Include " | "4. include_watchonly (bool, optional, default=false) Include " | ||||
"transactions to watch-only addresses (see 'importaddress')\n" | "transactions to watch-only addresses (see 'importaddress')\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"account\":\"accountname\", (string) DEPRECATED. The " | " \"account\":\"accountname\", (string) DEPRECATED. This " | ||||
"account name associated with the transaction. \n" | "field will be removed in V0.21. The account name associated with " | ||||
"the transaction. \n" | |||||
" It will be \"\" " | " It will be \"\" " | ||||
"for the default account.\n" | "for the default account.\n" | ||||
" \"address\":\"address\", (string) The bitcoin address of " | " \"address\":\"address\", (string) The bitcoin address of " | ||||
"the transaction. Not present for \n" | "the transaction. Not present for \n" | ||||
" move transactions " | " move transactions " | ||||
"(category = move).\n" | "(category = move).\n" | ||||
" \"category\":\"send|receive|move\", (string) The transaction " | " \"category\":\"send|receive|move\", (string) The transaction " | ||||
"category. 'move' is a local (off blockchain)\n" | "category. 'move' is a local (off blockchain)\n" | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (!IsDeprecatedRPCEnabled(gArgs, "accounts")) { | ||||
" \"time\": xxx, (numeric) The transaction time in " | " \"time\": xxx, (numeric) The transaction time in " | ||||
"seconds since epoch (midnight Jan 1 1970 GMT).\n" | "seconds since epoch (midnight Jan 1 1970 GMT).\n" | ||||
" \"timereceived\": xxx, (numeric) The time received in " | " \"timereceived\": xxx, (numeric) The time received in " | ||||
"seconds since epoch (midnight Jan 1 1970 GMT). Available \n" | "seconds since epoch (midnight Jan 1 1970 GMT). Available \n" | ||||
" for 'send' and " | " for 'send' and " | ||||
"'receive' category of transactions.\n" | "'receive' category of transactions.\n" | ||||
" \"comment\": \"...\", (string) If a comment is " | " \"comment\": \"...\", (string) If a comment is " | ||||
"associated with the transaction.\n" | "associated with the transaction.\n" | ||||
" \"otheraccount\": \"accountname\", (string) DEPRECATED. For " | " \"otheraccount\": \"accountname\", (string) DEPRECATED. This " | ||||
"the 'move' category of transactions, the account the funds came \n" | "field will be removed in V0.21. For the 'move' category of " | ||||
"transactions, the account the funds came \n" | |||||
" from (for receiving " | " from (for receiving " | ||||
"funds, positive amounts), or went to (for sending funds,\n" | "funds, positive amounts), or went to (for sending funds,\n" | ||||
" negative amounts).\n" | " negative amounts).\n" | ||||
" \"abandoned\": xxx (bool) 'true' if the transaction " | " \"abandoned\": xxx (bool) 'true' if the transaction " | ||||
"has been abandoned (inputs are respendable). Only available for " | "has been abandoned (inputs are respendable). Only available for " | ||||
"the \n" | "the \n" | ||||
" 'send' category of " | " 'send' category of " | ||||
"transactions.\n" | "transactions.\n" | ||||
" }\n" | " }\n" | ||||
"]\n" | "]\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nList the most recent 10 transactions in the systems\n" + | "\nList the most recent 10 transactions in the systems\n" + | ||||
HelpExampleCli("listtransactions", "") + | HelpExampleCli("listtransactions", "") + | ||||
"\nList transactions 100 to 120\n" + | "\nList transactions 100 to 120\n" + | ||||
HelpExampleCli("listtransactions", "\"*\" 20 100") + | HelpExampleCli("listtransactions", "\"*\" 20 100") + | ||||
"\nAs a json rpc call\n" + | "\nAs a json rpc call\n" + | ||||
HelpExampleRpc("listtransactions", "\"*\", 20, 100")); | HelpExampleRpc("listtransactions", "\"*\", 20, 100"); | ||||
} | |||||
if (request.fHelp || request.params.size() > 4) { | |||||
throw std::runtime_error(help_text); | |||||
} | } | ||||
// 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(); | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
std::string strAccount = "*"; | std::string strAccount = "*"; | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
strAccount = request.params[0].get_str(); | strAccount = request.params[0].get_str(); | ||||
if (!IsDeprecatedRPCEnabled(gArgs, "accounts") && strAccount != "*") { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"Dummy value must be set to \"*\""); | |||||
} | |||||
} | } | ||||
int nCount = 10; | int nCount = 10; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
nCount = request.params[1].get_int(); | nCount = request.params[1].get_int(); | ||||
} | } | ||||
int nFrom = 0; | int nFrom = 0; | ||||
if (!request.params[2].isNull()) { | if (!request.params[2].isNull()) { | ||||
nFrom = request.params[2].get_int(); | nFrom = request.params[2].get_int(); | ||||
Show All 16 Lines | UniValue listtransactions(const Config &config, const JSONRPCRequest &request) { | ||||
// iterate backwards until we have nCount items to return: | // iterate backwards until we have nCount items to return: | ||||
for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); | for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); | ||||
it != txOrdered.rend(); ++it) { | it != txOrdered.rend(); ++it) { | ||||
CWalletTx *const pwtx = (*it).second.first; | CWalletTx *const pwtx = (*it).second.first; | ||||
if (pwtx != nullptr) { | if (pwtx != nullptr) { | ||||
ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter); | ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter); | ||||
} | } | ||||
if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | |||||
CAccountingEntry *const pacentry = (*it).second.second; | CAccountingEntry *const pacentry = (*it).second.second; | ||||
if (pacentry != nullptr) { | if (pacentry != nullptr) { | ||||
AcentryToJSON(*pacentry, strAccount, ret); | AcentryToJSON(*pacentry, strAccount, ret); | ||||
} | } | ||||
} | |||||
if ((int)ret.size() >= (nCount + nFrom)) { | if ((int)ret.size() >= (nCount + nFrom)) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// ret is newest to oldest | // ret is newest to oldest | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 4) { | ||||
"4. include_removed: (bool, optional, default=true) Show " | "4. include_removed: (bool, optional, default=true) Show " | ||||
"transactions that were removed due to a reorg in the \"removed\" " | "transactions that were removed due to a reorg in the \"removed\" " | ||||
"array\n" | "array\n" | ||||
" (not " | " (not " | ||||
"guaranteed to work on pruned nodes)\n" | "guaranteed to work on pruned nodes)\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"transactions\": [\n" | " \"transactions\": [\n" | ||||
" \"account\":\"accountname\", (string) DEPRECATED. The " | " \"account\":\"accountname\", (string) DEPRECATED. This " | ||||
"field will be removed in V0.21. To see this deprecated field, " | |||||
"start bitcoind with -deprecatedrpc=accounts. The " | |||||
"account name associated with the transaction. Will be \"\" for " | "account name associated with the transaction. Will be \"\" for " | ||||
"the default account.\n" | "the default account.\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 " | ||||
"amounts.\n" | "amounts.\n" | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
" \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether " | " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether " | ||||
"this transaction could be replaced due to BIP125 " | "this transaction could be replaced due to BIP125 " | ||||
"(replace-by-fee);\n" | "(replace-by-fee);\n" | ||||
" may be unknown " | " may be unknown " | ||||
"for unconfirmed transactions not in the mempool\n" | "for unconfirmed transactions not in the mempool\n" | ||||
" \"details\" : [\n" | " \"details\" : [\n" | ||||
" {\n" | " {\n" | ||||
" \"account\" : \"accountname\", (string) DEPRECATED. " | " \"account\" : \"accountname\", (string) DEPRECATED. " | ||||
"The account name involved in the transaction, can be \"\" for the " | "This field will be removed in a V0.21. To see this deprecated " | ||||
"default account.\n" | "field, start bitcoind with -deprecatedrpc=accounts. The account " | ||||
"name involved in the transaction, can be \"\" for the default " | |||||
"account.\n" | |||||
" \"address\" : \"address\", (string) The bitcoin " | " \"address\" : \"address\", (string) The bitcoin " | ||||
"address involved in the transaction\n" | "address involved in the transaction\n" | ||||
" \"category\" : \"send|receive\", (string) The category, " | " \"category\" : \"send|receive\", (string) The category, " | ||||
"either 'send' or 'receive'\n" | "either 'send' or 'receive'\n" | ||||
" \"amount\" : x.xxx, (numeric) The amount " | " \"amount\" : x.xxx, (numeric) The amount " | ||||
"in " + | "in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
▲ Show 20 Lines • Show All 1,150 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 5) { | ||||
"\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" | ||||
" \"account\" : \"account\", (string) DEPRECATED. Backwards " | " \"account\" : \"account\", (string) DEPRECATED. This field " | ||||
"compatible alias for label.\n" | "will be removed in v0.21. To see this deprecated field, start " | ||||
"bitcoind with -deprecatedrpc=accounts. The associated account, or " | |||||
"\"\" for the default account\n" | |||||
" \"scriptPubKey\" : \"key\", (string) the script key\n" | " \"scriptPubKey\" : \"key\", (string) the script key\n" | ||||
" \"amount\" : x.xxx, (numeric) the transaction output " | " \"amount\" : x.xxx, (numeric) the transaction output " | ||||
"amount in " + | "amount in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"confirmations\" : n, (numeric) The number of " | " \"confirmations\" : n, (numeric) The number of " | ||||
"confirmations\n" | "confirmations\n" | ||||
" \"redeemScript\" : n (string) The redeemScript if " | " \"redeemScript\" : n (string) The redeemScript if " | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | for (const COutput &out : vecOutputs) { | ||||
entry.pushKV("txid", out.tx->GetId().GetHex()); | entry.pushKV("txid", out.tx->GetId().GetHex()); | ||||
entry.pushKV("vout", out.i); | entry.pushKV("vout", out.i); | ||||
if (fValidAddress) { | if (fValidAddress) { | ||||
entry.pushKV("address", EncodeDestination(address, config)); | entry.pushKV("address", EncodeDestination(address, config)); | ||||
if (pwallet->mapAddressBook.count(address)) { | if (pwallet->mapAddressBook.count(address)) { | ||||
entry.pushKV("label", pwallet->mapAddressBook[address].name); | entry.pushKV("label", pwallet->mapAddressBook[address].name); | ||||
entry.pushKV("account", pwallet->mapAddressBook[address].name); | if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | ||||
entry.pushKV("account", | |||||
pwallet->mapAddressBook[address].name); | |||||
} | |||||
} | } | ||||
if (scriptPubKey.IsPayToScriptHash()) { | if (scriptPubKey.IsPayToScriptHash()) { | ||||
const CScriptID &hash = boost::get<CScriptID>(address); | const CScriptID &hash = boost::get<CScriptID>(address); | ||||
CScript redeemScript; | CScript redeemScript; | ||||
if (pwallet->GetCScript(hash, redeemScript)) { | if (pwallet->GetCScript(hash, redeemScript)) { | ||||
entry.pushKV("redeemScript", HexStr(redeemScript.begin(), | entry.pushKV("redeemScript", HexStr(redeemScript.begin(), | ||||
redeemScript.end())); | redeemScript.end())); | ||||
▲ Show 20 Lines • Show All 641 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
" \"embedded\" : {...}, (object, optional) Information " | " \"embedded\" : {...}, (object, optional) Information " | ||||
"about the address embedded in P2SH or P2WSH, if relevant and " | "about the address embedded in P2SH or P2WSH, if relevant and " | ||||
"known. It includes all getaddressinfo output fields for the " | "known. It includes all getaddressinfo output fields for the " | ||||
"embedded address, excluding metadata (\"timestamp\", " | "embedded address, excluding metadata (\"timestamp\", " | ||||
"\"hdkeypath\", \"hdseedid\") and relation to the wallet " | "\"hdkeypath\", \"hdseedid\") and relation to the wallet " | ||||
"(\"ismine\", \"iswatchonly\", \"account\").\n" | "(\"ismine\", \"iswatchonly\", \"account\").\n" | ||||
" \"iscompressed\" : true|false, (boolean) If the address is " | " \"iscompressed\" : true|false, (boolean) If the address is " | ||||
"compressed\n" | "compressed\n" | ||||
" \"account\" : \"account\" (string) The account " | " \"label\" : \"label\" (string) The label associated " | ||||
"with the address, \"\" is the default account\n" | |||||
" \"account\" : \"account\" (string) DEPRECATED. This " | |||||
"field will be removed in V0.21. To see this deprecated field, " | |||||
"start bitcoind with -deprecatedrpc=accounts. The account " | |||||
"associated with the address, \"\" is the default account\n" | "associated with the address, \"\" is the default account\n" | ||||
" \"timestamp\" : timestamp, (number, optional) The creation " | " \"timestamp\" : timestamp, (number, optional) The creation " | ||||
"time of the key if available in seconds since epoch (Jan 1 1970 " | "time of the key if available in seconds since epoch (Jan 1 1970 " | ||||
"GMT)\n" | "GMT)\n" | ||||
" \"hdkeypath\" : \"keypath\" (string, optional) The HD " | " \"hdkeypath\" : \"keypath\" (string, optional) The HD " | ||||
"keypath if the key is HD and available\n" | "keypath if the key is HD and available\n" | ||||
" \"hdseedid\" : \"<hash160>\" (string, optional) The " | " \"hdseedid\" : \"<hash160>\" (string, optional) The " | ||||
"Hash160 of the HD seed\n" | "Hash160 of the HD seed\n" | ||||
Show All 37 Lines | ret.pushKV("scriptPubKey", | ||||
HexStr(scriptPubKey.begin(), scriptPubKey.end())); | HexStr(scriptPubKey.begin(), scriptPubKey.end())); | ||||
isminetype mine = IsMine(*pwallet, dest); | isminetype mine = IsMine(*pwallet, dest); | ||||
ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); | ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); | ||||
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); | ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); | ||||
UniValue detail = DescribeWalletAddress(pwallet, dest); | UniValue detail = DescribeWalletAddress(pwallet, dest); | ||||
ret.pushKVs(detail); | ret.pushKVs(detail); | ||||
if (pwallet->mapAddressBook.count(dest)) { | if (pwallet->mapAddressBook.count(dest)) { | ||||
ret.pushKV("label", pwallet->mapAddressBook[dest].name); | |||||
if (IsDeprecatedRPCEnabled(gArgs, "accounts")) { | |||||
ret.pushKV("account", pwallet->mapAddressBook[dest].name); | ret.pushKV("account", pwallet->mapAddressBook[dest].name); | ||||
} | } | ||||
} | |||||
const CKeyMetadata *meta = nullptr; | const CKeyMetadata *meta = nullptr; | ||||
CKeyID key_id = GetKeyForDestination(*pwallet, dest); | CKeyID key_id = GetKeyForDestination(*pwallet, dest); | ||||
if (!key_id.IsNull()) { | if (!key_id.IsNull()) { | ||||
auto it = pwallet->mapKeyMetadata.find(key_id); | auto it = pwallet->mapKeyMetadata.find(key_id); | ||||
if (it != pwallet->mapKeyMetadata.end()) { | if (it != pwallet->mapKeyMetadata.end()) { | ||||
meta = &it->second; | meta = &it->second; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | static const ContextFreeRPCCommand commands[] = { | ||||
{ "wallet", "gettransaction", gettransaction, {"txid","include_watchonly"} }, | { "wallet", "gettransaction", gettransaction, {"txid","include_watchonly"} }, | ||||
{ "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, | { "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, | ||||
{ "wallet", "getwalletinfo", getwalletinfo, {} }, | { "wallet", "getwalletinfo", getwalletinfo, {} }, | ||||
{ "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, | { "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, | ||||
{ "wallet", "listaddressgroupings", listaddressgroupings, {} }, | { "wallet", "listaddressgroupings", listaddressgroupings, {} }, | ||||
{ "wallet", "listlockunspent", listlockunspent, {} }, | { "wallet", "listlockunspent", listlockunspent, {} }, | ||||
{ "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} }, | { "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} }, | ||||
{ "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} }, | { "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} }, | ||||
{ "wallet", "listtransactions", listtransactions, {"account","count","skip","include_watchonly"} }, | { "wallet", "listtransactions", listtransactions, {"account|dummy","count","skip","include_watchonly"} }, | ||||
{ "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, | { "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, | ||||
{ "wallet", "listwallets", listwallets, {} }, | { "wallet", "listwallets", listwallets, {} }, | ||||
{ "wallet", "loadwallet", loadwallet, {"filename"} }, | { "wallet", "loadwallet", loadwallet, {"filename"} }, | ||||
{ "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | { "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | ||||
{ "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | { "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | ||||
{ "wallet", "sethdseed", sethdseed, {"newkeypool","seed"} }, | { "wallet", "sethdseed", sethdseed, {"newkeypool","seed"} }, | ||||
{ "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | { "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | ||||
{ "wallet", "sendmany", sendmany, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, | { "wallet", "sendmany", sendmany, {"fromaccount|dummy","amounts","minconf","comment","subtractfeefrom"} }, | ||||
{ "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | { "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | ||||
{ "wallet", "settxfee", settxfee, {"amount"} }, | { "wallet", "settxfee", settxfee, {"amount"} }, | ||||
{ "wallet", "signmessage", signmessage, {"address","message"} }, | { "wallet", "signmessage", signmessage, {"address","message"} }, | ||||
{ "wallet", "signrawtransactionwithwallet", signrawtransactionwithwallet, {"hextring","prevtxs","sighashtype"} }, | { "wallet", "signrawtransactionwithwallet", signrawtransactionwithwallet, {"hextring","prevtxs","sighashtype"} }, | ||||
{ "wallet", "unloadwallet", unloadwallet, {"wallet_name"} }, | { "wallet", "unloadwallet", unloadwallet, {"wallet_name"} }, | ||||
{ "wallet", "walletlock", walletlock, {} }, | { "wallet", "walletlock", walletlock, {} }, | ||||
{ "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, | { "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, | ||||
{ "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, | { "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, | ||||
Show All 28 Lines |