@smartledger/bsv 7.4.0 → 7.5.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.4.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.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.4.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.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.5.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.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.4.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -223,15 +223,23 @@ Interpreter.MAXIMUM_ELEMENT_SIZE = 4
223
223
  // number) so applications can opt into post-Genesis rules — e.g. OP_PUSH_TX
224
224
  // covenants, which need a few hundred opcodes — without forking the interpreter.
225
225
  Interpreter.MAX_OPS_PER_SCRIPT = 201
226
+ // Maximum total serialized script size. Pre-Genesis consensus is 10,000 bytes;
227
+ // post-Genesis BSV removed this limit too. It was previously a literal inside
228
+ // evaluate(), so `useGenesisLimits()` could not lift it and any script over 10 KB —
229
+ // a large 1Sat Ordinals inscription, for instance — failed SCRIPT_ERR_SCRIPT_SIZE
230
+ // no matter what the caller asked for.
231
+ Interpreter.MAX_SCRIPT_SIZE = 10000
226
232
 
227
233
  Interpreter.LOCKTIME_THRESHOLD = 500000000
228
234
  Interpreter.LOCKTIME_THRESHOLD_BN = new BN(Interpreter.LOCKTIME_THRESHOLD)
229
235
 
230
236
  /**
231
237
  * Opt into post-Genesis BSV consensus limits: effectively no caps on stack
232
- * element size, script-number width, or opcode count. Pre-Genesis defaults
233
- * (520 / 4 / 201) remain the out-of-the-box behavior; call this before
234
- * verify() to run modern covenants such as OP_PUSH_TX.
238
+ * element size, script-number width, opcode count, or total script size.
239
+ * Pre-Genesis defaults (520 / 4 / 201 / 10,000) remain the out-of-the-box
240
+ * behavior; call this before verify() to run modern covenants such as
241
+ * OP_PUSH_TX, or to evaluate a script larger than 10 KB such as a sizeable
242
+ * 1Sat Ordinals inscription.
235
243
  *
236
244
  * IMPORTANT: this mutates static properties on the Interpreter constructor
237
245
  * and therefore affects EVERY subsequent `new Interpreter()` in this
@@ -245,7 +253,7 @@ Interpreter.LOCKTIME_THRESHOLD_BN = new BN(Interpreter.LOCKTIME_THRESHOLD)
245
253
  *
246
254
  * bsv.Script.Interpreter.useGenesisLimits(64 * 1024)
247
255
  *
248
- * @param {number} [max=0x7fffffff] Ceiling applied to all three caps.
256
+ * @param {number} [max=0x7fffffff] Ceiling applied to all four caps.
249
257
  * @returns {Interpreter} the Interpreter constructor (for chaining)
250
258
  */
251
259
  Interpreter.useGenesisLimits = function (max) {
@@ -253,6 +261,40 @@ Interpreter.useGenesisLimits = function (max) {
253
261
  Interpreter.MAX_SCRIPT_ELEMENT_SIZE = max
254
262
  Interpreter.MAXIMUM_ELEMENT_SIZE = max
255
263
  Interpreter.MAX_OPS_PER_SCRIPT = max
264
+ Interpreter.MAX_SCRIPT_SIZE = max
265
+ return Interpreter
266
+ }
267
+
268
+ /** The four consensus caps, as a plain object. */
269
+ Interpreter.getLimits = function () {
270
+ return {
271
+ maxScriptElementSize: Interpreter.MAX_SCRIPT_ELEMENT_SIZE,
272
+ maximumElementSize: Interpreter.MAXIMUM_ELEMENT_SIZE,
273
+ maxOpsPerScript: Interpreter.MAX_OPS_PER_SCRIPT,
274
+ maxScriptSize: Interpreter.MAX_SCRIPT_SIZE
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Restore caps captured by `getLimits()`. Because the caps are process-wide statics,
280
+ * anything that raises them must put them back or it silently changes the rules for
281
+ * unrelated code later in the same process — which is exactly how a test that opts
282
+ * into Genesis limits can make a pre-Genesis consensus fixture pass. Pair the two:
283
+ *
284
+ * var saved = Interpreter.getLimits()
285
+ * Interpreter.useGenesisLimits()
286
+ * ...
287
+ * Interpreter.setLimits(saved)
288
+ *
289
+ * @param {object} limits as returned by getLimits()
290
+ * @returns {Interpreter} the Interpreter constructor (for chaining)
291
+ */
292
+ Interpreter.setLimits = function (limits) {
293
+ limits = limits || {}
294
+ if (limits.maxScriptElementSize != null) Interpreter.MAX_SCRIPT_ELEMENT_SIZE = limits.maxScriptElementSize
295
+ if (limits.maximumElementSize != null) Interpreter.MAXIMUM_ELEMENT_SIZE = limits.maximumElementSize
296
+ if (limits.maxOpsPerScript != null) Interpreter.MAX_OPS_PER_SCRIPT = limits.maxOpsPerScript
297
+ if (limits.maxScriptSize != null) Interpreter.MAX_SCRIPT_SIZE = limits.maxScriptSize
256
298
  return Interpreter
257
299
  }
258
300
 
@@ -520,8 +562,7 @@ Interpreter._minimallyEncode = function (buf) {
520
562
  * bitcoind commit: b5d1b1092998bc95313856d535c632ea5a8f9104
521
563
  */
522
564
  Interpreter.prototype.evaluate = function () {
523
- // TODO: script size should be configurable. no magic numbers
524
- if (this.script.toBuffer().length > 10000) {
565
+ if (this.script.toBuffer().length > Interpreter.MAX_SCRIPT_SIZE) {
525
566
  this.errstr = 'SCRIPT_ERR_SCRIPT_SIZE'
526
567
  return false
527
568
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "7.4.0",
3
+ "version": "7.5.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",
@@ -222,4 +222,98 @@ describe('Ordinals inscriptions', function () {
222
222
  }).satoshis.should.equal(1)
223
223
  })
224
224
  })
225
+
226
+ // The case that motivated making the script-size cap configurable: transferring a
227
+ // large inscription. The envelope is inert, so the spend is an ordinary P2PKH — but
228
+ // the interpreter could not even load the script, because total script size was a
229
+ // hard-coded 10,000 bytes that useGenesisLimits() did not lift.
230
+ describe('transferring a large inscription', function () {
231
+ var I = bsv.Script.Interpreter
232
+ var Sighash = bsv.Transaction.Sighash
233
+ var BN = bsv.crypto.BN
234
+ var SIGHASH = bsv.crypto.Signature.SIGHASH_ALL | bsv.crypto.Signature.SIGHASH_FORKID
235
+ var FLAGS = I.SCRIPT_VERIFY_STRICTENC | I.SCRIPT_ENABLE_SIGHASH_FORKID
236
+ var saved
237
+
238
+ beforeEach(function () { saved = I.getLimits() })
239
+ afterEach(function () { I.setLimits(saved) })
240
+
241
+ // A signed transfer of a `kb`-sized inscription to a new owner.
242
+ function transfer (kb) {
243
+ var owner = bsv.PrivateKey.fromBuffer(Buffer.alloc(32, 11))
244
+ var recipient = bsv.PrivateKey.fromBuffer(Buffer.alloc(32, 22))
245
+ var lock = Ord.buildInscription({
246
+ address: owner.toAddress(),
247
+ contentType: 'image/png',
248
+ content: bsv.crypto.Random.getRandomBuffer(kb * 1024)
249
+ })
250
+ var spend = new bsv.Transaction()
251
+ spend.addInput(new bsv.Transaction.Input({
252
+ prevTxId: 'aa'.repeat(32), outputIndex: 0, script: bsv.Script.empty()
253
+ }), lock, 1)
254
+ spend.addOutput(new bsv.Transaction.Output({
255
+ script: bsv.Script.buildPublicKeyHashOut(recipient.toAddress()), satoshis: 1
256
+ }))
257
+ // Sign over the FULL previous locking script — envelope included. That is the
258
+ // script code the network uses; signing the base lock alone yields a signature
259
+ // that verifies against its own preimage and nothing else.
260
+ var sig = Sighash.sign(spend, owner, SIGHASH, 0, lock, new BN(1), FLAGS)
261
+ var unlock = new bsv.Script()
262
+ .add(Buffer.concat([sig.toDER(), Buffer.from([SIGHASH])]))
263
+ .add(owner.toPublicKey().toBuffer())
264
+ spend.inputs[0].setScript(unlock)
265
+ return { lock: lock, unlock: unlock, spend: spend, sig: sig, owner: owner }
266
+ }
267
+
268
+ function evaluate (t) {
269
+ var interp = new I()
270
+ var ok = interp.verify(t.unlock, t.lock, t.spend, 0, FLAGS, new BN(1))
271
+ return { ok: ok, err: interp.errstr }
272
+ }
273
+
274
+ it('cannot be evaluated under pre-Genesis limits — two separate caps bite', function () {
275
+ // Under 10 KB the script loads and the 520-byte push cap rejects the content...
276
+ var small = evaluate(transfer(3))
277
+ small.ok.should.equal(false)
278
+ small.err.should.equal('SCRIPT_ERR_PUSH_SIZE')
279
+ // ...over 10 KB it never gets that far: evaluate() refuses the script outright.
280
+ // This is the cap useGenesisLimits() could not lift.
281
+ var big = evaluate(transfer(50))
282
+ big.ok.should.equal(false)
283
+ big.err.should.equal('SCRIPT_ERR_SCRIPT_SIZE')
284
+ })
285
+
286
+ it('evaluates once Genesis limits are enabled', function () {
287
+ bsv.SmartContract.enableGenesis()
288
+ var t = transfer(50)
289
+ t.lock.toBuffer().length.should.be.above(10000) // past the old hard-coded cap
290
+ evaluate(t).ok.should.equal(true)
291
+ })
292
+
293
+ it('agrees with a direct signature check against the sighash', function () {
294
+ // The fallback used when the interpreter cannot run: verify the signature over
295
+ // the sighash directly. It must agree with the interpreter where both work.
296
+ bsv.SmartContract.enableGenesis()
297
+ var t = transfer(50)
298
+ var hash = Sighash.sighash(t.spend, SIGHASH, 0, t.lock, new BN(1), FLAGS)
299
+ var sigOk = bsv.crypto.ECDSA.verify(hash, t.sig, t.owner.toPublicKey(), 'little')
300
+ sigOk.should.equal(true)
301
+ evaluate(t).ok.should.equal(true)
302
+ })
303
+
304
+ it('rejects a signature made over the base lock instead of the full script', function () {
305
+ bsv.SmartContract.enableGenesis()
306
+ var t = transfer(50)
307
+ var baseLock = bsv.Script.buildPublicKeyHashOut(t.owner.toAddress())
308
+ var wrong = Sighash.sign(t.spend, t.owner, SIGHASH, 0, baseLock, new BN(1), FLAGS)
309
+ var hash = Sighash.sighash(t.spend, SIGHASH, 0, t.lock, new BN(1), FLAGS)
310
+ // Verifies against its own (wrong) preimage, but not the one the network checks.
311
+ bsv.crypto.ECDSA.verify(hash, wrong, t.owner.toPublicKey(), 'little').should.equal(false)
312
+ t.spend.inputs[0].setScript(new bsv.Script()
313
+ .add(Buffer.concat([wrong.toDER(), Buffer.from([SIGHASH])]))
314
+ .add(t.owner.toPublicKey().toBuffer()))
315
+ var interp = new I()
316
+ interp.verify(t.spend.inputs[0].script, t.lock, t.spend, 0, FLAGS, new BN(1)).should.equal(false)
317
+ })
318
+ })
225
319
  })
@@ -28,13 +28,11 @@ describe('Ordinals OrdLock marketplace', function () {
28
28
  var saved
29
29
 
30
30
  before(function () {
31
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
31
+ saved = I.getLimits()
32
32
  SC.enableGenesis()
33
33
  })
34
34
  after(function () {
35
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
36
- I.MAXIMUM_ELEMENT_SIZE = saved.num
37
- I.MAX_OPS_PER_SCRIPT = saved.ops
35
+ I.setLimits(saved)
38
36
  })
39
37
 
40
38
  var seller = PrivateKey.fromRandom()
@@ -173,13 +171,11 @@ describe('Ordinals OrdLock — multi-output payments (royalties + marketplace fe
173
171
  var I = bsv.Script.Interpreter
174
172
  var saved
175
173
  before(function () {
176
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
174
+ saved = I.getLimits()
177
175
  SC.enableGenesis()
178
176
  })
179
177
  after(function () {
180
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
181
- I.MAXIMUM_ELEMENT_SIZE = saved.num
182
- I.MAX_OPS_PER_SCRIPT = saved.ops
178
+ I.setLimits(saved)
183
179
  })
184
180
 
185
181
  var seller = PrivateKey.fromRandom()
@@ -290,13 +286,11 @@ describe('Ordinals OrdLock — buildPurchaseTx (end-to-end)', function () {
290
286
  var I = bsv.Script.Interpreter
291
287
  var saved
292
288
  before(function () {
293
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
289
+ saved = I.getLimits()
294
290
  SC.enableGenesis()
295
291
  })
296
292
  after(function () {
297
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
298
- I.MAXIMUM_ELEMENT_SIZE = saved.num
299
- I.MAX_OPS_PER_SCRIPT = saved.ops
293
+ I.setLimits(saved)
300
294
  })
301
295
 
302
296
  var seller = PrivateKey.fromRandom()
@@ -386,13 +380,11 @@ describe('Ordinals OrdLock — full lifecycle (list -> buy / cancel)', function
386
380
  var I = bsv.Script.Interpreter
387
381
  var saved
388
382
  before(function () {
389
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
383
+ saved = I.getLimits()
390
384
  SC.enableGenesis()
391
385
  })
392
386
  after(function () {
393
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
394
- I.MAXIMUM_ELEMENT_SIZE = saved.num
395
- I.MAX_OPS_PER_SCRIPT = saved.ops
387
+ I.setLimits(saved)
396
388
  })
397
389
 
398
390
  var owner = PrivateKey.fromRandom() // current ordinal owner / seller
@@ -486,13 +478,11 @@ describe('Ordinals OrdLock — code-review regressions', function () {
486
478
  var I = bsv.Script.Interpreter
487
479
  var saved
488
480
  before(function () {
489
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
481
+ saved = I.getLimits()
490
482
  SC.enableGenesis()
491
483
  })
492
484
  after(function () {
493
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
494
- I.MAXIMUM_ELEMENT_SIZE = saved.num
495
- I.MAX_OPS_PER_SCRIPT = saved.ops
485
+ I.setLimits(saved)
496
486
  })
497
487
 
498
488
  var owner = PrivateKey.fromRandom()
@@ -15,16 +15,10 @@ describe('Interpreter post-Genesis limits', function () {
15
15
  var saved
16
16
 
17
17
  beforeEach(function () {
18
- saved = {
19
- el: Interpreter.MAX_SCRIPT_ELEMENT_SIZE,
20
- num: Interpreter.MAXIMUM_ELEMENT_SIZE,
21
- ops: Interpreter.MAX_OPS_PER_SCRIPT
22
- }
18
+ saved = Interpreter.getLimits()
23
19
  })
24
20
  afterEach(function () {
25
- Interpreter.MAX_SCRIPT_ELEMENT_SIZE = saved.el
26
- Interpreter.MAXIMUM_ELEMENT_SIZE = saved.num
27
- Interpreter.MAX_OPS_PER_SCRIPT = saved.ops
21
+ Interpreter.setLimits(saved)
28
22
  })
29
23
 
30
24
  it('keeps pre-Genesis defaults out of the box', function () {
@@ -77,4 +71,46 @@ describe('Interpreter post-Genesis limits', function () {
77
71
  Interpreter.useGenesisLimits()
78
72
  run(manyOps).should.equal(true)
79
73
  })
74
+ // Total script size was a hard-coded 10,000 in evaluate(), so useGenesisLimits()
75
+ // could not lift it: any script over 10 KB failed SCRIPT_ERR_SCRIPT_SIZE regardless
76
+ // of what the caller asked for. That put every sizeable 1Sat Ordinals inscription
77
+ // out of reach of the interpreter entirely.
78
+ function scriptOfSize (bytes) {
79
+ // OP_DROP a single large push, then OP_1 — trivially true, but big.
80
+ return new Script()
81
+ .add(Buffer.alloc(bytes))
82
+ .add(Opcode.OP_DROP)
83
+ .add(Opcode.OP_1)
84
+ }
85
+
86
+ it('exposes the total script size cap as a constant, defaulting to pre-Genesis', function () {
87
+ Interpreter.MAX_SCRIPT_SIZE.should.equal(10000)
88
+ })
89
+
90
+ it('rejects a >10 KB script under default limits', function () {
91
+ Interpreter.useGenesisLimits() // lift element/ops caps so SIZE is what is under test
92
+ Interpreter.MAX_SCRIPT_SIZE = 10000 // ...but keep the pre-Genesis size cap
93
+ var interp = new Interpreter()
94
+ interp.verify(new Script(), scriptOfSize(20 * 1024)).should.equal(false)
95
+ interp.errstr.should.equal('SCRIPT_ERR_SCRIPT_SIZE')
96
+ })
97
+
98
+ it('allows a >10 KB script after useGenesisLimits()', function () {
99
+ Interpreter.useGenesisLimits()
100
+ run(scriptOfSize(20 * 1024)).should.equal(true)
101
+ })
102
+
103
+ it('useGenesisLimits raises all four caps, and getLimits/setLimits round-trip', function () {
104
+ var before = Interpreter.getLimits()
105
+ before.maxScriptSize.should.equal(10000)
106
+ Interpreter.useGenesisLimits(64 * 1024)
107
+ var after = Interpreter.getLimits()
108
+ after.maxScriptElementSize.should.equal(64 * 1024)
109
+ after.maximumElementSize.should.equal(64 * 1024)
110
+ after.maxOpsPerScript.should.equal(64 * 1024)
111
+ after.maxScriptSize.should.equal(64 * 1024)
112
+ Interpreter.setLimits(before)
113
+ Interpreter.getLimits().maxScriptSize.should.equal(10000)
114
+ Interpreter.MAX_SCRIPT_ELEMENT_SIZE.should.equal(520)
115
+ })
80
116
  })
@@ -24,13 +24,11 @@ describe('SmartContract covenants (v4.2.0)', function () {
24
24
  var saved
25
25
 
26
26
  before(function () {
27
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
27
+ saved = I.getLimits()
28
28
  SC.enableGenesis() // OP_PUSH_TX covenants need post-Genesis limits
29
29
  })
30
30
  after(function () {
31
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
32
- I.MAXIMUM_ELEMENT_SIZE = saved.num
33
- I.MAX_OPS_PER_SCRIPT = saved.ops
31
+ I.setLimits(saved)
34
32
  })
35
33
 
36
34
  var alice = PrivateKey.fromRandom()
@@ -17,13 +17,11 @@ describe('SmartContract covenant DSL + debugger (v4.5.0)', function () {
17
17
  var I = bsv.Script.Interpreter
18
18
  var saved
19
19
  before(function () {
20
- saved = { el: I.MAX_SCRIPT_ELEMENT_SIZE, num: I.MAXIMUM_ELEMENT_SIZE, ops: I.MAX_OPS_PER_SCRIPT }
20
+ saved = I.getLimits()
21
21
  SC.enableGenesis()
22
22
  })
23
23
  after(function () {
24
- I.MAX_SCRIPT_ELEMENT_SIZE = saved.el
25
- I.MAXIMUM_ELEMENT_SIZE = saved.num
26
- I.MAX_OPS_PER_SCRIPT = saved.ops
24
+ I.setLimits(saved)
27
25
  })
28
26
 
29
27
  var alice = PrivateKey.fromRandom()