3 import "encoding/binary"
5 func opFalse(vm *virtualMachine) error {
10 return vm.pushBool(false, false)
13 func opPushdata(vm *virtualMachine) error {
14 err := vm.applyCost(1)
18 d := make([]byte, len(vm.data))
20 return vm.push(d, false)
23 func op1Negate(vm *virtualMachine) error {
24 err := vm.applyCost(1)
28 return vm.pushInt64(-1, false)
31 func opNop(vm *virtualMachine) error {
32 return vm.applyCost(1)
35 // PushDataBytes push bytes to stack
36 func PushDataBytes(in []byte) []byte {
39 return []byte{byte(OP_0)}
42 return append([]byte{byte(OP_DATA_1) + uint8(l) - 1}, in...)
45 return append([]byte{byte(OP_PUSHDATA1), uint8(l)}, in...)
49 binary.LittleEndian.PutUint16(b[:], uint16(l))
50 return append([]byte{byte(OP_PUSHDATA2), b[0], b[1]}, in...)
53 binary.LittleEndian.PutUint32(b[:], uint32(l))
54 return append([]byte{byte(OP_PUSHDATA4), b[0], b[1], b[2], b[3]}, in...)
57 // PushDataInt64 push int64 to stack
58 func PushDataInt64(n int64) []byte {
60 return []byte{byte(OP_0)}
62 if n >= 1 && n <= 16 {
63 return []byte{uint8(OP_1) + uint8(n) - 1}
65 return PushDataBytes(Int64Bytes(n))