smartledger-bsv 3.3.5 → 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.
Files changed (126) hide show
  1. package/CHANGELOG.md +400 -0
  2. package/README.md +235 -80
  3. package/SECURITY.md +88 -0
  4. package/anchor-entry.js +1 -0
  5. package/bin/cli.js +354 -0
  6. package/bsv-anchor.min.js +12 -0
  7. package/bsv-covenant.min.js +8 -8
  8. package/bsv-didweb.min.js +12 -0
  9. package/bsv-gdaf.min.js +9 -9
  10. package/bsv-ltp.min.js +9 -9
  11. package/bsv-mnemonic.min.js +2 -2
  12. package/bsv-shamir.min.js +3 -3
  13. package/bsv-smartcontract.min.js +9 -9
  14. package/bsv-statuslist.min.js +18 -0
  15. package/bsv-vcjwt.min.js +12 -0
  16. package/bsv.bundle.js +9 -9
  17. package/bsv.d.ts +486 -9
  18. package/bsv.min.js +8 -8
  19. package/build/webpack.anchor.config.js +17 -0
  20. package/build/webpack.didweb.config.js +17 -0
  21. package/build/webpack.statuslist.config.js +17 -0
  22. package/build/webpack.vcjwt.config.js +17 -0
  23. package/didweb-entry.js +1 -0
  24. package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
  25. package/docs/MODULE_REFERENCE_COMPLETE.md +61 -58
  26. package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +3 -3
  27. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  28. package/docs/getting-started/INSTALLATION.md +30 -30
  29. package/docs/getting-started/QUICK_START.md +18 -18
  30. package/docs/migration/FROM_BSV_1_5_6.md +16 -10
  31. package/docs/technical/roadmap.md +3 -3
  32. package/gdaf-entry.js +1 -2
  33. package/index.js +68 -9
  34. package/lib/anchor/index.js +102 -0
  35. package/lib/browser-utxo-manager-es5.js +11 -4
  36. package/lib/browser-utxo-manager.js +15 -8
  37. package/lib/didweb/index.js +177 -0
  38. package/lib/ltp/claim.js +1 -0
  39. package/lib/ltp/obligation.js +1 -0
  40. package/lib/ltp/registry.js +2 -0
  41. package/lib/ltp/right.js +1 -0
  42. package/lib/smart_contract/covenant.js +10 -1
  43. package/lib/smartutxo.js +20 -12
  44. package/lib/statuslist/index.js +164 -0
  45. package/lib/transaction/transaction.js +8 -1
  46. package/lib/util/_.js +7 -1
  47. package/lib/vcjwt/index.js +189 -0
  48. package/ltp-entry.js +1 -2
  49. package/package.json +21 -15
  50. package/statuslist-entry.js +1 -0
  51. package/utilities/blockchain-state.js +32 -23
  52. package/vcjwt-entry.js +1 -0
  53. package/demos/README.md +0 -188
  54. package/demos/architecture_demo.js +0 -247
  55. package/demos/browser-test.html +0 -1208
  56. package/demos/bsv_wallet_demo.js +0 -242
  57. package/demos/complete_ltp_demo.js +0 -511
  58. package/demos/debug_tools_demo.js +0 -87
  59. package/demos/demo_features.js +0 -123
  60. package/demos/easy_interface_demo.js +0 -109
  61. package/demos/ecies_demo.js +0 -182
  62. package/demos/gdaf_core_test.js +0 -131
  63. package/demos/gdaf_demo.js +0 -237
  64. package/demos/ltp_demo.js +0 -361
  65. package/demos/ltp_primitives_demo.js +0 -403
  66. package/demos/message_demo.js +0 -209
  67. package/demos/preimage_separation_demo.js +0 -383
  68. package/demos/script_helper_demo.js +0 -289
  69. package/demos/security_demo.js +0 -287
  70. package/demos/shamir_demo.js +0 -121
  71. package/demos/simple_demo.js +0 -204
  72. package/demos/simple_p2pkh_demo.js +0 -169
  73. package/demos/simple_utxo_preimage_demo.js +0 -196
  74. package/demos/smart_contract_demo.html +0 -1347
  75. package/demos/smart_contract_demo.js +0 -910
  76. package/demos/utxo_generator_demo.js +0 -244
  77. package/demos/validation_pipeline_demo.js +0 -155
  78. package/demos/web3keys.html +0 -740
  79. package/examples/README.md +0 -200
  80. package/examples/basic/transaction-creation.js +0 -534
  81. package/examples/basic/transaction_signature_api_gap.js +0 -178
  82. package/examples/complete_workflow_demo.js +0 -783
  83. package/examples/covenants/advanced_covenant_demo.js +0 -219
  84. package/examples/covenants/covenant_interface_demo.js +0 -270
  85. package/examples/covenants/covenant_manual_signature_resolved.js +0 -212
  86. package/examples/covenants/covenant_signature_template.js +0 -117
  87. package/examples/covenants2/covenant_bidirectional_example.js +0 -262
  88. package/examples/covenants2/covenant_utils_demo.js +0 -120
  89. package/examples/covenants2/preimage_covenant_utils.js +0 -287
  90. package/examples/covenants2/production_integration.js +0 -256
  91. package/examples/data/covenant_utxos.json +0 -28
  92. package/examples/data/utxos.json +0 -26
  93. package/examples/definitive_working_demo.js +0 -261
  94. package/examples/final_working_contracts.js +0 -338
  95. package/examples/preimage/README.md +0 -178
  96. package/examples/preimage/extract_preimage_bidirectional.js +0 -421
  97. package/examples/preimage/generate_sample_preimage.js +0 -208
  98. package/examples/preimage/generate_sighash_examples.js +0 -152
  99. package/examples/preimage/parse_preimage.js +0 -117
  100. package/examples/preimage/test_preimage_extractor.js +0 -53
  101. package/examples/preimage/test_varint_extraction.js +0 -95
  102. package/examples/scripts/custom_script_helper_example.js +0 -273
  103. package/examples/scripts/custom_script_signature_test.js +0 -344
  104. package/examples/scripts/script_interpreter.js +0 -193
  105. package/examples/smart_contract/complete_workflow_demo.js +0 -343
  106. package/examples/smart_contract/covenant_builder_demo.js +0 -176
  107. package/examples/smart_contract/script_testing_integration.js +0 -198
  108. package/examples/smart_contract_templates.js +0 -718
  109. package/examples/working_smart_contracts.js +0 -348
  110. package/lib/smart_contract/test_integration.js +0 -269
  111. package/tests/browser-compatibility/README.md +0 -35
  112. package/tests/browser-compatibility/test-cdn-vs-local.html +0 -186
  113. package/tests/browser-compatibility/test-pbkdf2.html +0 -51
  114. package/tests/bundle-completeness-test.html +0 -131
  115. package/tests/bundle-demo.html +0 -476
  116. package/tests/smartcontract-test.html +0 -239
  117. package/tests/standalone-modules-test.html +0 -260
  118. package/tests/test.html +0 -612
  119. package/tests/test_builtin_verify.js +0 -117
  120. package/tests/test_debug_integration.js +0 -71
  121. package/tests/test_ecdsa_little.js +0 -70
  122. package/tests/test_shamir.js +0 -221
  123. package/tests/test_smartverify_der.js +0 -110
  124. package/tests/test_standalone_shamir.html +0 -83
  125. package/tests/unpkg-demo.html +0 -194
  126. package/utilities/blockchain-state.json +0 -118565
@@ -1,200 +0,0 @@
1
- # SmartLedger-BSV Examples
2
-
3
- This directory contains comprehensive examples demonstrating all features of SmartLedger-BSV v3.1.1+.
4
-
5
- ## 📁 Directory Structure
6
-
7
- ### `/basic` - Basic BSV Operations
8
- - **[transaction-creation.js](basic/transaction-creation.js)**: Ultra-low fee transactions and UTXO management
9
- - **[transaction_signature_api_gap.js](basic/transaction_signature_api_gap.js)**: Manual signature creation examples
10
-
11
- ### `/covenants` - Advanced Covenant Framework
12
- - **[advanced_covenant_demo.js](covenants/advanced_covenant_demo.js)**: Complete covenant showcase with BIP143 + PUSHTX
13
- - **[covenant_manual_signature_resolved.js](covenants/covenant_manual_signature_resolved.js)**: Working covenant patterns
14
- - **[covenant_signature_template.js](covenants/covenant_signature_template.js)**: Copy-paste covenant templates
15
- - **[covenant_interface_demo.js](covenants/covenant_interface_demo.js)**: Dual-level API demonstration
16
-
17
- ### `/scripts` - Custom Script Development
18
- - **[custom_script_helper_example.js](scripts/custom_script_helper_example.js)**: CustomScriptHelper API examples
19
- - **[custom_script_signature_test.js](scripts/custom_script_signature_test.js)**: Complete test suite for all script types
20
-
21
- ### `/preimage` - BIP-143 Preimage Tools
22
- - **[extract_preimage_bidirectional.js](preimage/extract_preimage_bidirectional.js)**: Advanced bidirectional preimage field extractor with CompactSize varint support
23
- - **[generate_sample_preimage.js](preimage/generate_sample_preimage.js)**: Multi-type preimage generator with varint testing
24
- - **[generate_sighash_examples.js](preimage/generate_sighash_examples.js)**: SIGHASH flag examples showing "zero hash" behavior
25
- - **[test_varint_extraction.js](preimage/test_varint_extraction.js)**: CompactSize varint test suite
26
-
27
- ## 🚀 Running Examples
28
-
29
- ### Prerequisites
30
- ```bash
31
- npm install @smartledger/bsv
32
- ```
33
-
34
- ### Basic Examples
35
- ```bash
36
- # Transaction creation with ultra-low fees
37
- node examples/basic/transaction-creation.js
38
-
39
- # Manual signature API examples
40
- node examples/basic/transaction_signature_api_gap.js
41
- ```
42
-
43
- ### Covenant Examples
44
- ```bash
45
- # Complete covenant framework demonstration
46
- node examples/covenants/advanced_covenant_demo.js
47
-
48
- # Working covenant patterns with manual signatures
49
- node examples/covenants/covenant_manual_signature_resolved.js
50
-
51
- # Dual-level API demonstration
52
- node examples/covenants/covenant_interface_demo.js
53
- ```
54
-
55
- ### Custom Script Examples
56
- ```bash
57
- # CustomScriptHelper API usage
58
- node examples/scripts/custom_script_helper_example.js
59
-
60
- # Complete test suite for all script types
61
- node examples/scripts/custom_script_signature_test.js
62
- ```
63
-
64
- ### Preimage Tools
65
- ```bash
66
- # Extract any BIP-143 preimage field with CompactSize varint support
67
- node examples/preimage/extract_preimage_bidirectional.js <preimage_hex> <field_name>
68
-
69
- # Generate test preimages with different varint sizes
70
- node examples/preimage/generate_sample_preimage.js [standard|multisig|large|huge]
71
-
72
- # Demonstrate SIGHASH flag "zero hash" behavior
73
- node examples/preimage/generate_sighash_examples.js [ALL_FORKID|NONE_FORKID|ALL_ANYONECANPAY_FORKID]
74
-
75
- # Test CompactSize varint extraction
76
- node examples/preimage/test_varint_extraction.js
77
-
78
- # Examples
79
- node examples/preimage/extract_preimage_bidirectional.js 01000000ab... scriptLen # Show varint
80
- node examples/preimage/extract_preimage_bidirectional.js 01000000ab... hashPrevouts # Detect zeros
81
- ```
82
-
83
- ## 📖 Learning Path
84
-
85
- ### 1. Start with Basic Examples
86
- Begin with transaction creation and UTXO management to understand the foundation:
87
- - Learn ultra-low fee configuration (0.01 sats/byte)
88
- - Understand UTXO state management and change outputs
89
- - Master manual signature creation for custom scripts
90
-
91
- ### 2. Explore Custom Scripts
92
- Move to custom script development for advanced Bitcoin patterns:
93
- - Multi-signature scripts (m-of-n schemes)
94
- - Timelock contracts (block height and timestamp constraints)
95
- - Conditional scripts with branching logic
96
- - Template system for rapid development
97
-
98
- ### 3. Understand BIP-143 Preimage Structure
99
- Learn the foundation of covenant development with preimage tools:
100
- - Extract and analyze transaction preimage fields
101
- - Understand bidirectional parsing strategies (left vs right extraction)
102
- - Generate optimal Bitcoin Script ASM for field extraction
103
- - Master dynamic scriptCode handling with variable lengths
104
-
105
- ### 4. Master Covenant Framework
106
- Dive into the advanced covenant framework for enterprise applications:
107
- - BIP143 preimage parsing with field-by-field access
108
- - nChain PUSHTX techniques for in-script signature generation
109
- - Perpetually Enforcing Locking Scripts (PELS) for ongoing rule enforcement
110
- - Transaction introspection and validation patterns
111
-
112
- ## 🔧 Example Categories
113
-
114
- ### Transaction Management
115
- ```javascript
116
- // Ultra-low fee configuration
117
- const tx = new bsv.Transaction()
118
- .from(utxo)
119
- .to(address, amount)
120
- .feePerKb(10); // 0.01 sats/byte (91% reduction)
121
- ```
122
-
123
- ### Custom Script Patterns
124
- ```javascript
125
- // Multi-signature script
126
- const helper = new CustomScriptHelper();
127
- const multisig = helper.createMultisigScript([pk1, pk2, pk3], 2);
128
-
129
- // Timelock script
130
- const timelock = helper.createTimelockScript(publicKey, 750000, 'block');
131
- ```
132
-
133
- ### Advanced Covenants
134
- ```javascript
135
- // PUSHTX covenant with nChain techniques
136
- const covenant = new CovenantInterface();
137
- const pushtx = covenant.createAdvancedCovenant('pushtx', {
138
- publicKey: publicKey,
139
- enforceOutputs: true
140
- });
141
-
142
- // Perpetual covenant (PELS)
143
- const pels = covenant.createAdvancedCovenant('perpetual', {
144
- publicKeyHash: pubkeyHash,
145
- feeDeduction: 512,
146
- enforceScript: true
147
- });
148
- ```
149
-
150
- ## 🔍 Key Features Demonstrated
151
-
152
- ### Core Library Features
153
- - ✅ Complete BSV API compatibility
154
- - ✅ Ultra-low fee system (0.01 sats/byte)
155
- - ✅ Advanced UTXO management
156
- - ✅ CDN bundle usage
157
- - ✅ Enhanced error handling
158
-
159
- ### Covenant Framework Features
160
- - 🔒 BIP143 preimage parsing with field accessors
161
- - 🔒 nChain PUSHTX in-script signature generation
162
- - 🔒 Perpetually Enforcing Locking Scripts (PELS)
163
- - 🔒 Transaction introspection capabilities
164
- - 🔒 Dual-level API (abstractions + granular control)
165
-
166
- ### Custom Script Features
167
- - 🛠️ Multi-signature scripts (m-of-n)
168
- - 🛠️ Timelock contracts (height/timestamp)
169
- - 🛠️ Conditional branching logic
170
- - 🛠️ Template system for common patterns
171
- - 🛠️ Simplified developer API
172
-
173
- ## 📚 Related Documentation
174
-
175
- - **[Advanced Covenant Development Guide](../docs/ADVANCED_COVENANT_DEVELOPMENT.md)**: Complete BIP143 + PUSHTX techniques
176
- - **[Custom Script Development Guide](../docs/CUSTOM_SCRIPT_DEVELOPMENT.md)**: Script creation patterns
177
- - **[Covenant Development Resolved](../docs/COVENANT_DEVELOPMENT_RESOLVED.md)**: Problem solutions
178
- - **[Main README](../README.md)**: Project overview and quick start
179
-
180
- ## 🤝 Contributing Examples
181
-
182
- To contribute new examples:
183
-
184
- 1. Follow the directory structure (`basic/`, `covenants/`, `scripts/`)
185
- 2. Include comprehensive comments explaining each step
186
- 3. Provide both working examples and error handling
187
- 4. Add corresponding documentation links
188
- 5. Test examples with multiple scenarios
189
-
190
- ## 🔐 Security Notes
191
-
192
- All examples follow security best practices:
193
- - Parameter validation and error handling
194
- - Canonical signature enforcement
195
- - Proper preimage structure validation
196
- - Production-ready patterns with security analysis
197
-
198
- ---
199
-
200
- *These examples demonstrate SmartLedger-BSV v3.1.1+ capabilities for enterprise Bitcoin SV development.*