@@ -143,25 +143,22 @@ std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags)
143143 return HexStr (ssTx);
144144}
145145
146- void ScriptToUniv (const CScript& script, UniValue& out)
147- {
148- ScriptPubKeyToUniv (script, out, /* include_hex */ true , /* include_address */ false );
149- }
150-
151- void ScriptPubKeyToUniv (const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address)
146+ void ScriptToUniv (const CScript& script, UniValue& out, bool include_hex, bool include_address)
152147{
153148 CTxDestination address;
154149
155- out.pushKV (" asm" , ScriptToAsmStr (scriptPubKey ));
150+ out.pushKV (" asm" , ScriptToAsmStr (script ));
156151 if (include_address) {
157- out.pushKV (" desc" , InferDescriptor (scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString ());
152+ out.pushKV (" desc" , InferDescriptor (script, DUMMY_SIGNING_PROVIDER)->ToString ());
153+ }
154+ if (include_hex) {
155+ out.pushKV (" hex" , HexStr (script));
158156 }
159- if (include_hex) out.pushKV (" hex" , HexStr (scriptPubKey));
160157
161158 std::vector<std::vector<unsigned char >> solns;
162- const TxoutType type{Solver (scriptPubKey , solns)};
159+ const TxoutType type{Solver (script , solns)};
163160
164- if (include_address && ExtractDestination (scriptPubKey , address) && type != TxoutType::PUBKEY) {
161+ if (include_address && ExtractDestination (script , address) && type != TxoutType::PUBKEY) {
165162 out.pushKV (" address" , EncodeDestination (address));
166163 }
167164 out.pushKV (" type" , GetTxnOutputType (type));
@@ -215,7 +212,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
215212
216213 if (verbosity == TxVerbosity::SHOW_DETAILS_AND_PREVOUT) {
217214 UniValue o_script_pub_key (UniValue::VOBJ);
218- ScriptPubKeyToUniv (prev_txout.scriptPubKey , o_script_pub_key, /* include_hex=*/ true );
215+ ScriptToUniv (prev_txout.scriptPubKey , /* out= */ o_script_pub_key, /* include_hex=*/ true , /* include_address= */ true );
219216
220217 UniValue p (UniValue::VOBJ);
221218 p.pushKV (" generated" , bool (prev_coin.fCoinBase ));
@@ -240,7 +237,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
240237 out.pushKV (" n" , (int64_t )i);
241238
242239 UniValue o (UniValue::VOBJ);
243- ScriptPubKeyToUniv (txout.scriptPubKey , o, true );
240+ ScriptToUniv (txout.scriptPubKey , /* out= */ o, /* include_hex= */ true , /* include_address= */ true );
244241 out.pushKV (" scriptPubKey" , o);
245242 vout.push_back (out);
246243
0 commit comments