@smartledger/bsv 7.8.1 → 7.9.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.
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
55
55
  - **Purpose**: Threshold cryptography for secure secret distribution
56
56
  - **Use Cases**: Backup keys, multi-party security, key recovery
57
57
  - **Features**: Split secrets into N shares, require M to reconstruct
58
- - **CDN**: `unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.9.0/bsv-shamir.min.js`
59
59
 
60
60
  #### **🌐 Global Digital Attestation Framework - GDAF (1184KB)**
61
61
  - **Purpose**: W3C Verifiable Credentials and decentralized identity
62
62
  - **Use Cases**: Identity verification, attestations, zero-knowledge proofs
63
63
  - **Features**: DID creation, credential issuance, selective disclosure
64
- - **CDN**: `unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js`
65
65
 
66
66
  #### **⚖️ Legal Token Protocol - LTP (1184KB)**
67
67
  - **Purpose**: Legal compliance framework for tokenized assets
68
68
  - **Use Cases**: Property rights, obligations, compliant tokenization
69
69
  - **Features**: Legal primitives, compliance checking, attestation anchoring
70
- - **CDN**: `unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js`
71
71
 
72
72
  ### **2. Incorrect File Sizes in Documentation**
73
73
 
@@ -81,18 +81,18 @@ Three advanced modules totaling **~2.7MB** of functionality:
81
81
 
82
82
  | Module | Size | Use Case | CDN Link |
83
83
  |--------|------|----------|----------|
84
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.8.1/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.8.1/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.8.1/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.9.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.9.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.9.0/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.9.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.9.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.9.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.9.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.9.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js` |
96
96
 
97
97
  ## 🎯 **Updated Usage Examples**
98
98
 
@@ -100,22 +100,22 @@ Three advanced modules totaling **~2.7MB** of functionality:
100
100
 
101
101
  #### **1. Basic Development (~963KB)**
102
102
  ```html
103
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-script-helper.min.js"></script>
105
105
  ```
106
106
 
107
107
  #### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
108
108
  ```html
109
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-smartcontract.min.js"></script>
112
112
  ```
113
113
 
114
114
  #### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
115
115
  ```html
116
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js"></script>
119
119
  <script>
120
120
  // Legal Token Protocol
121
121
  const legalToken = bsv.createLegalToken({
@@ -132,9 +132,9 @@ Three advanced modules totaling **~2.7MB** of functionality:
132
132
 
133
133
  #### **4. 🆕 Security & Cryptography (~1.4MB)**
134
134
  ```html
135
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-shamir.min.js"></script>
138
138
  <script>
139
139
  // Shamir Secret Sharing
140
140
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -146,7 +146,7 @@ Three advanced modules totaling **~2.7MB** of functionality:
146
146
 
147
147
  #### **5. Everything Bundle (937KB)**
148
148
  ```html
149
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js"></script>
150
150
  <script>
151
151
  // Everything available immediately
152
152
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -722,7 +722,7 @@ interface UTXO {
722
722
  <html>
723
723
  <head>
724
724
  <title>UTXO Manager Demo</title>
725
- <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.8.1/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.9.0/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
48
48
  #### **Core Library Only (937KB)**
49
49
  For basic Bitcoin SV operations:
50
50
  ```html
51
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
52
52
  <script>
53
53
  const privateKey = new bsv.PrivateKey();
54
54
  const address = privateKey.toAddress();
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
58
58
  #### **Complete Bundle (937KB)**
59
59
  Everything in one file:
60
60
  ```html
61
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js"></script>
62
62
  <script>
63
63
  // All features available immediately
64
64
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -71,9 +71,9 @@ Everything in one file:
71
71
 
72
72
  #### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
73
73
  ```html
74
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-smartcontract.min.js"></script>
77
77
  <script>
78
78
  const covenant = bsv.SmartContract.createCovenantBuilder()
79
79
  .extractField('amount').push(50000).greaterThanOrEqual().build();
@@ -82,9 +82,9 @@ Everything in one file:
82
82
 
83
83
  #### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
84
84
  ```html
85
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js"></script>
88
88
  <script>
89
89
  // Legal Token Protocol
90
90
  const propertyToken = bsv.createPropertyToken({
@@ -98,9 +98,9 @@ Everything in one file:
98
98
 
99
99
  #### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
100
100
  ```html
101
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-shamir.min.js"></script>
104
104
  <script>
105
105
  // Threshold Cryptography
106
106
  const shares = bsv.splitSecret('my_secret_key', 5, 3);
@@ -114,18 +114,18 @@ Everything in one file:
114
114
 
115
115
  | Module | Size | Purpose | CDN Link |
116
116
  |--------|------|---------|----------|
117
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.8.1/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.8.1/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.8.1/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.9.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.9.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.9.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.9.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.9.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.9.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.9.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.9.0/bsv-message.min.js` |
129
129
 
130
130
  ## ⚙️ **Development Environment Setup**
131
131
 
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
14
14
  ### Browser CDN (Instant)
15
15
  ```html
16
16
  <!-- Core library (937KB) -->
17
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js"></script>
21
21
  ```
22
22
 
23
23
  ## 💰 **Your First Transaction (60 seconds)**
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
127
127
 
128
128
  ```html
129
129
  <!-- Core BSV only (937KB) -->
130
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js"></script>
143
143
  ```
144
144
 
145
145
  ## ⚡ **Key Advantages**
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
159
159
  ### **New Modular Options**
160
160
  ```html
161
161
  <!-- Core compatibility (same size as bsv@1.5.6) -->
162
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.9.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -728,6 +728,13 @@ function padBufferToSize (buf, len) {
728
728
  * Based on the inner loop of bitcoind's EvalScript function
729
729
  * bitcoind commit: b5d1b1092998bc95313856d535c632ea5a8f9104
730
730
  */
731
+ /** The transaction version as the four little-endian bytes Chronicle compares. */
732
+ function versionLE (version) {
733
+ var buf = Buffer.alloc(4)
734
+ buf.writeInt32LE(version | 0, 0)
735
+ return buf
736
+ }
737
+
731
738
  Interpreter.prototype.step = function () {
732
739
  var self = this
733
740
 
@@ -1044,7 +1051,19 @@ Interpreter.prototype.step = function () {
1044
1051
  break
1045
1052
 
1046
1053
  case Opcode.OP_VER:
1047
- // Chronicle: pushes the executing transaction's version.
1054
+ // Chronicle: pushes the transaction version as FOUR LITTLE-ENDIAN
1055
+ // BYTES, not as a script number. The node is:
1056
+ //
1057
+ // const auto tx_version{checker.Version()};
1058
+ // std::vector<uint8_t> val(sizeof(tx_version));
1059
+ // to_le(tx_version, val.data());
1060
+ // stack.push_back(std::move(val));
1061
+ //
1062
+ // A script number pushes `01` for version 1 where the node pushes
1063
+ // `01000000`, so anything consuming the value diverges.
1064
+ //
1065
+ // Unlike the string opcodes, BAD_OPCODE pre-Chronicle IS correct here —
1066
+ // the node returns it unconditionally.
1048
1067
  if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
1049
1068
  this.errstr = 'SCRIPT_ERR_BAD_OPCODE'
1050
1069
  return false
@@ -1053,18 +1072,26 @@ Interpreter.prototype.step = function () {
1053
1072
  this.errstr = 'SCRIPT_ERR_UNKNOWN_ERROR'
1054
1073
  return false
1055
1074
  }
1056
- this.stack.push(new BN(this.tx.version).toScriptNumBuffer())
1075
+ this.stack.push(versionLE(this.tx.version))
1057
1076
  break
1058
1077
 
1059
1078
  case Opcode.OP_VERIF:
1060
1079
  case Opcode.OP_VERNOTIF:
1061
- // Chronicle: an IF whose condition is "top of stack equals the executing
1062
- // transaction's version", closed by OP_ENDIF.
1080
+ // Chronicle: an IF whose condition is "top of stack equals the
1081
+ // transaction version", closed by OP_ENDIF.
1063
1082
  //
1064
- // Before Chronicle these are invalid EVEN IN AN UNEXECUTED BRANCH — a rule
1065
- // Bitcoin applies to no other opcode — so the flag check deliberately sits
1066
- // OUTSIDE the fExec guard below, which preserves that.
1083
+ // if(!utxo_after_chronicle) {
1084
+ // if(utxo_after_genesis && !fExec) break;
1085
+ // else return SCRIPT_ERR_BAD_OPCODE;
1086
+ // }
1087
+ //
1088
+ // So pre-Chronicle they are an error only in an EXECUTED branch. BSV is
1089
+ // post-Genesis, which is the whole condition. Returning BAD_OPCODE
1090
+ // unconditionally rejected scripts the network accepts.
1067
1091
  if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
1092
+ if (!fExec) {
1093
+ break
1094
+ }
1068
1095
  this.errstr = 'SCRIPT_ERR_BAD_OPCODE'
1069
1096
  return false
1070
1097
  }
@@ -1078,12 +1105,16 @@ Interpreter.prototype.step = function () {
1078
1105
  this.errstr = 'SCRIPT_ERR_UNKNOWN_ERROR'
1079
1106
  return false
1080
1107
  }
1081
- // Popping mirrors OP_IF. The spec describes the comparison but not the
1082
- // stack effect; the OP_VERIF ... OP_ENDIF form it documents is an IF, and
1083
- // an IF that left its condition behind would unbalance every script using
1084
- // it. Pinned by its own test so a correction shows up as a diff.
1085
- bn = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal)
1086
- fValue = bn.cmp(new BN(this.tx.version)) === 0
1108
+ // BYTE-WISE against the 4-byte little-endian version, not a numeric
1109
+ // compare. An operand of any other length simply yields false — it is
1110
+ // NOT an error — so `OP_2 OP_VERIF` against version 2 is false, where
1111
+ // a numeric comparison made it true. The idiomatic form is
1112
+ // `OP_VER OP_VERIF`.
1113
+ //
1114
+ // MINIMALIF deliberately does not apply: the node guards it with
1115
+ // `(opcode == OP_IF || opcode == OP_NOTIF) && VerifyMinimalIf(flags)`.
1116
+ buf = stacktop(-1)
1117
+ fValue = buf.length === 4 && buf.equals(versionLE(this.tx.version))
1087
1118
  if (opcodenum === Opcode.OP_VERNOTIF) {
1088
1119
  fValue = !fValue
1089
1120
  }
@@ -1953,21 +1984,39 @@ Interpreter.prototype.step = function () {
1953
1984
 
1954
1985
  case Opcode.OP_LEFT:
1955
1986
  case Opcode.OP_RIGHT:
1956
- // (in size -- out) OP_LEFT keeps the first `size` bytes; OP_RIGHT the last.
1957
- // Re-enabled string opcodes (BSV Chronicle). Original Satoshi semantics.
1987
+ // (in size -- out) Chronicle, ported from SV Node.
1988
+ // Pre-Chronicle these bytes are UPGRADABLE NOPS on the network — they were
1989
+ // OP_NOP4/OP_NOP5/OP_NOP6 — so the node breaks rather than erroring:
1990
+ //
1991
+ // if(!utxo_after_chronicle) {
1992
+ // if(flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)
1993
+ // return SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS;
1994
+ // else break;
1995
+ // }
1996
+ //
1997
+ // Running them unconditionally consumed stack where the network does
1998
+ // nothing, which is a wrong answer rather than an error.
1999
+ if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
2000
+ if (this.flags & Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
2001
+ this.errstr = 'SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS'
2002
+ return false
2003
+ }
2004
+ break
2005
+ }
2006
+
1958
2007
  if (this.stack.length < 2) {
1959
2008
  this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'
1960
2009
  return false
1961
2010
  }
1962
2011
  buf1 = stacktop(-2)
1963
- n = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal).toNumber()
1964
- if (n < 0) {
2012
+ n = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal, Interpreter.MAXIMUM_ELEMENT_SIZE).toNumber()
2013
+ // ERRORS on out of range; it does not clamp. The node is
2014
+ // `if(len < 0 || len > size) return SCRIPT_ERR_INVALID_NUMBER_RANGE`.
2015
+ // Clamping made scripts the node rejects succeed here.
2016
+ if (n < 0 || n > buf1.length) {
1965
2017
  this.errstr = 'SCRIPT_ERR_INVALID_NUMBER_RANGE'
1966
2018
  return false
1967
2019
  }
1968
- if (n > buf1.length) {
1969
- n = buf1.length
1970
- }
1971
2020
  this.stack.pop()
1972
2021
  if (opcodenum === Opcode.OP_LEFT) {
1973
2022
  this.stack[this.stack.length - 1] = Buffer.from(buf1).slice(0, n)
@@ -1977,25 +2026,41 @@ Interpreter.prototype.step = function () {
1977
2026
  break
1978
2027
 
1979
2028
  case Opcode.OP_SUBSTR:
1980
- // (in begin size -- out) out = in[begin : begin + size]
1981
- // Re-enabled string opcode (BSV Chronicle). Original Satoshi semantics.
2029
+ // (in begin size -- out) Chronicle, ported from SV Node.
2030
+ // Pre-Chronicle these bytes are UPGRADABLE NOPS on the network — they were
2031
+ // OP_NOP4/OP_NOP5/OP_NOP6 — so the node breaks rather than erroring:
2032
+ //
2033
+ // if(!utxo_after_chronicle) {
2034
+ // if(flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)
2035
+ // return SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS;
2036
+ // else break;
2037
+ // }
2038
+ //
2039
+ // Running them unconditionally consumed stack where the network does
2040
+ // nothing, which is a wrong answer rather than an error.
2041
+ if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
2042
+ if (this.flags & Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
2043
+ this.errstr = 'SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS'
2044
+ return false
2045
+ }
2046
+ break
2047
+ }
2048
+
1982
2049
  if (this.stack.length < 3) {
1983
2050
  this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'
1984
2051
  return false
1985
2052
  }
1986
2053
  buf1 = stacktop(-3)
1987
- var subSize = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal).toNumber()
1988
- var subBegin = BN.fromScriptNumBuffer(stacktop(-2), fRequireMinimal).toNumber()
1989
- if (subBegin < 0 || subSize < 0) {
2054
+ var subSize = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal, Interpreter.MAXIMUM_ELEMENT_SIZE).toNumber()
2055
+ var subBegin = BN.fromScriptNumBuffer(stacktop(-2), fRequireMinimal, Interpreter.MAXIMUM_ELEMENT_SIZE).toNumber()
2056
+ // ERRORS on out of range, matching
2057
+ // offset < 0 || offset >= size || len < 0 || len > size - offset
2058
+ // Note `offset >= size` is strict: a begin index AT the end is an
2059
+ // error, not an empty result.
2060
+ if (subBegin < 0 || subBegin >= buf1.length || subSize < 0 || subSize > buf1.length - subBegin) {
1990
2061
  this.errstr = 'SCRIPT_ERR_INVALID_NUMBER_RANGE'
1991
2062
  return false
1992
2063
  }
1993
- if (subBegin > buf1.length) {
1994
- subBegin = buf1.length
1995
- }
1996
- if (subBegin + subSize > buf1.length) {
1997
- subSize = buf1.length - subBegin
1998
- }
1999
2064
  this.stack.pop()
2000
2065
  this.stack.pop()
2001
2066
  this.stack[this.stack.length - 1] = Buffer.from(buf1).slice(subBegin, subBegin + subSize)
@@ -33,7 +33,18 @@ function flags () {
33
33
  I.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY |
34
34
  I.SCRIPT_ENABLE_SIGHASH_FORKID |
35
35
  I.SCRIPT_ENABLE_MAGNETIC_OPCODES |
36
- I.SCRIPT_ENABLE_MONOLITH_OPCODES
36
+ I.SCRIPT_ENABLE_MONOLITH_OPCODES |
37
+ // REQUIRED, not optional. pushTxCore emits OP_RIGHT/OP_LEFT — see
38
+ // extractHashOutputs and assertSighashType — and those bytes (180/181) are
39
+ // upgradable NOPs on the network until Chronicle activates. Without this
40
+ // flag the interpreter treats them as no-ops, exactly as a pre-Chronicle
41
+ // node does, and the covenant does not verify.
42
+ //
43
+ // Stated plainly: OP_PUSH_TX covenants built by this library DEPEND on
44
+ // Chronicle and cannot be spent on a pre-Chronicle chain. That was
45
+ // previously invisible because the interpreter ran the string opcodes
46
+ // unconditionally — more permissively than the network.
47
+ I.SCRIPT_ENABLE_CHRONICLE
37
48
  }
38
49
 
39
50
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "7.8.1",
3
+ "version": "7.9.0",
4
4
  "description": "🚀 Complete Bitcoin SV development framework with legally-recognizable DID:web + W3C VC-JWT toolkit, Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), StatusList2021 revocation, and 16 flexible loading options. Standards-based credentials with ES256/ES256K support, on-chain BSV anchoring, and comprehensive Bitcoin SV API. Perfect for legal tokens, verifiable credentials, DeFi, smart contracts, and secure Bitcoin applications.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
@@ -114,32 +114,75 @@ describe('Chronicle script surface', function () {
114
114
  })
115
115
 
116
116
  describe('OP_VERIF / OP_VERNOTIF', function () {
117
- it('are BAD_OPCODE without the flag EVEN IN AN UNEXECUTED BRANCH', function () {
118
- // A rule Bitcoin applies to no other opcode, which is why the flag check sits
119
- // outside the fExec guard. If it moved inside, this script would pass.
120
- var r = run(function (s) {
117
+ it('without the flag, errors only in an EXECUTED branch', function () {
118
+ // Core treats OP_VERIF as illegal everywhere, including unexecuted
119
+ // branches — a rule it applies to no other opcode. BSV dropped that at
120
+ // Genesis, and the node is explicit:
121
+ //
122
+ // if(!utxo_after_chronicle) {
123
+ // if(utxo_after_genesis && !fExec) break;
124
+ // else return SCRIPT_ERR_BAD_OPCODE;
125
+ // }
126
+ //
127
+ // Asserting BAD_OPCODE here made this library reject scripts the network
128
+ // accepts.
129
+ var unexecuted = run(function (s) {
121
130
  s.add(Opcode.OP_0).add(Opcode.OP_IF).add(Opcode.OP_VERIF).add(Opcode.OP_ENDIF).add(Opcode.OP_1)
122
131
  }, { flags: 0 })
123
- r.verified.should.equal(false)
124
- r.errstr.should.match(/BAD_OPCODE/)
132
+ unexecuted.verified.should.equal(true)
133
+
134
+ var executed = run(function (s) {
135
+ s.add(Opcode.OP_1).add(Opcode.OP_VERIF).add(Opcode.OP_ENDIF)
136
+ }, { flags: 0 })
137
+ executed.verified.should.equal(false)
138
+ executed.errstr.should.match(/BAD_OPCODE/)
125
139
  })
126
140
 
127
- it('OP_VERIF takes the branch when the top of stack equals the tx version', function () {
141
+ // The comparison is BYTE-WISE against the four little-endian version
142
+ // bytes, not numeric:
143
+ //
144
+ // if(vch.size() == 4) { to_le(checker.Version(), val.data());
145
+ // fValue = std::ranges::equal(val, vch); }
146
+ //
147
+ // So a 1-byte script number never matches, however equal it looks
148
+ // numerically, and the idiomatic form is `OP_VER OP_VERIF`.
149
+ var LE = function (v) {
150
+ var b = Buffer.alloc(4)
151
+ b.writeInt32LE(v, 0)
152
+ return b
153
+ }
154
+
155
+ it('OP_VERIF takes the branch on a 4-byte little-endian version match', function () {
128
156
  var taken = run(function (s) {
129
- s.add(new BN(2).toScriptNumBuffer()).add(Opcode.OP_VERIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF)
157
+ s.add(LE(2)).add(Opcode.OP_VERIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF)
130
158
  }, { version: 2 })
131
159
  taken.verified.should.equal(true)
132
160
 
133
161
  var notTaken = run(function (s) {
134
- s.add(new BN(9).toScriptNumBuffer()).add(Opcode.OP_VERIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF).add(Opcode.OP_1)
162
+ s.add(LE(9)).add(Opcode.OP_VERIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF).add(Opcode.OP_1)
135
163
  }, { version: 2 })
136
164
  notTaken.verified.should.equal(true)
137
165
  notTaken.stack.length.should.equal(1) // only the trailing OP_1
138
166
  })
139
167
 
168
+ it('a numerically-equal operand of the wrong LENGTH does not match', function () {
169
+ var r = run(function (s) {
170
+ s.add(new BN(2).toScriptNumBuffer()).add(Opcode.OP_VERIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF).add(Opcode.OP_1)
171
+ }, { version: 2 })
172
+ r.verified.should.equal(true)
173
+ r.stack.length.should.equal(1) // branch NOT taken
174
+ })
175
+
176
+ it('OP_VER feeds OP_VERIF directly', function () {
177
+ var r = run(function (s) {
178
+ s.add(Opcode.OP_VER).add(Opcode.OP_VERIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF)
179
+ }, { version: 2 })
180
+ r.verified.should.equal(true)
181
+ })
182
+
140
183
  it('OP_VERNOTIF is its negation', function () {
141
184
  var r = run(function (s) {
142
- s.add(new BN(9).toScriptNumBuffer()).add(Opcode.OP_VERNOTIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF)
185
+ s.add(LE(9)).add(Opcode.OP_VERNOTIF).add(Opcode.OP_1).add(Opcode.OP_ENDIF)
143
186
  }, { version: 2 })
144
187
  r.verified.should.equal(true)
145
188
  })
@@ -649,6 +649,14 @@ describe('Interpreter', function () {
649
649
  // (0xba is no longer a NOP either; it is unassigned, which now AGREES with
650
650
  // Core, so its former override has been removed.)
651
651
  var BSV_DIVERGENCES = {
652
+ // - OP_VERIF/OP_VERNOTIF are "illegal everywhere" in Core, including in an
653
+ // unexecuted branch — a rule it applies to no other opcode. BSV dropped
654
+ // that at Genesis: the node breaks when the branch is not executed and
655
+ // the UTXO predates Chronicle. So these four verify here.
656
+ '0|IF VERIF ELSE 1 ENDIF|P2SH,STRICTENC': 'OK',
657
+ '0|IF ELSE 1 ELSE VERIF ENDIF|P2SH,STRICTENC': 'OK',
658
+ '0|IF VERNOTIF ELSE 1 ENDIF|P2SH,STRICTENC': 'OK',
659
+ '0|IF ELSE 1 ELSE VERNOTIF ENDIF|P2SH,STRICTENC': 'OK',
652
660
  "'a' 'b'|CAT|P2SH,STRICTENC": 'OK',
653
661
  "'a' 'b' 0|IF CAT ELSE 1 ENDIF|P2SH,STRICTENC": 'OK',
654
662
  "'abc' 1|SPLIT|P2SH,STRICTENC": 'OK',
@@ -661,15 +669,10 @@ describe('Interpreter', function () {
661
669
  '2 2 0 IF DIV ELSE 1 ENDIF|NOP|P2SH,STRICTENC': 'OK',
662
670
  '2 2 0 IF MOD ELSE 1 ENDIF|NOP|P2SH,STRICTENC': 'OK',
663
671
  '2 DUP DIV|1 EQUAL|P2SH,STRICTENC': 'OK',
664
- '7 3 MOD|1 EQUAL|P2SH,STRICTENC': 'OK',
672
+ '7 3 MOD|1 EQUAL|P2SH,STRICTENC': 'OK'
665
673
 
666
674
  // Chronicle byte reassignment (see the note above). Values are the BSV error,
667
675
  // recorded for documentation; the harness only distinguishes 'OK' from not-'OK'.
668
- '1|NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION',
669
- "'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10|'NOP_1_to_10' EQUAL|P2SH,STRICTENC": 'SCRIPT_ERR_INVALID_STACK_OPERATION',
670
- 'NOP|NOP4 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION',
671
- 'NOP|NOP5 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION',
672
- 'NOP|NOP6 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION'
673
676
  }
674
677
 
675
678
  describe('bitcoind script evaluation fixtures', function () {