Each function name is replaced by its index in the functions list. A script can only contain 32
Each function name is replaced by its index in the functions list. A script can only contain 64
functions, but we'll see how can use more if needed. A function can have at most 15 parameters.
The script begin with the number of user functions contained in the script (minus the final one, must be at most 31) followed by 4 bits per function storing the number of parameters. 4 `0` bits must be added if
function count is odd to maintain byte alignment.
The script begin with the number of user functions contained in the script (minus the final one,
must be at most 63) followed by 4 bits per function storing the number of parameters. 4 `0` bits
must be added if function count is odd to maintain byte alignment.
Then, each fonction contains on of these opcodes.
| Opcode | Name | Description
|:-------|:-----|:---------
| `0b00XXXXXX` | `valXXXXXX` | Use a value of `XXXXXX` (0-63).
| `0b01XXXXXX` | `sys[XXXXXX]` | Use system function `XXXXXX` (0-63).
| `0b100XXXXX` | `usrXXXXX` | Use user function `XXXXX` (0-31).
| `0b1010XXXX` | `parXXXX` | Use function parameter `XXXX` (0-15)
| `0b1011XXXX` | `grpXXXX+2` | Create a group of the following `XXXX + 2` items. The first item should be a function call, and the following items its parameters.
| `0b1100000X` | `datX+1` | Use data with its `size` stored in the next `X + 1` following bytes, and the data in the `size` next bytes. If the size is 0 a null-length value will be created.
| `0b1100001X` | `arrX+1` | Create an *array function* with a `size` stored in the next `X + 1` following bytes, then `size` opcodes defining each value. If the size is 0 an empty array will be created.
| `0b110001..` | |
| `0b111.....` | | *Unused opcodes. Their presence makes the script returns `true` to allow new opcodes additions with soft-forks.*
| `0b01XXXXXX` | `sys[name]` | Use system function `XXXXXX` (0-63).
| `0b10XXXXXX` | `usrXXXXX` | Use user function `XXXXX` (0-63).
| `0b1100XXXX` | `parXXXX` | Use function parameter `XXXX` (0-15)
| `0b1101XXXX` | `grpXXXX+2` | Create a group of the following `XXXX + 2` items. The first item should be a function call, and the following items its parameters.
| `0b1110000X` | `datX+1` | Use data with its `size` stored in the next `X + 1` following bytes, and the data in the `size` next bytes. If the size is 0 a null-length value will be created.
| `0b1110001X` | `arrX+1` | Create an *array function* with a `size` stored in the next `X + 1` following bytes, then `size` opcodes defining each value. If the size is 0 an empty array will be created.
| `0b111001..` | |
| `0b1111....` | | *Unused opcodes. Their presence makes the script returns `true` to allow new opcodes additions with soft-forks.*
| `0b11111111` | `use` | *Can only be used as the only opcode of a function*. Allow to refeer to a subscript by providing its hash stored in the next 32 bytes. When this function is used in the script, the subscript with the provided hash can be provided and its final function is called. If the subscript is not provided, the return value is the opcode following the hash. If this opcode is another `use`, then the subscript is mandatory and its absence prevent the script from running (making it invalid).