script tracer: Put an obvious "opcode failed" message in the pre-execute stack

This commit is contained in:
Andrew Poelstra 2014-08-25 16:09:00 -07:00
parent 47c346be71
commit 46bffa304c
1 changed files with 8 additions and 5 deletions

View File

@ -110,6 +110,7 @@ pub struct TraceIteration {
index: uint, index: uint,
opcode: allops::Opcode, opcode: allops::Opcode,
executed: bool, executed: bool,
errored: bool,
effect: opcodes::OpcodeClass, effect: opcodes::OpcodeClass,
stack: Vec<String> stack: Vec<String>
} }
@ -127,7 +128,7 @@ pub struct ScriptTrace {
pub error: Option<ScriptError> pub error: Option<ScriptError>
} }
impl_json!(TraceIteration, index, opcode, executed, effect, stack) impl_json!(TraceIteration, index, opcode, executed, errored, effect, stack)
/// Hashtype of a transaction, encoded in the last byte of a signature, /// Hashtype of a transaction, encoded in the last byte of a signature,
/// specifically in the last 5 bits `byte & 31` /// specifically in the last 5 bits `byte & 31`
@ -635,8 +636,9 @@ impl Script {
index: index, index: index,
opcode: opcode, opcode: opcode,
executed: executing, executed: executing,
errored: true,
effect: opcode.classify(), effect: opcode.classify(),
stack: vec![] stack: vec!["<failed to execute opcode>".to_string()]
}); });
} }
None => {} None => {}
@ -938,9 +940,10 @@ impl Script {
} // end loop } // end loop
// Store the stack in the trace // Store the stack in the trace
trace.as_mut().map(|t| trace.as_mut().map(|t|
t.mut_last().map(|t| t.mut_last().map(|t| {
t.stack = stack.iter().map(|elem| elem.as_slice().to_hex()).collect() t.errored = false;
) t.stack = stack.iter().map(|elem| elem.as_slice().to_hex()).collect();
})
); );
} }
Ok(()) Ok(())