rpc: add "ischange: true" in wallet gettransaction decoded tx output

This commit is contained in:
Matthew Zipkin
2025-05-15 11:32:04 -04:00
parent c779ee3a40
commit d633db5416
5 changed files with 25 additions and 6 deletions

View File

@@ -168,7 +168,7 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex, bool i
out.pushKV("type", GetTxnOutputType(type));
}
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, const CTxUndo* txundo, TxVerbosity verbosity)
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, const CTxUndo* txundo, TxVerbosity verbosity, std::function<bool(const CTxOut&)> is_change_func)
{
CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS);
@@ -243,6 +243,11 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
UniValue o(UniValue::VOBJ);
ScriptToUniv(txout.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
out.pushKV("scriptPubKey", std::move(o));
if (is_change_func && is_change_func(txout)) {
out.pushKV("ischange", true);
}
vout.push_back(std::move(out));
if (have_undo) {