Skip to content

Commit 755b4ba

Browse files
committed
Merge pull request #5574
fd55571 wallet: Expose GUI labels in RPC (Luke Dashjr)
2 parents 77beab7 + fd55571 commit 755b4ba

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,8 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
11821182
obj.push_back(Pair("account", strAccount));
11831183
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
11841184
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
1185+
if (!fByAccounts)
1186+
obj.push_back(Pair("label", strAccount));
11851187
UniValue transactions(UniValue::VARR);
11861188
if (it != mapTally.end())
11871189
{
@@ -1235,7 +1237,8 @@ UniValue listreceivedbyaddress(const UniValue& params, bool fHelp)
12351237
" \"address\" : \"receivingaddress\", (string) The receiving address\n"
12361238
" \"account\" : \"accountname\", (string) DEPRECATED. The account of the receiving address. The default account is \"\".\n"
12371239
" \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " received by the address\n"
1238-
" \"confirmations\" : n (numeric) The number of confirmations of the most recent transaction included\n"
1240+
" \"confirmations\" : n, (numeric) The number of confirmations of the most recent transaction included\n"
1241+
" \"label\" : \"label\" (string) A comment for the address/transaction, if any\n"
12391242
" }\n"
12401243
" ,...\n"
12411244
"]\n"
@@ -1271,7 +1274,8 @@ UniValue listreceivedbyaccount(const UniValue& params, bool fHelp)
12711274
" \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n"
12721275
" \"account\" : \"accountname\", (string) The account name of the receiving account\n"
12731276
" \"amount\" : x.xxx, (numeric) The total amount received by addresses with this account\n"
1274-
" \"confirmations\" : n (numeric) The number of confirmations of the most recent transaction included\n"
1277+
" \"confirmations\" : n, (numeric) The number of confirmations of the most recent transaction included\n"
1278+
" \"label\" : \"label\" (string) A comment for the address/transaction, if any\n"
12751279
" }\n"
12761280
" ,...\n"
12771281
"]\n"
@@ -1318,6 +1322,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
13181322
MaybePushAddress(entry, s.destination);
13191323
entry.push_back(Pair("category", "send"));
13201324
entry.push_back(Pair("amount", ValueFromAmount(-s.amount)));
1325+
if (pwalletMain->mapAddressBook.count(s.destination))
1326+
entry.push_back(Pair("label", pwalletMain->mapAddressBook[s.destination].name));
13211327
entry.push_back(Pair("vout", s.vout));
13221328
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
13231329
if (fLong)
@@ -1355,6 +1361,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
13551361
entry.push_back(Pair("category", "receive"));
13561362
}
13571363
entry.push_back(Pair("amount", ValueFromAmount(r.amount)));
1364+
if (pwalletMain->mapAddressBook.count(r.destination))
1365+
entry.push_back(Pair("label", account));
13581366
entry.push_back(Pair("vout", r.vout));
13591367
if (fLong)
13601368
WalletTxToJSON(wtx, entry);
@@ -1423,6 +1431,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp)
14231431
" \"timereceived\": xxx, (numeric) The time received in seconds since epoch (midnight Jan 1 1970 GMT). Available \n"
14241432
" for 'send' and 'receive' category of transactions.\n"
14251433
" \"comment\": \"...\", (string) If a comment is associated with the transaction.\n"
1434+
" \"label\" : \"label\" (string) A comment for the address/transaction, if any\n"
14261435
" \"otheraccount\": \"accountname\", (string) For the 'move' category of transactions, the account the funds came \n"
14271436
" from (for receiving funds, positive amounts), or went to (for sending funds,\n"
14281437
" negative amounts).\n"
@@ -1613,6 +1622,7 @@ UniValue listsinceblock(const UniValue& params, bool fHelp)
16131622
" \"time\": xxx, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT).\n"
16141623
" \"timereceived\": xxx, (numeric) The time received in seconds since epoch (Jan 1 1970 GMT). Available for 'send' and 'receive' category of transactions.\n"
16151624
" \"comment\": \"...\", (string) If a comment is associated with the transaction.\n"
1625+
" \"label\" : \"label\" (string) A comment for the address/transaction, if any\n"
16161626
" \"to\": \"...\", (string) If a comment to is associated with the transaction.\n"
16171627
" ],\n"
16181628
" \"lastblock\": \"lastblockhash\" (string) The hash of the last block\n"
@@ -1700,7 +1710,8 @@ UniValue gettransaction(const UniValue& params, bool fHelp)
17001710
" \"account\" : \"accountname\", (string) DEPRECATED. The account name involved in the transaction, can be \"\" for the default account.\n"
17011711
" \"address\" : \"bitcoinaddress\", (string) The bitcoin address involved in the transaction\n"
17021712
" \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n"
1703-
" \"amount\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n"
1713+
" \"amount\" : x.xxx, (numeric) The amount in " + CURRENCY_UNIT + "\n"
1714+
" \"label\" : \"label\", (string) A comment for the address/transaction, if any\n"
17041715
" \"vout\" : n, (numeric) the vout value\n"
17051716
" }\n"
17061717
" ,...\n"

0 commit comments

Comments
 (0)