2929#include < evo/specialtx.h>
3030#include < llmq/commitment.h>
3131
32+ #include < map>
33+ #include < string>
34+ #include < vector>
35+
3236UniValue ValueFromAmount (const CAmount amount)
3337{
3438 static_assert (COIN > 1 );
@@ -153,31 +157,28 @@ std::string EncodeHexTx(const CTransaction& tx)
153157 return HexStr (ssTx);
154158}
155159
156- void ScriptToUniv (const CScript& script, UniValue& out)
157- {
158- ScriptPubKeyToUniv (script, out, /* include_hex */ true , /* include_address */ false );
159- }
160-
161- void ScriptPubKeyToUniv (const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address)
160+ void ScriptToUniv (const CScript& script, UniValue& out, bool include_hex, bool include_address)
162161{
163162 CTxDestination address;
164163
165- out.pushKV (" asm" , ScriptToAsmStr (scriptPubKey ));
164+ out.pushKV (" asm" , ScriptToAsmStr (script ));
166165 if (include_address) {
167- out.pushKV (" desc" , InferDescriptor (scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString ());
166+ out.pushKV (" desc" , InferDescriptor (script, DUMMY_SIGNING_PROVIDER)->ToString ());
167+ }
168+ if (include_hex) {
169+ out.pushKV (" hex" , HexStr (script));
168170 }
169- if (include_hex) out.pushKV (" hex" , HexStr (scriptPubKey));
170171
171172 std::vector<std::vector<unsigned char >> solns;
172- const TxoutType type{Solver (scriptPubKey , solns)};
173+ const TxoutType type{Solver (script , solns)};
173174
174- if (include_address && ExtractDestination (scriptPubKey , address) && type != TxoutType::PUBKEY) {
175+ if (include_address && ExtractDestination (script , address) && type != TxoutType::PUBKEY) {
175176 out.pushKV (" address" , EncodeDestination (address));
176177 }
177178 out.pushKV (" type" , GetTxnOutputType (type));
178179}
179180
180- void TxToUniv (const CTransaction& tx, const uint256& hashBlock , UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo, TxVerbosity verbosity, const CSpentIndexTxInfo* ptxSpentInfo)
181+ void TxToUniv (const CTransaction& tx, const uint256& block_hash , UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo, TxVerbosity verbosity, const CSpentIndexTxInfo* ptxSpentInfo)
181182{
182183 uint256 txid = tx.GetHash ();
183184 entry.pushKV (" txid" , txid.GetHex ());
@@ -233,7 +234,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
233234
234235 if (verbosity == TxVerbosity::SHOW_DETAILS_AND_PREVOUT) {
235236 UniValue o_script_pub_key (UniValue::VOBJ);
236- ScriptPubKeyToUniv (prev_txout.scriptPubKey , o_script_pub_key, /* include_hex=*/ true , /* include_address=*/ true );
237+ ScriptToUniv (prev_txout.scriptPubKey , /* out= */ o_script_pub_key, /* include_hex=*/ true , /* include_address=*/ true );
237238
238239 UniValue p (UniValue::VOBJ);
239240 p.pushKV (" generated" , bool (prev_coin.fCoinBase ));
@@ -259,7 +260,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
259260 out.pushKV (" n" , (int64_t )i);
260261
261262 UniValue o (UniValue::VOBJ);
262- ScriptPubKeyToUniv (txout.scriptPubKey , o, true );
263+ ScriptToUniv (txout.scriptPubKey , /* out= */ o, /* include_hex= */ true , /* include_address= */ true );
263264 out.pushKV (" scriptPubKey" , o);
264265
265266 // Add spent information if spentindex is enabled
@@ -335,8 +336,9 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
335336 entry.pushKV (" fee" , ValueFromAmount (fee));
336337 }
337338
338- if (!hashBlock.IsNull ())
339- entry.pushKV (" blockhash" , hashBlock.GetHex ());
339+ if (!block_hash.IsNull ()) {
340+ entry.pushKV (" blockhash" , block_hash.GetHex ());
341+ }
340342
341343 if (include_hex) {
342344 entry.pushKV (" hex" , EncodeHexTx (tx)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction".
0 commit comments