@smartledger/bsv 4.1.0 → 4.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 +118 -0
- package/README.md +217 -205
- package/bsv-covenant.min.js +8 -8
- package/bsv-gdaf.min.js +9 -9
- package/bsv-ltp.min.js +9 -9
- package/bsv-smartcontract.min.js +9 -9
- package/bsv.bundle.js +9 -9
- package/bsv.min.js +8 -8
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +25 -25
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/script/interpreter.js +52 -2
- package/lib/smart_contract/covenant_helpers.js +119 -0
- package/lib/smart_contract/index.js +30 -1
- package/lib/smart_contract/locks.js +101 -0
- package/lib/smart_contract/pels.js +61 -0
- package/lib/smart_contract/pushtx.js +155 -0
- package/lib/smart_contract/token.js +93 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,124 @@ 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.4.0] - 2026-06-07
|
|
9
|
+
|
|
10
|
+
### Added — BSV string opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT
|
|
11
|
+
|
|
12
|
+
- **Implemented the re-enabled BSV (Chronicle) string opcodes in the script
|
|
13
|
+
interpreter.** They were declared in the opcode map (`0xb3`/`0xb4`/`0xb5`) but
|
|
14
|
+
unimplemented — executing one returned `BAD_OPCODE`. Now they evaluate with the
|
|
15
|
+
original Satoshi semantics:
|
|
16
|
+
- `OP_LEFT (in n -- out)` — the first `n` bytes.
|
|
17
|
+
- `OP_RIGHT (in n -- out)` — the last `n` bytes (`OP_RIGHT 0` ⇒ empty, not the
|
|
18
|
+
whole string).
|
|
19
|
+
- `OP_SUBSTR (in begin size -- out)` — `in[begin : begin+size]`.
|
|
20
|
+
Out-of-range lengths clamp to the string length; negative arguments fail with
|
|
21
|
+
`SCRIPT_ERR_INVALID_NUMBER_RANGE`. New test: `test/script/string_ops.js`.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **Covenant field-extraction now uses these opcodes**, shrinking the scripts
|
|
26
|
+
further: perpetual covenant 429→**421 B**, ownership token 493→**482 B**, value
|
|
27
|
+
covenant 428→**424 B** (vs. the verbose `OP_SIZE/OP_SUB/OP_SPLIT/OP_NIP` form).
|
|
28
|
+
|
|
29
|
+
Full mocha suite 4190 → 4199 passing, 0 failing. Lint clean.
|
|
30
|
+
|
|
31
|
+
## [4.3.0] - 2026-06-07
|
|
32
|
+
|
|
33
|
+
### Changed — mainnet hardening of OP_PUSH_TX covenants
|
|
34
|
+
|
|
35
|
+
- **Canonical low-S signatures.** The OP_PUSH_TX grind now requires `s <= n/2`,
|
|
36
|
+
so the in-script signature is canonical (low-S) and non-malleable, and the
|
|
37
|
+
covenant verify path enforces `SCRIPT_VERIFY_LOW_S`. This makes the produced
|
|
38
|
+
spends standard for mainnet relay/mining. Cost: zero extra script bytes — the
|
|
39
|
+
constraint is satisfied by the spender's grind, not by added opcodes.
|
|
40
|
+
(`SmartContract.PushTx.sFromPreimage`, `CovenantHelpers.flags`.)
|
|
41
|
+
- **Smaller scripts (−22 bytes per covenant).** `pushTxCore` now shares a single
|
|
42
|
+
`Gx` push between the DER signature's r-value and the `02||Gx` public key
|
|
43
|
+
(parked on the alt-stack) instead of embedding the 32-byte constant twice.
|
|
44
|
+
Authenticator 404→382 B, value covenant 450→428 B, perpetual 451→429 B,
|
|
45
|
+
ownership token 515→493 B.
|
|
46
|
+
|
|
47
|
+
### Notes
|
|
48
|
+
|
|
49
|
+
- The remaining ~382-byte floor is intrinsic to OP_PUSH_TX on BSV: ~248 B is the
|
|
50
|
+
two mandatory 32-byte endianness reversals (big-endian hash ↔ little-endian
|
|
51
|
+
script arithmetic ↔ big-endian DER), the rest is fixed secp256k1 constants and
|
|
52
|
+
the DER template. There is no single-opcode byte reverse on BSV —
|
|
53
|
+
`OP_REVERSEBYTES` is a Bitcoin Cash opcode, not part of the BSV opcode set, so
|
|
54
|
+
the `OP_SPLIT`/`OP_SWAP`/`OP_CAT` reversal gadget is the correct approach.
|
|
55
|
+
- New test: `test/smart_contract/covenants.js` proves the grind yields low-S
|
|
56
|
+
signatures enforced under `SCRIPT_VERIFY_LOW_S`. Full suite 4189 → 4190.
|
|
57
|
+
|
|
58
|
+
## [4.2.1] - 2026-06-07
|
|
59
|
+
|
|
60
|
+
### Docs
|
|
61
|
+
|
|
62
|
+
- **Substantial README rewrite for the v4.x line.** The README still
|
|
63
|
+
headlined v3.4.x (4 minors and a major stale), showed the *old*
|
|
64
|
+
`lib/covenant-interface` API in the covenant examples instead of the
|
|
65
|
+
v4.2.0 `bsv.SmartContract.PushTx`/`PELS`/`Token`/`Locks`/`verifyScript`
|
|
66
|
+
surface, had a wrong CDN-Bundles size table (off by up to 7× on
|
|
67
|
+
`bsv-mnemonic`), duplicate "Complete Documentation" sections, a
|
|
68
|
+
"planned 3.5.0" security note that was overtaken by 4.0.0, and a
|
|
69
|
+
footer stamp claiming "v3.3.4 • 9 Loading Options". Replaced the
|
|
70
|
+
headline with the v4.2.0 covenant section, rewrote PUSHTX/PELS
|
|
71
|
+
examples to use the new API, added Ownership Tokens + end-to-end
|
|
72
|
+
verification snippets, merged the two Documentation sections (7
|
|
73
|
+
broken file paths fixed, 4 dead links removed), replaced the
|
|
74
|
+
inaccurate CDN sub-table with a pointer to the canonical
|
|
75
|
+
loading-options table, updated Security to point at the v4.0.0 GDAF
|
|
76
|
+
fix, and stamped the footer at v4.2.1.
|
|
77
|
+
|
|
78
|
+
### Semver
|
|
79
|
+
|
|
80
|
+
Patch — README only. No source changes; no `lib/`, `bin/`, `bsv.d.ts`,
|
|
81
|
+
or test diffs. Out-of-band republish: `@smartledger/bsv@4.2.0` was
|
|
82
|
+
published from a separate session with the OLD README, then
|
|
83
|
+
unpublished after the rewrite. npm's anti-republish policy refuses to
|
|
84
|
+
reuse the 4.2.0 version number; 4.2.1 is the canonical version with
|
|
85
|
+
the corrected README content. `smartledger-bsv@4.2.0` (unscoped) was
|
|
86
|
+
published with the new README; for parity, the unscoped is also
|
|
87
|
+
republished at 4.2.1.
|
|
88
|
+
|
|
89
|
+
## [4.2.0] - 2026-06-07
|
|
90
|
+
|
|
91
|
+
### Added
|
|
92
|
+
|
|
93
|
+
- **First-class, interpreter-verified covenants under `bsv.SmartContract`.**
|
|
94
|
+
A complete, tested stack of custom locking scripts that verify end-to-end
|
|
95
|
+
through `Script.Interpreter` (positive and negative cases), building on the
|
|
96
|
+
post-Genesis limits from 4.1.0:
|
|
97
|
+
- **`SmartContract.PushTx`** — a *correct* OP_PUSH_TX (nChain WP1605). The
|
|
98
|
+
locking script generates an ECDSA signature in-script from the pushed
|
|
99
|
+
preimage (`a=k=1`, `r=Gx`, `s=(e+Gx) mod n`, pubkey `02||Gx`) and verifies
|
|
100
|
+
it with `OP_CHECKSIG`, proving the preimage is this very transaction. Uses a
|
|
101
|
+
fixed-length DER template with an `nLockTime` grind (`PushTx.grind`). Exposes
|
|
102
|
+
`authenticator()`, `valueCovenant()`, `hashOutputs()`, `extractHashOutputs()`.
|
|
103
|
+
- **`SmartContract.PELS` / `perpetualCovenant(fee)`** — a Perpetually Enforcing
|
|
104
|
+
Locking Script: every spend must recreate the same script (value − fee).
|
|
105
|
+
Reads its own script from the authenticated preimage's `scriptCode`, so there
|
|
106
|
+
is no self-hash circularity.
|
|
107
|
+
- **`SmartContract.Token` / `ownershipToken(fee, ownerHash)`** — a stateful
|
|
108
|
+
ownership token (NFT) carrying its owner as on-chain state; transfer requires
|
|
109
|
+
the owner's secret and rewrites the state, perpetuating the token code.
|
|
110
|
+
- **`SmartContract.Locks`** — hash-lock, P2PKH, CLTV time-lock, m-of-n
|
|
111
|
+
multisig, and HTLC primitives.
|
|
112
|
+
- **`SmartContract.CovenantHelpers`** + convenience methods
|
|
113
|
+
`enableGenesis()`, `verifyScript()`, `valueCovenant()` — a consensus-flag
|
|
114
|
+
`verify()` harness, raw BIP-143 preimage access, signing, and fund/spend
|
|
115
|
+
scaffolding.
|
|
116
|
+
- New mocha suite `test/smart_contract/covenants.js` (11 specs / 24 assertions),
|
|
117
|
+
all green; full suite 4178 → 4189 passing.
|
|
118
|
+
|
|
119
|
+
### Notes
|
|
120
|
+
|
|
121
|
+
- These covenants require post-Genesis limits: call `SmartContract.enableGenesis()`
|
|
122
|
+
(a.k.a `Interpreter.useGenesisLimits()`) before verifying. Research-grade and
|
|
123
|
+
interpreter-verified — review before mainnet value (the OP_PUSH_TX key is the
|
|
124
|
+
intentionally public `a=k=1`; low-S malleability is left unenforced).
|
|
125
|
+
|
|
8
126
|
## [4.1.0] - 2026-06-07
|
|
9
127
|
|
|
10
128
|
### Added
|