From f87ba3df64bb5825f7e2f6a33c93cf5738682019 Mon Sep 17 00:00:00 2001 From: JaSK Date: Fri, 23 May 2014 00:58:15 +0200 Subject: [PATCH] added includeWatchonly argument to 'gettransaction' because it affects balance calculation --- src/rpcclient.cpp | 1 + src/rpcwallet.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index f329d517b3..b2387cb062 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -65,6 +65,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 1 }, { "listunspent", 2 }, { "getblock", 1 }, + { "gettransaction", 1}, { "getrawtransaction", 1 }, { "createrawtransaction", 0 }, { "createrawtransaction", 1 }, diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index e9a111f523..61bc0b22f4 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -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 \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) 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) 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);