aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaSK <temp@temp.temp>2014-04-08 17:51:04 +0200
committerJaSK <temp@temp.temp>2014-07-02 15:48:39 +0200
commitd7d5d23b77e204eccd4bf8a5608c1a499d5fc42f (patch)
treee9773ab433534248ab31c6557d889f628841dbaa /src
parent952877e01c1045298fd51d1152d96c304d4cf2a4 (diff)
Added argument to listtransactions and listsinceblock to include watchonly addresses
Diffstat (limited to 'src')
-rw-r--r--src/rpcclient.cpp3
-rw-r--r--src/rpcwallet.cpp62
2 files changed, 42 insertions, 23 deletions
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index d96b47833f..f329d517b3 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -48,11 +48,13 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "sendfrom", 3 },
{ "listtransactions", 1 },
{ "listtransactions", 2 },
+ { "listtransactions", 3 },
{ "listaccounts", 0 },
{ "listaccounts", 1 },
{ "walletpassphrase", 1 },
{ "getblocktemplate", 0 },
{ "listsinceblock", 1 },
+ { "listsinceblock", 2 },
{ "sendmany", 1 },
{ "sendmany", 2 },
{ "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);
params.push_back(jVal);
}
-
}
return params;
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];