Basic functionality to read and write opcodes.
Opcode is a number and not an enum for two reasons:
- Having to type Opcode.OP_CHECKSIG every time instead of OP_CHECKSIG is much simpler
- The opcode list isn't exhaustive, e.g. 0xd0 would be a valid opcode, it would just fail immediately if in an executed branch.
Also, for pushops, the used opcode is explicit and not automatically chosen, this is because there's different usages require different rules:
- In executed Bitcoin script, all pushops must be encoded minimally, e.g. the empty string must be pushed using OP_0, not using OP_PUSHDATA1
- In SLP, single push opcodes like OP_0 cannot be used, so to push the empty string, OP_PUSHDATAn must be used in this case.
In future diffs, we can add functions to get us minimal Ops for either of these cases.