From 1b4568cb0f00dd7a24575fe54c017e743c4e7d35 Mon Sep 17 00:00:00 2001 From: Cozz Lovan Date: Fri, 30 May 2014 00:54:00 +0200 Subject: Add vout to ListTransactions output --- src/wallet.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index a754c1cd5f..89a260480e 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -798,8 +798,8 @@ int CWalletTx::GetRequestCount() const return nRequests; } -void CWalletTx::GetAmounts(list >& listReceived, - list >& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const +void CWalletTx::GetAmounts(list& listReceived, + list& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const { nFee = 0; listReceived.clear(); @@ -815,10 +815,10 @@ void CWalletTx::GetAmounts(list >& listReceived, } // Sent/received. - BOOST_FOREACH(const CTxOut& txout, vout) + for (int i = 0; i < vout.size(); ++i) { + const CTxOut& txout = vout[i]; isminetype fIsMine = pwallet->IsMine(txout); - // Only need to handle txouts if AT LEAST one of these is true: // 1) they debit from us (sent) // 2) the output is to us (received) @@ -840,13 +840,15 @@ void CWalletTx::GetAmounts(list >& listReceived, address = CNoDestination(); } + COutputEntry output = {address, txout.nValue, i}; + // If we are debited by the transaction, add the output as a "sent" entry if (nDebit > 0) - listSent.push_back(make_pair(address, txout.nValue)); + listSent.push_back(output); // If we are receiving the output, add it as a "received" entry if (fIsMine & filter) - listReceived.push_back(make_pair(address, txout.nValue)); + listReceived.push_back(output); } } @@ -858,29 +860,29 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nReceived, int64_t allFee; string strSentAccount; - list > listReceived; - list > listSent; + list listReceived; + list listSent; GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (strAccount == strSentAccount) { - BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& s, listSent) - nSent += s.second; + BOOST_FOREACH(const COutputEntry& s, listSent) + nSent += s.amount; nFee = allFee; } { LOCK(pwallet->cs_wallet); - BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived) + BOOST_FOREACH(const COutputEntry& r, listReceived) { - if (pwallet->mapAddressBook.count(r.first)) + if (pwallet->mapAddressBook.count(r.destination)) { - map::const_iterator mi = pwallet->mapAddressBook.find(r.first); + map::const_iterator mi = pwallet->mapAddressBook.find(r.destination); if (mi != pwallet->mapAddressBook.end() && (*mi).second.name == strAccount) - nReceived += r.second; + nReceived += r.amount; } else if (strAccount.empty()) { - nReceived += r.second; + nReceived += r.amount; } } } -- cgit v1.2.3