Skip to content

Commit

Permalink
txscript: Make op callbacks take opcode and data.
Browse files Browse the repository at this point in the history
This converts the callback function defined on the internal opcode
struct to accept the opcode and data slice instead of a parsed opcode as
the final step towards removing the parsed opcode struct and associated
supporting code altogether.

It also updates all of the callbacks and tests accordingly and finally
removes the now unused parsedOpcode struct.
  • Loading branch information
davecgh authored and cfromknecht committed Feb 2, 2021
1 parent 85eb436 commit f038748
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 101 deletions.
5 changes: 2 additions & 3 deletions txscript/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,14 @@ func (vm *Engine) executeOpcode(op *opcode, data []byte) error {
// Ensure all executed data push opcodes use the minimal encoding when
// the minimal data verification flag is set.
if vm.dstack.verifyMinimalData && vm.isBranchExecuting() &&
pop.opcode.value >= 0 && pop.opcode.value <= OP_PUSHDATA4 {
op.value >= 0 && op.value <= OP_PUSHDATA4 {

if err := checkMinimalDataPush(op, data); err != nil {
return err
}
}

pop := parsedOpcode{opcode: op, data: data}
return op.opfunc(&pop, vm)
return op.opfunc(op, data, vm)
}

// checkValidPC returns an error if the current script position is not valid for
Expand Down
Loading

0 comments on commit f038748

Please sign in to comment.