mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Added argument to listtransactions and listsinceblock to include watchonly addresses
This commit is contained in:
parent
952877e01c
commit
d7d5d23b77
@ -48,11 +48,13 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "sendfrom", 3 },
|
{ "sendfrom", 3 },
|
||||||
{ "listtransactions", 1 },
|
{ "listtransactions", 1 },
|
||||||
{ "listtransactions", 2 },
|
{ "listtransactions", 2 },
|
||||||
|
{ "listtransactions", 3 },
|
||||||
{ "listaccounts", 0 },
|
{ "listaccounts", 0 },
|
||||||
{ "listaccounts", 1 },
|
{ "listaccounts", 1 },
|
||||||
{ "walletpassphrase", 1 },
|
{ "walletpassphrase", 1 },
|
||||||
{ "getblocktemplate", 0 },
|
{ "getblocktemplate", 0 },
|
||||||
{ "listsinceblock", 1 },
|
{ "listsinceblock", 1 },
|
||||||
|
{ "listsinceblock", 2 },
|
||||||
{ "sendmany", 1 },
|
{ "sendmany", 1 },
|
||||||
{ "sendmany", 2 },
|
{ "sendmany", 2 },
|
||||||
{ "addmultisigaddress", 0 },
|
{ "addmultisigaddress", 0 },
|
||||||
@ -129,7 +131,6 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
|
|||||||
throw runtime_error(string("Error parsing JSON:")+strVal);
|
throw runtime_error(string("Error parsing JSON:")+strVal);
|
||||||
params.push_back(jVal);
|
params.push_back(jVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
|
@ -1107,14 +1107,14 @@ static void MaybePushAddress(Object & entry, const CTxDestination &dest)
|
|||||||
entry.push_back(Pair("address", addr.ToString()));
|
entry.push_back(Pair("address", addr.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)
|
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret, const isminefilter& filter=MINE_SPENDABLE)
|
||||||
{
|
{
|
||||||
int64_t nFee;
|
int64_t nFee;
|
||||||
string strSentAccount;
|
string strSentAccount;
|
||||||
list<pair<CTxDestination, int64_t> > listReceived;
|
list<pair<CTxDestination, int64_t> > listReceived;
|
||||||
list<pair<CTxDestination, int64_t> > listSent;
|
list<pair<CTxDestination, int64_t> > listSent;
|
||||||
|
|
||||||
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount);
|
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter);
|
||||||
|
|
||||||
bool fAllAccounts = (strAccount == string("*"));
|
bool fAllAccounts = (strAccount == string("*"));
|
||||||
bool involvesWatchonly = wtx.IsFromMe(MINE_WATCH_ONLY);
|
bool involvesWatchonly = wtx.IsFromMe(MINE_WATCH_ONLY);
|
||||||
@ -1194,16 +1194,16 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar
|
|||||||
|
|
||||||
Value listtransactions(const Array& params, bool fHelp)
|
Value listtransactions(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 3)
|
if (fHelp || params.size() > 4)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"listtransactions ( \"account\" count from )\n"
|
"listtransactions ( \"account\" count from includeWatchonly)\n"
|
||||||
"\nReturns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'.\n"
|
"\nReturns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'.\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"account\" (string, optional) The account name. If not included, it will list all transactions for all accounts.\n"
|
"1. \"account\" (string, optional) The account name. If not included, it will list all transactions for all accounts.\n"
|
||||||
" If \"\" is set, it will list transactions for the default account.\n"
|
" If \"\" is set, it will list transactions for the default account.\n"
|
||||||
"2. count (numeric, optional, default=10) The number of transactions to return\n"
|
"2. count (numeric, optional, default=10) The number of transactions to return\n"
|
||||||
"3. from (numeric, optional, default=0) The number of transactions to skip\n"
|
"3. from (numeric, optional, default=0) The number of transactions to skip\n"
|
||||||
|
"4. includeWatchonly (bool, optional, default=false) Include transactions to watchonly addresses (see 'importaddress')\n"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"[\n"
|
"[\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
@ -1255,15 +1255,26 @@ Value listtransactions(const Array& params, bool fHelp)
|
|||||||
);
|
);
|
||||||
|
|
||||||
string strAccount = "*";
|
string strAccount = "*";
|
||||||
if (params.size() > 0)
|
|
||||||
strAccount = params[0].get_str();
|
|
||||||
int nCount = 10;
|
int nCount = 10;
|
||||||
if (params.size() > 1)
|
|
||||||
nCount = params[1].get_int();
|
|
||||||
int nFrom = 0;
|
int nFrom = 0;
|
||||||
if (params.size() > 2)
|
isminefilter filter = MINE_SPENDABLE;
|
||||||
nFrom = params[2].get_int();
|
if (params.size() > 0)
|
||||||
|
{
|
||||||
|
strAccount = params[0].get_str();
|
||||||
|
if (params.size() > 1)
|
||||||
|
{
|
||||||
|
nCount = params[1].get_int();
|
||||||
|
if (params.size() > 2)
|
||||||
|
{
|
||||||
|
nFrom = params[2].get_int();
|
||||||
|
if(params.size() > 3)
|
||||||
|
{
|
||||||
|
if(params[3].get_bool())
|
||||||
|
filter = filter | MINE_WATCH_ONLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (nCount < 0)
|
if (nCount < 0)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
|
||||||
if (nFrom < 0)
|
if (nFrom < 0)
|
||||||
@ -1279,7 +1290,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, true, ret);
|
ListTransactions(*pwtx, strAccount, 0, true, ret, filter);
|
||||||
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);
|
||||||
@ -1386,11 +1397,12 @@ Value listsinceblock(const Array& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
if (fHelp)
|
if (fHelp)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"listsinceblock ( \"blockhash\" target-confirmations )\n"
|
"listsinceblock ( \"blockhash\" target-confirmations includeWatchonly)\n"
|
||||||
"\nGet all transactions in blocks since block [blockhash], or all transactions if omitted\n"
|
"\nGet all transactions in blocks since block [blockhash], or all transactions if omitted\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"blockhash\" (string, optional) The block hash to list transactions since\n"
|
"1. \"blockhash\" (string, optional) The block hash to list transactions since\n"
|
||||||
"2. target-confirmations: (numeric, optional) The confirmations required, must be 1 or more\n"
|
"2. target-confirmations: (numeric, optional) The confirmations required, must be 1 or more\n"
|
||||||
|
"3. includeWatchonly: (bool, optional, default=false) Include transactions to watchonly addresses (see 'importaddress')"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" \"transactions\": [\n"
|
" \"transactions\": [\n"
|
||||||
@ -1426,7 +1438,7 @@ Value listsinceblock(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
CBlockIndex *pindex = NULL;
|
CBlockIndex *pindex = NULL;
|
||||||
int target_confirms = 1;
|
int target_confirms = 1;
|
||||||
|
isminefilter filter = MINE_SPENDABLE;
|
||||||
if (params.size() > 0)
|
if (params.size() > 0)
|
||||||
{
|
{
|
||||||
uint256 blockId = 0;
|
uint256 blockId = 0;
|
||||||
@ -1435,14 +1447,20 @@ Value listsinceblock(const Array& params, bool fHelp)
|
|||||||
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId);
|
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId);
|
||||||
if (it != mapBlockIndex.end())
|
if (it != mapBlockIndex.end())
|
||||||
pindex = it->second;
|
pindex = it->second;
|
||||||
}
|
|
||||||
|
|
||||||
if (params.size() > 1)
|
if (params.size() > 1)
|
||||||
{
|
{
|
||||||
target_confirms = params[1].get_int();
|
target_confirms = params[1].get_int();
|
||||||
|
|
||||||
if (target_confirms < 1)
|
if (target_confirms < 1)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
|
||||||
|
|
||||||
|
if(params.size() > 2)
|
||||||
|
{
|
||||||
|
if(params[2].get_bool())
|
||||||
|
filter = filter | MINE_WATCH_ONLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1;
|
int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1;
|
||||||
@ -1454,7 +1472,7 @@ Value listsinceblock(const Array& params, bool fHelp)
|
|||||||
CWalletTx tx = (*it).second;
|
CWalletTx tx = (*it).second;
|
||||||
|
|
||||||
if (depth == -1 || tx.GetDepthInMainChain() < depth)
|
if (depth == -1 || tx.GetDepthInMainChain() < depth)
|
||||||
ListTransactions(tx, "*", 0, true, transactions);
|
ListTransactions(tx, "*", 0, true, transactions, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];
|
CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];
|
||||||
|
Loading…
Reference in New Issue
Block a user