Bugfix: Supress "address" key in transaction details, when the destination isn't... 9/head
authorLuke Dashjr <luke-jr+git@utopios.org>
Sat, 22 Sep 2012 03:22:34 +0000 (03:22 +0000)
committerCryptoManiac <balthazar@yandex.ru>
Sun, 23 Feb 2014 16:49:04 +0000 (20:49 +0400)
Previously, it would pass corrupt/random through base58.

Conflicts:

src/rpcwallet.cpp

src/rpcwallet.cpp

index c6a4302..184894c 100644 (file)
@@ -1001,6 +1001,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 nGeneratedImmature, nGeneratedMature, nFee;
@@ -1039,7 +1046,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);
 
             if (wtx.GetDepthInMainChain() < 0) {
                 entry.push_back(Pair("category", "conflicted"));
@@ -1067,7 +1074,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)