diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-01-18 14:35:03 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-01-18 14:35:03 -0500 |
commit | 76e97c40028b544e54df017382679e8b954bb9b5 (patch) | |
tree | 3673e204c00da61fffec62aed3c4edb318422d5c /rpc.cpp | |
parent | 1aefe491fb1b1311973c9561493d201c7504a120 (diff) | |
parent | 80be6e69a92130175da623fbb75552a04d3ff4f8 (diff) |
Merge branch 'gettransaction' of https://github.com/gavinandresen/bitcoin-git into integration
Diffstat (limited to 'rpc.cpp')
-rw-r--r-- | rpc.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -877,7 +877,7 @@ Value listreceivedbyaccount(const Array& params, bool fHelp) return ListReceived(params, true); } -void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, Array& ret) +void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret) { int64 nGenerated, nFee; string strSentAccount; @@ -894,7 +894,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe entry.push_back(Pair("account", string(""))); entry.push_back(Pair("category", "generate")); entry.push_back(Pair("amount", ValueFromAmount(nGenerated))); - WalletTxToJSON(wtx, entry); + if (fLong) + WalletTxToJSON(wtx, entry); ret.push_back(entry); } @@ -909,7 +910,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe entry.push_back(Pair("category", "send")); entry.push_back(Pair("amount", ValueFromAmount(-s.second))); entry.push_back(Pair("fee", ValueFromAmount(-nFee))); - WalletTxToJSON(wtx, entry); + if (fLong) + WalletTxToJSON(wtx, entry); ret.push_back(entry); } } @@ -930,7 +932,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe entry.push_back(Pair("address", r.first)); entry.push_back(Pair("category", "receive")); entry.push_back(Pair("amount", ValueFromAmount(r.second))); - WalletTxToJSON(wtx, entry); + if (fLong) + WalletTxToJSON(wtx, entry); ret.push_back(entry); } } @@ -996,7 +999,7 @@ Value listtransactions(const Array& params, bool fHelp) { CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) - ListTransactions(*pwtx, strAccount, 0, ret); + ListTransactions(*pwtx, strAccount, 0, true, ret); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); @@ -1083,7 +1086,7 @@ Value gettransaction(const Array& params, bool fHelp) CRITICAL_BLOCK(cs_mapWallet) { if (!mapWallet.count(hash)) - throw JSONRPCError(-5, "Invalid transaction id"); + throw JSONRPCError(-5, "Invalid or non-wallet transaction id"); const CWalletTx& wtx = mapWallet[hash]; int64 nCredit = wtx.GetCredit(); @@ -1094,7 +1097,12 @@ Value gettransaction(const Array& params, bool fHelp) entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); if (wtx.IsFromMe()) entry.push_back(Pair("fee", ValueFromAmount(nFee))); + WalletTxToJSON(mapWallet[hash], entry); + + Array details; + ListTransactions(mapWallet[hash], "*", 0, false, details); + entry.push_back(Pair("details", details)); } return entry; |