Add vout to ListTransactions output
This commit is contained in:
@@ -798,8 +798,8 @@ int CWalletTx::GetRequestCount() const
|
||||
return nRequests;
|
||||
}
|
||||
|
||||
void CWalletTx::GetAmounts(list<pair<CTxDestination, int64_t> >& listReceived,
|
||||
list<pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const
|
||||
void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
|
||||
list<COutputEntry>& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const
|
||||
{
|
||||
nFee = 0;
|
||||
listReceived.clear();
|
||||
@@ -815,10 +815,10 @@ void CWalletTx::GetAmounts(list<pair<CTxDestination, int64_t> >& 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<pair<CTxDestination, int64_t> >& 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<pair<CTxDestination, int64_t> > listReceived;
|
||||
list<pair<CTxDestination, int64_t> > listSent;
|
||||
list<COutputEntry> listReceived;
|
||||
list<COutputEntry> 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<CTxDestination, CAddressBookData>::const_iterator mi = pwallet->mapAddressBook.find(r.first);
|
||||
map<CTxDestination, CAddressBookData>::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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user