aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-05-30 00:54:00 +0200
committerCozz Lovan <cozzlovan@yahoo.com>2014-07-15 15:50:33 +0200
commit1b4568cb0f00dd7a24575fe54c017e743c4e7d35 (patch)
treee84e0945325614794a6a016869dd04c7f7c969ee /src/rpcwallet.cpp
parent2c0f019bfc0b9381b6dcad5960df48379b8dfe20 (diff)
downloadbitcoin-1b4568cb0f00dd7a24575fe54c017e743c4e7d35.tar.xz
Add vout to ListTransactions output
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index e8c62fd37b..631f72d1a1 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -641,16 +641,16 @@ Value getbalance(const Array& params, bool fHelp)
int64_t allFee;
string strSentAccount;
- list<pair<CTxDestination, int64_t> > listReceived;
- list<pair<CTxDestination, int64_t> > listSent;
+ list<COutputEntry> listReceived;
+ list<COutputEntry> listSent;
wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter);
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived)
- nBalance += r.second;
+ BOOST_FOREACH(const COutputEntry& r, listReceived)
+ nBalance += r.amount;
}
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listSent)
- nBalance -= r.second;
+ BOOST_FOREACH(const COutputEntry& s, listSent)
+ nBalance -= s.amount;
nBalance -= allFee;
}
return ValueFromAmount(nBalance);
@@ -1133,8 +1133,8 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
{
int64_t nFee;
string strSentAccount;
- list<pair<CTxDestination, int64_t> > listReceived;
- list<pair<CTxDestination, int64_t> > listSent;
+ list<COutputEntry> listReceived;
+ list<COutputEntry> listSent;
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter);
@@ -1144,15 +1144,16 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Sent
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;
- 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("account", strSentAccount));
- MaybePushAddress(entry, s.first);
+ MaybePushAddress(entry, s.destination);
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)));
if (fLong)
WalletTxToJSON(wtx, entry);
@@ -1163,18 +1164,18 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived)
+ BOOST_FOREACH(const COutputEntry& r, listReceived)
{
string account;
- if (pwalletMain->mapAddressBook.count(r.first))
- account = pwalletMain->mapAddressBook[r.first].name;
+ if (pwalletMain->mapAddressBook.count(r.destination))
+ account = pwalletMain->mapAddressBook[r.destination].name;
if (fAllAccounts || (account == strAccount))
{
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("account", account));
- MaybePushAddress(entry, r.first);
+ MaybePushAddress(entry, r.destination);
if (wtx.IsCoinBase())
{
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("amount", ValueFromAmount(r.second)));
+ entry.push_back(Pair("amount", ValueFromAmount(r.amount)));
+ entry.push_back(Pair("vout", r.vout));
if (fLong)
WalletTxToJSON(wtx, 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"
" 'move' category for moves outbound. It is positive for the 'receive' category,\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"
" 'send' category of transactions.\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;
int64_t nFee;
string strSentAccount;
- list<pair<CTxDestination, int64_t> > listReceived;
- list<pair<CTxDestination, int64_t> > listSent;
+ list<COutputEntry> listReceived;
+ list<COutputEntry> listSent;
int nDepth = wtx.GetDepthInMainChain();
if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0)
continue;
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly);
mapAccountBalances[strSentAccount] -= nFee;
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent)
- mapAccountBalances[strSentAccount] -= s.second;
+ BOOST_FOREACH(const COutputEntry& s, listSent)
+ mapAccountBalances[strSentAccount] -= s.amount;
if (nDepth >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived)
- if (pwalletMain->mapAddressBook.count(r.first))
- mapAccountBalances[pwalletMain->mapAddressBook[r.first].name] += r.second;
+ BOOST_FOREACH(const COutputEntry& r, listReceived)
+ if (pwalletMain->mapAddressBook.count(r.destination))
+ mapAccountBalances[pwalletMain->mapAddressBook[r.destination].name] += r.amount;
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"
" \"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"
+ " \"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"
" \"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"
@@ -1528,6 +1532,7 @@ Value gettransaction(const Array& params, bool fHelp)
" \"address\" : \"bitcoinaddress\", (string) The bitcoin address involved in the transaction\n"
" \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n"
" \"amount\" : x.xxx (numeric) The amount in btc\n"
+ " \"vout\" : n, (numeric) the vout value\n"
" }\n"
" ,...\n"
" ],\n"