From: Luke Dashjr Date: Sat, 22 Sep 2012 03:22:34 +0000 (+0000) Subject: Bugfix: Supress "address" key in transaction details, when the destination isn't... X-Git-Tag: v0.4.4.6-nvc-update4~3 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=3f179a1e71ab1f391f385328abd8b3f9f4051dca;hp=3802178d00f0794d8369924cd333e12bfc1f946c;p=novacoin.git Bugfix: Supress "address" key in transaction details, when the destination isn't recognized Previously, it would pass corrupt/random through base58. Conflicts: src/rpcwallet.cpp --- diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 8a1967a..f6cd0fe 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -986,6 +986,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; @@ -1024,8 +1031,14 @@ 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())); - entry.push_back(Pair("category", "send")); + MaybePushAddress(entry, s.first); + + if (wtx.GetDepthInMainChain() < 0) { + entry.push_back(Pair("category", "conflicted")); + } else { + entry.push_back(Pair("category", "send")); + } + entry.push_back(Pair("amount", ValueFromAmount(-s.second))); entry.push_back(Pair("fee", ValueFromAmount(-nFee))); if (fLong) @@ -1046,7 +1059,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)