@@ -185,7 +185,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
185185
186186void TxToUniv (const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags, int version)
187187{
188- const auto txInToUniValue = [](const CTransaction& tx, const CTxIn& txin, const unsigned int index, bool include_hex) {
188+ const auto txInToUniValue = [](const CTransaction& tx, const CTxIn& txin, const unsigned int index, bool include_hex, int version ) {
189189 UniValue in (UniValue::VOBJ);
190190 if (tx.IsCoinBase ())
191191 in.pushKV (" coinbase" , HexStr (txin.scriptSig .begin (), txin.scriptSig .end ()));
@@ -194,7 +194,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
194194 in.pushKV (" vout" , (int64_t )txin.prevout .n );
195195 UniValue o (UniValue::VOBJ);
196196 o.pushKV (" asm" , ScriptToAsmStr (txin.scriptSig , true ));
197- if (include_hex) {
197+ if (include_hex || version <= 2 ) {
198198 o.pushKV (" hex" , HexStr (txin.scriptSig .begin (), txin.scriptSig .end ()));
199199 }
200200 in.pushKV (" scriptSig" , o);
@@ -215,7 +215,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
215215 out.pushKV (" value" , ValueFromAmount (txout.nValue ));
216216 out.pushKV (" n" , (int64_t )index);
217217 UniValue o (UniValue::VOBJ);
218- ScriptPubKeyToUniv (txout.scriptPubKey , o, include_hex);
218+ ScriptPubKeyToUniv (txout.scriptPubKey , o, include_hex || version <= 2 );
219219 out.pushKV (" scriptPubKey" , o);
220220 // We skip this for v3+ as we tokenId field is unused.
221221 if (version <= 2 && tx.nVersion >= CTransaction::TOKENS_MIN_VERSION) {
@@ -235,7 +235,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
235235
236236 UniValue vin (UniValue::VARR);
237237 for (unsigned int i = 0 ; i < tx.vin .size (); i++) {
238- vin.push_back (txInToUniValue (tx, tx.vin [i], i, include_hex));
238+ vin.push_back (txInToUniValue (tx, tx.vin [i], i, include_hex, version ));
239239 }
240240 entry.pushKV (" vin" , vin);
241241
0 commit comments