@smartledger/bsv 7.2.0 → 7.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,142 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.4.0] - 2026-08-05
11
+
12
+ Completes BSV-21 coverage. 7.3.0 taught the parser every operation the specification
13
+ defines; this release lets you *build* them too, so the authority-based token model is
14
+ usable end to end rather than only readable.
15
+
16
+ ### Added
17
+
18
+ - **`BSV20.buildAuth` / `buildDeployAuth` / `buildBurn`**, with matching
19
+ `createAuthOutput` / `createDeployAuthOutput` / `createBurnOutput` 1-sat output helpers.
20
+ These complete the BSV-21 authority model, which is the current standard (v1 tickers
21
+ are deprecated):
22
+
23
+ - `deploy+auth` declares a token with **no supply** — `amt` is forbidden, and minting
24
+ happens later against the deploy's outpoint.
25
+ - `auth` marks an output as carrying the right to mint, which "can be split, combined,
26
+ or transferred to delegate minting authority". It carries no amount.
27
+ - `burn` retires an amount of a BSV-21 token. Id-based only: the specification defines
28
+ no ticker form, and a `tick` is rejected with a message saying so rather than being
29
+ quietly reinterpreted.
30
+
31
+ - **`buildMint` accepts `id`**, so a BSV-21 token can be minted against its outpoint
32
+ (`{p, op:'mint', id, amt}`, which requires an auth input to be spent on chain). Only
33
+ the v1 ticker form was previously expressible, which meant a token deployed under the
34
+ authority model could be read but never minted. The v1 ticker path is byte-for-byte
35
+ unchanged — a regression test pins the exact emitted JSON.
36
+
37
+ ### Fixed
38
+
39
+ - **`buildTransfer` no longer silently drops `tick` when `id` is also given.** It
40
+ preferred `id` and discarded the ticker, but those name *different tokens*, so the
41
+ caller got a transfer of something other than what they asked for. Both `buildMint` and
42
+ `buildTransfer` now require exactly one of the two and say which is missing when neither
43
+ is supplied. Same silent-argument family as 7.0.1, 7.0.2, 7.2.0 and 7.3.0.
44
+
45
+ ### Changed
46
+
47
+ - `bsv.d.ts`: `buildMint` takes `{amt, tick?, id?}`; the new builders and output helpers
48
+ are declared; `Payload.op` lists `deploy+auth`, `auth` and `burn`. Verified under
49
+ `tsc --strict` — valid calls compile, and omitting the required `id` on `buildAuth` is
50
+ a compile error.
51
+
52
+ Suite 4525 → 4536.
53
+
54
+ ## [7.3.0] - 2026-08-05
55
+
56
+ Conformance pass over the rest of `lib/ordinals/`, checked against the published
57
+ 1Sat Ordinals specification rather than against our own tests. `parseOrdLock` and
58
+ `parseBsv20` both reported validity they did not enforce; the builders emitted
59
+ payloads the spec rejects. Some calls that previously succeeded now throw — see
60
+ **Breaking**.
61
+
62
+ ### Fixed (security)
63
+
64
+ - **`parseOrdLock` / `isOrdLock` verify the covenant instead of matching a shape.**
65
+ Both recovered a listing's terms from the script's *arrangement of opcodes* — a
66
+ top-level `OP_IF` with a 20-byte push, and `OP_TOALTSTACK <blob> OP_CAT OP_SWAP`
67
+ in the `OP_ELSE` branch — and reported a seller and a price on that basis alone.
68
+ A script wearing that arrangement while containing **no `OP_PUSH_TX` covenant at
69
+ all** was therefore reported as a genuine listing: the regression test builds one
70
+ that ends in `OP_TRUE`, gets `isOrdLock` → `true` with an attacker-chosen seller
71
+ address and a 1 BSV price, and then proves through the interpreter that the
72
+ ordinal is spendable **for free**. A marketplace UI reading listings this way
73
+ displays fabricated offers.
74
+
75
+ The recovered terms are now verified by reconstruction: the listing is rebuilt
76
+ from the recovered seller / payment outputs / inscription via `buildOrdLock` and
77
+ must match the input byte-for-byte. A non-null result means the purchase branch
78
+ genuinely binds the payment into `hashOutputs`. Every listing this library builds
79
+ — simple, multi-output royalty/fee, and inscribe-and-list — still parses.
80
+
81
+ - **`parseBsv20` / `isBsv20` enforce the validity they document.** Both were
82
+ documented to report whether input "carries a **valid** BSV-20 inscription" but
83
+ checked only that `p === 'bsv-20'` and that `op` was a string, so
84
+ `{p:'bsv-20', op:'transfer'}` — no amount, no token — and even
85
+ `{p:'bsv-20', op:'not-an-op'}` returned `true`. The operation must now be one the
86
+ specification defines and must carry that operation's required fields, with
87
+ `tick` / `id` / amounts / `dec` well-formed. Operations this library does not yet
88
+ build are still read: `burn`, `auth` and `deploy+auth` parse. Non-canonical
89
+ amounts (leading zeros) are tolerated when reading, since other people's payloads
90
+ are not ours to reject over formatting.
91
+
92
+ ### Fixed
93
+
94
+ - **`lim: 0` is accepted; the spec defines it as unlimited.** The deploy builder ran
95
+ `lim` through the strictly-positive check used for `max` and `amt`, so the legal
96
+ value documented as "0 or omitted = unlimited" threw `lim must be greater than
97
+ zero` — there was no way to state an unlimited per-mint cap explicitly.
98
+
99
+ - **Amounts are bounded by uint64.** `amt`, `max` and `lim` are "strings
100
+ representing uint64" (max `18446744073709551615`), but any length of digit string
101
+ was accepted and emitted — a 26-digit supply produced valid JSON that indexers
102
+ discard, burning the tokens. Values above `2^64-1` are now rejected, and exactly
103
+ `2^64-1` is accepted. A *numeric* amount above `Number.MAX_SAFE_INTEGER` is also
104
+ rejected rather than silently rounded to a different number than the caller passed;
105
+ pass it as a string.
106
+
107
+ - **`sym` and `icon` reject non-strings instead of stringifying them.** Both ran
108
+ through `String()`, so `sym: {}` wrote the literal text `[object Object]` into a
109
+ permanent token payload — the same coercion class fixed in `inscription.js` in
110
+ 7.2.0, which that sweep did not reach. `icon` must additionally be an outpoint
111
+ reference (`<txid>_<vout>`), which is what the specification defines it as.
112
+
113
+ ### Changed
114
+
115
+ - Two tests asserted that 26-digit amounts round-trip. Their intent — amounts beyond
116
+ 2^53 stay exact as strings and are never coerced to JS numbers — is right and is
117
+ preserved, but the magnitude was out of spec and would have been burned on chain;
118
+ they now use `18446744073709551615`, which is both far beyond 2^53 and the largest
119
+ amount the spec permits.
120
+
121
+ - Documented in `lib/ordinals/README.md` that this OrdLock, while semantically the
122
+ widely deployed ordinal-lock pattern (`hash256(destOutput ‖ payOutput ‖
123
+ trailingOutputs) == hashOutputs` under `SIGHASH_ALL|ANYONECANPAY`, generalized to
124
+ multiple payment outputs), is built on our `OP_PUSH_TX` core rather than compiled
125
+ from the sCrypt `OrdinalLock` contract — so the bytes differ and listings are not
126
+ interchangeable with that template.
127
+
128
+ ### Breaking
129
+
130
+ `buildDeploy`/`buildMint`/`buildTransfer`/`buildDeployMint` now throw on amounts above
131
+ uint64, numeric amounts above `Number.MAX_SAFE_INTEGER`, non-string `sym`/`icon`, and an
132
+ `icon` that is not an outpoint. Each previously emitted a payload the network does not
133
+ honour.
134
+
135
+ `parseBsv20` returns `null` — and `isBsv20` `false` — for payloads that were previously
136
+ returned but are not valid: unknown operations, missing required fields, a `transfer`
137
+ naming both `tick` and `id`, `auth`/`deploy+auth` carrying `amt`, malformed `tick`/`id`,
138
+ out-of-range `dec`, and over-uint64 amounts.
139
+
140
+ `parseOrdLock` returns `null` for any script that is not byte-identical to a listing this
141
+ library would build. Callers relying on it to describe arbitrary scripts were being told
142
+ about listings that did not exist.
143
+
144
+ Suite 4502 → 4525.
145
+
10
146
  ## [7.2.0] - 2026-08-05
11
147
 
12
148
  Extends the 7.0.1/7.0.2 silent-argument sweep into `lib/ordinals/`, which the earlier
package/README.md CHANGED
@@ -186,42 +186,42 @@ console.log('Status:', status) // 'revoked'
186
186
  ### **Core Modules**
187
187
  | Module | Size | Use Case | CDN |
188
188
  |--------|------|----------|-----|
189
- | **bsv.min.js** | 1149KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js` |
190
- | **bsv.bundle.js** | 1149KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js` |
189
+ | **bsv.min.js** | 1149KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js` |
190
+ | **bsv.bundle.js** | 1149KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
191
191
 
192
192
  ### **W3C Verifiable Credentials**
193
193
  | Module | Size | Use Case | CDN |
194
194
  |--------|------|----------|-----|
195
- | **🟢 bsv-didweb.min.js** | 315KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-didweb.min.js` |
196
- | **🟢 bsv-vcjwt.min.js** | 315KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-vcjwt.min.js` |
197
- | **🟢 bsv-statuslist.min.js** | 415KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-statuslist.min.js` |
198
- | **🟢 bsv-anchor.min.js** | 314KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-anchor.min.js` |
195
+ | **🟢 bsv-didweb.min.js** | 315KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-didweb.min.js` |
196
+ | **🟢 bsv-vcjwt.min.js** | 315KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-vcjwt.min.js` |
197
+ | **🟢 bsv-statuslist.min.js** | 415KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-statuslist.min.js` |
198
+ | **🟢 bsv-anchor.min.js** | 314KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-anchor.min.js` |
199
199
 
200
200
  ### **Smart Contract & Development**
201
201
  | Module | Size | Use Case | CDN |
202
202
  |--------|------|----------|-----|
203
- | **bsv-smartcontract.min.js** | 873KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js` |
204
- | **bsv-covenant.min.js** | 873KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js` |
205
- | **bsv-script-helper.min.js** | 30KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.2.0/bsv-script-helper.min.js` |
206
- | **bsv-security.min.js** | 30KB | Security enhancements | `unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js` |
203
+ | **bsv-smartcontract.min.js** | 873KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
204
+ | **bsv-covenant.min.js** | 873KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
205
+ | **bsv-script-helper.min.js** | 30KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js` |
206
+ | **bsv-security.min.js** | 30KB | Security enhancements | `unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js` |
207
207
 
208
208
  ### **Legal & Compliance**
209
209
  | Module | Size | Use Case | CDN |
210
210
  |--------|------|----------|-----|
211
- | **bsv-ltp.min.js** | 1149KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js` |
212
- | **bsv-gdaf.min.js** | 1149KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js` |
211
+ | **bsv-ltp.min.js** | 1149KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
212
+ | **bsv-gdaf.min.js** | 1149KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
213
213
 
214
214
  ### **Advanced Cryptography**
215
215
  | Module | Size | Use Case | CDN |
216
216
  |--------|------|----------|-----|
217
- | **bsv-shamir.min.js** | 353KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@7.2.0/bsv-shamir.min.js` |
217
+ | **bsv-shamir.min.js** | 353KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
218
218
 
219
219
  ### **Utilities**
220
220
  | Module | Size | Use Case | CDN |
221
221
  |--------|------|----------|-----|
222
- | **bsv-ecies.min.js** | 79KB | Encryption | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ecies.min.js` |
223
- | **bsv-message.min.js** | 30KB | Message signing | `unpkg.com/@smartledger/bsv@7.2.0/bsv-message.min.js` |
224
- | **bsv-mnemonic.min.js** | 592KB | HD wallets | `unpkg.com/@smartledger/bsv@7.2.0/bsv-mnemonic.min.js` |
222
+ | **bsv-ecies.min.js** | 79KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
223
+ | **bsv-message.min.js** | 30KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
224
+ | **bsv-mnemonic.min.js** | 592KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
225
225
 
226
226
  ## ⚡ **2-Minute Quick Start**
227
227
 
@@ -232,7 +232,7 @@ Get started with Bitcoin SV development in under 2 minutes:
232
232
  npm install @smartledger/bsv
233
233
 
234
234
  # Or include in HTML
235
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
235
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
236
236
  ```
237
237
 
238
238
  > **🔒 v5.0.0 (production hardening — has breaking changes):** Shamir secret
@@ -332,8 +332,8 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
332
332
 
333
333
  ### 🔧 **Basic Development** (~1.2MB total)
334
334
  ```html
335
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
336
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-script-helper.min.js"></script>
335
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
336
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js"></script>
337
337
  <script>
338
338
  const privateKey = new bsv.PrivateKey();
339
339
  const utxos = new bsv.SmartContract.UTXOGenerator().createRealUTXOs(2, 100000);
@@ -342,9 +342,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
342
342
 
343
343
  ### 🔒 **Smart Contract Development** (~2.8MB total — each bundle re-embeds core BSV)
344
344
  ```html
345
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
346
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js"></script>
347
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js"></script>
345
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
346
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
347
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
348
348
  <script>
349
349
  const covenant = bsv.SmartContract.createCovenantBuilder()
350
350
  .extractField('amount').push(50000).greaterThanOrEqual().verify().build();
@@ -354,9 +354,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
354
354
 
355
355
  ### 🆕 **Legal & Identity Development** (~3.4MB total — each bundle re-embeds core BSV)
356
356
  ```html
357
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
358
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
359
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js"></script>
357
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
358
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
359
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
360
360
  <script>
361
361
  // Legal Token Protocol
362
362
  const propertyToken = bsv.createPropertyToken({
@@ -370,9 +370,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
370
370
 
371
371
  ### 🆕 **Security & Cryptography** (~1.5MB total)
372
372
  ```html
373
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
374
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js"></script>
375
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-shamir.min.js"></script>
373
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
374
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
375
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
376
376
  <script>
377
377
  // Threshold Cryptography
378
378
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -384,7 +384,7 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
384
384
 
385
385
  ### 🎯 **Everything Bundle** (~1.1MB)
386
386
  ```html
387
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js"></script>
387
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
388
388
  <script>
389
389
  // Everything available immediately
390
390
  const shares = bsv.splitSecret('secret', 5, 3); // Shamir Secret Sharing
@@ -494,8 +494,8 @@ const contractTx = covenant.createCovenantTransaction({
494
494
 
495
495
  #### 1. **Minimal Setup** - Core + Script Helper (~1.2MB)
496
496
  ```html
497
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
498
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-script-helper.min.js"></script>
497
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
498
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js"></script>
499
499
  <script>
500
500
  const tx = new bsv.Transaction();
501
501
  const sig = bsvScriptHelper.createSignature(tx, privateKey, 0, script, satoshis);
@@ -504,9 +504,9 @@ const contractTx = covenant.createCovenantTransaction({
504
504
 
505
505
  #### 2. **DeFi Development** - Core + Covenants + Debug (~2.8MB — each bundle re-embeds core BSV)
506
506
  ```html
507
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
508
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js"></script>
509
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js"></script>
507
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
508
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
509
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
510
510
  <script>
511
511
  const covenant = new bsvCovenant.CovenantInterface();
512
512
  const debugInfo = SmartContract.interpretScript(script);
@@ -516,8 +516,8 @@ const contractTx = covenant.createCovenantTransaction({
516
516
 
517
517
  #### 3. **Security First** - Core + Enhanced Security (~1.2MB)
518
518
  ```html
519
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
520
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js"></script>
519
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
520
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
521
521
  <script>
522
522
  const verified = bsvSecurity.SmartVerify.verify(signature, hash, publicKey);
523
523
  const enhanced = bsvSecurity.EllipticFixed.createSignature(privateKey, hash);
@@ -526,7 +526,7 @@ const contractTx = covenant.createCovenantTransaction({
526
526
 
527
527
  #### 4. **Everything Bundle** - One File Solution (~1.1MB)
528
528
  ```html
529
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js"></script>
529
+ <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
530
530
  <script>
531
531
  // Everything available under bsv namespace
532
532
  const keys = bsv.SmartLedgerBundle.generateKeys();
@@ -834,7 +834,7 @@ const timelockScript = helper.createTimelockScript(
834
834
 
835
835
  See the **[16 Loading Options](#-16-loading-options---choose-your-approach)**
836
836
  table near the top for the full list of bundles with current sizes and
837
- canonical `unpkg.com/@smartledger/bsv@7.2.0/...` URLs.
837
+ canonical `unpkg.com/@smartledger/bsv@7.4.0/...` URLs.
838
838
 
839
839
  ## 🔐 Security
840
840