mirror of https://github.com/bitcoin/bitcoin
add decompiled redeemScript to TxToUniv result
This commit is contained in:
parent
9d85c03620
commit
65b7634976
|
@ -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);
|
||||
|
|
|
@ -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)"},
|
||||
|
|
Loading…
Reference in New Issue