@smartledger/bsv 9.3.0 → 9.4.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 CHANGED
@@ -7,6 +7,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [9.4.0] - 2026-09-01
11
+
12
+ ### Fixed — `policy().lockUntil()` did not bind, and `OP_BIN2NUM` used the wrong era's width
13
+
14
+ Two defects, found together because the second is what stops you fixing the first.
15
+
16
+ #### `lockUntil` checked one third of a time lock
17
+
18
+ The compiled script asserted `nLockTime >= floor` and nothing else. A time lock
19
+ is three rules in the node's `CheckLockTime`, and the other two each have a spend
20
+ that walks straight through:
21
+
22
+ - **Sequence.** `IsFinalTx()` ignores `nLockTime` outright when every input is
23
+ `0xffffffff`. A spender who set a final sequence satisfied the script with the
24
+ very locktime it demanded and produced a transaction minable in the next block.
25
+ The honest `unlock()` helper set `0xfffffffe`, so the covenant looked correct
26
+ from inside — and the test that covered the early-locktime case set
27
+ `0xfffffffe` too, which is why nothing caught it.
28
+ - **Units.** Consensus reads `nLockTime` below 500,000,000 as a block height and
29
+ at or above it as a unix timestamp. A bare `>=` compares the two as plain
30
+ numbers, so `1500000000 >= 900000` cleared a floor of block 900,000 with a
31
+ timestamp from July 2017 — a transaction that is final today.
32
+
33
+ Both are now enforced in script: this input must be non-final, and a height floor
34
+ requires the locktime to be a height. `describe()` reports both, and
35
+ `lockUntil(0)` throws, since consensus reads 0 as "no lock" whatever the
36
+ sequences are.
37
+
38
+ This is the same defect that removed `Locks.timeLockCLTV` and `Locks.htlc` in
39
+ 9.0.0 — a time lock that enforces nothing — reappearing in the DSL that replaced
40
+ them. There, the cause was Genesis reverting `OP_CHECKLOCKTIMEVERIFY` to a NOP.
41
+ Here, it was reimplementing `CHECKLOCKTIMEVERIFY` by hand and reproducing only
42
+ its comparison.
43
+
44
+ #### `OP_BIN2NUM` capped every era at the pre-Genesis 4 bytes
45
+
46
+ It range-checked its result with `_isMinimallyEncoded(buf)`, whose `nMaxNumSize`
47
+ argument **defaults to 4**. The node passes `maxScriptNumLength`, which is 4
48
+ before Genesis, 750,000 after it and 32,000,000 after Chronicle.
49
+
50
+ Any unsigned field whose top byte has the sign bit set needs a fifth byte to read
51
+ as positive, so this rejected:
52
+
53
+ - **Every perpetual covenant and ownership token holding 21.47 BSV or more**
54
+ (2³¹ satoshis). Both read the preimage's 8-byte value field through
55
+ `OP_BIN2NUM`, so the coins were locked in and unspendable.
56
+ - **Every `nLockTime` from 19 Jan 2038**, whose high bit is set.
57
+
58
+ The node's own corpus did not catch it: all 25 of its `OP_BIN2NUM` vectors run
59
+ under `P2SH,STRICTENC` alone — pre-Genesis, where 4 is the right answer either
60
+ way. 1,483/1,483 passed before the fix and after it. The opcode was covered; the
61
+ *era* was not, and era selection is where both of this library's consensus
62
+ defects have been.
63
+
64
+ `lockUntil` also needed this: `nLockTime` is unsigned and `OP_BIN2NUM` reads
65
+ signed, so from 2038 the extracted value came back as negative zero and no spend
66
+ could clear the floor. The fix is to sign-pad to five bytes first, and that push
67
+ is only legal once `OP_BIN2NUM` honours the era.
68
+
69
+ #### Upgrading
70
+
71
+ `lockUntil` compiles different bytes, so a UTXO locked by 9.3.0 or earlier cannot
72
+ be spent with a script compiled by this version — keep the compiled object, or
73
+ recompile with the old version. Those locks bind nothing, so treat their coins as
74
+ spendable by anyone and move them.
75
+
10
76
  ## [9.3.0] - 2026-08-28
11
77
 
12
78
  ### Added
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Bitcoin SV library with an interpreter-verified script engine.
4
4
 
5
- [![Version](https://img.shields.io/badge/version-9.3.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-9.4.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
6
6
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7
7
  [![Stability](https://img.shields.io/badge/9.x%20stable%20until-2027--09--01-brightgreen.svg)](STABILITY.md)
8
8
 
@@ -155,44 +155,44 @@ const bsv = require('@smartledger/bsv') // 128 modules
155
155
  ### **Core Modules**
156
156
  | Module | Size | Use Case | CDN |
157
157
  |--------|------|----------|-----|
158
- | **bsv.min.js** | 1044KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.3.0/bsv.min.js` |
159
- | **bsv.bundle.js** | 1044KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.3.0/bsv.bundle.js` |
158
+ | **bsv.min.js** | 1045KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js` |
159
+ | **bsv.bundle.js** | 1045KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.4.0/bsv.bundle.js` |
160
160
 
161
161
  ### **W3C Verifiable Credentials**
162
162
  | Module | Size | Use Case | CDN |
163
163
  |--------|------|----------|-----|
164
- | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.3.0/bsv-didweb.min.js` |
165
- | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.3.0/bsv-vcjwt.min.js` |
166
- | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.3.0/bsv-statuslist.min.js` |
167
- | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.3.0/bsv-anchor.min.js` |
164
+ | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.4.0/bsv-didweb.min.js` |
165
+ | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.4.0/bsv-vcjwt.min.js` |
166
+ | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.4.0/bsv-statuslist.min.js` |
167
+ | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.4.0/bsv-anchor.min.js` |
168
168
 
169
169
  ### **Smart Contract & Development**
170
170
  | Module | Size | Use Case | CDN |
171
171
  |--------|------|----------|-----|
172
- | **bsv-smartcontract.min.js** | 140KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.3.0/bsv-smartcontract.min.js` |
173
- | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.3.0/bsv-covenant.min.js` |
174
- | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.3.0/bsv-script-helper.min.js` |
175
- | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.3.0/bsv-security.min.js` |
172
+ | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.4.0/bsv-smartcontract.min.js` |
173
+ | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.4.0/bsv-covenant.min.js` |
174
+ | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.4.0/bsv-script-helper.min.js` |
175
+ | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.4.0/bsv-security.min.js` |
176
176
 
177
177
  ### **Legal & Compliance**
178
178
  | Module | Size | Use Case | CDN |
179
179
  |--------|------|----------|-----|
180
- | **bsv-ltp.min.js** | 539KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.3.0/bsv-ltp.min.js` |
181
- | **bsv-gdaf.min.js** | 1044KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.3.0/bsv-gdaf.min.js` |
180
+ | **bsv-ltp.min.js** | 539KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.4.0/bsv-ltp.min.js` |
181
+ | **bsv-gdaf.min.js** | 1045KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.4.0/bsv-gdaf.min.js` |
182
182
 
183
183
  ### **Advanced Cryptography**
184
184
  | Module | Size | Use Case | CDN |
185
185
  |--------|------|----------|-----|
186
- | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.3.0/bsv-shamir.min.js` |
186
+ | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.4.0/bsv-shamir.min.js` |
187
187
 
188
188
  ### **Utilities**
189
189
  | Module | Size | Use Case | CDN |
190
190
  |--------|------|----------|-----|
191
- | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.3.0/bsv-ecies.min.js` |
192
- | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.3.0/bsv-message.min.js` |
193
- | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.3.0/bsv-mnemonic.min.js` |
191
+ | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.4.0/bsv-ecies.min.js` |
192
+ | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.4.0/bsv-message.min.js` |
193
+ | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.4.0/bsv-mnemonic.min.js` |
194
194
  ```html
195
- <script src="https://unpkg.com/@smartledger/bsv@9.3.0/bsv.min.js"></script>
195
+ <script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js"></script>
196
196
  <script>
197
197
  const key = bsv.PrivateKey.fromRandom()
198
198
  </script>
@@ -240,4 +240,4 @@ MIT
240
240
 
241
241
  ---
242
242
 
243
- **SmartLedger-BSV v9.3.0**
243
+ **SmartLedger-BSV v9.4.0**