|
|
@ -641,16 +641,16 @@ Value getbalance(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
int64_t allFee; |
|
|
|
int64_t allFee; |
|
|
|
string strSentAccount; |
|
|
|
string strSentAccount; |
|
|
|
list<pair<CTxDestination, int64_t> > listReceived; |
|
|
|
list<COutputEntry> listReceived; |
|
|
|
list<pair<CTxDestination, int64_t> > listSent; |
|
|
|
list<COutputEntry> listSent; |
|
|
|
wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); |
|
|
|
wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); |
|
|
|
if (wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
if (wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived) |
|
|
|
BOOST_FOREACH(const COutputEntry& r, listReceived) |
|
|
|
nBalance += r.second; |
|
|
|
nBalance += r.amount; |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listSent) |
|
|
|
BOOST_FOREACH(const COutputEntry& s, listSent) |
|
|
|
nBalance -= r.second; |
|
|
|
nBalance -= s.amount; |
|
|
|
nBalance -= allFee; |
|
|
|
nBalance -= allFee; |
|
|
|
} |
|
|
|
} |
|
|
|
return ValueFromAmount(nBalance); |
|
|
|
return ValueFromAmount(nBalance); |
|
|
@ -1133,8 +1133,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nFee; |
|
|
|
int64_t nFee; |
|
|
|
string strSentAccount; |
|
|
|
string strSentAccount; |
|
|
|
list<pair<CTxDestination, int64_t> > listReceived; |
|
|
|
list<COutputEntry> listReceived; |
|
|
|
list<pair<CTxDestination, int64_t> > listSent; |
|
|
|
list<COutputEntry> listSent; |
|
|
|
|
|
|
|
|
|
|
|
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter); |
|
|
|
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter); |
|
|
|
|
|
|
|
|
|
|
@ -1144,15 +1144,16 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
// Sent
|
|
|
|
// Sent
|
|
|
|
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) |
|
|
|
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) |
|
|
|
BOOST_FOREACH(const COutputEntry& s, listSent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
Object entry; |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, s.first) & ISMINE_WATCH_ONLY)) |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("account", strSentAccount)); |
|
|
|
entry.push_back(Pair("account", strSentAccount)); |
|
|
|
MaybePushAddress(entry, s.first); |
|
|
|
MaybePushAddress(entry, s.destination); |
|
|
|
entry.push_back(Pair("category", "send")); |
|
|
|
entry.push_back(Pair("category", "send")); |
|
|
|
entry.push_back(Pair("amount", ValueFromAmount(-s.second))); |
|
|
|
entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); |
|
|
|
|
|
|
|
entry.push_back(Pair("vout", s.vout)); |
|
|
|
entry.push_back(Pair("fee", ValueFromAmount(-nFee))); |
|
|
|
entry.push_back(Pair("fee", ValueFromAmount(-nFee))); |
|
|
|
if (fLong) |
|
|
|
if (fLong) |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
@ -1163,18 +1164,18 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
// Received
|
|
|
|
// Received
|
|
|
|
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived) |
|
|
|
BOOST_FOREACH(const COutputEntry& r, listReceived) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string account; |
|
|
|
string account; |
|
|
|
if (pwalletMain->mapAddressBook.count(r.first)) |
|
|
|
if (pwalletMain->mapAddressBook.count(r.destination)) |
|
|
|
account = pwalletMain->mapAddressBook[r.first].name; |
|
|
|
account = pwalletMain->mapAddressBook[r.destination].name; |
|
|
|
if (fAllAccounts || (account == strAccount)) |
|
|
|
if (fAllAccounts || (account == strAccount)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
Object entry; |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, r.first) & ISMINE_WATCH_ONLY)) |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("account", account)); |
|
|
|
entry.push_back(Pair("account", account)); |
|
|
|
MaybePushAddress(entry, r.first); |
|
|
|
MaybePushAddress(entry, r.destination); |
|
|
|
if (wtx.IsCoinBase()) |
|
|
|
if (wtx.IsCoinBase()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (wtx.GetDepthInMainChain() < 1) |
|
|
|
if (wtx.GetDepthInMainChain() < 1) |
|
|
@ -1188,7 +1189,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
{ |
|
|
|
{ |
|
|
|
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.amount))); |
|
|
|
|
|
|
|
entry.push_back(Pair("vout", r.vout)); |
|
|
|
if (fLong) |
|
|
|
if (fLong) |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
ret.push_back(entry); |
|
|
|
ret.push_back(entry); |
|
|
@ -1240,6 +1242,7 @@ Value listtransactions(const Array& params, bool fHelp) |
|
|
|
" \"amount\": x.xxx, (numeric) The amount in btc. This is negative for the 'send' category, and for the\n" |
|
|
|
" \"amount\": x.xxx, (numeric) The amount in btc. This is negative for the 'send' category, and for the\n" |
|
|
|
" 'move' category for moves outbound. It is positive for the 'receive' category,\n" |
|
|
|
" 'move' category for moves outbound. It is positive for the 'receive' category,\n" |
|
|
|
" and for the 'move' category for inbound funds.\n" |
|
|
|
" and for the 'move' category for inbound funds.\n" |
|
|
|
|
|
|
|
" \"vout\" : n, (numeric) the vout value\n" |
|
|
|
" \"fee\": x.xxx, (numeric) The amount of the fee in btc. This is negative and only available for the \n" |
|
|
|
" \"fee\": x.xxx, (numeric) The amount of the fee in btc. This is negative and only available for the \n" |
|
|
|
" 'send' category of transactions.\n" |
|
|
|
" 'send' category of transactions.\n" |
|
|
|
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n" |
|
|
|
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n" |
|
|
@ -1375,22 +1378,22 @@ Value listaccounts(const Array& params, bool fHelp) |
|
|
|
const CWalletTx& wtx = (*it).second; |
|
|
|
const CWalletTx& wtx = (*it).second; |
|
|
|
int64_t nFee; |
|
|
|
int64_t nFee; |
|
|
|
string strSentAccount; |
|
|
|
string strSentAccount; |
|
|
|
list<pair<CTxDestination, int64_t> > listReceived; |
|
|
|
list<COutputEntry> listReceived; |
|
|
|
list<pair<CTxDestination, int64_t> > listSent; |
|
|
|
list<COutputEntry> listSent; |
|
|
|
int nDepth = wtx.GetDepthInMainChain(); |
|
|
|
int nDepth = wtx.GetDepthInMainChain(); |
|
|
|
if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0) |
|
|
|
if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); |
|
|
|
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); |
|
|
|
mapAccountBalances[strSentAccount] -= nFee; |
|
|
|
mapAccountBalances[strSentAccount] -= nFee; |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) |
|
|
|
BOOST_FOREACH(const COutputEntry& s, listSent) |
|
|
|
mapAccountBalances[strSentAccount] -= s.second; |
|
|
|
mapAccountBalances[strSentAccount] -= s.amount; |
|
|
|
if (nDepth >= nMinDepth) |
|
|
|
if (nDepth >= nMinDepth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived) |
|
|
|
BOOST_FOREACH(const COutputEntry& r, listReceived) |
|
|
|
if (pwalletMain->mapAddressBook.count(r.first)) |
|
|
|
if (pwalletMain->mapAddressBook.count(r.destination)) |
|
|
|
mapAccountBalances[pwalletMain->mapAddressBook[r.first].name] += r.second; |
|
|
|
mapAccountBalances[pwalletMain->mapAddressBook[r.destination].name] += r.amount; |
|
|
|
else |
|
|
|
else |
|
|
|
mapAccountBalances[""] += r.second; |
|
|
|
mapAccountBalances[""] += r.amount; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1424,6 +1427,7 @@ Value listsinceblock(const Array& params, bool fHelp) |
|
|
|
" \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" |
|
|
|
" \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" |
|
|
|
" \"amount\": x.xxx, (numeric) The amount in btc. This is negative for the 'send' category, and for the 'move' category for moves \n" |
|
|
|
" \"amount\": x.xxx, (numeric) The amount in btc. This is negative for the 'send' category, and for the 'move' category for moves \n" |
|
|
|
" outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" |
|
|
|
" outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" |
|
|
|
|
|
|
|
" \"vout\" : n, (numeric) the vout value\n" |
|
|
|
" \"fee\": x.xxx, (numeric) The amount of the fee in btc. This is negative and only available for the 'send' category of transactions.\n" |
|
|
|
" \"fee\": x.xxx, (numeric) The amount of the fee in btc. This is negative and only available for the 'send' category of transactions.\n" |
|
|
|
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" |
|
|
|
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" |
|
|
|
" \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" |
|
|
|
" \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" |
|
|
@ -1528,6 +1532,7 @@ Value gettransaction(const Array& params, bool fHelp) |
|
|
|
" \"address\" : \"bitcoinaddress\", (string) The bitcoin address involved in the transaction\n" |
|
|
|
" \"address\" : \"bitcoinaddress\", (string) The bitcoin address involved in the transaction\n" |
|
|
|
" \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n" |
|
|
|
" \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n" |
|
|
|
" \"amount\" : x.xxx (numeric) The amount in btc\n" |
|
|
|
" \"amount\" : x.xxx (numeric) The amount in btc\n" |
|
|
|
|
|
|
|
" \"vout\" : n, (numeric) the vout value\n" |
|
|
|
" }\n" |
|
|
|
" }\n" |
|
|
|
" ,...\n" |
|
|
|
" ,...\n" |
|
|
|
" ],\n" |
|
|
|
" ],\n" |
|
|
|