@smartledger/bsv 3.4.3 → 3.4.5

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +367 -0
  2. package/README.md +72 -72
  3. package/SECURITY.md +88 -0
  4. package/bin/cli.js +13 -8
  5. package/bsv-covenant.min.js +4 -4
  6. package/bsv-gdaf.min.js +5 -5
  7. package/bsv-ltp.min.js +7 -7
  8. package/bsv-smartcontract.min.js +5 -5
  9. package/bsv.bundle.js +5 -5
  10. package/bsv.d.ts +486 -9
  11. package/bsv.min.js +5 -5
  12. package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
  13. package/docs/MODULE_REFERENCE_COMPLETE.md +60 -57
  14. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  15. package/docs/getting-started/INSTALLATION.md +30 -30
  16. package/docs/getting-started/QUICK_START.md +14 -14
  17. package/docs/migration/FROM_BSV_1_5_6.md +5 -5
  18. package/gdaf-entry.js +1 -2
  19. package/index.js +20 -7
  20. package/lib/script/script.js +19 -0
  21. package/lib/smart_contract/covenant.js +10 -1
  22. package/lib/smartutxo.js +20 -12
  23. package/lib/transaction/input/publickeyhash.js +6 -1
  24. package/lib/transaction/transaction.js +12 -1
  25. package/ltp-entry.js +1 -2
  26. package/package.json +3 -3
  27. package/utilities/blockchain-state.js +32 -23
  28. package/demos/README.md +0 -188
  29. package/demos/architecture_demo.js +0 -247
  30. package/demos/browser-test.html +0 -1208
  31. package/demos/bsv_wallet_demo.js +0 -242
  32. package/demos/complete_ltp_demo.js +0 -511
  33. package/demos/debug_tools_demo.js +0 -87
  34. package/demos/demo_features.js +0 -123
  35. package/demos/easy_interface_demo.js +0 -109
  36. package/demos/ecies_demo.js +0 -182
  37. package/demos/gdaf_demo.js +0 -237
  38. package/demos/ltp_demo.js +0 -361
  39. package/demos/ltp_primitives_demo.js +0 -403
  40. package/demos/message_demo.js +0 -209
  41. package/demos/preimage_separation_demo.js +0 -383
  42. package/demos/script_helper_demo.js +0 -289
  43. package/demos/security_demo.js +0 -287
  44. package/demos/shamir_demo.js +0 -121
  45. package/demos/simple_demo.js +0 -204
  46. package/demos/simple_p2pkh_demo.js +0 -169
  47. package/demos/simple_utxo_preimage_demo.js +0 -196
  48. package/demos/smart_contract_demo.html +0 -1347
  49. package/demos/smart_contract_demo.js +0 -910
  50. package/demos/utxo_generator_demo.js +0 -244
  51. package/demos/validation_pipeline_demo.js +0 -155
  52. package/demos/web3keys.html +0 -740
  53. package/examples/README.md +0 -200
  54. package/examples/basic/transaction-creation.js +0 -534
  55. package/examples/basic/transaction_signature_api_gap.js +0 -178
  56. package/examples/complete_workflow_demo.js +0 -783
  57. package/examples/covenants/advanced_covenant_demo.js +0 -219
  58. package/examples/covenants/covenant_interface_demo.js +0 -270
  59. package/examples/covenants/covenant_manual_signature_resolved.js +0 -212
  60. package/examples/covenants/covenant_signature_template.js +0 -117
  61. package/examples/covenants2/covenant_bidirectional_example.js +0 -262
  62. package/examples/covenants2/covenant_utils_demo.js +0 -120
  63. package/examples/covenants2/preimage_covenant_utils.js +0 -287
  64. package/examples/covenants2/production_integration.js +0 -256
  65. package/examples/data/covenant_utxos.json +0 -28
  66. package/examples/data/utxos.json +0 -26
  67. package/examples/definitive_working_demo.js +0 -261
  68. package/examples/final_working_contracts.js +0 -338
  69. package/examples/legacy/README.md +0 -11
  70. package/examples/legacy/smart_contract_test_integration.js +0 -269
  71. package/examples/legacy/test_builtin_verify.js +0 -117
  72. package/examples/legacy/test_debug_integration.js +0 -71
  73. package/examples/legacy/test_ecdsa_little.js +0 -70
  74. package/examples/legacy/test_shamir.js +0 -221
  75. package/examples/legacy/test_smartverify_der.js +0 -110
  76. package/examples/preimage/README.md +0 -178
  77. package/examples/preimage/extract_preimage_bidirectional.js +0 -421
  78. package/examples/preimage/generate_sample_preimage.js +0 -208
  79. package/examples/preimage/generate_sighash_examples.js +0 -152
  80. package/examples/preimage/parse_preimage.js +0 -117
  81. package/examples/preimage/test_preimage_extractor.js +0 -53
  82. package/examples/preimage/test_varint_extraction.js +0 -95
  83. package/examples/scripts/custom_script_helper_example.js +0 -273
  84. package/examples/scripts/script_interpreter.js +0 -193
  85. package/examples/smart_contract/complete_workflow_demo.js +0 -343
  86. package/examples/smart_contract/covenant_builder_demo.js +0 -176
  87. package/examples/smart_contract/script_testing_integration.js +0 -198
  88. package/examples/smart_contract_templates.js +0 -718
  89. 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.1.1
139
+ npm install smartledger-bsv@3.4.5
140
140
  # or
141
- npm install @smartledger/bsv@3.1.1
141
+ npm install @smartledger/bsv@3.4.5
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 | 449KB | Complete BSV development | ✅ Documented |
19
- | **bsv.bundle.js** | Everything in one | 885KB | All features included | ⚠️ Size wrong (764KB→885KB) |
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 | 451KB | Covenant development | ✅ Documented |
26
- | **bsv-covenant.min.js** | Covenant interface | 32KB | Covenant operations | ✅ Documented |
27
- | **bsv-script-helper.min.js** | Custom script tools | 27KB | Script development | ✅ Documented |
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 | 670KB | Mnemonic operations | ✅ Documented |
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 | 433KB | Threshold cryptography | **NOT DOCUMENTED** |
43
- | **🌐 bsv-gdaf.min.js** | Global Digital Attestation | 604KB | Verifiable credentials | **NOT DOCUMENTED** |
44
- | **⚖️ bsv-ltp.min.js** | Legal Token Protocol | 817KB | Legal compliance tokens | **NOT DOCUMENTED** |
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 major modules totaling **1.82MB** of functionality are completely missing from documentation:
52
+ Three advanced modules totaling **~2.7MB** of functionality:
53
53
 
54
- #### **🔐 Shamir Secret Sharing (433KB)**
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.2/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@3.4.5/bsv-shamir.min.js`
59
59
 
60
- #### **🌐 Global Digital Attestation Framework - GDAF (604KB)**
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.2/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@3.4.5/bsv-gdaf.min.js`
65
65
 
66
- #### **⚖️ Legal Token Protocol - LTP (817KB)**
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.2/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@3.4.5/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
- | `bsv.bundle.js` | 764KB | 885KB | +121KB (+16%) |
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** | 449KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.2/bsv.min.js` |
86
- | **bsv.bundle.js** | 885KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.2/bsv.bundle.js` |
87
- | **bsv-smartcontract.min.js** | 451KB | Covenant development | `unpkg.com/@smartledger/bsv@3.4.2/bsv-smartcontract.min.js` |
88
- | **bsv-covenant.min.js** | 32KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.2/bsv-covenant.min.js` |
89
- | **bsv-script-helper.min.js** | 27KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.2/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.2/bsv-security.min.js` |
91
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.2/bsv-ecies.min.js` |
92
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.2/bsv-message.min.js` |
93
- | **bsv-mnemonic.min.js** | 670KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.2/bsv-mnemonic.min.js` |
94
- | **🆕 bsv-shamir.min.js** | 433KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@3.4.2/bsv-shamir.min.js` |
95
- | **🆕 bsv-gdaf.min.js** | 604KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@3.4.2/bsv-gdaf.min.js` |
96
- | **🆕 bsv-ltp.min.js** | 817KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@3.4.2/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.5/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@3.4.5/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.5/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.5/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.5/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.5/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.5/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.5/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@3.4.5/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@3.4.5/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@3.4.5/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 (476KB)**
101
+ #### **1. Basic Development (~963KB)**
103
102
  ```html
104
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.min.js"></script>
105
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-script-helper.min.js"></script>
106
105
  ```
107
106
 
108
- #### **2. Smart Contract Development (932KB)**
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.2/bsv.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-covenant.min.js"></script>
112
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-smartcontract.min.js"></script>
113
112
  ```
114
113
 
115
- #### **3. 🆕 Legal & Compliance Development (1.7MB)**
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.2/bsv.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-ltp.min.js"></script>
119
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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.35MB)**
133
+ #### **4. 🆕 Security & Cryptography (~1.4MB)**
135
134
  ```html
136
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-security.min.js"></script>
138
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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 (885KB)**
147
+ #### **5. Everything Bundle (937KB)**
149
148
  ```html
150
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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**: 4.82MB across 12 modules
251
+ ### **Total Library Capabilities**: ~8.9MB across 16 standalone bundles
253
252
 
254
- | Category | Modules | Total Size | Percentage |
255
- |----------|---------|------------|------------|
256
- | **Core & Smart Contracts** | 4 modules | 1.39MB | 29% |
257
- | **🆕 Legal & Identity** | 2 modules | 1.42MB | 29% |
258
- | **Utilities** | 3 modules | 767KB | 16% |
259
- | **🆕 Advanced Crypto** | 1 module | 433KB | 9% |
260
- | **Security** | 1 module | 290KB | 6% |
261
- | **Everything Bundle** | 1 file | 885KB | 18% |
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
- - `README.md` - Update file sizes (bundle.js: 764KB → 885KB)
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.3.4/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@3.4.5/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.2
15
+ npm install @smartledger/bsv@3.4.5
16
16
 
17
17
  # Install with exact version lock
18
- npm install --save-exact @smartledger/bsv@3.4.2
18
+ npm install --save-exact @smartledger/bsv@3.4.5
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 (449KB)**
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.2/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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 (885KB)**
58
+ #### **Complete Bundle (937KB)**
59
59
  Everything in one file:
60
60
  ```html
61
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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 (932KB total)**
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.2/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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 (1.87MB total)**
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.2/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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.17MB total)**
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.2/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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** | 449KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.2/bsv.min.js` |
118
- | **bsv.bundle.js** | 885KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.2/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 451KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@3.4.2/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 817KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@3.4.2/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 604KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@3.4.2/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 433KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@3.4.2/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@3.4.2/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 670KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.2/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.2/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 32KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.2/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 27KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.2/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.2/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.5/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@3.4.5/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@3.4.5/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@3.4.5/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@3.4.5/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@3.4.5/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.5/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.5/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.5/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.5/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.5/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 (449KB) -->
17
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.min.js"></script>
16
+ <!-- Core library (937KB) -->
17
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
18
18
 
19
- <!-- Everything included (885KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.bundle.js"></script>
19
+ <!-- Everything included (937KB) -->
20
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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 (449KB) -->
130
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.min.js"></script>
129
+ <!-- Core BSV only (937KB) -->
130
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
131
131
 
132
- <!-- Smart contracts (873KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-smartcontract.min.js"></script>
132
+ <!-- Smart contracts (937KB) -->
133
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-smartcontract.min.js"></script>
134
134
 
135
- <!-- Legal tokens (1.1MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-ltp.min.js"></script>
135
+ <!-- Legal tokens (1.16MB) -->
136
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-ltp.min.js"></script>
137
137
 
138
- <!-- Digital identity (1.1MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv-gdaf.min.js"></script>
138
+ <!-- Digital identity (1.16MB) -->
139
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-gdaf.min.js"></script>
140
140
 
141
- <!-- Everything (885KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@3.4.2/bsv.bundle.js"></script>
141
+ <!-- Everything (937KB) -->
142
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/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.3.4/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@3.3.4/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@3.3.4/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@3.3.4/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@3.3.4/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@3.4.5/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
package/gdaf-entry.js CHANGED
@@ -1,2 +1 @@
1
- // GDAF module placeholder - will be implemented in future release
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
- try {
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
- bsv.deps._ = require('./lib/util/_')
13
- } catch (e) {
14
- // Handle browser environment gracefully
15
- console.warn('Some dependencies may not be available in browser environment:', e.message)
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
@@ -334,6 +334,25 @@ Script.prototype.isPublicKeyHashOut = function () {
334
334
  this.chunks[4].opcodenum === Opcode.OP_CHECKSIG)
335
335
  }
336
336
 
337
+ /**
338
+ * @returns {boolean} true if the FIRST five chunks are a P2PKH pattern, regardless
339
+ * of any trailing chunks. Matches 1Sat Ordinals (P2PKH + `OP_FALSE OP_IF "ord" …
340
+ * OP_ENDIF`), MAP+BAP-style appended metadata, sCrypt covenants with a P2PKH
341
+ * spendable guard, etc. The strict `isPublicKeyHashOut()` is unchanged so
342
+ * address derivation / script classification keep their canonical semantics;
343
+ * this loose check is used by `Transaction.from()` so spending such outputs
344
+ * via the high-level API Just Works.
345
+ */
346
+ Script.prototype.isPublicKeyHashOutPrefix = function () {
347
+ return !!(this.chunks.length >= 5 &&
348
+ this.chunks[0].opcodenum === Opcode.OP_DUP &&
349
+ this.chunks[1].opcodenum === Opcode.OP_HASH160 &&
350
+ this.chunks[2].buf &&
351
+ this.chunks[2].buf.length === 20 &&
352
+ this.chunks[3].opcodenum === Opcode.OP_EQUALVERIFY &&
353
+ this.chunks[4].opcodenum === Opcode.OP_CHECKSIG)
354
+ }
355
+
337
356
  /**
338
357
  * @returns {boolean} if this is a pay to public key hash input script
339
358
  */
@@ -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
- console.warn('File system operations not available in browser environment')
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
- // Fallback for environments where these modules aren't available
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
- console.log('⚠️ Could not load blockchain state:', error.message)
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
- console.log(`💾 Saved blockchain state with ${utxoCount} UTXOs`)
64
+ debug(`💾 Saved blockchain state with ${utxoCount} UTXOs`)
57
65
  } catch (error) {
58
- console.log('⚠️ Could not save blockchain state:', error.message)
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
- console.log('⚠️ Error getting UTXOs:', error.message)
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
- console.log('⚠️ Error adding UTXO:', error.message)
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
- console.log('⚠️ Error spending UTXOs:', error.message)
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
- console.log('⚠️ Error getting balance:', error.message)
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
- console.log('⚠️ Error getting stats:', error.message)
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
- console.log('🔄 Blockchain state reset')
200
+ debug('🔄 Blockchain state reset')
193
201
  }
194
202
  } catch (error) {
195
- console.log('⚠️ Could not reset blockchain state:', error.message)
203
+ debug('⚠️ Could not reset blockchain state:', error.message)
196
204
  }
197
205
  }
198
206
  }