aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-09-22 03:22:34 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2013-07-17 03:05:38 +0000
commitcc6cfab38fcdd4ec3e4784e01c4407a129289f77 (patch)
tree81918b4a1e7e33a67dd7cc41e99047a8f4982d33 /src/rpcwallet.cpp
parent96ed68217626ad07b0d8d9ea6e4871b092535963 (diff)
downloadbitcoin-cc6cfab38fcdd4ec3e4784e01c4407a129289f77.tar.xz
Bugfix: Supress "address" key in transaction details, when the destination isn't recognized
Previously, it would pass corrupt/random through base58.
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 5388bd4d84..23ea52f5b9 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -953,6 +953,13 @@ Value listreceivedbyaccount(const Array& params, bool fHelp)
return ListReceived(params, true);
}
+static void MaybePushAddress(Object & entry, const CTxDestination &dest)
+{
+ CBitcoinAddress addr;
+ if (addr.Set(dest))
+ entry.push_back(Pair("address", addr.ToString()));
+}
+
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)
{
int64 nFee;
@@ -971,7 +978,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
{
Object entry;
entry.push_back(Pair("account", strSentAccount));
- entry.push_back(Pair("address", CBitcoinAddress(s.first).ToString()));
+ MaybePushAddress(entry, s.first);
entry.push_back(Pair("category", "send"));
entry.push_back(Pair("amount", ValueFromAmount(-s.second)));
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
@@ -993,7 +1000,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
{
Object entry;
entry.push_back(Pair("account", account));
- entry.push_back(Pair("address", CBitcoinAddress(r.first).ToString()));
+ MaybePushAddress(entry, r.first);
if (wtx.IsCoinBase())
{
if (wtx.GetDepthInMainChain() < 1)