From 473ac8f6764bfd69746378a21e6ce264be554344 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 22 Sep 2012 03:22:34 +0000 Subject: [PATCH] Bugfix: Supress "address" key in transaction details, when the destination isn't recognized Previously, it would pass corrupt/random through base58. Rebased-from: 33a3cfaf0fe7ab8f23b815e678fe72f2a95fb61f 0.8.x --- src/rpcwallet.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 73ee8289e..670258de2 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -976,6 +976,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; @@ -994,7 +1001,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))); @@ -1016,7 +1023,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)