@smartledger/bsv 4.2.1 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/bsv-covenant.min.js +7 -7
- package/bsv-gdaf.min.js +8 -8
- package/bsv-ltp.min.js +8 -8
- package/bsv-smartcontract.min.js +8 -8
- package/bsv.bundle.js +8 -8
- package/bsv.d.ts +94 -0
- package/bsv.min.js +7 -7
- package/lib/script/interpreter.js +52 -2
- package/lib/smart_contract/covenant_helpers.js +3 -2
- package/lib/smart_contract/debugger.js +71 -0
- package/lib/smart_contract/dsl.js +129 -0
- package/lib/smart_contract/index.js +68 -55
- package/lib/smart_contract/pels.js +1 -2
- package/lib/smart_contract/pushtx.js +25 -8
- package/lib/smart_contract/token.js +3 -5
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,85 @@ All notable changes to SmartLedger-BSV will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.5.0] - 2026-06-09
|
|
9
|
+
|
|
10
|
+
### Added — declarative covenant DSL + stack debugger
|
|
11
|
+
|
|
12
|
+
- **`SmartContract.policy()` — a declarative covenant DSL.** Describe a spending
|
|
13
|
+
policy and compile it to a verified OP_PUSH_TX locking script, no opcodes:
|
|
14
|
+
```js
|
|
15
|
+
const c = bsv.SmartContract.policy()
|
|
16
|
+
.payTo(aliceAddr, 9500) // the spend MUST create this output...
|
|
17
|
+
.lockUntil(800000) // ...with nLockTime >= 800000
|
|
18
|
+
.compile()
|
|
19
|
+
// c.lock, c.outputs, c.unlock(spendTx, satoshis)
|
|
20
|
+
```
|
|
21
|
+
Clauses AND together (each compiles to one preimage-field check on a single
|
|
22
|
+
OP_PUSH_TX authentication). `payTo` pins outputs via `hashOutputs`; `lockUntil`
|
|
23
|
+
checks the `nLockTime` field. The compiled `unlock()` grinds the OP_PUSH_TX
|
|
24
|
+
nonce *from the locktime floor upward* so it never collides with a `lockUntil`
|
|
25
|
+
constraint. Shortcuts: `policy.perpetual(fee)`, `policy.token(fee, ownerHash)`.
|
|
26
|
+
- **`SmartContract.trace()` — a covenant stack debugger.** Step-traces a
|
|
27
|
+
locking/unlocking pair and records the stack + alt-stack after every opcode, so
|
|
28
|
+
you can watch an OP_PUSH_TX covenant build its signature and enforce its
|
|
29
|
+
constraints. `SmartContract.Debugger.format(result)` pretty-prints it.
|
|
30
|
+
- **TypeScript types** for the full covenant suite in `bsv.d.ts`
|
|
31
|
+
(`SmartContract.{PushTx,PELS,Token,Locks,CovenantHelpers,policy,Policy,trace,
|
|
32
|
+
Debugger}` + `enableGenesis`/`verifyScript`/`perpetualCovenant`/…).
|
|
33
|
+
|
|
34
|
+
New mocha suite `test/smart_contract/dsl_debugger.js` (7 specs). Full suite
|
|
35
|
+
4199 → 4206 passing. Lint clean; `bsv.d.ts` type-checks.
|
|
36
|
+
|
|
37
|
+
## [4.4.0] - 2026-06-07
|
|
38
|
+
|
|
39
|
+
### Added — BSV string opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT
|
|
40
|
+
|
|
41
|
+
- **Implemented the re-enabled BSV (Chronicle) string opcodes in the script
|
|
42
|
+
interpreter.** They were declared in the opcode map (`0xb3`/`0xb4`/`0xb5`) but
|
|
43
|
+
unimplemented — executing one returned `BAD_OPCODE`. Now they evaluate with the
|
|
44
|
+
original Satoshi semantics:
|
|
45
|
+
- `OP_LEFT (in n -- out)` — the first `n` bytes.
|
|
46
|
+
- `OP_RIGHT (in n -- out)` — the last `n` bytes (`OP_RIGHT 0` ⇒ empty, not the
|
|
47
|
+
whole string).
|
|
48
|
+
- `OP_SUBSTR (in begin size -- out)` — `in[begin : begin+size]`.
|
|
49
|
+
Out-of-range lengths clamp to the string length; negative arguments fail with
|
|
50
|
+
`SCRIPT_ERR_INVALID_NUMBER_RANGE`. New test: `test/script/string_ops.js`.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- **Covenant field-extraction now uses these opcodes**, shrinking the scripts
|
|
55
|
+
further: perpetual covenant 429→**421 B**, ownership token 493→**482 B**, value
|
|
56
|
+
covenant 428→**424 B** (vs. the verbose `OP_SIZE/OP_SUB/OP_SPLIT/OP_NIP` form).
|
|
57
|
+
|
|
58
|
+
Full mocha suite 4190 → 4199 passing, 0 failing. Lint clean.
|
|
59
|
+
|
|
60
|
+
## [4.3.0] - 2026-06-07
|
|
61
|
+
|
|
62
|
+
### Changed — mainnet hardening of OP_PUSH_TX covenants
|
|
63
|
+
|
|
64
|
+
- **Canonical low-S signatures.** The OP_PUSH_TX grind now requires `s <= n/2`,
|
|
65
|
+
so the in-script signature is canonical (low-S) and non-malleable, and the
|
|
66
|
+
covenant verify path enforces `SCRIPT_VERIFY_LOW_S`. This makes the produced
|
|
67
|
+
spends standard for mainnet relay/mining. Cost: zero extra script bytes — the
|
|
68
|
+
constraint is satisfied by the spender's grind, not by added opcodes.
|
|
69
|
+
(`SmartContract.PushTx.sFromPreimage`, `CovenantHelpers.flags`.)
|
|
70
|
+
- **Smaller scripts (−22 bytes per covenant).** `pushTxCore` now shares a single
|
|
71
|
+
`Gx` push between the DER signature's r-value and the `02||Gx` public key
|
|
72
|
+
(parked on the alt-stack) instead of embedding the 32-byte constant twice.
|
|
73
|
+
Authenticator 404→382 B, value covenant 450→428 B, perpetual 451→429 B,
|
|
74
|
+
ownership token 515→493 B.
|
|
75
|
+
|
|
76
|
+
### Notes
|
|
77
|
+
|
|
78
|
+
- The remaining ~382-byte floor is intrinsic to OP_PUSH_TX on BSV: ~248 B is the
|
|
79
|
+
two mandatory 32-byte endianness reversals (big-endian hash ↔ little-endian
|
|
80
|
+
script arithmetic ↔ big-endian DER), the rest is fixed secp256k1 constants and
|
|
81
|
+
the DER template. There is no single-opcode byte reverse on BSV —
|
|
82
|
+
`OP_REVERSEBYTES` is a Bitcoin Cash opcode, not part of the BSV opcode set, so
|
|
83
|
+
the `OP_SPLIT`/`OP_SWAP`/`OP_CAT` reversal gadget is the correct approach.
|
|
84
|
+
- New test: `test/smart_contract/covenants.js` proves the grind yields low-S
|
|
85
|
+
signatures enforced under `SCRIPT_VERIFY_LOW_S`. Full suite 4189 → 4190.
|
|
86
|
+
|
|
8
87
|
## [4.2.1] - 2026-06-07
|
|
9
88
|
|
|
10
89
|
### Docs
|