36 std::cout <<
"Script executed without errors" << std::endl;
43 return strprintf(
"0x%02x", int32_t(opcode));
46 }
else if (opcode ==
OP_0 || (opcode >=
OP_1 && opcode <=
OP_16)) {
64 std::cout <<
"======= " << title <<
" =======" << std::endl;
68 for (
size_t entryIdx = 0; entryIdx < trace.
entries.size(); ++entryIdx) {
70 std::cout <<
strprintf(
"OP%3d: %s", entryIdx,
75 std::cout << std::endl;
77 if (entryIdx == trace.
entries.size() - 1 &&
91 std::cerr << title <<
" failed execution: ";
97 std::cerr << std::endl;
105 std::cout <<
strprintf(
" Stack (%d item%s):", stacks.
stack.size(),
106 stacks.
stack.size() == 1 ?
"" :
"s");
107 if (stacks.
stack.empty()) {
108 std::cout <<
" (empty stack)";
110 std::cout << std::endl;
111 for (
size_t itemIdx = 0; itemIdx < stacks.
stack.size(); ++itemIdx) {
112 std::cout <<
strprintf(
" %2d: %s", itemIdx,
118 " Altstack (%d item%s):", stacks.
altstack.size(),
119 stacks.
altstack.size() == 1 ?
"" :
"s")
121 for (
size_t itemIdx = 0; itemIdx < stacks.
altstack.size(); ++itemIdx) {
122 std::cout <<
strprintf(
" %2d: %s", itemIdx,
131 std::cout <<
"Number of sigChecks: " << metrics.
nSigChecks << std::endl;
136 size_t topStackSize = 0;
137 size_t topAltStackSize = 0;
144 std::cout <<
"scriptName,index,opcode,";
145 for (
size_t idx = 0; idx < topStackSize; ++idx) {
146 std::cout <<
"stack " << idx <<
",";
148 for (
size_t idx = 0; idx < topAltStackSize; ++idx) {
149 std::cout <<
"altstack " << idx <<
",";
151 std::cout << std::endl;
165 result.
metrics, topStackSize)) {
171 std::cout <<
"Script executed without errors" << std::endl;
177 size_t &topAltStackSize) {
179 topStackSize = std::max(topStackSize, entry.
stacks.
stack.size());
188 size_t topStackSize) {
189 for (
size_t entryIdx = 0; entryIdx < trace.
entries.size(); ++entryIdx) {
191 std::cout << traceName <<
",";
192 std::cout << entryIdx <<
",";
199 std::cout << std::endl;
207 std::cout << traceName <<
" failed execution: ";
213 std::cout << std::endl;
221 size_t topStackSize) {
224 for (
size_t padIdx = 0; padIdx < topStackSize - stacks.
stack.size();
233 for (
const std::vector<uint8_t> &item : stack) {
235 std::cout <<
"(empty)";
237 std::cout <<
"\"" <<
HexStr(item) <<
"\"";
245 std::cout <<
"#sigChecks"
std::string GetOpName(opcodetype opcode)
opcodetype
Script opcodes.
std::string ScriptErrorString(const ScriptError serror)
IguanaTrace traceScriptSig
IguanaTrace traceScriptPubKey
ScriptExecutionMetrics metrics
std::optional< IguanaTrace > traceRedeemScript
std::vector< std::vector< uint8_t > > stack
std::vector< std::vector< uint8_t > > altstack
std::vector< uint8_t > pushdata
std::vector< IguanaTraceEntry > entries
IguanaStacks initialStacks
Struct for holding cumulative results from executing a script or a sequence of scripts.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.