Module Bitcoinml.Script

type data = string

Script is a forth-like language used in Bitcoin transactions

type opcode =
| OP_COINBASE of string
| OP_0
| OP_FALSE
| OP_DATA of int * data
| OP_PUSHDATA1 of int * data
| OP_PUSHDATA2 of int * int * data
| OP_PUSHDATA4 of int * int * int * int * data
| OP_1NEGATE
| OP_1
| OP_TRUE
| OP_2
| OP_3
| OP_4
| OP_5
| OP_6
| OP_7
| OP_8
| OP_9
| OP_10
| OP_11
| OP_12
| OP_13
| OP_14
| OP_15
| OP_16
| OP_IF
| OP_NOTIF
| OP_ELSE
| OP_ENDIF
| OP_VERIFY
| OP_RETURN of data
| OP_TOALTSTACK
| OP_FROMALTSTACK
| OP_IFDUP
| OP_DEPTH
| OP_DROP
| OP_DUP
| OP_NIP
| OP_OVER
| OP_PICK
| OP_ROLL
| OP_ROT
| OP_SWAP
| OP_TUCK
| OP_2DROP
| OP_2DUP
| OP_3DUP
| OP_2OVER
| OP_2ROT
| OP_2SWAP
| OP_CAT
| OP_SUBSTR
| OP_LEFT
| OP_RIGHT
| OP_SIZE
| OP_INVERT
| OP_AND
| OP_OR
| OP_XOR
| OP_EQUAL
| OP_EQUALVERIFY
| OP_1ADD
| OP_1SUB
| OP_2MUL
| OP_2DIV
| OP_NEGATE
| OP_ABS
| OP_NOT
| OP_0NOTEQUAL
| OP_ADD
| OP_SUB
| OP_MUL
| OP_DIV
| OP_MOD
| OP_LSHIFT
| OP_RSHIFT
| OP_BOOLAND
| OP_BOOLOR
| OP_NUMEQUAL
| OP_NUMEQUALVERIFY
| OP_NUMNOTEQUAL
| OP_LESSTHAN
| OP_GREATERTHAN
| OP_LESSTHANOREQUAL
| OP_GREATERTHANOREQUAL
| OP_MIN
| OP_MAX
| OP_WITHIN
| OP_RIPEMD160
| OP_SHA1
| OP_SHA256
| OP_HASH160
| OP_HASH256
| OP_CODESEPARATOR
| OP_CHECKSIG
| OP_CHECKSIGVERIFY
| OP_CHECKMULTISIG
| OP_CHECKMULTISIGVERIFY
| OP_CHECKLOCKTIMEVERIFY
| OP_CHECKSEQUENCEVERIFY
| OP_PUBKEYHASH
| OP_PUBKEY
| OP_INVALIDOPCODE
| OP_RESERVED
| OP_VER
| OP_VERIF
| OP_VERNOTIF
| OP_RESERVED1
| OP_RESERVED2
| OP_NOP of int
val opcode_to_hex : opcode -> int list

opcode_to_hex op transform an opcode to binary as int list

val opcode_of_hex : string -> opcode * string

opcode_of_hex s parse s and return the opcode plus the rest string

type t = opcode list * int

Script.t defined as a list of opcodes

val empty : t

empty returns an empty script

val length : t -> int

length s returns the length of s

val serialize : t -> string

serialize s serializes the script s and returns binary data

val join : t -> t -> t

join s1 s2 joins script s1 with s2

val parse : string -> t

parse data parses binary data and returns the script

val parse_coinbase : string -> t

parse_coinbase data parses coinbase script

val of_opcodes : opcode list -> t

of_opcodes ops returns the script of a list ops of opcodes