May 15th is bringing a network upgrade (also known as a hard fork) to the $BCH network. Along w/ a 32 MB block size we're reactivating a bunch of OP
codes. Thanks to the advice of @MADinMelbourne I decided to see exactly what each new OP
code was bringing to the table.
Below I list each new OP
code w/ a quick description and then demonstrate how it works by showing a small validation script and then what the stack would look like after.
Please let me know if you spot errors. Thanks!
Concatenates 2 strings
'foo' 'bar' OP_CAT
- 'foobar'
Boolean AND
between each bit in the inputs.
true false OP_AND
false
Boolean OR
between each bit in the inputs.
true false OP_OR
true
Boolean XOR
between each bit in the inputs.
true true OP_XOR
false
a is divided by b.
10 5 OP_DIV
- 2
Returns the remainder after dividing a by b.
11 5 OP_MOD
- 1
Split string at positions
'foobar' 2 OP_SPLIT
- 'obar'
- 'fo'
Convert the numeric value into a binary array of a certain size, taking account of the sign bit.
12 size OP_NUM2BIN
- binaryArray
Convert the binary array into a valid numeric value, including minimal encoding.
binaryArray OP_BIN2NUM
- 12
increasing from 80 bytes to 220 bytes
'foobar' 2 OP_SPLIT would be 'fo' 'obar'. Each char has one byte.
And stack size stays constant because 'foobar' and 2 are stack elements, they become 'fo' and 'obar'