|
|
@ -859,10 +859,11 @@ Value listreceivedbyaccount(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, Array& ret) |
|
|
|
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, Array& ret) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64 nGenerated, nSent, nFee; |
|
|
|
int64 nGenerated, nFee; |
|
|
|
string strSentAccount; |
|
|
|
string strSentAccount; |
|
|
|
list<pair<string, int64> > listReceived; |
|
|
|
list<pair<string, int64> > listReceived; |
|
|
|
wtx.GetAmounts(nGenerated, listReceived, nSent, nFee, strSentAccount); |
|
|
|
list<pair<string, int64> > listSent; |
|
|
|
|
|
|
|
wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount); |
|
|
|
|
|
|
|
|
|
|
|
bool fAllAccounts = (strAccount == string("*")); |
|
|
|
bool fAllAccounts = (strAccount == string("*")); |
|
|
|
|
|
|
|
|
|
|
@ -878,32 +879,42 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sent
|
|
|
|
// Sent
|
|
|
|
if ((nSent != 0 || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) |
|
|
|
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach(const PAIRTYPE(string, int64)& s, listSent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
Object entry; |
|
|
|
entry.push_back(Pair("account", strSentAccount)); |
|
|
|
entry.push_back(Pair("account", strSentAccount)); |
|
|
|
|
|
|
|
entry.push_back(Pair("address", s.first)); |
|
|
|
entry.push_back(Pair("category", "send")); |
|
|
|
entry.push_back(Pair("category", "send")); |
|
|
|
entry.push_back(Pair("amount", ValueFromAmount(-nSent))); |
|
|
|
entry.push_back(Pair("amount", ValueFromAmount(-s.second))); |
|
|
|
entry.push_back(Pair("fee", ValueFromAmount(-nFee))); |
|
|
|
entry.push_back(Pair("fee", ValueFromAmount(-nFee))); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
ret.push_back(entry); |
|
|
|
ret.push_back(entry); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Received
|
|
|
|
// Received
|
|
|
|
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
CRITICAL_BLOCK(cs_mapAddressBook) |
|
|
|
CRITICAL_BLOCK(cs_mapAddressBook) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach(const PAIRTYPE(string, int64)& r, listReceived) |
|
|
|
foreach(const PAIRTYPE(string, int64)& r, listReceived) |
|
|
|
if (mapAddressBook.count(r.first) && (fAllAccounts || mapAddressBook[r.first] == strAccount)) |
|
|
|
{ |
|
|
|
|
|
|
|
string account; |
|
|
|
|
|
|
|
if (mapAddressBook.count(r.first)) |
|
|
|
|
|
|
|
account = mapAddressBook[r.first]; |
|
|
|
|
|
|
|
if (fAllAccounts || (account == strAccount)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
Object entry; |
|
|
|
entry.push_back(Pair("account", mapAddressBook[r.first])); |
|
|
|
entry.push_back(Pair("account", account)); |
|
|
|
|
|
|
|
entry.push_back(Pair("address", r.first)); |
|
|
|
entry.push_back(Pair("category", "receive")); |
|
|
|
entry.push_back(Pair("category", "receive")); |
|
|
|
entry.push_back(Pair("amount", ValueFromAmount(r.second))); |
|
|
|
entry.push_back(Pair("amount", ValueFromAmount(r.second))); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
ret.push_back(entry); |
|
|
|
ret.push_back(entry); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1007,11 +1018,14 @@ Value listaccounts(const Array& params, bool fHelp) |
|
|
|
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx& wtx = (*it).second; |
|
|
|
const CWalletTx& wtx = (*it).second; |
|
|
|
int64 nGenerated, nSent, nFee; |
|
|
|
int64 nGenerated, nFee; |
|
|
|
string strSentAccount; |
|
|
|
string strSentAccount; |
|
|
|
list<pair<string, int64> > listReceived; |
|
|
|
list<pair<string, int64> > listReceived; |
|
|
|
wtx.GetAmounts(nGenerated, listReceived, nSent, nFee, strSentAccount); |
|
|
|
list<pair<string, int64> > listSent; |
|
|
|
mapAccountBalances[strSentAccount] -= nSent+nFee; |
|
|
|
wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount); |
|
|
|
|
|
|
|
mapAccountBalances[strSentAccount] -= nFee; |
|
|
|
|
|
|
|
foreach(const PAIRTYPE(string, int64)& s, listSent) |
|
|
|
|
|
|
|
mapAccountBalances[strSentAccount] -= s.second; |
|
|
|
if (wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
if (wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mapAccountBalances[""] += nGenerated; |
|
|
|
mapAccountBalances[""] += nGenerated; |
|
|
|