[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.
This commit is contained in:
parent
fb4f5beb6e
commit
7dee8f4808
4 changed files with 14 additions and 14 deletions
|
@ -1,3 +1,3 @@
|
||||||
RPC changes
|
RPC changes
|
||||||
-----------
|
-----------
|
||||||
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.
|
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.
|
||||||
|
|
|
@ -85,7 +85,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||||
{ "getblockheader", 1, "verbose" },
|
{ "getblockheader", 1, "verbose" },
|
||||||
{ "getchaintxstats", 0, "nblocks" },
|
{ "getchaintxstats", 0, "nblocks" },
|
||||||
{ "gettransaction", 1, "include_watchonly" },
|
{ "gettransaction", 1, "include_watchonly" },
|
||||||
{ "gettransaction", 2, "decode" },
|
{ "gettransaction", 2, "verbose" },
|
||||||
{ "getrawtransaction", 1, "verbose" },
|
{ "getrawtransaction", 1, "verbose" },
|
||||||
{ "createrawtransaction", 0, "inputs" },
|
{ "createrawtransaction", 0, "inputs" },
|
||||||
{ "createrawtransaction", 1, "outputs" },
|
{ "createrawtransaction", 1, "outputs" },
|
||||||
|
|
|
@ -1649,7 +1649,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
|
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
|
||||||
{"include_watchonly", RPCArg::Type::BOOL, /* default */ "true for watch-only wallets, otherwise false", "Whether to include watch-only addresses in balance calculation and details[]"},
|
{"include_watchonly", RPCArg::Type::BOOL, /* default */ "true for watch-only wallets, otherwise false", "Whether to include watch-only addresses in balance calculation and details[]"},
|
||||||
{"decode", RPCArg::Type::BOOL, /* default */ "false", "Whether to add a field with the decoded transaction"},
|
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "Whether to add a field with additional transaction details"},
|
||||||
},
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -1685,7 +1685,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
|
||||||
" ,...\n"
|
" ,...\n"
|
||||||
" ],\n"
|
" ],\n"
|
||||||
" \"hex\" : \"data\" (string) Raw data for transaction\n"
|
" \"hex\" : \"data\" (string) Raw data for transaction\n"
|
||||||
" \"decoded\" : transaction (json object) Optional, the decoded transaction\n"
|
" \"details\" : transaction (json object) Optional, additional transaction details. This object contains the same transaction details as the `getrawtransaction` RPC method\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
},
|
},
|
||||||
RPCExamples{
|
RPCExamples{
|
||||||
|
@ -1711,7 +1711,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
|
||||||
filter |= ISMINE_WATCH_ONLY;
|
filter |= ISMINE_WATCH_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool decode_tx = request.params[2].isNull() ? false : request.params[2].get_bool();
|
bool verbose = request.params[2].isNull() ? false : request.params[2].get_bool();
|
||||||
|
|
||||||
UniValue entry(UniValue::VOBJ);
|
UniValue entry(UniValue::VOBJ);
|
||||||
auto it = pwallet->mapWallet.find(hash);
|
auto it = pwallet->mapWallet.find(hash);
|
||||||
|
@ -1738,10 +1738,10 @@ static UniValue gettransaction(const JSONRPCRequest& request)
|
||||||
std::string strHex = EncodeHexTx(*wtx.tx, pwallet->chain().rpcSerializationFlags());
|
std::string strHex = EncodeHexTx(*wtx.tx, pwallet->chain().rpcSerializationFlags());
|
||||||
entry.pushKV("hex", strHex);
|
entry.pushKV("hex", strHex);
|
||||||
|
|
||||||
if (decode_tx) {
|
if (verbose) {
|
||||||
UniValue decoded(UniValue::VOBJ);
|
UniValue details(UniValue::VOBJ);
|
||||||
TxToUniv(*wtx.tx, uint256(), decoded, false);
|
TxToUniv(*wtx.tx, uint256(), details, false);
|
||||||
entry.pushKV("decoded", decoded);
|
entry.pushKV("details", details);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
@ -4189,7 +4189,7 @@ static const CRPCCommand commands[] =
|
||||||
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, {"address_type"} },
|
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, {"address_type"} },
|
||||||
{ "wallet", "getreceivedbyaddress", &getreceivedbyaddress, {"address","minconf"} },
|
{ "wallet", "getreceivedbyaddress", &getreceivedbyaddress, {"address","minconf"} },
|
||||||
{ "wallet", "getreceivedbylabel", &getreceivedbylabel, {"label","minconf"} },
|
{ "wallet", "getreceivedbylabel", &getreceivedbylabel, {"label","minconf"} },
|
||||||
{ "wallet", "gettransaction", &gettransaction, {"txid","include_watchonly","decode"} },
|
{ "wallet", "gettransaction", &gettransaction, {"txid","include_watchonly","verbose"} },
|
||||||
{ "wallet", "getunconfirmedbalance", &getunconfirmedbalance, {} },
|
{ "wallet", "getunconfirmedbalance", &getunconfirmedbalance, {} },
|
||||||
{ "wallet", "getbalances", &getbalances, {} },
|
{ "wallet", "getbalances", &getbalances, {} },
|
||||||
{ "wallet", "getwalletinfo", &getwalletinfo, {} },
|
{ "wallet", "getwalletinfo", &getwalletinfo, {} },
|
||||||
|
|
|
@ -499,10 +499,10 @@ class WalletTest(BitcoinTestFramework):
|
||||||
self.nodes[0].setlabel(change, 'foobar')
|
self.nodes[0].setlabel(change, 'foobar')
|
||||||
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)
|
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)
|
||||||
|
|
||||||
# Test "decoded" field value in gettransaction response
|
# Test "verbose" field value in gettransaction response
|
||||||
self.log.info("Testing gettransaction decoding...")
|
self.log.info("Testing verbose gettransaction...")
|
||||||
tx = self.nodes[0].gettransaction(txid=txid, decode=True)
|
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)
|
||||||
assert_equal(tx["decoded"], self.nodes[0].decoderawtransaction(tx["hex"]))
|
assert_equal(tx["details"], self.nodes[0].decoderawtransaction(tx["hex"]))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Reference in a new issue