bitcoin-tx-tutorial icon indicating copy to clipboard operation
bitcoin-tx-tutorial copied to clipboard

fix script-level locktime encoding

Open Amir-m-a opened this issue 11 months ago • 0 comments

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.

Amir-m-a avatar Jan 02 '25 06:01 Amir-m-a