Skip to content

Commit 7dee8f4

Browse files
committed
[wallet] Rename 'decode' argument in gettransaction method to 'verbose'
This makes the RPC method consistent with other RPC methods that have a 'verbose' option. Change the name of the return object from 'decoded' to details. Update help text.
1 parent fb4f5be commit 7dee8f4

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

doc/release-notes-16185.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
RPC changes
22
-----------
3-
The `gettransaction` RPC now accepts a third (boolean) argument `decode`. If set to `true`, a new `decoded` field will be added to the response containing the decoded transaction.
3+
The `gettransaction` RPC now accepts a third (boolean) argument `verbose`. If set to `true`, a new `details` field will be added to the response containing additional transaction details.

src/rpc/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
8585
{ "getblockheader", 1, "verbose" },
8686
{ "getchaintxstats", 0, "nblocks" },
8787
{ "gettransaction", 1, "include_watchonly" },
88-
{ "gettransaction", 2, "decode" },
88+
{ "gettransaction", 2, "verbose" },
8989
{ "getrawtransaction", 1, "verbose" },
9090
{ "createrawtransaction", 0, "inputs" },
9191
{ "createrawtransaction", 1, "outputs" },

src/wallet/rpcwallet.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
16491649
{
16501650
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
16511651
{"include_watchonly", RPCArg::Type::BOOL, /* default */ "true for watch-only wallets, otherwise false", "Whether to include watch-only addresses in balance calculation and details[]"},
1652-
{"decode", RPCArg::Type::BOOL, /* default */ "false", "Whether to add a field with the decoded transaction"},
1652+
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "Whether to add a field with additional transaction details"},
16531653
},
16541654
RPCResult{
16551655
"{\n"
@@ -1685,7 +1685,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
16851685
" ,...\n"
16861686
" ],\n"
16871687
" \"hex\" : \"data\" (string) Raw data for transaction\n"
1688-
" \"decoded\" : transaction (json object) Optional, the decoded transaction\n"
1688+
" \"details\" : transaction (json object) Optional, additional transaction details. This object contains the same transaction details as the `getrawtransaction` RPC method\n"
16891689
"}\n"
16901690
},
16911691
RPCExamples{
@@ -1711,7 +1711,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
17111711
filter |= ISMINE_WATCH_ONLY;
17121712
}
17131713

1714-
bool decode_tx = request.params[2].isNull() ? false : request.params[2].get_bool();
1714+
bool verbose = request.params[2].isNull() ? false : request.params[2].get_bool();
17151715

17161716
UniValue entry(UniValue::VOBJ);
17171717
auto it = pwallet->mapWallet.find(hash);
@@ -1738,10 +1738,10 @@ static UniValue gettransaction(const JSONRPCRequest& request)
17381738
std::string strHex = EncodeHexTx(*wtx.tx, pwallet->chain().rpcSerializationFlags());
17391739
entry.pushKV("hex", strHex);
17401740

1741-
if (decode_tx) {
1742-
UniValue decoded(UniValue::VOBJ);
1743-
TxToUniv(*wtx.tx, uint256(), decoded, false);
1744-
entry.pushKV("decoded", decoded);
1741+
if (verbose) {
1742+
UniValue details(UniValue::VOBJ);
1743+
TxToUniv(*wtx.tx, uint256(), details, false);
1744+
entry.pushKV("details", details);
17451745
}
17461746

17471747
return entry;
@@ -4189,7 +4189,7 @@ static const CRPCCommand commands[] =
41894189
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, {"address_type"} },
41904190
{ "wallet", "getreceivedbyaddress", &getreceivedbyaddress, {"address","minconf"} },
41914191
{ "wallet", "getreceivedbylabel", &getreceivedbylabel, {"label","minconf"} },
4192-
{ "wallet", "gettransaction", &gettransaction, {"txid","include_watchonly","decode"} },
4192+
{ "wallet", "gettransaction", &gettransaction, {"txid","include_watchonly","verbose"} },
41934193
{ "wallet", "getunconfirmedbalance", &getunconfirmedbalance, {} },
41944194
{ "wallet", "getbalances", &getbalances, {} },
41954195
{ "wallet", "getwalletinfo", &getwalletinfo, {} },

test/functional/wallet_basic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ def run_test(self):
499499
self.nodes[0].setlabel(change, 'foobar')
500500
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)
501501

502-
# Test "decoded" field value in gettransaction response
503-
self.log.info("Testing gettransaction decoding...")
504-
tx = self.nodes[0].gettransaction(txid=txid, decode=True)
505-
assert_equal(tx["decoded"], self.nodes[0].decoderawtransaction(tx["hex"]))
502+
# Test "verbose" field value in gettransaction response
503+
self.log.info("Testing verbose gettransaction...")
504+
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)
505+
assert_equal(tx["details"], self.nodes[0].decoderawtransaction(tx["hex"]))
506506

507507

508508
if __name__ == '__main__':

0 commit comments

Comments
 (0)