CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
112 stars 79 forks source link

Support for [CHIP-2021-03: Bigger Script Integers] #104

Closed rkalis closed 2 years ago

rkalis commented 2 years ago

Link to the CHIP: https://gitlab.com/GeneralProtocols/research/chips/-/blob/master/CHIP-2021-02-Bigger-Script-Integers.md

No action seems to be required for bigger integer support on the compiler side. However on the SDK side JS numbers are limited to 53 bytes (versus 64 bytes of the new BCH big integers). So for that we need to allow the use of JS bigint at any place where you can currently provide number parameters.

The second part of the CHIP is the enabling of OP_MUL, so the * operator needs to be added to CashScript.

rkalis commented 2 years ago

Note that we do not need to add support for bigint for any "satoshis" values, since the max amoount of satoshis is 21 000 000 00000000, while the max value of a JS number is 90 071 992 54740991 (about 4x the max satoshis).

rkalis commented 2 years ago

Also note that locktime and version fields in the transaction fit within a JS number since they're 32bit integers.

rkalis commented 2 years ago

This has been implemented in v0.7.0-next.0. If some issues with it come up I'll have the time to fix that before May, if no issues come up, I will release v0.7.0 once the May 2022 upgrade hits mainnet.

rkalis commented 2 years ago

v0.7.0 has been released for mainnet support of bigger integers and OP_MUL