smartledger-bsv 3.4.0 → 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 +400 -0
- package/README.md +112 -84
- package/SECURITY.md +88 -0
- package/bin/cli.js +13 -8
- package/bsv-anchor.min.js +12 -0
- package/bsv-covenant.min.js +8 -8
- package/bsv-didweb.min.js +12 -0
- package/bsv-gdaf.min.js +9 -9
- package/bsv-ltp.min.js +9 -9
- package/bsv-mnemonic.min.js +2 -2
- package/bsv-shamir.min.js +3 -3
- package/bsv-smartcontract.min.js +5 -5
- package/bsv-statuslist.min.js +18 -0
- package/bsv-vcjwt.min.js +12 -0
- package/bsv.bundle.js +9 -9
- package/bsv.d.ts +486 -9
- package/bsv.min.js +5 -5
- package/build/webpack.anchor.config.js +9 -13
- package/build/webpack.didweb.config.js +10 -14
- package/build/webpack.statuslist.config.js +9 -14
- package/build/webpack.vcjwt.config.js +9 -13
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +61 -58
- package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +3 -3
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +30 -30
- package/docs/getting-started/QUICK_START.md +18 -18
- package/docs/migration/FROM_BSV_1_5_6.md +16 -10
- package/gdaf-entry.js +1 -2
- package/index.js +44 -13
- package/lib/browser-utxo-manager-es5.js +11 -4
- package/lib/browser-utxo-manager.js +15 -8
- package/lib/ltp/claim.js +1 -0
- package/lib/ltp/obligation.js +1 -0
- package/lib/ltp/registry.js +2 -0
- package/lib/ltp/right.js +1 -0
- package/lib/smart_contract/covenant.js +10 -1
- package/lib/smartutxo.js +20 -12
- package/lib/transaction/transaction.js +8 -1
- package/lib/util/_.js +7 -1
- package/ltp-entry.js +1 -2
- package/package.json +11 -13
- 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_core_test.js +0 -131
- 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/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/custom_script_signature_test.js +0 -344
- 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
- package/lib/smart_contract/test_integration.js +0 -269
- package/tests/browser-compatibility/README.md +0 -35
- package/tests/browser-compatibility/test-cdn-vs-local.html +0 -186
- package/tests/browser-compatibility/test-pbkdf2.html +0 -51
- package/tests/bundle-completeness-test.html +0 -131
- package/tests/bundle-demo.html +0 -476
- package/tests/smartcontract-test.html +0 -239
- package/tests/standalone-modules-test.html +0 -260
- package/tests/test.html +0 -612
- package/tests/test_builtin_verify.js +0 -117
- package/tests/test_debug_integration.js +0 -71
- package/tests/test_ecdsa_little.js +0 -70
- package/tests/test_shamir.js +0 -221
- package/tests/test_smartverify_der.js +0 -110
- package/tests/test_standalone_shamir.html +0 -83
- package/tests/unpkg-demo.html +0 -194
- package/utilities/blockchain-state.json +0 -118565
package/examples/README.md
DELETED
|
@@ -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.*
|