@smartledger/bsv 3.4.2 → 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 +336 -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 +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 +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
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SmartLedger-BSV Legal Token Protocol (LTP) - Primitives-Only Architecture Demo
|
|
3
|
-
*
|
|
4
|
-
* This demonstrates the key architectural difference:
|
|
5
|
-
* BEFORE: Library did blockchain publishing and storage
|
|
6
|
-
* AFTER: Library provides preparation primitives, external systems handle publishing
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const bsv = require('../index.js')
|
|
10
|
-
|
|
11
|
-
console.log('🚀 SmartLedger-BSV LTP: Primitives-Only Architecture')
|
|
12
|
-
console.log('==================================================\n')
|
|
13
|
-
|
|
14
|
-
console.log('🔄 ARCHITECTURAL TRANSFORMATION DEMO')
|
|
15
|
-
console.log('------------------------------------\n')
|
|
16
|
-
|
|
17
|
-
// Demo keys and identities
|
|
18
|
-
const issuerPrivateKey = new bsv.PrivateKey()
|
|
19
|
-
const ownerDID = `did:bsv:${new bsv.PrivateKey().publicKey.toString()}`
|
|
20
|
-
const obligorDID = `did:bsv:${new bsv.PrivateKey().publicKey.toString()}`
|
|
21
|
-
|
|
22
|
-
console.log('📋 Participants:')
|
|
23
|
-
console.log(` Issuer DID: ${issuerPrivateKey.publicKey.toString()}`)
|
|
24
|
-
console.log(` Owner DID: ${ownerDID}`)
|
|
25
|
-
console.log(` Obligor DID: ${obligorDID}\n`)
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* DEMONSTRATE CLAIM VALIDATION PRIMITIVES
|
|
29
|
-
*/
|
|
30
|
-
console.log('1️⃣ CLAIM VALIDATION - Primitives Only')
|
|
31
|
-
console.log('=====================================')
|
|
32
|
-
|
|
33
|
-
const propertyClaimData = {
|
|
34
|
-
type: 'PropertyTitle',
|
|
35
|
-
property: {
|
|
36
|
-
address: '123 Blockchain Street',
|
|
37
|
-
parcel_id: 'BLK-2024-001',
|
|
38
|
-
property_type: 'residential'
|
|
39
|
-
},
|
|
40
|
-
owner: ownerDID
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Get available schemas (unchanged utility)
|
|
44
|
-
const availableSchemas = bsv.getClaimSchemaNames()
|
|
45
|
-
console.log('📚 Available claim schemas:', availableSchemas.join(', '))
|
|
46
|
-
|
|
47
|
-
// Create claim template (utility function)
|
|
48
|
-
const claimTemplate = bsv.createClaimTemplate('PropertyTitle')
|
|
49
|
-
console.log('📋 Claim template structure:')
|
|
50
|
-
console.log(' Required fields:', Object.keys(claimTemplate).slice(0, 3).join(', '), '...')
|
|
51
|
-
|
|
52
|
-
console.log('\n🔧 PRIMITIVES-ONLY APPROACH:')
|
|
53
|
-
console.log(' ✅ Library validates claim structure')
|
|
54
|
-
console.log(' ✅ Library provides canonicalization')
|
|
55
|
-
console.log(' ✅ Library generates claim hash')
|
|
56
|
-
console.log(' ❌ Library does NOT store claims')
|
|
57
|
-
console.log(' ❌ Library does NOT publish to blockchain')
|
|
58
|
-
|
|
59
|
-
// Demonstrate claim processing primitives
|
|
60
|
-
const claimHash = bsv.hashClaim(propertyClaimData)
|
|
61
|
-
const canonicalClaim = bsv.canonicalizeClaim(propertyClaimData)
|
|
62
|
-
|
|
63
|
-
console.log('📊 Claim processing results:')
|
|
64
|
-
console.log(` Claim Hash: ${claimHash}`)
|
|
65
|
-
console.log(` Canonical Form: ${canonicalClaim.length} bytes`)
|
|
66
|
-
console.log('')
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* DEMONSTRATE RIGHT TOKEN PRIMITIVES
|
|
70
|
-
*/
|
|
71
|
-
console.log('2️⃣ RIGHT TOKEN - Preparation Primitives')
|
|
72
|
-
console.log('=======================================')
|
|
73
|
-
|
|
74
|
-
console.log('🔧 PRIMITIVES-ONLY APPROACH:')
|
|
75
|
-
|
|
76
|
-
// Get available right types
|
|
77
|
-
const rightTypes = bsv.getRightTypes()
|
|
78
|
-
console.log('⚖️ Available right types:', Object.keys(rightTypes).slice(0, 4).join(', '), '...')
|
|
79
|
-
|
|
80
|
-
// Prepare right token (doesn't create, just prepares structure)
|
|
81
|
-
try {
|
|
82
|
-
const rightTokenPrep = bsv.prepareRightToken(
|
|
83
|
-
'PROPERTY_OWNERSHIP',
|
|
84
|
-
`did:bsv:${issuerPrivateKey.publicKey.toString()}`,
|
|
85
|
-
ownerDID,
|
|
86
|
-
propertyClaimData,
|
|
87
|
-
issuerPrivateKey,
|
|
88
|
-
{
|
|
89
|
-
jurisdiction: 'demo_jurisdiction',
|
|
90
|
-
validUntil: '2034-01-15'
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
console.log('🏠 Right token prepared:')
|
|
95
|
-
console.log(` Token ID: ${rightTokenPrep.tokenId}`)
|
|
96
|
-
console.log(` Right Type: ${rightTokenPrep.rightType}`)
|
|
97
|
-
console.log(` Valid Until: ${rightTokenPrep.validUntil}`)
|
|
98
|
-
console.log(` Jurisdiction: ${rightTokenPrep.jurisdiction}`)
|
|
99
|
-
|
|
100
|
-
// Prepare verification data
|
|
101
|
-
const verificationPrep = bsv.prepareRightTokenVerification(rightTokenPrep.token)
|
|
102
|
-
console.log(` Verification Ready: ${verificationPrep.isValid ? 'YES' : 'NO'}`)
|
|
103
|
-
|
|
104
|
-
console.log('\n ✅ Library prepares token structure')
|
|
105
|
-
console.log(' ✅ Library validates token format')
|
|
106
|
-
console.log(' ✅ Library signs token data')
|
|
107
|
-
console.log(' ❌ Library does NOT publish to blockchain')
|
|
108
|
-
console.log(' ❌ Library does NOT store in registry')
|
|
109
|
-
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.log('⚠️ Right token preparation demo skipped (module loading)')
|
|
112
|
-
console.log(' Expected: Token preparation without blockchain publishing')
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
console.log('')
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* DEMONSTRATE OBLIGATION PRIMITIVES
|
|
119
|
-
*/
|
|
120
|
-
console.log('3️⃣ OBLIGATION TOKEN - Management Primitives')
|
|
121
|
-
console.log('===========================================')
|
|
122
|
-
|
|
123
|
-
console.log('🔧 PRIMITIVES-ONLY APPROACH:')
|
|
124
|
-
|
|
125
|
-
// Get obligation types and statuses
|
|
126
|
-
try {
|
|
127
|
-
const obligationTypes = bsv.getObligationTypes()
|
|
128
|
-
const obligationStatuses = bsv.getObligationStatus()
|
|
129
|
-
|
|
130
|
-
console.log('📊 Obligation framework:')
|
|
131
|
-
console.log(` Types available: ${Object.keys(obligationTypes).length}`)
|
|
132
|
-
console.log(` Status options: ${Object.keys(obligationStatuses).length}`)
|
|
133
|
-
console.log(` Priority levels: ${Object.keys(bsv.getObligationPriority()).length}`)
|
|
134
|
-
|
|
135
|
-
console.log('\n ✅ Library prepares obligation tokens')
|
|
136
|
-
console.log(' ✅ Library validates fulfillment data')
|
|
137
|
-
console.log(' ✅ Library tracks obligation status')
|
|
138
|
-
console.log(' ❌ Library does NOT execute payments')
|
|
139
|
-
console.log(' ❌ Library does NOT enforce obligations')
|
|
140
|
-
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.log('⚠️ Obligation demo skipped (module loading)')
|
|
143
|
-
console.log(' Expected: Obligation management without execution')
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
console.log('')
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* DEMONSTRATE REGISTRY PRIMITIVES
|
|
150
|
-
*/
|
|
151
|
-
console.log('4️⃣ REGISTRY MANAGEMENT - Preparation Primitives')
|
|
152
|
-
console.log('===============================================')
|
|
153
|
-
|
|
154
|
-
console.log('🔧 PRIMITIVES-ONLY APPROACH:')
|
|
155
|
-
console.log(' ✅ Library prepares registry data structures')
|
|
156
|
-
console.log(' ✅ Library formats token registration data')
|
|
157
|
-
console.log(' ✅ Library validates registry queries')
|
|
158
|
-
console.log(' ❌ Library does NOT store registry data')
|
|
159
|
-
console.log(' ❌ Library does NOT manage database connections')
|
|
160
|
-
|
|
161
|
-
// Simulate registry preparation
|
|
162
|
-
console.log('📝 Registry operations prepared:')
|
|
163
|
-
console.log(' • Token registration data formatted')
|
|
164
|
-
console.log(' • Search query structure validated')
|
|
165
|
-
console.log(' • Audit log format prepared')
|
|
166
|
-
console.log(' • Statistics query template ready')
|
|
167
|
-
console.log('')
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* DEMONSTRATE BLOCKCHAIN ANCHORING PRIMITIVES
|
|
171
|
-
*/
|
|
172
|
-
console.log('5️⃣ BLOCKCHAIN ANCHORING - Commitment Primitives')
|
|
173
|
-
console.log('===============================================')
|
|
174
|
-
|
|
175
|
-
console.log('🔧 PRIMITIVES-ONLY APPROACH:')
|
|
176
|
-
console.log(' ✅ Library prepares commitment hashes')
|
|
177
|
-
console.log(' ✅ Library creates merkle tree structures')
|
|
178
|
-
console.log(' ✅ Library validates anchor proofs')
|
|
179
|
-
console.log(' ❌ Library does NOT publish transactions')
|
|
180
|
-
console.log(' ❌ Library does NOT manage wallet keys')
|
|
181
|
-
|
|
182
|
-
// Simulate anchor preparation
|
|
183
|
-
console.log('⛓️ Blockchain operations prepared:')
|
|
184
|
-
console.log(' • Token commitment hash: ready for transaction')
|
|
185
|
-
console.log(' • Batch merkle root: ready for efficient anchoring')
|
|
186
|
-
console.log(' • Verification proof: ready for anchor validation')
|
|
187
|
-
console.log(' • Revocation format: ready for token cancellation')
|
|
188
|
-
console.log('')
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* SUMMARY OF ARCHITECTURAL BENEFITS
|
|
192
|
-
*/
|
|
193
|
-
console.log('🎯 PRIMITIVES-ONLY ARCHITECTURE BENEFITS')
|
|
194
|
-
console.log('========================================')
|
|
195
|
-
console.log('')
|
|
196
|
-
console.log('🏗️ SEPARATION OF CONCERNS:')
|
|
197
|
-
console.log(' 📚 SmartLedger-BSV: Foundation library with crypto primitives')
|
|
198
|
-
console.log(' 🔧 External Apps: Handle UI, storage, and blockchain publishing')
|
|
199
|
-
console.log(' ⚖️ Legal Framework: Validated structure and compliance tools')
|
|
200
|
-
console.log('')
|
|
201
|
-
console.log('💪 DEVELOPER BENEFITS:')
|
|
202
|
-
console.log(' • Maximum flexibility in implementation choices')
|
|
203
|
-
console.log(' • No vendor lock-in to specific platforms or blockchains')
|
|
204
|
-
console.log(' • Clean separation between crypto/legal logic and app logic')
|
|
205
|
-
console.log(' • Easy integration with existing systems and workflows')
|
|
206
|
-
console.log('')
|
|
207
|
-
console.log('⚡ LIBRARY ADVANTAGES:')
|
|
208
|
-
console.log(' • Focused on what it does best: cryptography and validation')
|
|
209
|
-
console.log(' • Smaller footprint and fewer dependencies')
|
|
210
|
-
console.log(' • More predictable behavior and easier testing')
|
|
211
|
-
console.log(' • Clear API boundaries and responsibilities')
|
|
212
|
-
console.log('')
|
|
213
|
-
console.log('🔗 INTEGRATION PATTERN:')
|
|
214
|
-
console.log(' 1. Use SmartLedger-BSV to prepare and validate legal tokens')
|
|
215
|
-
console.log(' 2. Use external systems for blockchain publishing')
|
|
216
|
-
console.log(' 3. Use external systems for storage and registries')
|
|
217
|
-
console.log(' 4. Use external systems for user interfaces and workflows')
|
|
218
|
-
console.log('')
|
|
219
|
-
console.log('🚀 RESULT: Complete foundation for any Legal Token Protocol')
|
|
220
|
-
console.log(' application while maintaining architectural flexibility!')
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* SHOW EXAMPLE EXTERNAL SYSTEM INTEGRATION
|
|
224
|
-
*/
|
|
225
|
-
console.log('')
|
|
226
|
-
console.log('📋 EXAMPLE: How External Systems Would Use These Primitives')
|
|
227
|
-
console.log('=========================================================')
|
|
228
|
-
console.log('')
|
|
229
|
-
console.log('// External Application Code Example:')
|
|
230
|
-
console.log('const bsv = require("smartledger-bsv")')
|
|
231
|
-
console.log('const MyBlockchainAPI = require("my-blockchain-service")')
|
|
232
|
-
console.log('const MyStorage = require("my-database-service")')
|
|
233
|
-
console.log('')
|
|
234
|
-
console.log('// 1. Use SmartLedger-BSV to prepare legal token')
|
|
235
|
-
console.log('const tokenPrep = bsv.prepareRightToken(...)')
|
|
236
|
-
console.log('')
|
|
237
|
-
console.log('// 2. Use external service to publish to blockchain')
|
|
238
|
-
console.log('const txResult = await MyBlockchainAPI.publish(tokenPrep.commitment)')
|
|
239
|
-
console.log('')
|
|
240
|
-
console.log('// 3. Use external service to store token data')
|
|
241
|
-
console.log('const storeResult = await MyStorage.save(tokenPrep.token)')
|
|
242
|
-
console.log('')
|
|
243
|
-
console.log('// 4. Use SmartLedger-BSV to verify results')
|
|
244
|
-
console.log('const verification = bsv.verifyTokenAnchor(token, txResult.txid)')
|
|
245
|
-
console.log('')
|
|
246
|
-
console.log('This pattern gives developers complete control while ensuring')
|
|
247
|
-
console.log('cryptographic and legal correctness through SmartLedger-BSV!')
|