bitcoin-tx-tutorial
bitcoin-tx-tutorial copied to clipboard
fix script-level locktime encoding
After changing locktime from 500 to 200 in the original code, the following error occurs (v24.0.1 is used):
'reject-reason': 'non-mandatory-script-verify-flag (unknown error)'
Apparently locktime should be encoded minimally in the script and since 2 bytes is used for 200, which can fit in a single byte, the error is raised. Also if locktime <= 16 then OP_1 to OP_16 can be used.
Same goes for the solution of exercise but since 398 also needs 2 bytes, no change is needed.
This PR doesn't change the locktime value and only adds the code to handle other cases for OP_CLTV.