aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2018-10-06 00:48:23 -0400
committerJohn Newbery <john@johnnewbery.com>2018-10-10 16:34:50 +0900
commit89306ab0df93bfdf5630910bc20b1eccb7379172 (patch)
treee44f6391b1ecc4d5d906999e3c561b9d1997b0da /src/wallet
parent5b47b8efd48d233a5f7c12d1d7713dcd2f616255 (diff)
downloadbitcoin-89306ab0df93bfdf5630910bc20b1eccb7379172.tar.xz
[wallet] Restore ability to list incoming transactions by label
Backport of PR 14411 to v0.17. This change partially reverts #13075 and #14023. Fixes #14382
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/rpcwallet.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index bb7ceb424c..a3de618059 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -1805,9 +1805,14 @@ static void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const
bool fAllAccounts = (strAccount == std::string("*"));
bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);
+ bool list_sent = fAllAccounts;
+
+ if (IsDeprecatedRPCEnabled("accounts")) {
+ list_sent |= strAccount == strSentAccount;
+ }
+
// Sent
- if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
- {
+ if (list_sent) {
for (const COutputEntry& s : listSent)
{
UniValue entry(UniValue::VOBJ);
@@ -1901,12 +1906,14 @@ UniValue listtransactions(const JSONRPCRequest& request)
std::string help_text {};
if (!IsDeprecatedRPCEnabled("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"
+ help_text = "listtransactions (label count skip include_watchonly)\n"
+ "\nIf a label name is provided, this will return only incoming transactions paying to addresses with the specified label.\n"
+ "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n"
"Note that the \"account\" argument and \"otheraccount\" return value have been removed in V0.17. 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"
+ "1. \"label\" (string, optional) If set, should be a valid label name to return only incoming transactions\n"
+ " with the specified label, or \"*\" to disable filtering and return all transactions.\n"
"2. count (numeric, optional, default=10) The number of transactions to return\n"
"3. skip (numeric, optional, default=0) The number of transactions to skip\n"
"4. include_watchonly (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')\n"
@@ -2012,8 +2019,8 @@ UniValue listtransactions(const JSONRPCRequest& request)
std::string strAccount = "*";
if (!request.params[0].isNull()) {
strAccount = request.params[0].get_str();
- if (!IsDeprecatedRPCEnabled("accounts") && strAccount != "*") {
- throw JSONRPCError(RPC_INVALID_PARAMETER, "Dummy value must be set to \"*\"");
+ if (!IsDeprecatedRPCEnabled("accounts") && strAccount.empty()) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Label argument must be a valid label name or \"*\".");
}
}
int nCount = 10;
@@ -4801,7 +4808,7 @@ static const CRPCCommand commands[] =
{ "wallet", "listlockunspent", &listlockunspent, {} },
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} },
{ "wallet", "listsinceblock", &listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} },
- { "wallet", "listtransactions", &listtransactions, {"account|dummy","count","skip","include_watchonly"} },
+ { "wallet", "listtransactions", &listtransactions, {"account|label|dummy","count","skip","include_watchonly"} },
{ "wallet", "listunspent", &listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} },
{ "wallet", "listwallets", &listwallets, {} },
{ "wallet", "loadwallet", &loadwallet, {"filename"} },