smartledger-bsv 3.3.2 → 3.3.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 (118) hide show
  1. package/CHANGELOG.md +220 -79
  2. package/README.md +283 -71
  3. package/bsv-covenant.min.js +26 -3
  4. package/bsv-gdaf.min.js +11 -9
  5. package/bsv-ltp.min.js +10 -8
  6. package/bsv-mnemonic.min.js +4 -4
  7. package/bsv-script-helper.min.js +2 -2
  8. package/bsv-security.min.js +3 -24
  9. package/bsv-shamir.min.js +2 -2
  10. package/bsv-smartcontract.min.js +10 -8
  11. package/bsv.bundle.js +9 -9
  12. package/bsv.min.js +10 -8
  13. package/build/webpack.bundle.config.js +2 -2
  14. package/build/webpack.config.js +2 -2
  15. package/build/webpack.covenant.config.js +2 -2
  16. package/build/webpack.gdaf.config.js +6 -43
  17. package/build/webpack.script-helper.config.js +2 -2
  18. package/build/webpack.security.config.js +2 -2
  19. package/build/webpack.smartcontract.config.js +2 -2
  20. package/bundle-entry.js +1 -341
  21. package/covenant-entry.js +1 -44
  22. package/demos/README.md +188 -0
  23. package/{architecture_demo.js → demos/architecture_demo.js} +2 -2
  24. package/demos/bsv_wallet_demo.js +242 -0
  25. package/{complete_ltp_demo.js → demos/complete_ltp_demo.js} +1 -1
  26. package/demos/debug_tools_demo.js +87 -0
  27. package/demos/demo_features.js +123 -0
  28. package/demos/easy_interface_demo.js +109 -0
  29. package/demos/ecies_demo.js +182 -0
  30. package/demos/gdaf_core_test.js +131 -0
  31. package/demos/gdaf_demo.js +237 -0
  32. package/demos/ltp_demo.js +361 -0
  33. package/demos/ltp_primitives_demo.js +403 -0
  34. package/demos/message_demo.js +209 -0
  35. package/demos/preimage_separation_demo.js +383 -0
  36. package/demos/script_helper_demo.js +289 -0
  37. package/demos/security_demo.js +287 -0
  38. package/{shamir_demo.js → demos/shamir_demo.js} +1 -1
  39. package/{simple_demo.js → demos/simple_demo.js} +1 -1
  40. package/demos/simple_p2pkh_demo.js +169 -0
  41. package/demos/simple_utxo_preimage_demo.js +196 -0
  42. package/demos/smart_contract_demo.html +1347 -0
  43. package/demos/smart_contract_demo.js +910 -0
  44. package/demos/utxo_generator_demo.js +244 -0
  45. package/demos/validation_pipeline_demo.js +155 -0
  46. package/demos/web3keys.html +740 -0
  47. package/docs/BUNDLE_UPDATE_SUMMARY.md +40 -0
  48. package/docs/DOCUMENTATION_REVIEW_REPORT.md +295 -0
  49. package/docs/FIX_CREATEHMAC_ISSUE.md +91 -0
  50. package/docs/MODULE_REFERENCE_COMPLETE.md +330 -0
  51. package/docs/README.md +107 -79
  52. package/docs/SMARTLEDGER_BSV_USAGE_ANSWERS.md +477 -0
  53. package/docs/SMARTLEDGER_BSV_USAGE_EXAMPLES.js +372 -0
  54. package/docs/SMARTLEDGER_BSV_USAGE_GUIDE.md +555 -0
  55. package/docs/SMART_CONTRACT_DEVELOPMENT_GUIDE.md +1459 -0
  56. package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +411 -0
  57. package/docs/advanced/SMART_CONTRACT_GUIDE.md +1255 -0
  58. package/docs/advanced/UTXO_MANAGER_GUIDE.md +851 -0
  59. package/docs/api/LTP.md +334 -0
  60. package/docs/getting-started/INSTALLATION.md +410 -0
  61. package/docs/getting-started/QUICK_START.md +180 -0
  62. package/docs/migration/FROM_BSV_1_5_6.md +260 -0
  63. package/docs/technical/GDAF_DEVELOPER_INTERFACE.md +187 -0
  64. package/docs/technical/GDAF_IMPLEMENTATION_COMPLETE.md +190 -0
  65. package/docs/technical/SHAMIR_INTEGRATION_SUMMARY.md +165 -0
  66. package/docs/technical/roadmap.md +1250 -0
  67. package/docs/technical/trust_law.md +142 -0
  68. package/examples/complete_workflow_demo.js +783 -0
  69. package/examples/definitive_working_demo.js +261 -0
  70. package/examples/final_working_contracts.js +338 -0
  71. package/examples/smart_contract_templates.js +718 -0
  72. package/examples/working_smart_contracts.js +348 -0
  73. package/gdaf-entry.js +2 -54
  74. package/index.js +32 -0
  75. package/lib/mnemonic/pbkdf2.browser.js +69 -0
  76. package/lib/mnemonic/pbkdf2.js +2 -68
  77. package/lib/mnemonic/pbkdf2.node.js +68 -0
  78. package/ltp-entry.js +2 -92
  79. package/package.json +21 -8
  80. package/script-helper-entry.js +1 -49
  81. package/security-entry.js +1 -70
  82. package/shamir-entry.js +1 -173
  83. package/smartcontract-entry.js +1 -133
  84. package/tests/browser-compatibility/README.md +35 -0
  85. package/tests/browser-compatibility/test-cdn-vs-local.html +186 -0
  86. package/tests/browser-compatibility/test-pbkdf2.html +51 -0
  87. package/tests/test_builtin_verify.js +117 -0
  88. package/tests/test_debug_integration.js +71 -0
  89. package/tests/test_ecdsa_little.js +70 -0
  90. package/tests/test_smartverify_der.js +110 -0
  91. package/utilities/blockchain-state.js +155 -155
  92. package/utilities/blockchain-state.json +103293 -5244
  93. package/utilities/miner-simulator.js +354 -358
  94. package/utilities/mock-utxo-generator.js +54 -54
  95. package/utilities/raw-tx-examples.js +120 -122
  96. package/utilities/success-demo.js +104 -105
  97. package/utilities/transaction-examples.js +188 -188
  98. package/utilities/utxo-manager.js +91 -91
  99. package/utilities/wallet-setup.js +79 -80
  100. package/utilities/working-signature-demo.js +108 -110
  101. package/SECURITY.md +0 -75
  102. package/build/bsv-covenant.min.js +0 -10
  103. package/build/bsv-script-helper.min.js +0 -10
  104. package/build/bsv-security.min.js +0 -31
  105. package/build/bsv-smartcontract.min.js +0 -39
  106. package/build/bsv.bundle.js +0 -39
  107. package/build/bsv.min.js +0 -39
  108. package/validation_test.js +0 -97
  109. /package/docs/{ADVANCED_COVENANT_DEVELOPMENT.md → advanced/ADVANCED_COVENANT_DEVELOPMENT.md} +0 -0
  110. /package/docs/{CUSTOM_SCRIPT_DEVELOPMENT.md → advanced/CUSTOM_SCRIPT_DEVELOPMENT.md} +0 -0
  111. /package/docs/{block.md → api/BLOCKS.md} +0 -0
  112. /package/docs/{ecies.md → api/ECIES.md} +0 -0
  113. /package/docs/{networks.md → api/NETWORKS.md} +0 -0
  114. /package/docs/{script.md → api/SCRIPTS.md} +0 -0
  115. /package/docs/{transaction.md → api/TRANSACTIONS.md} +0 -0
  116. /package/docs/{unspentoutput.md → api/UTXO.md} +0 -0
  117. /package/{test_shamir.js → tests/test_shamir.js} +0 -0
  118. /package/{test_standalone_shamir.html → tests/test_standalone_shamir.html} +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * 🔄 BSV Transaction Examples
5
- *
5
+ *
6
6
  * Demonstrates the complete transaction flow:
7
7
  * 1. Create transaction
8
8
  * 2. Broadcast to miner
@@ -10,53 +10,53 @@
10
10
  * 4. UTXO set updates
11
11
  */
12
12
 
13
- const bsv = require('../index.js');
14
- const fs = require('fs');
15
- const path = require('path');
13
+ const bsv = require('../index.js')
14
+ // const fs = require('fs') // Currently unused
15
+ // const path = require('path') // Currently unused
16
16
 
17
17
  // Import our utilities
18
- const {
19
- loadBlockchainState,
18
+ const {
19
+ // loadBlockchainState, // Currently unused
20
20
  importWalletFromFile,
21
- getBlockchainStats
22
- } = require('./blockchain-state');
23
- const {
24
- acceptTransaction,
25
- getMempoolStatus
26
- } = require('./miner-simulator');
21
+ getBlockchainStats
22
+ } = require('./blockchain-state')
23
+ const {
24
+ acceptTransaction,
25
+ getMempoolStatus
26
+ } = require('./miner-simulator')
27
27
  const {
28
28
  loadConfig,
29
29
  updateUTXOFromTransaction
30
- } = require('./utxo-manager');
30
+ } = require('./utxo-manager')
31
31
 
32
32
  /**
33
33
  * Initialize the blockchain with our test wallet
34
34
  */
35
- async function initializeBlockchain() {
36
- console.log('🚀 Initializing blockchain with test wallet...\n');
37
-
35
+ async function initializeBlockchain () {
36
+ console.log('🚀 Initializing blockchain with test wallet...\n')
37
+
38
38
  // Import wallet from wallet.json into blockchain state
39
- const imported = importWalletFromFile();
40
-
39
+ const imported = importWalletFromFile()
40
+
41
41
  if (!imported) {
42
- console.log('❌ Failed to import wallet. Run wallet-setup.js first!');
43
- return false;
42
+ console.log('❌ Failed to import wallet. Run wallet-setup.js first!')
43
+ return false
44
44
  }
45
-
46
- console.log('');
47
- getBlockchainStats();
48
- return true;
45
+
46
+ console.log('')
47
+ getBlockchainStats()
48
+ return true
49
49
  }
50
50
 
51
51
  /**
52
52
  * Create a simple P2PKH transaction
53
53
  */
54
- function createSimpleTransaction(fromAddress, toAddress, amount, privateKey, utxo) {
55
- console.log(`\n💸 Creating P2PKH transaction:`);
56
- console.log(`From: ${fromAddress}`);
57
- console.log(`To: ${toAddress}`);
58
- console.log(`Amount: ${amount} satoshis\n`);
59
-
54
+ function createSimpleTransaction (fromAddress, toAddress, amount, privateKey, utxo) {
55
+ console.log(`\n💸 Creating P2PKH transaction:`)
56
+ console.log(`From: ${fromAddress}`)
57
+ console.log(`To: ${toAddress}`)
58
+ console.log(`Amount: ${amount} satoshis\n`)
59
+
60
60
  try {
61
61
  // Create transaction with proper SIGHASH_FORKID
62
62
  const tx = new bsv.Transaction()
@@ -64,173 +64,173 @@ function createSimpleTransaction(fromAddress, toAddress, amount, privateKey, utx
64
64
  .to(toAddress, amount)
65
65
  .change(fromAddress)
66
66
  .fee(1000) // 1000 sat fee
67
- .sign(privateKey, bsv.crypto.Signature.SIGHASH_ALL | bsv.crypto.Signature.SIGHASH_FORKID);
68
-
69
- console.log(`✅ Transaction created: ${tx.id}`);
70
- console.log(`Inputs: ${tx.inputs.length}`);
71
- console.log(`Outputs: ${tx.outputs.length}`);
72
- console.log(`Fee: ${tx.getFee()} satoshis\n`);
73
-
74
- return tx;
67
+ .sign(privateKey, bsv.crypto.Signature.SIGHASH_ALL | bsv.crypto.Signature.SIGHASH_FORKID)
68
+
69
+ console.log(`✅ Transaction created: ${tx.id}`)
70
+ console.log(`Inputs: ${tx.inputs.length}`)
71
+ console.log(`Outputs: ${tx.outputs.length}`)
72
+ console.log(`Fee: ${tx.getFee()} satoshis\n`)
73
+
74
+ return tx
75
75
  } catch (error) {
76
- console.error('❌ Error creating transaction:', error.message);
77
- return null;
76
+ console.error('❌ Error creating transaction:', error.message)
77
+ return null
78
78
  }
79
79
  }
80
80
 
81
81
  /**
82
82
  * Example 1: Simple P2PKH payment
83
83
  */
84
- async function exampleSimplePayment() {
85
- console.log('\n' + '='.repeat(80));
86
- console.log('📝 EXAMPLE 1: Simple P2PKH Payment');
87
- console.log('='.repeat(80));
88
-
84
+ async function exampleSimplePayment () {
85
+ console.log('\n' + '='.repeat(80))
86
+ console.log('📝 EXAMPLE 1: Simple P2PKH Payment')
87
+ console.log('='.repeat(80))
88
+
89
89
  // Load wallet config
90
- const config = loadConfig();
91
- const wallet = config.wallet;
92
-
90
+ const config = loadConfig()
91
+ const wallet = config.wallet
92
+
93
93
  // Create recipient address (just generate a new one for demo)
94
- const recipientKey = new bsv.PrivateKey();
95
- const recipientAddress = recipientKey.toAddress().toString();
96
-
97
- console.log(`👛 Sender: ${wallet.address}`);
98
- console.log(`🎯 Recipient: ${recipientAddress}`);
99
-
94
+ const recipientKey = new bsv.PrivateKey()
95
+ const recipientAddress = recipientKey.toAddress().toString()
96
+
97
+ console.log(`👛 Sender: ${wallet.address}`)
98
+ console.log(`🎯 Recipient: ${recipientAddress}`)
99
+
100
100
  // Use the primary UTXO
101
- const utxo = config.utxo;
102
- console.log(`💰 Using UTXO: ${utxo.txid}:${utxo.vout} (${utxo.satoshis} sats)`);
103
-
101
+ const utxo = config.utxo
102
+ console.log(`💰 Using UTXO: ${utxo.txid}:${utxo.vout} (${utxo.satoshis} sats)`)
103
+
104
104
  // Create transaction (send 15,000 sats)
105
- const amount = 15000;
105
+ const amount = 15000
106
106
  const tx = createSimpleTransaction(
107
107
  wallet.address,
108
108
  recipientAddress,
109
109
  amount,
110
110
  bsv.PrivateKey.fromWIF(wallet.privateKeyWIF),
111
111
  utxo
112
- );
113
-
112
+ )
113
+
114
114
  if (!tx) {
115
- console.log('❌ Failed to create transaction');
116
- return;
115
+ console.log('❌ Failed to create transaction')
116
+ return
117
117
  }
118
-
118
+
119
119
  // Broadcast to miner
120
- console.log('📡 Broadcasting transaction to miner...');
121
- const result = acceptTransaction(tx);
122
-
120
+ console.log('📡 Broadcasting transaction to miner...')
121
+ const result = acceptTransaction(tx)
122
+
123
123
  if (result.accepted) {
124
- console.log('\n🎉 Transaction accepted and processed!');
125
-
124
+ console.log('\n🎉 Transaction accepted and processed!')
125
+
126
126
  // Update local wallet
127
- updateUTXOFromTransaction(tx, utxo);
128
-
129
- console.log('\n📊 Updated blockchain state:');
130
- getBlockchainStats();
127
+ updateUTXOFromTransaction(tx, utxo)
128
+
129
+ console.log('\n📊 Updated blockchain state:')
130
+ getBlockchainStats()
131
131
  } else {
132
- console.log('\n❌ Transaction rejected by miner');
133
- console.log('Errors:', result.errors);
132
+ console.log('\n❌ Transaction rejected by miner')
133
+ console.log('Errors:', result.errors)
134
134
  }
135
135
  }
136
136
 
137
137
  /**
138
138
  * Example 2: Chain multiple transactions
139
139
  */
140
- async function exampleTransactionChain() {
141
- console.log('\n' + '='.repeat(80));
142
- console.log('🔗 EXAMPLE 2: Transaction Chain');
143
- console.log('='.repeat(80));
144
-
145
- const config = loadConfig();
146
- const wallet = config.wallet;
147
-
140
+ async function exampleTransactionChain () {
141
+ console.log('\n' + '='.repeat(80))
142
+ console.log('🔗 EXAMPLE 2: Transaction Chain')
143
+ console.log('='.repeat(80))
144
+
145
+ const config = loadConfig()
146
+ const wallet = config.wallet
147
+
148
148
  // Find an available UTXO for the second transaction
149
- const availableUTXOs = config.availableUTXOs || [];
150
-
149
+ const availableUTXOs = config.availableUTXOs || []
150
+
151
151
  if (availableUTXOs.length === 0) {
152
- console.log('❌ No available UTXOs for chaining. Run example 1 first.');
153
- return;
152
+ console.log('❌ No available UTXOs for chaining. Run example 1 first.')
153
+ return
154
154
  }
155
-
155
+
156
156
  // Use the first available UTXO
157
- const utxo = availableUTXOs[0];
158
- console.log(`💰 Using UTXO: ${utxo.txid}:${utxo.vout} (${utxo.satoshis} sats)`);
159
-
157
+ const utxo = availableUTXOs[0]
158
+ console.log(`💰 Using UTXO: ${utxo.txid}:${utxo.vout} (${utxo.satoshis} sats)`)
159
+
160
160
  // Create another recipient
161
- const recipientKey = new bsv.PrivateKey();
162
- const recipientAddress = recipientKey.toAddress().toString();
163
-
164
- console.log(`👛 Sender: ${wallet.address}`);
165
- console.log(`🎯 Recipient: ${recipientAddress}`);
166
-
161
+ const recipientKey = new bsv.PrivateKey()
162
+ const recipientAddress = recipientKey.toAddress().toString()
163
+
164
+ console.log(`👛 Sender: ${wallet.address}`)
165
+ console.log(`🎯 Recipient: ${recipientAddress}`)
166
+
167
167
  // Create second transaction
168
- const amount = Math.min(5000, utxo.satoshis - 1000); // Leave room for fee
168
+ const amount = Math.min(5000, utxo.satoshis - 1000) // Leave room for fee
169
169
  const tx = createSimpleTransaction(
170
170
  wallet.address,
171
171
  recipientAddress,
172
172
  amount,
173
173
  bsv.PrivateKey.fromWIF(wallet.privateKeyWIF),
174
174
  utxo
175
- );
176
-
175
+ )
176
+
177
177
  if (!tx) {
178
- console.log('❌ Failed to create transaction');
179
- return;
178
+ console.log('❌ Failed to create transaction')
179
+ return
180
180
  }
181
-
181
+
182
182
  // Broadcast to miner
183
- console.log('📡 Broadcasting transaction to miner...');
184
- const result = acceptTransaction(tx);
185
-
183
+ console.log('📡 Broadcasting transaction to miner...')
184
+ const result = acceptTransaction(tx)
185
+
186
186
  if (result.accepted) {
187
- console.log('\n🎉 Transaction accepted and processed!');
188
-
187
+ console.log('\n🎉 Transaction accepted and processed!')
188
+
189
189
  // Update local wallet
190
- updateUTXOFromTransaction(tx, utxo);
191
-
192
- console.log('\n📊 Updated blockchain state:');
193
- getBlockchainStats();
190
+ updateUTXOFromTransaction(tx, utxo)
191
+
192
+ console.log('\n📊 Updated blockchain state:')
193
+ getBlockchainStats()
194
194
  } else {
195
- console.log('\n❌ Transaction rejected by miner');
196
- console.log('Errors:', result.errors);
195
+ console.log('\n❌ Transaction rejected by miner')
196
+ console.log('Errors:', result.errors)
197
197
  }
198
198
  }
199
199
 
200
200
  /**
201
201
  * Example 3: Multi-output transaction
202
202
  */
203
- async function exampleMultiOutput() {
204
- console.log('\n' + '='.repeat(80));
205
- console.log('🎭 EXAMPLE 3: Multi-Output Transaction');
206
- console.log('='.repeat(80));
207
-
208
- const config = loadConfig();
209
- const wallet = config.wallet;
210
-
203
+ async function exampleMultiOutput () {
204
+ console.log('\n' + '='.repeat(80))
205
+ console.log('🎭 EXAMPLE 3: Multi-Output Transaction')
206
+ console.log('='.repeat(80))
207
+
208
+ const config = loadConfig()
209
+ const wallet = config.wallet
210
+
211
211
  // Find an available UTXO
212
- const availableUTXOs = config.availableUTXOs || [];
213
-
212
+ const availableUTXOs = config.availableUTXOs || []
213
+
214
214
  if (availableUTXOs.length === 0) {
215
- console.log('❌ No available UTXOs. Run example 1 first.');
216
- return;
215
+ console.log('❌ No available UTXOs. Run example 1 first.')
216
+ return
217
217
  }
218
-
218
+
219
219
  // Use the largest available UTXO
220
- const utxo = availableUTXOs.reduce((max, current) =>
220
+ const utxo = availableUTXOs.reduce((max, current) =>
221
221
  current.satoshis > max.satoshis ? current : max
222
- );
223
-
224
- console.log(`💰 Using UTXO: ${utxo.txid}:${utxo.vout} (${utxo.satoshis} sats)`);
225
-
222
+ )
223
+
224
+ console.log(`💰 Using UTXO: ${utxo.txid}:${utxo.vout} (${utxo.satoshis} sats)`)
225
+
226
226
  // Create multiple recipients
227
- const recipient1 = new bsv.PrivateKey().toAddress().toString();
228
- const recipient2 = new bsv.PrivateKey().toAddress().toString();
229
- const recipient3 = new bsv.PrivateKey().toAddress().toString();
230
-
231
- console.log(`👛 Sender: ${wallet.address}`);
232
- console.log(`🎯 Recipients: ${recipient1.slice(0, 10)}... ${recipient2.slice(0, 10)}... ${recipient3.slice(0, 10)}...`);
233
-
227
+ const recipient1 = new bsv.PrivateKey().toAddress().toString()
228
+ const recipient2 = new bsv.PrivateKey().toAddress().toString()
229
+ const recipient3 = new bsv.PrivateKey().toAddress().toString()
230
+
231
+ console.log(`👛 Sender: ${wallet.address}`)
232
+ console.log(`🎯 Recipients: ${recipient1.slice(0, 10)}... ${recipient2.slice(0, 10)}... ${recipient3.slice(0, 10)}...`)
233
+
234
234
  try {
235
235
  // Create multi-output transaction with proper SIGHASH_FORKID
236
236
  const tx = new bsv.Transaction()
@@ -240,81 +240,81 @@ async function exampleMultiOutput() {
240
240
  .to(recipient3, 5000)
241
241
  .change(wallet.address)
242
242
  .fee(1000)
243
- .sign(bsv.PrivateKey.fromWIF(wallet.privateKeyWIF), bsv.crypto.Signature.SIGHASH_ALL | bsv.crypto.Signature.SIGHASH_FORKID);
244
-
245
- console.log(`\n✅ Multi-output transaction created: ${tx.id}`);
246
- console.log(`Inputs: ${tx.inputs.length}`);
247
- console.log(`Outputs: ${tx.outputs.length}`);
248
- console.log(`Total sent: 12,000 satoshis to 3 recipients`);
249
-
243
+ .sign(bsv.PrivateKey.fromWIF(wallet.privateKeyWIF), bsv.crypto.Signature.SIGHASH_ALL | bsv.crypto.Signature.SIGHASH_FORKID)
244
+
245
+ console.log(`\n✅ Multi-output transaction created: ${tx.id}`)
246
+ console.log(`Inputs: ${tx.inputs.length}`)
247
+ console.log(`Outputs: ${tx.outputs.length}`)
248
+ console.log(`Total sent: 12,000 satoshis to 3 recipients`)
249
+
250
250
  // Broadcast to miner
251
- console.log('\n📡 Broadcasting transaction to miner...');
252
- const result = acceptTransaction(tx);
253
-
251
+ console.log('\n📡 Broadcasting transaction to miner...')
252
+ const result = acceptTransaction(tx)
253
+
254
254
  if (result.accepted) {
255
- console.log('\n🎉 Transaction accepted and processed!');
256
-
255
+ console.log('\n🎉 Transaction accepted and processed!')
256
+
257
257
  // Update local wallet
258
- updateUTXOFromTransaction(tx, utxo);
259
-
260
- console.log('\n📊 Updated blockchain state:');
261
- getBlockchainStats();
258
+ updateUTXOFromTransaction(tx, utxo)
259
+
260
+ console.log('\n📊 Updated blockchain state:')
261
+ getBlockchainStats()
262
262
  } else {
263
- console.log('\n❌ Transaction rejected by miner');
264
- console.log('Errors:', result.errors);
263
+ console.log('\n❌ Transaction rejected by miner')
264
+ console.log('Errors:', result.errors)
265
265
  }
266
266
  } catch (error) {
267
- console.error('❌ Error creating multi-output transaction:', error.message);
267
+ console.error('❌ Error creating multi-output transaction:', error.message)
268
268
  }
269
269
  }
270
270
 
271
271
  /**
272
272
  * Run all examples
273
273
  */
274
- async function runAllExamples() {
275
- console.log('🚀 BSV Transaction Examples');
276
- console.log('🌟 Demonstrating complete transaction flow with miner simulation\n');
277
-
274
+ async function runAllExamples () {
275
+ console.log('🚀 BSV Transaction Examples')
276
+ console.log('🌟 Demonstrating complete transaction flow with miner simulation\n')
277
+
278
278
  // Initialize blockchain state
279
- const initialized = await initializeBlockchain();
279
+ const initialized = await initializeBlockchain()
280
280
  if (!initialized) {
281
- return;
281
+ return
282
282
  }
283
-
283
+
284
284
  // Show initial miner status
285
- console.log('\n📊 Initial miner status:');
286
- getMempoolStatus();
287
-
285
+ console.log('\n📊 Initial miner status:')
286
+ getMempoolStatus()
287
+
288
288
  // Run examples
289
- await exampleSimplePayment();
290
- await new Promise(resolve => setTimeout(resolve, 1000)); // Small delay
291
-
292
- await exampleTransactionChain();
293
- await new Promise(resolve => setTimeout(resolve, 1000)); // Small delay
294
-
295
- await exampleMultiOutput();
296
-
289
+ await exampleSimplePayment()
290
+ await new Promise(resolve => setTimeout(resolve, 1000)) // Small delay
291
+
292
+ await exampleTransactionChain()
293
+ await new Promise(resolve => setTimeout(resolve, 1000)) // Small delay
294
+
295
+ await exampleMultiOutput()
296
+
297
297
  // Final status
298
- console.log('\n📊 Final miner status:');
299
- getMempoolStatus();
300
-
301
- console.log('\n🎯 Examples completed!');
302
- console.log('Check blockchain-state.json to see the global UTXO set');
303
- console.log('Check wallet.json to see your local wallet state');
298
+ console.log('\n📊 Final miner status:')
299
+ getMempoolStatus()
300
+
301
+ console.log('\n🎯 Examples completed!')
302
+ console.log('Check blockchain-state.json to see the global UTXO set')
303
+ console.log('Check wallet.json to see your local wallet state')
304
304
  }
305
305
 
306
306
  // If called directly, run examples
307
307
  if (require.main === module) {
308
- const args = process.argv.slice(2);
309
-
308
+ const args = process.argv.slice(2)
309
+
310
310
  if (args[0] === '1') {
311
- initializeBlockchain().then(() => exampleSimplePayment());
311
+ initializeBlockchain().then(() => exampleSimplePayment())
312
312
  } else if (args[0] === '2') {
313
- exampleTransactionChain();
313
+ exampleTransactionChain()
314
314
  } else if (args[0] === '3') {
315
- exampleMultiOutput();
315
+ exampleMultiOutput()
316
316
  } else {
317
- runAllExamples();
317
+ runAllExamples()
318
318
  }
319
319
  }
320
320
 
@@ -325,4 +325,4 @@ module.exports = {
325
325
  exampleTransactionChain,
326
326
  exampleMultiOutput,
327
327
  runAllExamples
328
- };
328
+ }