This commit is contained in:
Riahiamirreza 2024-04-29 04:32:08 +02:00 committed by GitHub
commit bcf36003e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -202,6 +202,21 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
o.pushKV("hex", HexStr(txin.scriptSig));
in.pushKV("scriptSig", o);
if ((int*)txundo && txundo->vprevout.size() && txundo->vprevout[txin.prevout.n].out.scriptPubKey.IsPayToScriptHash()) {
UniValue redeemScript(UniValue::VOBJ);
opcodetype opcode;
std::vector<unsigned char> vch;
CScript::const_iterator pc = txin.scriptSig.begin();
while (true) {
if (!txin.scriptSig.GetOp(pc, opcode, vch))
break;
}
CScript script;
std::vector<unsigned char> scriptData(ParseHex(HexStr(vch)));
script = CScript(scriptData.begin(), scriptData.end());
ScriptToUniv(script, /*out=*/redeemScript, /*include_hex=*/false, /*include_address=*/true);
in.pushKV("redeemScript", redeemScript);
}
}
if (!tx.vin[i].scriptWitness.IsNull()) {
UniValue txinwitness(UniValue::VARR);

View File

@ -114,6 +114,12 @@ static std::vector<RPCResult> DecodeTxDoc(const std::string& txid_field_doc)
{RPCResult::Type::STR, "asm", "Disassembly of the signature script"},
{RPCResult::Type::STR_HEX, "hex", "The raw signature script bytes, hex-encoded"},
}},
{RPCResult::Type::OBJ, "redeemScript", /*optional=*/true, "",
{
{RPCResult::Type::STR, "asm", ""},
{RPCResult::Type::STR, "desc", ""},
{RPCResult::Type::STR, "type", ""},
}},
{RPCResult::Type::ARR, "txinwitness", /*optional=*/true, "",
{
{RPCResult::Type::STR_HEX, "hex", "hex-encoded witness data (if any)"},