@smartledger/bsv 4.0.1 → 4.2.1

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 CHANGED
@@ -5,6 +5,143 @@ 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.2.1] - 2026-06-07
9
+
10
+ ### Docs
11
+
12
+ - **Substantial README rewrite for the v4.x line.** The README still
13
+ headlined v3.4.x (4 minors and a major stale), showed the *old*
14
+ `lib/covenant-interface` API in the covenant examples instead of the
15
+ v4.2.0 `bsv.SmartContract.PushTx`/`PELS`/`Token`/`Locks`/`verifyScript`
16
+ surface, had a wrong CDN-Bundles size table (off by up to 7× on
17
+ `bsv-mnemonic`), duplicate "Complete Documentation" sections, a
18
+ "planned 3.5.0" security note that was overtaken by 4.0.0, and a
19
+ footer stamp claiming "v3.3.4 • 9 Loading Options". Replaced the
20
+ headline with the v4.2.0 covenant section, rewrote PUSHTX/PELS
21
+ examples to use the new API, added Ownership Tokens + end-to-end
22
+ verification snippets, merged the two Documentation sections (7
23
+ broken file paths fixed, 4 dead links removed), replaced the
24
+ inaccurate CDN sub-table with a pointer to the canonical
25
+ loading-options table, updated Security to point at the v4.0.0 GDAF
26
+ fix, and stamped the footer at v4.2.1.
27
+
28
+ ### Semver
29
+
30
+ Patch — README only. No source changes; no `lib/`, `bin/`, `bsv.d.ts`,
31
+ or test diffs. Out-of-band republish: `@smartledger/bsv@4.2.0` was
32
+ published from a separate session with the OLD README, then
33
+ unpublished after the rewrite. npm's anti-republish policy refuses to
34
+ reuse the 4.2.0 version number; 4.2.1 is the canonical version with
35
+ the corrected README content. `smartledger-bsv@4.2.0` (unscoped) was
36
+ published with the new README; for parity, the unscoped is also
37
+ republished at 4.2.1.
38
+
39
+ ## [4.2.0] - 2026-06-07
40
+
41
+ ### Added
42
+
43
+ - **First-class, interpreter-verified covenants under `bsv.SmartContract`.**
44
+ A complete, tested stack of custom locking scripts that verify end-to-end
45
+ through `Script.Interpreter` (positive and negative cases), building on the
46
+ post-Genesis limits from 4.1.0:
47
+ - **`SmartContract.PushTx`** — a *correct* OP_PUSH_TX (nChain WP1605). The
48
+ locking script generates an ECDSA signature in-script from the pushed
49
+ preimage (`a=k=1`, `r=Gx`, `s=(e+Gx) mod n`, pubkey `02||Gx`) and verifies
50
+ it with `OP_CHECKSIG`, proving the preimage is this very transaction. Uses a
51
+ fixed-length DER template with an `nLockTime` grind (`PushTx.grind`). Exposes
52
+ `authenticator()`, `valueCovenant()`, `hashOutputs()`, `extractHashOutputs()`.
53
+ - **`SmartContract.PELS` / `perpetualCovenant(fee)`** — a Perpetually Enforcing
54
+ Locking Script: every spend must recreate the same script (value − fee).
55
+ Reads its own script from the authenticated preimage's `scriptCode`, so there
56
+ is no self-hash circularity.
57
+ - **`SmartContract.Token` / `ownershipToken(fee, ownerHash)`** — a stateful
58
+ ownership token (NFT) carrying its owner as on-chain state; transfer requires
59
+ the owner's secret and rewrites the state, perpetuating the token code.
60
+ - **`SmartContract.Locks`** — hash-lock, P2PKH, CLTV time-lock, m-of-n
61
+ multisig, and HTLC primitives.
62
+ - **`SmartContract.CovenantHelpers`** + convenience methods
63
+ `enableGenesis()`, `verifyScript()`, `valueCovenant()` — a consensus-flag
64
+ `verify()` harness, raw BIP-143 preimage access, signing, and fund/spend
65
+ scaffolding.
66
+ - New mocha suite `test/smart_contract/covenants.js` (11 specs / 24 assertions),
67
+ all green; full suite 4178 → 4189 passing.
68
+
69
+ ### Notes
70
+
71
+ - These covenants require post-Genesis limits: call `SmartContract.enableGenesis()`
72
+ (a.k.a `Interpreter.useGenesisLimits()`) before verifying. Research-grade and
73
+ interpreter-verified — review before mainnet value (the OP_PUSH_TX key is the
74
+ intentionally public `a=k=1`; low-S malleability is left unenforced).
75
+
76
+ ## [4.1.0] - 2026-06-07
77
+
78
+ ### Added
79
+
80
+ - **`Interpreter.useGenesisLimits([max])` — one-call opt-in for
81
+ post-Genesis BSV consensus.** The bundled `Script.Interpreter`
82
+ hardcoded the *pre-Genesis* consensus caps that BSV removed at the
83
+ Genesis upgrade (February 2020): 520-byte stack elements, 4-byte
84
+ script numbers, 201 non-push opcodes per script. Those caps make this
85
+ library's own flagship features impossible to evaluate — OP_PUSH_TX
86
+ covenants push a ~585-byte preimage element, do 32-byte modular
87
+ arithmetic (`OP_ADD`/`OP_MOD`), and run a few hundred opcodes.
88
+
89
+ ```js
90
+ // Default: bound the limits to a safe ceiling.
91
+ // 64 KB covers every covenant pattern seen in production and blocks
92
+ // memory-exhaustion via oversized pushes from untrusted scripts.
93
+ bsv.Script.Interpreter.useGenesisLimits(64 * 1024)
94
+
95
+ // Or fully unbounded (~2 GB) — only safe for trusted scripts:
96
+ // bsv.Script.Interpreter.useGenesisLimits()
97
+ ```
98
+
99
+ Defaults are unchanged out of the box (520 / 4 / 201) — existing
100
+ consumers see zero behavior change unless they opt in. The call
101
+ mutates static properties on the `Interpreter` constructor and
102
+ therefore affects every subsequent `new Interpreter()` in the
103
+ process; treat it as an app-startup setting, not per-request.
104
+
105
+ - **`Interpreter.MAX_OPS_PER_SCRIPT`** exposed as a named constant
106
+ (= 201). Replaces the two hardcoded `> 201` checks in `Interpreter.step`.
107
+
108
+ - **`bsv.d.ts`** now types `Interpreter.MAX_SCRIPT_ELEMENT_SIZE`,
109
+ `MAXIMUM_ELEMENT_SIZE`, `MAX_OPS_PER_SCRIPT`, and `useGenesisLimits()`.
110
+
111
+ ### Fixed
112
+
113
+ - **`Interpreter.MAXIMUM_ELEMENT_SIZE` was a dead knob in the numeric
114
+ opcodes.** The constant was defined as `4` but never threaded into the
115
+ `BN.fromScriptNumBuffer(buf, fRequireMinimal, size)` calls in
116
+ `OP_ADD`/`OP_SUB`/`OP_MUL`/`OP_DIV`/`OP_MOD`/`OP_BOOLAND`/`OP_BOOLOR`/
117
+ `OP_NUMEQUAL`/`OP_NUMEQUALVERIFY`/`OP_NUMNOTEQUAL`/`OP_LESSTHAN`/
118
+ `OP_GREATERTHAN`/`OP_LESSTHANOREQUAL`/`OP_GREATERTHANOREQUAL`/`OP_MIN`/
119
+ `OP_MAX` (binary) and `OP_WITHIN` (ternary). The 3rd `size` argument was
120
+ always omitted, so BN fell back to its own 4-byte default — raising
121
+ `Interpreter.MAXIMUM_ELEMENT_SIZE` above 4 had no effect. Now threaded
122
+ through, so the knob actually does what its name implies.
123
+
124
+ ### Tests
125
+
126
+ - Added `test/script/genesis_limits.js` (6 tests) covering defaults,
127
+ the lift, rejection of >4-byte arithmetic and >201 opcodes under
128
+ defaults, and acceptance of both after `useGenesisLimits()`. Full
129
+ suite: **4178 passing, 0 failing**.
130
+
131
+ ### Docs
132
+
133
+ - README §"Evaluating covenants locally" — one-paragraph mention of
134
+ the new API in the covenant/smart-contract section.
135
+ - JSDoc on `useGenesisLimits` calls out the process-wide-mutation
136
+ semantics and recommends bounded ceilings for untrusted input.
137
+ - CDN/install refs bumped `@4.0.1` → `@4.1.0` across README + 6 docs
138
+ files.
139
+
140
+ ### Semver
141
+
142
+ Minor bump — purely additive: a new public method and a fixed-but-was-
143
+ dead constant. No existing API or default behavior changes.
144
+
8
145
  ## [4.0.1] - 2026-05-31
9
146
 
10
147
  ### Deprecated