aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp62
1 files changed, 40 insertions, 22 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 8de10c52f8..a9db442d4c 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1107,14 +1107,14 @@ static void MaybePushAddress(Object & entry, const CTxDestination &dest)
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;
string strSentAccount;
list<pair<CTxDestination, int64_t> > listReceived;
list<pair<CTxDestination, int64_t> > listSent;
- wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount);
+ wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter);
bool fAllAccounts = (strAccount == string("*"));
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)
{
- if (fHelp || params.size() > 3)
+ if (fHelp || params.size() > 4)
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"
"\nArguments:\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"
"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"
-
+ "4. includeWatchonly (bool, optional, default=false) Include transactions to watchonly addresses (see 'importaddress')\n"
"\nResult:\n"
"[\n"
" {\n"
@@ -1255,15 +1255,26 @@ Value listtransactions(const Array& params, bool fHelp)
);
string strAccount = "*";
- if (params.size() > 0)
- strAccount = params[0].get_str();
int nCount = 10;
- if (params.size() > 1)
- nCount = params[1].get_int();
int nFrom = 0;
- if (params.size() > 2)
- nFrom = params[2].get_int();
-
+ isminefilter filter = MINE_SPENDABLE;
+ 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)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
if (nFrom < 0)
@@ -1279,7 +1290,7 @@ Value listtransactions(const Array& params, bool fHelp)
{
CWalletTx *const pwtx = (*it).second.first;
if (pwtx != 0)
- ListTransactions(*pwtx, strAccount, 0, true, ret);
+ ListTransactions(*pwtx, strAccount, 0, true, ret, filter);
CAccountingEntry *const pacentry = (*it).second.second;
if (pacentry != 0)
AcentryToJSON(*pacentry, strAccount, ret);
@@ -1386,11 +1397,12 @@ Value listsinceblock(const Array& params, bool fHelp)
{
if (fHelp)
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"
"\nArguments:\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"
+ "3. includeWatchonly: (bool, optional, default=false) Include transactions to watchonly addresses (see 'importaddress')"
"\nResult:\n"
"{\n"
" \"transactions\": [\n"
@@ -1426,7 +1438,7 @@ Value listsinceblock(const Array& params, bool fHelp)
CBlockIndex *pindex = NULL;
int target_confirms = 1;
-
+ isminefilter filter = MINE_SPENDABLE;
if (params.size() > 0)
{
uint256 blockId = 0;
@@ -1435,14 +1447,20 @@ Value listsinceblock(const Array& params, bool fHelp)
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId);
if (it != mapBlockIndex.end())
pindex = it->second;
- }
- if (params.size() > 1)
- {
- target_confirms = params[1].get_int();
+ if (params.size() > 1)
+ {
+ target_confirms = params[1].get_int();
+
+ if (target_confirms < 1)
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
- if (target_confirms < 1)
- 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;
@@ -1454,7 +1472,7 @@ Value listsinceblock(const Array& params, bool fHelp)
CWalletTx tx = (*it).second;
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];