mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
Added argument to listaccounts to include watchonly addresses
This commit is contained in:
parent
d4640d7d8c
commit
83f3543f20
@ -49,6 +49,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "listtransactions", 1 },
|
{ "listtransactions", 1 },
|
||||||
{ "listtransactions", 2 },
|
{ "listtransactions", 2 },
|
||||||
{ "listaccounts", 0 },
|
{ "listaccounts", 0 },
|
||||||
|
{ "listaccounts", 1 },
|
||||||
{ "walletpassphrase", 1 },
|
{ "walletpassphrase", 1 },
|
||||||
{ "getblocktemplate", 0 },
|
{ "getblocktemplate", 0 },
|
||||||
{ "listsinceblock", 1 },
|
{ "listsinceblock", 1 },
|
||||||
|
@ -1302,12 +1302,13 @@ Value listtransactions(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
Value listaccounts(const Array& params, bool fHelp)
|
Value listaccounts(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"listaccounts ( minconf )\n"
|
"listaccounts ( minconf includeWatchonly)\n"
|
||||||
"\nReturns Object that has account names as keys, account balances as values.\n"
|
"\nReturns Object that has account names as keys, account balances as values.\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. minconf (numeric, optional, default=1) Only onclude transactions with at least this many confirmations\n"
|
"1. minconf (numeric, optional, default=1) Only onclude transactions with at least this many confirmations\n"
|
||||||
|
"2. includeWatchonly (bool, optional, default=false) Include balances in watchonly addresses (see 'importaddress')\n"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"{ (json object where keys are account names, and values are numeric balances\n"
|
"{ (json object where keys are account names, and values are numeric balances\n"
|
||||||
" \"account\": x.xxx, (numeric) The property name is the account name, and the value is the total balance for the account.\n"
|
" \"account\": x.xxx, (numeric) The property name is the account name, and the value is the total balance for the account.\n"
|
||||||
@ -1325,12 +1326,18 @@ Value listaccounts(const Array& params, bool fHelp)
|
|||||||
);
|
);
|
||||||
|
|
||||||
int nMinDepth = 1;
|
int nMinDepth = 1;
|
||||||
|
isminefilter includeWatchonly = MINE_SPENDABLE;
|
||||||
if (params.size() > 0)
|
if (params.size() > 0)
|
||||||
|
{
|
||||||
nMinDepth = params[0].get_int();
|
nMinDepth = params[0].get_int();
|
||||||
|
if(params.size() > 1)
|
||||||
|
if(params[1].get_bool())
|
||||||
|
includeWatchonly = includeWatchonly | MINE_WATCH_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
map<string, int64_t> mapAccountBalances;
|
map<string, int64_t> mapAccountBalances;
|
||||||
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) {
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) {
|
||||||
if (IsMine(*pwalletMain, entry.first)) // This address belongs to me
|
if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me
|
||||||
mapAccountBalances[entry.second.name] = 0;
|
mapAccountBalances[entry.second.name] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1344,7 +1351,7 @@ Value listaccounts(const Array& params, bool fHelp)
|
|||||||
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);
|
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 PAIRTYPE(CTxDestination, int64_t)& s, listSent)
|
||||||
mapAccountBalances[strSentAccount] -= s.second;
|
mapAccountBalances[strSentAccount] -= s.second;
|
||||||
|
Loading…
Reference in New Issue
Block a user