Repository navigation
This release contains several breaking changes, please refer to the migration notes for more information.
cashc compiler
- ✨ Add support for user-defined reusable functions, including multiple return values.
- ✨ Add support for top-level global constants, including simple arithmetic / concatenation operations.
- ✨ Add support for
importdirectives to share user-defined functions across files, including imports fromnode_modules. - ✨ Add support for reassigning existing variables in tuple destructuring (e.g.
(a, b) = swap(a, b)), optionally mixed with fresh declarations. - ✨ Add
unusedmodifier for parameters or variables that are intentionally unused. - 🛠️ Update
compileStringto take an optionalfilesobject for filesystem-free import resolution. - 🛠️ Unused variables that are not marked
unusednow produce a compiler warning instead of a compilation error. - 🛠️ Add a compiler warning for values assigned to a variable that are never read afterwards.
- 🐛 Fix bug where date literals were parsed in the local time zone instead of UTC.
- 🐛 BREAKING: Fix bug where
LockingBytecodeNullDataused incorrect push opcodes for empty chunks and chunks of 128-255 bytes, so it did not match the SDK'saddOpReturnOutput(). - 🐛 BREAKING: Fix bug where hex literals with an odd number of digits (e.g.
0x123) compiled to a different value (0x1203). They now cause a compile error. - 🐛 Fix bug where using the same variable in both arguments of
.slice()could fail to compile. - 🐛 Fix bug where a variable reassigned in a
forloop's init (e.g.for (i = 0; ...)) had an incorrect value after the loop. - 🐛 Fix bug where console.log showed an outdated value for a reassigned variable after its final use.
- 🐎 Add new optimisations for loop counter updates, reassignments, scope cleanup, stack shuffles, and order-independent operations.
- 🐎 Greatly improve compiler speed for very large contracts.
CashScript SDK
- ✨ Add support for debugging user-defined functions, including stack traces for nested functions.
- ✨ Add a
validateTransactionsoption (default:true) to theMockNetworkProviderto validate sent transactions against the BCH VM. - 💥 BREAKING: Remove
generateLockingBytecode()from theUnlockerinterface. - 🛠️ BREAKING: The
TransactionBuildernow requires UTXOs to include theirlockingBytecode, and validates it against the provided unlocker. - 🛠️ BREAKING: Replace the
SignatureTemplate'sgetHashType(),getPublicKey()andgetSignatureAlgorithm()methods with thesighashType,publicKeyandsignatureAlgorithmproperties. - 🛠️ BREAKING: Remove the
bchForkIdparameter fromSignatureTemplate'sgenerateSignature()method, since BCH consensus rules always require the fork ID flag. - 🛠️ BREAKING: Rename the
HashTypeenum toSighashType. - 🛠️ Add
lockingBytecodefield to theUtxointerface, set automatically on all UTXOs returned by network providers. - 🛠️
MockNetworkProvidernow logs a warning instead of throwing when the same transaction is sent twice. - 🛠️
ElectrumNetworkProvidernow uses Electrum protocol 1.5.0 (was 1.4.1), andgetBlockHeight()no longer subscribes to new headers. Custom electrum clients should negotiate 1.5.0 or later. - 🛠️ Update
@electrum-cash/networkto 4.4.0. In a browser, theElectrumNetworkProvidernow disconnects while the page is hidden and reconnects afterwards, restoring any subscriptions (see Browser visibility and connectivity). - 🛠️ Make
cashscript/vitesttypes compatible with Vitest 5. - 🐛 Fix bug where invalid hex string arguments were silently encoded to different bytes.
- 🐛 Fix bug where
pubkeyarguments were not checked to be 33 or 65 bytes. - 🐛 Fix bug in
ElectrumNetworkProviderautomatic connection management. - 🐛 Fix bug where
send()threw aFailedTransactionErrorwhen the transaction was broadcast but could not be retrieved afterwards. - 🐛 Fix bug where debugging reported a VM resource limit as a failed require statement.
- 🐛 Fix minimum fee check rounding bug.
- 🐛 Fix bug where
setLocktime()accepted invalid values. - 🐛 Fix edge case bug where a failing final
require(variable)statement was reported incorrectly in debugging.