@smartledger/bsv 3.4.3 → 3.4.4
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 +321 -0
- package/README.md +72 -72
- package/SECURITY.md +88 -0
- package/bin/cli.js +13 -8
- package/bsv-covenant.min.js +4 -4
- package/bsv-gdaf.min.js +5 -5
- package/bsv-ltp.min.js +7 -7
- package/bsv-smartcontract.min.js +5 -5
- package/bsv.bundle.js +5 -5
- package/bsv.d.ts +486 -9
- package/bsv.min.js +5 -5
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +60 -57
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +30 -30
- package/docs/getting-started/QUICK_START.md +14 -14
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/gdaf-entry.js +1 -2
- package/index.js +20 -7
- package/lib/smart_contract/covenant.js +10 -1
- package/lib/smartutxo.js +20 -12
- package/lib/transaction/transaction.js +7 -0
- package/ltp-entry.js +1 -2
- package/package.json +3 -3
- package/utilities/blockchain-state.js +32 -23
- package/demos/README.md +0 -188
- package/demos/architecture_demo.js +0 -247
- package/demos/browser-test.html +0 -1208
- package/demos/bsv_wallet_demo.js +0 -242
- package/demos/complete_ltp_demo.js +0 -511
- package/demos/debug_tools_demo.js +0 -87
- package/demos/demo_features.js +0 -123
- package/demos/easy_interface_demo.js +0 -109
- package/demos/ecies_demo.js +0 -182
- package/demos/gdaf_demo.js +0 -237
- package/demos/ltp_demo.js +0 -361
- package/demos/ltp_primitives_demo.js +0 -403
- package/demos/message_demo.js +0 -209
- package/demos/preimage_separation_demo.js +0 -383
- package/demos/script_helper_demo.js +0 -289
- package/demos/security_demo.js +0 -287
- package/demos/shamir_demo.js +0 -121
- package/demos/simple_demo.js +0 -204
- package/demos/simple_p2pkh_demo.js +0 -169
- package/demos/simple_utxo_preimage_demo.js +0 -196
- package/demos/smart_contract_demo.html +0 -1347
- package/demos/smart_contract_demo.js +0 -910
- package/demos/utxo_generator_demo.js +0 -244
- package/demos/validation_pipeline_demo.js +0 -155
- package/demos/web3keys.html +0 -740
- package/examples/README.md +0 -200
- package/examples/basic/transaction-creation.js +0 -534
- package/examples/basic/transaction_signature_api_gap.js +0 -178
- package/examples/complete_workflow_demo.js +0 -783
- package/examples/covenants/advanced_covenant_demo.js +0 -219
- package/examples/covenants/covenant_interface_demo.js +0 -270
- package/examples/covenants/covenant_manual_signature_resolved.js +0 -212
- package/examples/covenants/covenant_signature_template.js +0 -117
- package/examples/covenants2/covenant_bidirectional_example.js +0 -262
- package/examples/covenants2/covenant_utils_demo.js +0 -120
- package/examples/covenants2/preimage_covenant_utils.js +0 -287
- package/examples/covenants2/production_integration.js +0 -256
- package/examples/data/covenant_utxos.json +0 -28
- package/examples/data/utxos.json +0 -26
- package/examples/definitive_working_demo.js +0 -261
- package/examples/final_working_contracts.js +0 -338
- package/examples/legacy/README.md +0 -11
- package/examples/legacy/smart_contract_test_integration.js +0 -269
- package/examples/legacy/test_builtin_verify.js +0 -117
- package/examples/legacy/test_debug_integration.js +0 -71
- package/examples/legacy/test_ecdsa_little.js +0 -70
- package/examples/legacy/test_shamir.js +0 -221
- package/examples/legacy/test_smartverify_der.js +0 -110
- package/examples/preimage/README.md +0 -178
- package/examples/preimage/extract_preimage_bidirectional.js +0 -421
- package/examples/preimage/generate_sample_preimage.js +0 -208
- package/examples/preimage/generate_sighash_examples.js +0 -152
- package/examples/preimage/parse_preimage.js +0 -117
- package/examples/preimage/test_preimage_extractor.js +0 -53
- package/examples/preimage/test_varint_extraction.js +0 -95
- package/examples/scripts/custom_script_helper_example.js +0 -273
- package/examples/scripts/script_interpreter.js +0 -193
- package/examples/smart_contract/complete_workflow_demo.js +0 -343
- package/examples/smart_contract/covenant_builder_demo.js +0 -176
- package/examples/smart_contract/script_testing_integration.js +0 -198
- package/examples/smart_contract_templates.js +0 -718
- package/examples/working_smart_contracts.js +0 -348
|
@@ -136,9 +136,9 @@ node custom_script_signature_test.js
|
|
|
136
136
|
## 📦 Installation
|
|
137
137
|
|
|
138
138
|
```bash
|
|
139
|
-
npm install smartledger-bsv@3.
|
|
139
|
+
npm install smartledger-bsv@3.4.0
|
|
140
140
|
# or
|
|
141
|
-
npm install @smartledger/bsv@3.
|
|
141
|
+
npm install @smartledger/bsv@3.4.4
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
## ✅ Verification Results
|
|
@@ -15,16 +15,16 @@ Based on actual library analysis, SmartLedger-BSV provides **12 distinct modules
|
|
|
15
15
|
|
|
16
16
|
| Module | File | Size | Purpose | Status in Docs |
|
|
17
17
|
|--------|------|------|---------|----------------|
|
|
18
|
-
| **bsv.min.js** | Core BSV + SmartContract |
|
|
19
|
-
| **bsv.bundle.js** | Everything in one |
|
|
18
|
+
| **bsv.min.js** | Core BSV + SmartContract | 937KB | Complete BSV development | ✅ Documented |
|
|
19
|
+
| **bsv.bundle.js** | Everything in one | 937KB | All features included | ✅ Documented |
|
|
20
20
|
|
|
21
21
|
### **Specialized Modules**
|
|
22
22
|
|
|
23
23
|
| Module | File | Size | Purpose | Status in Docs |
|
|
24
24
|
|--------|------|------|---------|----------------|
|
|
25
|
-
| **bsv-smartcontract.min.js** | SmartContract framework |
|
|
26
|
-
| **bsv-covenant.min.js** | Covenant interface |
|
|
27
|
-
| **bsv-script-helper.min.js** | Custom script tools |
|
|
25
|
+
| **bsv-smartcontract.min.js** | SmartContract framework | 937KB | Covenant development | ✅ Documented |
|
|
26
|
+
| **bsv-covenant.min.js** | Covenant interface | 913KB | Covenant operations | ✅ Documented |
|
|
27
|
+
| **bsv-script-helper.min.js** | Custom script tools | 26KB | Script development | ✅ Documented |
|
|
28
28
|
| **bsv-security.min.js** | Security enhancements (opt-in helpers) | 26KB | `SmartVerify` / `EllipticFixed` | ✅ Documented |
|
|
29
29
|
|
|
30
30
|
### **Utility Modules**
|
|
@@ -33,15 +33,15 @@ Based on actual library analysis, SmartLedger-BSV provides **12 distinct modules
|
|
|
33
33
|
|--------|------|------|---------|----------------|
|
|
34
34
|
| **bsv-ecies.min.js** | ECIES encryption | 71KB | Message encryption | ✅ Documented |
|
|
35
35
|
| **bsv-message.min.js** | Message signing | 26KB | Message operations | ✅ Documented |
|
|
36
|
-
| **bsv-mnemonic.min.js** | HD wallet support |
|
|
36
|
+
| **bsv-mnemonic.min.js** | HD wallet support | 681KB | Mnemonic operations | ✅ Documented |
|
|
37
37
|
|
|
38
38
|
### **🆕 Advanced Modules (Missing from Documentation!)**
|
|
39
39
|
|
|
40
40
|
| Module | File | Size | Purpose | Status in Docs |
|
|
41
41
|
|--------|------|------|---------|----------------|
|
|
42
|
-
| **🔐 bsv-shamir.min.js** | Shamir Secret Sharing |
|
|
43
|
-
| **🌐 bsv-gdaf.min.js** | Global Digital Attestation |
|
|
44
|
-
| **⚖️ bsv-ltp.min.js** | Legal Token Protocol |
|
|
42
|
+
| **🔐 bsv-shamir.min.js** | Shamir Secret Sharing | 432KB | Threshold cryptography | ✅ Documented |
|
|
43
|
+
| **🌐 bsv-gdaf.min.js** | Global Digital Attestation | 1184KB | Verifiable credentials | ✅ Documented |
|
|
44
|
+
| **⚖️ bsv-ltp.min.js** | Legal Token Protocol | 1184KB | Legal compliance tokens | ✅ Documented |
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
@@ -49,32 +49,31 @@ Based on actual library analysis, SmartLedger-BSV provides **12 distinct modules
|
|
|
49
49
|
|
|
50
50
|
### **1. Missing Advanced Modules (40% of library undocumented!)**
|
|
51
51
|
|
|
52
|
-
Three
|
|
52
|
+
Three advanced modules totaling **~2.7MB** of functionality:
|
|
53
53
|
|
|
54
|
-
#### **🔐 Shamir Secret Sharing (
|
|
54
|
+
#### **🔐 Shamir Secret Sharing (432KB)**
|
|
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@3.4.
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@3.4.4/bsv-shamir.min.js`
|
|
59
59
|
|
|
60
|
-
#### **🌐 Global Digital Attestation Framework - GDAF (
|
|
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@3.4.
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js`
|
|
65
65
|
|
|
66
|
-
#### **⚖️ Legal Token Protocol - LTP (
|
|
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@3.4.
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js`
|
|
71
71
|
|
|
72
72
|
### **2. Incorrect File Sizes in Documentation**
|
|
73
73
|
|
|
74
74
|
| Module | Documented Size | Actual Size | Difference |
|
|
75
75
|
|--------|----------------|-------------|------------|
|
|
76
|
-
|
|
|
77
|
-
| All others | Accurate | Accurate | ✅ Correct |
|
|
76
|
+
| All bundles | Documented | Match disk | ✅ Resolved as of v3.4.4 |
|
|
78
77
|
|
|
79
78
|
---
|
|
80
79
|
|
|
@@ -82,41 +81,41 @@ Three major modules totaling **1.82MB** of functionality are completely missing
|
|
|
82
81
|
|
|
83
82
|
| Module | Size | Use Case | CDN Link |
|
|
84
83
|
|--------|------|----------|----------|
|
|
85
|
-
| **bsv.min.js** |
|
|
86
|
-
| **bsv.bundle.js** |
|
|
87
|
-
| **bsv-smartcontract.min.js** |
|
|
88
|
-
| **bsv-covenant.min.js** |
|
|
89
|
-
| **bsv-script-helper.min.js** |
|
|
90
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@3.4.
|
|
91
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.
|
|
92
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.
|
|
93
|
-
| **bsv-mnemonic.min.js** |
|
|
94
|
-
| **🆕 bsv-shamir.min.js** |
|
|
95
|
-
| **🆕 bsv-gdaf.min.js** |
|
|
96
|
-
| **🆕 bsv-ltp.min.js** |
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.4/bsv-script-helper.min.js` |
|
|
89
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.4/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.4/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.4/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js` |
|
|
97
96
|
|
|
98
97
|
## 🎯 **Updated Usage Examples**
|
|
99
98
|
|
|
100
99
|
### **Complete Loading Strategy Examples**
|
|
101
100
|
|
|
102
|
-
#### **1. Basic Development (
|
|
101
|
+
#### **1. Basic Development (~963KB)**
|
|
103
102
|
```html
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
105
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-script-helper.min.js"></script>
|
|
106
105
|
```
|
|
107
106
|
|
|
108
|
-
#### **2. Smart Contract Development (
|
|
107
|
+
#### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
|
|
109
108
|
```html
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
112
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js"></script>
|
|
113
112
|
```
|
|
114
113
|
|
|
115
|
-
#### **3. 🆕 Legal & Compliance Development (
|
|
114
|
+
#### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
|
|
116
115
|
```html
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
119
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js"></script>
|
|
120
119
|
<script>
|
|
121
120
|
// Legal Token Protocol
|
|
122
121
|
const legalToken = bsv.createLegalToken({
|
|
@@ -131,11 +130,11 @@ Three major modules totaling **1.82MB** of functionality are completely missing
|
|
|
131
130
|
</script>
|
|
132
131
|
```
|
|
133
132
|
|
|
134
|
-
#### **4. 🆕 Security & Cryptography (1.
|
|
133
|
+
#### **4. 🆕 Security & Cryptography (~1.4MB)**
|
|
135
134
|
```html
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
138
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-shamir.min.js"></script>
|
|
139
138
|
<script>
|
|
140
139
|
// Shamir Secret Sharing
|
|
141
140
|
const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
|
|
@@ -145,9 +144,9 @@ Three major modules totaling **1.82MB** of functionality are completely missing
|
|
|
145
144
|
</script>
|
|
146
145
|
```
|
|
147
146
|
|
|
148
|
-
#### **5. Everything Bundle (
|
|
147
|
+
#### **5. Everything Bundle (937KB)**
|
|
149
148
|
```html
|
|
150
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js"></script>
|
|
151
150
|
<script>
|
|
152
151
|
// Everything available immediately
|
|
153
152
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -249,16 +248,20 @@ const obligationPrep = bsv.prepareObligationToken('PaymentObligation', issuerDID
|
|
|
249
248
|
|
|
250
249
|
## 📈 **Module Size Analysis**
|
|
251
250
|
|
|
252
|
-
### **Total Library Capabilities**:
|
|
251
|
+
### **Total Library Capabilities**: ~8.9MB across 16 standalone bundles
|
|
253
252
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
|
259
|
-
|
|
260
|
-
| **
|
|
261
|
-
|
|
|
253
|
+
Each standalone bundle is self-contained (it re-embeds core BSV at ~937KB),
|
|
254
|
+
so the total is the sum of independently-loadable file sizes — not the
|
|
255
|
+
working-set size if you load multiple.
|
|
256
|
+
|
|
257
|
+
| Category | Modules | Total Size |
|
|
258
|
+
|----------|---------|------------|
|
|
259
|
+
| **Core / Smart Contracts** | bsv.min, bsv.bundle, bsv-smartcontract, bsv-covenant, bsv-script-helper | ~3.75MB |
|
|
260
|
+
| **🆕 Credentials (3.4.x)** | bsv-didweb, bsv-vcjwt, bsv-statuslist, bsv-anchor | ~1.65MB |
|
|
261
|
+
| **🆕 Legal & Identity** | bsv-ltp, bsv-gdaf | ~2.31MB |
|
|
262
|
+
| **Utilities** | bsv-ecies, bsv-message, bsv-mnemonic | ~778KB |
|
|
263
|
+
| **🆕 Advanced Crypto** | bsv-shamir | 432KB |
|
|
264
|
+
| **Security** | bsv-security | 26KB |
|
|
262
265
|
|
|
263
266
|
### **Modular Loading Benefits**
|
|
264
267
|
|
|
@@ -276,7 +279,7 @@ const obligationPrep = bsv.prepareObligationToken('PaymentObligation', issuerDID
|
|
|
276
279
|
**Files to Update:**
|
|
277
280
|
- `README.md` - Add 3 new modules to loading options table
|
|
278
281
|
- `README.md` - Add usage examples for Shamir, GDAF, LTP
|
|
279
|
-
-
|
|
282
|
+
- ~~`README.md` - Update file sizes (bundle.js: 764KB → 885KB)~~ — resolved; bundle.js is now 937KB and accurate everywhere
|
|
280
283
|
|
|
281
284
|
**New Sections Needed:**
|
|
282
285
|
- Shamir Secret Sharing usage guide
|
|
@@ -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@3.
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
726
726
|
</head>
|
|
727
727
|
<body>
|
|
728
728
|
<script>
|
|
@@ -12,10 +12,10 @@ SmartLedger-BSV offers multiple installation methods to suit different developme
|
|
|
12
12
|
npm install @smartledger/bsv
|
|
13
13
|
|
|
14
14
|
# Install specific version
|
|
15
|
-
npm install @smartledger/bsv@3.4.
|
|
15
|
+
npm install @smartledger/bsv@3.4.4
|
|
16
16
|
|
|
17
17
|
# Install with exact version lock
|
|
18
|
-
npm install --save-exact @smartledger/bsv@3.4.
|
|
18
|
+
npm install --save-exact @smartledger/bsv@3.4.4
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
### **Usage in Node.js**
|
|
@@ -45,20 +45,20 @@ const tx: Transaction = new Transaction();
|
|
|
45
45
|
|
|
46
46
|
### **CDN Links (Instant Setup)**
|
|
47
47
|
|
|
48
|
-
#### **Core Library Only (
|
|
48
|
+
#### **Core Library Only (937KB)**
|
|
49
49
|
For basic Bitcoin SV operations:
|
|
50
50
|
```html
|
|
51
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
52
52
|
<script>
|
|
53
53
|
const privateKey = new bsv.PrivateKey();
|
|
54
54
|
const address = privateKey.toAddress();
|
|
55
55
|
</script>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
#### **Complete Bundle (
|
|
58
|
+
#### **Complete Bundle (937KB)**
|
|
59
59
|
Everything in one file:
|
|
60
60
|
```html
|
|
61
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js"></script>
|
|
62
62
|
<script>
|
|
63
63
|
// All features available immediately
|
|
64
64
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -69,22 +69,22 @@ Everything in one file:
|
|
|
69
69
|
|
|
70
70
|
### **Modular Loading (Choose What You Need)**
|
|
71
71
|
|
|
72
|
-
#### **Smart Contract Development (
|
|
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@3.4.
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js"></script>
|
|
77
77
|
<script>
|
|
78
78
|
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
79
79
|
.extractField('amount').push(50000).greaterThanOrEqual().build();
|
|
80
80
|
</script>
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
#### **Legal & Identity Development (
|
|
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@3.4.
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js"></script>
|
|
88
88
|
<script>
|
|
89
89
|
// Legal Token Protocol
|
|
90
90
|
const propertyToken = bsv.createPropertyToken({
|
|
@@ -96,11 +96,11 @@ Everything in one file:
|
|
|
96
96
|
</script>
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
#### **Security & Cryptography (1.
|
|
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@3.4.
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/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** |
|
|
118
|
-
| **bsv.bundle.js** |
|
|
119
|
-
| **bsv-smartcontract.min.js** |
|
|
120
|
-
| **bsv-ltp.min.js** |
|
|
121
|
-
| **bsv-gdaf.min.js** |
|
|
122
|
-
| **bsv-shamir.min.js** |
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@3.4.
|
|
124
|
-
| **bsv-mnemonic.min.js** |
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.
|
|
126
|
-
| **bsv-covenant.min.js** |
|
|
127
|
-
| **bsv-script-helper.min.js** |
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.4/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.4/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.4/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.4/bsv-message.min.js` |
|
|
129
129
|
|
|
130
130
|
## ⚙️ **Development Environment Setup**
|
|
131
131
|
|
|
@@ -13,11 +13,11 @@ npm install @smartledger/bsv
|
|
|
13
13
|
|
|
14
14
|
### Browser CDN (Instant)
|
|
15
15
|
```html
|
|
16
|
-
<!-- Core library (
|
|
17
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
16
|
+
<!-- Core library (937KB) -->
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
18
18
|
|
|
19
|
-
<!-- Everything included (
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
19
|
+
<!-- Everything included (937KB) -->
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 💰 **Your First Transaction (60 seconds)**
|
|
@@ -126,20 +126,20 @@ const amount = preimage.getField('amount');
|
|
|
126
126
|
SmartLedger-BSV offers 12 different loading options - use only what you need:
|
|
127
127
|
|
|
128
128
|
```html
|
|
129
|
-
<!-- Core BSV only (
|
|
130
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
129
|
+
<!-- Core BSV only (937KB) -->
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
131
131
|
|
|
132
|
-
<!-- Smart contracts (
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
132
|
+
<!-- Smart contracts (937KB) -->
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
|
-
<!-- Legal tokens (1.
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
135
|
+
<!-- Legal tokens (1.16MB) -->
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
|
-
<!-- Digital identity (1.
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
138
|
+
<!-- Digital identity (1.16MB) -->
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
|
-
<!-- Everything (
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
141
|
+
<!-- Everything (937KB) -->
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/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@3.
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/gdaf-entry.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = require('./lib/smart_contract');
|
|
1
|
+
module.exports = require('./lib/gdaf')
|
package/index.js
CHANGED
|
@@ -2,17 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
var bsv = module.exports
|
|
4
4
|
|
|
5
|
-
// Initialize dependencies first to avoid circular dependency issues
|
|
5
|
+
// Initialize dependencies first to avoid circular dependency issues.
|
|
6
|
+
//
|
|
7
|
+
// `bn.js`, `bs58`, and `elliptic` are declared runtime deps in
|
|
8
|
+
// package.json. In Node they MUST be installed — silently swallowing
|
|
9
|
+
// a require() failure here used to mask broken installs behind cryptic
|
|
10
|
+
// downstream errors in lib/crypto/bn.js etc. We now let those throw in
|
|
11
|
+
// Node so the failure points at the real cause (`npm install` is broken).
|
|
12
|
+
// In a browser context the bundler is expected to inline these; if it
|
|
13
|
+
// somehow didn't, we tolerate the absence rather than block the whole
|
|
14
|
+
// library load.
|
|
6
15
|
bsv.deps = bsv.deps || {}
|
|
7
|
-
|
|
16
|
+
bsv.deps._ = require('./lib/util/_')
|
|
17
|
+
bsv.deps.Buffer = (typeof Buffer !== 'undefined') ? Buffer : null
|
|
18
|
+
|
|
19
|
+
if (typeof window === 'undefined') {
|
|
20
|
+
// Node — hard require; failure means broken install.
|
|
8
21
|
bsv.deps.bnjs = require('bn.js')
|
|
9
22
|
bsv.deps.bs58 = require('bs58')
|
|
10
|
-
bsv.deps.Buffer = (typeof Buffer !== 'undefined') ? Buffer : null
|
|
11
23
|
bsv.deps.elliptic = require('elliptic')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
} else {
|
|
25
|
+
// Browser — bundler-resolved; tolerate absence individually.
|
|
26
|
+
try { bsv.deps.bnjs = require('bn.js') } catch (e) { /* polyfilled by bundler */ }
|
|
27
|
+
try { bsv.deps.bs58 = require('bs58') } catch (e) { /* polyfilled by bundler */ }
|
|
28
|
+
try { bsv.deps.elliptic = require('elliptic') } catch (e) { /* polyfilled by bundler */ }
|
|
16
29
|
}
|
|
17
30
|
|
|
18
31
|
// module information
|
|
@@ -26,6 +26,15 @@ try {
|
|
|
26
26
|
fs = null
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// Set BSV_DEBUG=1 (Node) or window.BSV_DEBUG = true (browser) to surface
|
|
30
|
+
// informational warnings from this module. Matches the gating pattern
|
|
31
|
+
// used by lib/browser-utxo-manager-es5.js since v3.4.1.
|
|
32
|
+
var debug = function () {
|
|
33
|
+
var enabled = (typeof process !== 'undefined' && process.env && process.env.BSV_DEBUG) ||
|
|
34
|
+
(typeof window !== 'undefined' && window.BSV_DEBUG)
|
|
35
|
+
if (enabled) console.log.apply(console, arguments)
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
/**
|
|
30
39
|
* Covenant Class - Advanced covenant management
|
|
31
40
|
* @param {PrivateKey} privateKey - Private key for covenant operations
|
|
@@ -212,7 +221,7 @@ Covenant.prototype.validate = function(spendingTx, covenantUtxo) {
|
|
|
212
221
|
*/
|
|
213
222
|
Covenant.prototype.save = function(covenantUtxo) {
|
|
214
223
|
if (!fs) {
|
|
215
|
-
|
|
224
|
+
debug('File system operations not available in browser environment')
|
|
216
225
|
return covenantUtxo
|
|
217
226
|
}
|
|
218
227
|
|
package/lib/smartutxo.js
CHANGED
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
* Provides blockchain state management and UTXO tracking for testing and development
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
// Set BSV_DEBUG=1 (Node) or window.BSV_DEBUG = true (browser) to surface
|
|
9
|
+
// info/warning output from this module. Matches the gating pattern used
|
|
10
|
+
// by lib/browser-utxo-manager-es5.js since v3.4.1.
|
|
11
|
+
const debug = function () {
|
|
12
|
+
const enabled = (typeof process !== 'undefined' && process.env && process.env.BSV_DEBUG) ||
|
|
13
|
+
(typeof window !== 'undefined' && window.BSV_DEBUG)
|
|
14
|
+
if (enabled) console.log.apply(console, arguments)
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
// Browser-compatible imports
|
|
9
18
|
let fs, path, crypto, blockchainState
|
|
10
19
|
|
|
@@ -16,8 +25,7 @@ if (typeof window === 'undefined' && typeof require === 'function') {
|
|
|
16
25
|
crypto = require('crypto')
|
|
17
26
|
blockchainState = require('../utilities/blockchain-state')
|
|
18
27
|
} catch (e) {
|
|
19
|
-
|
|
20
|
-
console.warn('SmartUTXO: Running in browser mode - some features may be limited')
|
|
28
|
+
debug('SmartUTXO: Running in browser mode - some features may be limited')
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
|
|
@@ -40,7 +48,7 @@ class SmartUTXOManager {
|
|
|
40
48
|
const state = blockchainState.loadBlockchainState()
|
|
41
49
|
return state
|
|
42
50
|
} catch (error) {
|
|
43
|
-
|
|
51
|
+
debug('⚠️ Could not load blockchain state:', error.message)
|
|
44
52
|
return null
|
|
45
53
|
}
|
|
46
54
|
}
|
|
@@ -53,9 +61,9 @@ class SmartUTXOManager {
|
|
|
53
61
|
const state = blockchainState.loadBlockchainState()
|
|
54
62
|
blockchainState.saveBlockchainState(state)
|
|
55
63
|
const utxoCount = Object.keys(state.globalUTXOSet || {}).length
|
|
56
|
-
|
|
64
|
+
debug(`💾 Saved blockchain state with ${utxoCount} UTXOs`)
|
|
57
65
|
} catch (error) {
|
|
58
|
-
|
|
66
|
+
debug('⚠️ Could not save blockchain state:', error.message)
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
|
|
@@ -76,7 +84,7 @@ class SmartUTXOManager {
|
|
|
76
84
|
// Return the wallet's UTXOs
|
|
77
85
|
return state.wallets[address].utxos || []
|
|
78
86
|
} catch (error) {
|
|
79
|
-
|
|
87
|
+
debug('⚠️ Error getting UTXOs:', error.message)
|
|
80
88
|
return []
|
|
81
89
|
}
|
|
82
90
|
}
|
|
@@ -90,7 +98,7 @@ class SmartUTXOManager {
|
|
|
90
98
|
// Use the correct API: addUTXO(utxo, ownerAddress)
|
|
91
99
|
blockchainState.addUTXO(utxo, utxo.address)
|
|
92
100
|
} catch (error) {
|
|
93
|
-
|
|
101
|
+
debug('⚠️ Error adding UTXO:', error.message)
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
|
|
@@ -106,7 +114,7 @@ class SmartUTXOManager {
|
|
|
106
114
|
blockchainState.spendUTXO(input.txid, input.vout, spentInTx)
|
|
107
115
|
}
|
|
108
116
|
} catch (error) {
|
|
109
|
-
|
|
117
|
+
debug('⚠️ Error spending UTXOs:', error.message)
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
|
|
@@ -156,7 +164,7 @@ class SmartUTXOManager {
|
|
|
156
164
|
// Return the wallet's total value
|
|
157
165
|
return state.wallets[address].totalValue || 0
|
|
158
166
|
} catch (error) {
|
|
159
|
-
|
|
167
|
+
debug('⚠️ Error getting balance:', error.message)
|
|
160
168
|
return 0
|
|
161
169
|
}
|
|
162
170
|
}
|
|
@@ -176,7 +184,7 @@ class SmartUTXOManager {
|
|
|
176
184
|
lastUpdated: state.metadata.lastUpdated
|
|
177
185
|
}
|
|
178
186
|
} catch (error) {
|
|
179
|
-
|
|
187
|
+
debug('⚠️ Error getting stats:', error.message)
|
|
180
188
|
return { totalUTXOs: 0, totalValue: 0, totalWallets: 0, blockHeight: 0 }
|
|
181
189
|
}
|
|
182
190
|
}
|
|
@@ -189,10 +197,10 @@ class SmartUTXOManager {
|
|
|
189
197
|
const statePath = path.join(__dirname, '../utilities/blockchain-state.json')
|
|
190
198
|
if (fs.existsSync(statePath)) {
|
|
191
199
|
fs.unlinkSync(statePath)
|
|
192
|
-
|
|
200
|
+
debug('🔄 Blockchain state reset')
|
|
193
201
|
}
|
|
194
202
|
} catch (error) {
|
|
195
|
-
|
|
203
|
+
debug('⚠️ Could not reset blockchain state:', error.message)
|
|
196
204
|
}
|
|
197
205
|
}
|
|
198
206
|
}
|
|
@@ -911,6 +911,13 @@ Transaction.prototype._getUnspentValue = function () {
|
|
|
911
911
|
|
|
912
912
|
Transaction.prototype._clearSignatures = function () {
|
|
913
913
|
_.each(this.inputs, function (input) {
|
|
914
|
+
// Custom-script inputs (bare Input base class — e.g. covenant or other
|
|
915
|
+
// non-standard locking scripts) have no library-managed signatures to
|
|
916
|
+
// clear; the caller owns input.script. Mirror the guard pattern used by
|
|
917
|
+
// Transaction.prototype.isFullySigned / isValidSignature below.
|
|
918
|
+
if (input.clearSignatures === Input.prototype.clearSignatures) {
|
|
919
|
+
return
|
|
920
|
+
}
|
|
914
921
|
input.clearSignatures()
|
|
915
922
|
})
|
|
916
923
|
}
|
package/ltp-entry.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = require('./lib/smart_contract');
|
|
1
|
+
module.exports = require('./lib/ltp')
|