Browse Source

added includeWatchonly argument to 'gettransaction' because it affects balance calculation

0.10
JaSK 11 years ago
parent
commit
f87ba3df64
  1. 1
      src/rpcclient.cpp
  2. 10
      src/rpcwallet.cpp

1
src/rpcclient.cpp

@ -65,6 +65,7 @@ static const CRPCConvertParam vRPCConvertParams[] = @@ -65,6 +65,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listunspent", 1 },
{ "listunspent", 2 },
{ "getblock", 1 },
{ "gettransaction", 1},
{ "getrawtransaction", 1 },
{ "createrawtransaction", 0 },
{ "createrawtransaction", 1 },

10
src/rpcwallet.cpp

@ -1475,12 +1475,13 @@ Value listsinceblock(const Array& params, bool fHelp) @@ -1475,12 +1475,13 @@ Value listsinceblock(const Array& params, bool fHelp)
Value gettransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"gettransaction \"txid\"\n"
"\nGet detailed information about in-wallet transaction <txid>\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
"2. \"includeWatchonly\" (bool, optional, default=false) Whether to include watchonly addresses in balance calculation and details[]\n"
"\nResult:\n"
"{\n"
" \"amount\" : x.xxx, (numeric) The transaction amount in btc\n"
@ -1517,6 +1518,11 @@ Value gettransaction(const Array& params, bool fHelp) @@ -1517,6 +1518,11 @@ Value gettransaction(const Array& params, bool fHelp)
uint256 hash;
hash.SetHex(params[0].get_str());
isminefilter filter = MINE_SPENDABLE;
if(params.size() > 1)
if(params[1].get_bool())
filter = filter | MINE_WATCH_ONLY;
Object entry;
if (!pwalletMain->mapWallet.count(hash))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
@ -1534,7 +1540,7 @@ Value gettransaction(const Array& params, bool fHelp) @@ -1534,7 +1540,7 @@ Value gettransaction(const Array& params, bool fHelp)
WalletTxToJSON(wtx, entry);
Array details;
ListTransactions(wtx, "*", 0, false, details);
ListTransactions(wtx, "*", 0, false, details, filter);
entry.push_back(Pair("details", details));
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);

Loading…
Cancel
Save