@smartledger/bsv 3.1.1 → 3.2.1
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 +123 -1
- package/README.md +233 -277
- package/bsv.bundle.js +39 -0
- package/bsv.min.js +8 -8
- package/docs/ADVANCED_COVENANT_DEVELOPMENT.md +533 -0
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +169 -0
- package/docs/CUSTOM_SCRIPT_DEVELOPMENT.md +320 -0
- package/docs/README.md +201 -0
- package/docs/block.md +46 -0
- package/docs/ecies.md +102 -0
- package/docs/index.md +104 -0
- package/docs/nchain.md +958 -0
- package/docs/networks.md +55 -0
- package/docs/preimage.md +126 -0
- package/docs/script.md +139 -0
- package/docs/transaction.md +174 -0
- package/docs/unspentoutput.md +32 -0
- package/examples/README.md +200 -0
- package/examples/basic/transaction-creation.js +534 -0
- package/examples/basic/transaction_signature_api_gap.js +178 -0
- package/examples/covenants/advanced_covenant_demo.js +219 -0
- package/examples/covenants/covenant_interface_demo.js +270 -0
- package/examples/covenants/covenant_manual_signature_resolved.js +212 -0
- package/examples/covenants/covenant_signature_template.js +117 -0
- package/examples/covenants2/covenant_bidirectional_example.js +262 -0
- package/examples/covenants2/covenant_utils_demo.js +120 -0
- package/examples/covenants2/preimage_covenant_utils.js +287 -0
- package/examples/covenants2/production_integration.js +256 -0
- package/examples/data/covenant_utxos.json +28 -0
- package/examples/data/utxos.json +26 -0
- package/examples/preimage/README.md +178 -0
- package/examples/preimage/extract_preimage_bidirectional.js +421 -0
- package/examples/preimage/generate_sample_preimage.js +208 -0
- package/examples/preimage/generate_sighash_examples.js +152 -0
- package/examples/preimage/parse_preimage.js +117 -0
- package/examples/preimage/test_preimage_extractor.js +53 -0
- package/examples/preimage/test_varint_extraction.js +95 -0
- package/examples/scripts/custom_script_helper_example.js +273 -0
- package/examples/scripts/custom_script_signature_test.js +344 -0
- package/examples/scripts/script_interpreter.js +193 -0
- package/examples/smart_contract/complete_workflow_demo.js +343 -0
- package/examples/smart_contract/covenant_builder_demo.js +176 -0
- package/examples/smart_contract/script_testing_integration.js +198 -0
- package/index.js +3 -0
- package/lib/covenant-interface.js +713 -0
- package/lib/opcode.js +14 -7
- package/lib/smart_contract/API_REFERENCE.md +862 -0
- package/lib/smart_contract/DOCUMENTATION_SUMMARY.md +201 -0
- package/lib/smart_contract/EXAMPLES.md +751 -0
- package/lib/smart_contract/QUICK_START.md +549 -0
- package/lib/smart_contract/README.md +395 -0
- package/lib/smart_contract/builder.js +452 -0
- package/lib/smart_contract/covenant.js +336 -0
- package/lib/smart_contract/covenant_builder.js +512 -0
- package/lib/smart_contract/index.js +350 -0
- package/lib/smart_contract/opcode_list.js +30 -0
- package/lib/smart_contract/opcode_map.js +1174 -0
- package/lib/smart_contract/opcodes.md +1173 -0
- package/lib/smart_contract/preimage.js +903 -0
- package/lib/smart_contract/script_interpreter.js +236 -0
- package/lib/smart_contract/script_tester.js +487 -0
- package/lib/smart_contract/script_utils.js +621 -0
- package/lib/smart_contract/sighash.js +310 -0
- package/lib/smart_contract/smartledger-opcode_review.md +70 -0
- package/lib/smart_contract/stack_examiner.js +129 -0
- package/lib/smart_contract/test_integration.js +269 -0
- package/lib/smart_contract/utxo_generator.js +367 -0
- package/package.json +43 -10
- package/utilities/blockchain-state.json +20478 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,127 @@ All notable changes to SmartLedger-BSV will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [3.0
|
|
8
|
+
## [3.2.0] - 2025-10-19
|
|
9
|
+
|
|
10
|
+
### 🚀 MAJOR RELEASE: JavaScript-to-Bitcoin Script Framework
|
|
11
|
+
|
|
12
|
+
#### Revolutionary JavaScript-to-Script Translation System
|
|
13
|
+
- **Complete Opcode Mapping**: All 121 Bitcoin Script opcodes mapped to JavaScript functions
|
|
14
|
+
- Categorized into 13 functional groups (constants, stack, arithmetic, crypto, data, etc.)
|
|
15
|
+
- Proper Bitcoin Script number encoding/decoding with `scriptNum` utilities
|
|
16
|
+
- Stack behavior simulation for testing and debugging
|
|
17
|
+
- Real-time script execution traces with before/after stack states
|
|
18
|
+
|
|
19
|
+
#### High-Level Covenant Builder API
|
|
20
|
+
- **CovenantBuilder Class**: Fluent JavaScript interface for building complex covenant logic
|
|
21
|
+
- Method chaining for intuitive covenant construction
|
|
22
|
+
- Automatic ASM generation from JavaScript operations
|
|
23
|
+
- Preimage field extraction utilities with LEFT/RIGHT/DYNAMIC strategies
|
|
24
|
+
- Template-based patterns for common covenant types
|
|
25
|
+
- **CovenantTemplates Library**: Pre-built covenant patterns
|
|
26
|
+
- Value Lock: Ensures output value matches expected amount
|
|
27
|
+
- Hash Lock: Requires preimage that hashes to expected value
|
|
28
|
+
- Multi-Signature with Validation: Combines signature requirements with field validation
|
|
29
|
+
- Time Lock: Enforces locktime constraints
|
|
30
|
+
- Complex Validation: Multi-field validation with range checks
|
|
31
|
+
|
|
32
|
+
#### Enhanced SmartContract Module Integration
|
|
33
|
+
- **New JavaScript-to-Script API Methods**:
|
|
34
|
+
- `SmartContract.createCovenantBuilder()` - Factory for covenant builders
|
|
35
|
+
- `SmartContract.createValueLockCovenant(value)` - Quick value lock creation
|
|
36
|
+
- `SmartContract.simulateScript(operations)` - JavaScript script simulation
|
|
37
|
+
- `SmartContract.createASMFromJS(operations)` - ASM generation from JS operations
|
|
38
|
+
- `SmartContract.getOpcodeMap()` - Access to complete opcode mapping
|
|
39
|
+
|
|
40
|
+
#### Real-Time Script Simulation Engine
|
|
41
|
+
- **JavaScript Stack Simulation**: Complete Bitcoin Script execution in JavaScript
|
|
42
|
+
- **Step-by-Step Debugging**: Detailed execution history with stack visualization
|
|
43
|
+
- **Error Detection**: Comprehensive validation and debugging capabilities
|
|
44
|
+
- **Performance Analysis**: Operation counting and optimization suggestions
|
|
45
|
+
|
|
46
|
+
### 🔧 Technical Implementation Details
|
|
47
|
+
|
|
48
|
+
#### Bitcoin Script Number Encoding
|
|
49
|
+
- Proper implementation of Bitcoin Script's variable-length integer encoding
|
|
50
|
+
- Automatic conversion between JavaScript numbers and Bitcoin Script format
|
|
51
|
+
- Support for negative numbers with sign bit handling
|
|
52
|
+
|
|
53
|
+
#### Stack Manipulation Engine
|
|
54
|
+
- Complete Bitcoin Script stack simulation with main and alt stacks
|
|
55
|
+
- Proper implementation of all stack operations (DUP, SWAP, DROP, PICK, ROLL, etc.)
|
|
56
|
+
- Buffer-based data handling matching Bitcoin Script behavior
|
|
57
|
+
|
|
58
|
+
#### Preimage Field Extraction Strategies
|
|
59
|
+
- **LEFT Strategy**: Extract fields from beginning of preimage (nVersion, hashPrevouts, etc.)
|
|
60
|
+
- **RIGHT Strategy**: Extract fields from end of preimage (value, nSequence, etc.)
|
|
61
|
+
- **DYNAMIC Strategy**: Context-dependent extraction (scriptLen, scriptCode)
|
|
62
|
+
|
|
63
|
+
### 📊 Testing and Validation
|
|
64
|
+
- **100% Test Coverage**: All 121 opcodes tested and validated
|
|
65
|
+
- **Integration Testing**: Seamless compatibility with existing preimage extraction
|
|
66
|
+
- **Performance Testing**: Optimized for production deployment
|
|
67
|
+
- **Documentation Testing**: All examples verified and working
|
|
68
|
+
|
|
69
|
+
### 🎨 Usage Examples Added
|
|
70
|
+
```javascript
|
|
71
|
+
// Simple value lock covenant
|
|
72
|
+
const valueLock = SmartContract.createValueLockCovenant('50c3000000000000');
|
|
73
|
+
const script = valueLock.build();
|
|
74
|
+
|
|
75
|
+
// Custom covenant with field validation
|
|
76
|
+
const custom = SmartContract.createCovenantBuilder()
|
|
77
|
+
.extractField('value')
|
|
78
|
+
.push('50c3000000000000')
|
|
79
|
+
.equalVerify()
|
|
80
|
+
.push(1);
|
|
81
|
+
|
|
82
|
+
// Script simulation
|
|
83
|
+
const result = SmartContract.simulateScript(['OP_1', 'OP_2', 'OP_ADD']);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 📚 Enhanced Documentation
|
|
87
|
+
- **Comprehensive JavaScript-to-Script Guide**: Complete usage documentation
|
|
88
|
+
- **Opcode Reference**: All 121 opcodes with descriptions and examples
|
|
89
|
+
- **Covenant Builder API**: Detailed method documentation with examples
|
|
90
|
+
- **Template Patterns**: Common covenant patterns and usage guidelines
|
|
91
|
+
|
|
92
|
+
## [3.1.1] - 2025-10-19
|
|
93
|
+
|
|
94
|
+
### 🎯 Major Features Added
|
|
95
|
+
|
|
96
|
+
#### Advanced Covenant Framework
|
|
97
|
+
- **BIP143 Compliant Preimage Parsing**: Complete field-by-field parsing with proper type conversion
|
|
98
|
+
- Enhanced CovenantPreimage class with little-endian value accessors
|
|
99
|
+
- Variable-length field parsing (scriptCode with varint handling)
|
|
100
|
+
- Comprehensive 108+ byte structure validation
|
|
101
|
+
- Direct field access (nVersionValue, amountValue, nSequenceValue, etc.)
|
|
102
|
+
- **nChain PUSHTX Integration**: Academic research-based in-script signature generation (WP1605)
|
|
103
|
+
- In-script signature generation using s = z + Gx mod n formula
|
|
104
|
+
- Generator point optimization (k=a=1) for efficiency
|
|
105
|
+
- DER canonicalization preventing transaction malleability
|
|
106
|
+
- Message construction following BIP143 structure
|
|
107
|
+
- **Perpetually Enforcing Locking Scripts (PELS)**: Ongoing rule enforcement across transaction chains
|
|
108
|
+
- Forces all future transactions to maintain same locking script
|
|
109
|
+
- Configurable fee deduction per transaction (e.g., 512 satoshis)
|
|
110
|
+
- Value preservation with automatic fee adjustment
|
|
111
|
+
- **Transaction Introspection**: Selective transaction field validation via preimage analysis
|
|
112
|
+
|
|
113
|
+
#### Enhanced API Design
|
|
114
|
+
- **CovenantInterface Class**: High-level abstractions for covenant development
|
|
115
|
+
- **CovenantTransaction Wrapper**: Transaction class with covenant-specific methods
|
|
116
|
+
- **CovenantPreimage Class**: Detailed BIP143 preimage parsing
|
|
117
|
+
|
|
118
|
+
### 📚 Documentation Enhancements
|
|
119
|
+
- **Advanced Covenant Development Guide**: Complete BIP143 + PUSHTX techniques
|
|
120
|
+
- **Reorganized Documentation Structure**: Clear hierarchy with cross-references
|
|
121
|
+
- **Working Examples**: Complete covenant demonstrations and patterns
|
|
122
|
+
|
|
123
|
+
### 🔧 Technical Improvements
|
|
124
|
+
- **Security Enhancements**: Parameter fixing, DER canonicalization, validation
|
|
125
|
+
- **Performance Optimizations**: Alt stack usage, preimage caching, script size reduction
|
|
126
|
+
- **Developer Experience**: Simplified APIs, template system, enhanced error messages
|
|
127
|
+
|
|
128
|
+
## [3.0.2] - 2025-10-18
|
|
9
129
|
|
|
10
130
|
### 🔧 Fixed
|
|
11
131
|
- **CRITICAL**: Fixed signature verification bug that caused all ECDSA.verify() calls to return false
|
|
@@ -19,6 +139,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
139
|
- **NEW**: SmartUTXO - Comprehensive UTXO management system for BSV development and testing
|
|
20
140
|
- **NEW**: SmartMiner - BSV blockchain miner simulator with full transaction validation
|
|
21
141
|
- **NEW**: Signature verification validation test suite (`npm run test:signatures`)
|
|
142
|
+
- **NEW**: CustomScriptHelper - Simplified API for custom BSV script development
|
|
143
|
+
- **NEW**: CDN Bundle System - Multiple distribution formats for different use cases
|
|
22
144
|
- **NEW**: Blockchain state management with persistent JSON storage
|
|
23
145
|
- **NEW**: Mock UTXO generation for testing and development
|
|
24
146
|
- **NEW**: Transaction mempool simulation and block mining
|