Add account/address details to gettransaction output
This commit is contained in:
parent
009d5fb41f
commit
80be6e69a9
1 changed files with 14 additions and 6 deletions
14
rpc.cpp
14
rpc.cpp
|
@ -857,7 +857,7 @@ Value listreceivedbyaccount(const Array& params, bool fHelp)
|
||||||
return ListReceived(params, true);
|
return ListReceived(params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, Array& ret)
|
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)
|
||||||
{
|
{
|
||||||
int64 nGenerated, nFee;
|
int64 nGenerated, nFee;
|
||||||
string strSentAccount;
|
string strSentAccount;
|
||||||
|
@ -874,6 +874,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||||
entry.push_back(Pair("account", string("")));
|
entry.push_back(Pair("account", string("")));
|
||||||
entry.push_back(Pair("category", "generate"));
|
entry.push_back(Pair("category", "generate"));
|
||||||
entry.push_back(Pair("amount", ValueFromAmount(nGenerated)));
|
entry.push_back(Pair("amount", ValueFromAmount(nGenerated)));
|
||||||
|
if (fLong)
|
||||||
WalletTxToJSON(wtx, entry);
|
WalletTxToJSON(wtx, entry);
|
||||||
ret.push_back(entry);
|
ret.push_back(entry);
|
||||||
}
|
}
|
||||||
|
@ -889,6 +890,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||||
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.second)));
|
||||||
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
|
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
|
||||||
|
if (fLong)
|
||||||
WalletTxToJSON(wtx, entry);
|
WalletTxToJSON(wtx, entry);
|
||||||
ret.push_back(entry);
|
ret.push_back(entry);
|
||||||
}
|
}
|
||||||
|
@ -910,6 +912,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||||
entry.push_back(Pair("address", r.first));
|
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)));
|
||||||
|
if (fLong)
|
||||||
WalletTxToJSON(wtx, entry);
|
WalletTxToJSON(wtx, entry);
|
||||||
ret.push_back(entry);
|
ret.push_back(entry);
|
||||||
}
|
}
|
||||||
|
@ -976,7 +979,7 @@ Value listtransactions(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
CWalletTx *const pwtx = (*it).second.first;
|
CWalletTx *const pwtx = (*it).second.first;
|
||||||
if (pwtx != 0)
|
if (pwtx != 0)
|
||||||
ListTransactions(*pwtx, strAccount, 0, ret);
|
ListTransactions(*pwtx, strAccount, 0, true, ret);
|
||||||
CAccountingEntry *const pacentry = (*it).second.second;
|
CAccountingEntry *const pacentry = (*it).second.second;
|
||||||
if (pacentry != 0)
|
if (pacentry != 0)
|
||||||
AcentryToJSON(*pacentry, strAccount, ret);
|
AcentryToJSON(*pacentry, strAccount, ret);
|
||||||
|
@ -1063,7 +1066,7 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||||
CRITICAL_BLOCK(cs_mapWallet)
|
CRITICAL_BLOCK(cs_mapWallet)
|
||||||
{
|
{
|
||||||
if (!mapWallet.count(hash))
|
if (!mapWallet.count(hash))
|
||||||
throw JSONRPCError(-5, "Invalid transaction id");
|
throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
|
||||||
const CWalletTx& wtx = mapWallet[hash];
|
const CWalletTx& wtx = mapWallet[hash];
|
||||||
|
|
||||||
int64 nCredit = wtx.GetCredit();
|
int64 nCredit = wtx.GetCredit();
|
||||||
|
@ -1074,7 +1077,12 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||||
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
|
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
|
||||||
if (wtx.IsFromMe())
|
if (wtx.IsFromMe())
|
||||||
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
|
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
|
||||||
|
|
||||||
WalletTxToJSON(mapWallet[hash], entry);
|
WalletTxToJSON(mapWallet[hash], entry);
|
||||||
|
|
||||||
|
Array details;
|
||||||
|
ListTransactions(mapWallet[hash], "*", 0, false, details);
|
||||||
|
entry.push_back(Pair("details", details));
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
|
Loading…
Reference in a new issue