Merge bitcoin/bitcoin#32517: rpc: add "ischange: true" to decoded tx outputs in wallet gettransaction response
060bb55508rpc: add decoded tx details to gettransaction with extra wallet fields (Matthew Zipkin)ad1c3bdba5[move only] move DecodeTxDoc() to a common util file for sharing (Matthew Zipkin)d633db5416rpc: add "ischange: true" in wallet gettransaction decoded tx output (Matthew Zipkin) Pull request description: This change is motivated by external RBF clients like https://github.com/CardCoins/additive-rbf-batcher/. It saves the user a redundant re-looping of tx outputs, calling `getaddressinfo` on each one, looking for the change output in order to adjust the fee. The field `"ischange"` only appears when `gettransaction` is called on a wallet, and is either `true` or not present at all. I chose not to include `ischange: false` because it is confusing to see that on *received* transactions. Example of the new field: ``` "vout": [ { "value": 1.00000000, "n": 0, "scriptPubKey": { "asm": "0 5483235e05c76273b3b50af62519738781aff021", "desc": "addr(bcrt1q2jpjxhs9ca388va4ptmz2xtns7q6lupppkw7wu)#d42g84j6", "hex": "00145483235e05c76273b3b50af62519738781aff021", "address": "bcrt1q2jpjxhs9ca388va4ptmz2xtns7q6lupppkw7wu", "type": "witness_v0_keyhash" } }, { "value": 198.99859000, "n": 1, "scriptPubKey": { "asm": "0 870ab1ab58632b05a417d5295f4038500e407592", "desc": "addr(bcrt1qsu9tr26cvv4stfqh65547spc2q8yqavj7fnlju)#tgapemkv", "hex": "0014870ab1ab58632b05a417d5295f4038500e407592", "address": "bcrt1qsu9tr26cvv4stfqh65547spc2q8yqavj7fnlju", "type": "witness_v0_keyhash" }, "ischange": true } ] ``` ACKs for top commit: furszy: ACK [060bb55](https://github.com/bitcoin/bitcoin/pull/32517/commits/060bb55508245776bb6a39c8b7849769ee588d69) maflcko: review ACK060bb55508🌛 achow101: ACK060bb55508rkrux: lgtm ACK060bb55508Tree-SHA512: aae4854d2bb4e9a7bc1152691ea90e594e8da8a63c9c7fda72a504fb6a7e54ae274ed5fa98d35d270e0829cc8f8d2fd35a5fc9735c252a10aa42cc22828930e7
This commit is contained in:
7 files changed
+78
-50
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include <policy/rbf.h>
|
||||
#include <primitives/transaction_identifier.h>
|
||||
#include <rpc/util.h>
|
||||
#include <rpc/rawtransaction_util.h>
|
||||
#include <rpc/blockchain.h>
|
||||
#include <util/vector.h>
|
||||
#include <wallet/receive.h>
|
||||
@@ -700,7 +701,7 @@ RPCHelpMan gettransaction()
|
||||
{RPCResult::Type::STR_HEX, "hex", "Raw data for transaction"},
|
||||
{RPCResult::Type::OBJ, "decoded", /*optional=*/true, "The decoded transaction (only present when `verbose` is passed)",
|
||||
{
|
||||
{RPCResult::Type::ELISION, "", "Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."},
|
||||
DecodeTxDoc(/*txid_field_doc=*/"The transaction id", /*wallet=*/true),
|
||||
}},
|
||||
RESULT_LAST_PROCESSED_BLOCK,
|
||||
})
|
||||
@@ -752,7 +753,16 @@ RPCHelpMan gettransaction()
|
||||
|
||||
if (verbose) {
|
||||
UniValue decoded(UniValue::VOBJ);
|
||||
TxToUniv(*wtx.tx, /*block_hash=*/uint256(), /*entry=*/decoded, /*include_hex=*/false);
|
||||
TxToUniv(*wtx.tx,
|
||||
/*block_hash=*/uint256(),
|
||||
/*entry=*/decoded,
|
||||
/*include_hex=*/false,
|
||||
/*txundo=*/nullptr,
|
||||
/*verbosity=*/TxVerbosity::SHOW_DETAILS,
|
||||
/*is_change_func=*/[&pwallet](const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
AssertLockHeld(pwallet->cs_wallet);
|
||||
return OutputIsChange(*pwallet, txout);
|
||||
});
|
||||
entry.pushKV("decoded", std::move(decoded));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user