@bsv/wallet-toolbox 1.1.4 → 1.1.6

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 (84) hide show
  1. package/docs/README.md +1 -1
  2. package/docs/client.md +714 -470
  3. package/docs/monitor.md +54 -37
  4. package/docs/services.md +53 -34
  5. package/docs/setup.md +326 -53
  6. package/docs/storage.md +116 -104
  7. package/docs/wallet.md +713 -470
  8. package/license.md +28 -1
  9. package/out/src/Setup.d.ts +27 -3
  10. package/out/src/Setup.d.ts.map +1 -1
  11. package/out/src/Setup.js +17 -5
  12. package/out/src/Setup.js.map +1 -1
  13. package/out/src/SetupClient.d.ts +130 -15
  14. package/out/src/SetupClient.d.ts.map +1 -1
  15. package/out/src/SetupClient.js +29 -15
  16. package/out/src/SetupClient.js.map +1 -1
  17. package/out/src/Wallet.d.ts +4 -0
  18. package/out/src/Wallet.d.ts.map +1 -1
  19. package/out/src/Wallet.js +7 -0
  20. package/out/src/Wallet.js.map +1 -1
  21. package/out/src/sdk/WalletError.d.ts +0 -1
  22. package/out/src/sdk/WalletError.d.ts.map +1 -1
  23. package/out/src/sdk/WalletError.js +0 -1
  24. package/out/src/sdk/WalletError.js.map +1 -1
  25. package/out/src/sdk/validationHelpers.d.ts +1 -0
  26. package/out/src/sdk/validationHelpers.d.ts.map +1 -1
  27. package/out/src/sdk/validationHelpers.js +2 -1
  28. package/out/src/sdk/validationHelpers.js.map +1 -1
  29. package/out/src/storage/StorageProvider.d.ts +1 -4
  30. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  31. package/out/src/storage/StorageProvider.js +1 -4
  32. package/out/src/storage/StorageProvider.js.map +1 -1
  33. package/out/src/storage/WalletStorageManager.d.ts +1 -1
  34. package/out/src/storage/WalletStorageManager.js +1 -1
  35. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  36. package/out/src/storage/methods/createAction.js +42 -11
  37. package/out/src/storage/methods/createAction.js.map +1 -1
  38. package/out/src/storage/methods/generateChange.js +1 -1
  39. package/out/src/storage/methods/generateChange.js.map +1 -1
  40. package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
  41. package/out/src/storage/methods/listOutputs.js +4 -2
  42. package/out/src/storage/methods/listOutputs.js.map +1 -1
  43. package/out/src/storage/schema/tables/ProvenTxReq.d.ts +4 -4
  44. package/out/src/utility/ScriptTemplateSABPPP.d.ts +4 -0
  45. package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +1 -1
  46. package/out/src/utility/ScriptTemplateSABPPP.js +4 -0
  47. package/out/src/utility/ScriptTemplateSABPPP.js.map +1 -1
  48. package/out/test/examples/README.man.test.js +1 -1
  49. package/out/test/utils/TestUtilsWalletStorage.d.ts +2 -1
  50. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  51. package/out/test/utils/TestUtilsWalletStorage.js +112 -27
  52. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  53. package/out/test/wallet/action/createAction.test.js +31 -5
  54. package/out/test/wallet/action/createAction.test.js.map +1 -1
  55. package/out/test/wallet/action/createAction2.test.d.ts +37 -0
  56. package/out/test/wallet/action/createAction2.test.d.ts.map +1 -0
  57. package/out/test/wallet/action/createAction2.test.js +1145 -0
  58. package/out/test/wallet/action/createAction2.test.js.map +1 -0
  59. package/out/test/wallet/list/listOutputs.test.js +8 -12
  60. package/out/test/wallet/list/listOutputs.test.js.map +1 -1
  61. package/out/tsconfig.all.tsbuildinfo +1 -1
  62. package/package.json +2 -2
  63. package/src/Setup.ts +29 -5
  64. package/src/SetupClient.ts +136 -22
  65. package/src/Wallet.ts +9 -0
  66. package/src/sdk/WalletError.ts +0 -1
  67. package/src/sdk/validationHelpers.ts +3 -1
  68. package/src/storage/StorageProvider.ts +1 -4
  69. package/src/storage/WalletStorageManager.ts +1 -1
  70. package/src/storage/methods/createAction.ts +48 -12
  71. package/src/storage/methods/generateChange.ts +1 -1
  72. package/src/storage/methods/listOutputs.ts +4 -2
  73. package/src/storage/schema/tables/ProvenTxReq.ts +4 -4
  74. package/src/utility/ScriptTemplateSABPPP.ts +4 -0
  75. package/test/examples/README.man.test.ts +1 -1
  76. package/test/utils/TestUtilsWalletStorage.ts +131 -35
  77. package/test/wallet/action/createAction.test.ts +36 -5
  78. package/test/wallet/action/createAction2.test.ts +1400 -0
  79. package/test/wallet/list/listOutputs.test.ts +7 -13
  80. package/ts2md.json +6 -6
  81. package/tsconfig.all.json +1 -1
  82. package/LICENSE.txt +0 -28
  83. package/dev.sqlite3 +0 -0
  84. package/knexfile.js +0 -9
@@ -0,0 +1,1400 @@
1
+ import chalk from 'chalk'
2
+ import fs from 'fs'
3
+ import path from 'path'
4
+ import {
5
+ AtomicBEEF,
6
+ Beef,
7
+ CreateActionArgs,
8
+ CreateActionResult,
9
+ ListActionsResult,
10
+ MerklePath,
11
+ Transaction,
12
+ TransactionInput,
13
+ TransactionOutput,
14
+ WalletActionInput,
15
+ WalletActionOutput
16
+ } from '@bsv/sdk'
17
+ import { _tu, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
18
+
19
+ const noLog = true
20
+ const logFilePath = path.resolve(__dirname, 'createAction2.test.ts')
21
+
22
+ function sanitizeTestName(testName: string): string {
23
+ const cleanTestName = testName.replace(/[^a-zA-Z0-9_]/g, '_')
24
+ return cleanTestName.startsWith('LOG_')
25
+ ? cleanTestName
26
+ : `LOG_${cleanTestName}`
27
+ }
28
+
29
+ describe('createAction2 nosend transactions', () => {
30
+ jest.setTimeout(99999999)
31
+
32
+ let ctxs: TestWalletNoSetup[] = []
33
+ const env = _tu.getEnv('test')
34
+ const testName = () => expect.getState().currentTestName ?? 'test'
35
+
36
+ beforeEach(async () => {
37
+ ctxs = []
38
+
39
+ if (env.runMySQL) {
40
+ ctxs.push(await _tu.createLegacyWalletMySQLCopy(testName()))
41
+ }
42
+
43
+ ctxs.push(await _tu.createLegacyWalletSQLiteCopy(testName()))
44
+ })
45
+
46
+ afterEach(async () => {
47
+ for (const { wallet } of ctxs) await wallet.destroy()
48
+ })
49
+
50
+ test('1_transaction with single output checked using toLogString', async () => {
51
+ for (const { wallet } of ctxs) {
52
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
53
+ const fundingLabel = 'funding transaction for createAction'
54
+ const fundingArgs: CreateActionArgs = {
55
+ outputs: [
56
+ {
57
+ basket: 'funding basket',
58
+ tags: ['funding transaction output', 'test tag'],
59
+ satoshis: 3,
60
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
61
+ outputDescription: 'Funding Output'
62
+ }
63
+ ],
64
+ labels: [
65
+ fundingLabel,
66
+ 'this is an extra long test label that should be truncated at 80 chars when it is displayed'
67
+ ],
68
+ description: 'Funding transaction',
69
+ options: { noSend: true, randomizeOutputs: false }
70
+ }
71
+ const fundingResult: CreateActionResult =
72
+ await wallet.createAction(fundingArgs)
73
+ expect(fundingResult.tx).toBeDefined()
74
+ const actionsResult = await wallet.listActions({
75
+ labels: [fundingLabel],
76
+ includeInputs: true,
77
+ includeOutputs: true,
78
+ includeInputSourceLockingScripts: true,
79
+ includeInputUnlockingScripts: true,
80
+ includeOutputLockingScripts: true,
81
+ includeLabels: true
82
+ })
83
+ const rl1 = toLogString(fundingResult.tx!, actionsResult)
84
+ expect(rl1.log).toBe(`transactions:3
85
+ txid:30bdac0f5c6491f130820517802ff57e20e5a50c08b5c65e6976627fb82ae930 version:1 lockTime:0 sats:-4 status:nosend
86
+ outgoing:true desc:'Funding transaction' labels:['funding transaction for createaction','this is an extra long test
87
+ label that should be truncated at 80 chars when it is...']
88
+ inputs: 1
89
+ 0: sourceTXID:a3a8fe7f541c1383ff7b975af49b27284ae720af5f2705d8409baaf519190d26.2 sats:913
90
+ lock:(50)76a914f7238871139f4926cbd592a03a737981e558245d88ac
91
+ unlock:(214)483045022100cfef1f6d781af99a1de14efd6f24f2a14234a26097012f27121eb36f4e330c1d0220... seq:4294967295
92
+ outputs: 2
93
+ 0: sats:3 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true basket:'funding basket'
94
+ desc:'Funding Output' tags:['funding transaction output','test tag']
95
+ 1: sats:909 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:1 spendable:true basket:'default'`)
96
+ }
97
+ })
98
+
99
+ test('2_transaction with multiple outputs checked using toLogString', async () => {
100
+ for (const { wallet } of ctxs) {
101
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
102
+ const fundingLabel = 'funding transaction for createAction'
103
+ const fundingArgs: CreateActionArgs = {
104
+ outputs: [
105
+ {
106
+ basket: 'funding basket',
107
+ tags: ['funding transaction for createAction', 'test tag'],
108
+ satoshis: 5,
109
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
110
+ outputDescription: 'Funding output'
111
+ },
112
+ {
113
+ basket: 'extra basket',
114
+ tags: ['extra transaction output', 'extra test tag'],
115
+ satoshis: 6,
116
+ lockingScript: '76a914fedcba9876543210fedcba9876543210fedcba88ac',
117
+ outputDescription: 'Extra Output'
118
+ }
119
+ ],
120
+ labels: [fundingLabel, 'this is the extra label'],
121
+ description: 'Funding transaction with multiple outputs',
122
+ options: { noSend: true, randomizeOutputs: false }
123
+ }
124
+ const fundingResult: CreateActionResult =
125
+ await wallet.createAction(fundingArgs)
126
+ const actionsResult = await wallet.listActions({
127
+ labels: [fundingLabel],
128
+ includeInputs: true,
129
+ includeOutputs: true,
130
+ includeInputSourceLockingScripts: true,
131
+ includeInputUnlockingScripts: true,
132
+ includeOutputLockingScripts: true,
133
+ includeLabels: true
134
+ })
135
+ const rl1 = toLogString(fundingResult.tx!, actionsResult)
136
+ expect(rl1.log).toBe(`transactions:3
137
+ txid:b3848f2cabf5887ec679ca60347a29f6ecad425fda738700265c2f9d22c18ab5 version:1 lockTime:0 sats:-12 status:nosend
138
+ outgoing:true desc:'Funding transaction with multiple outputs' labels:['funding transaction for createaction','this
139
+ is the extra label']
140
+ inputs: 1
141
+ 0: sourceTXID:a3a8fe7f541c1383ff7b975af49b27284ae720af5f2705d8409baaf519190d26.2 sats:913
142
+ lock:(50)76a914f7238871139f4926cbd592a03a737981e558245d88ac
143
+ unlock:(212)473044022079020cc8ea5ee6b3610806286e41567147d4b4b07d16bc1341311e00ce7647b0022034... seq:4294967295
144
+ outputs: 3
145
+ 0: sats:5 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true basket:'funding basket'
146
+ desc:'Funding output' tags:['funding transaction for createaction','test tag']
147
+ 1: sats:6 lock:(48)76a914fedcba9876543210fedcba9876543210fedcba88ac index:1 spendable:true basket:'extra basket'
148
+ desc:'Extra Output' tags:['extra transaction output','extra test tag']
149
+ 2: sats:901 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:2 spendable:true basket:'default'`)
150
+ }
151
+ })
152
+
153
+ test('3_transaction with explicit change check also uses toLogString on the spend', async () => {
154
+ for (const { wallet } of ctxs) {
155
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
156
+ const fundingArgs: CreateActionArgs = {
157
+ outputs: [
158
+ {
159
+ satoshis: 4,
160
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
161
+ outputDescription: 'Funding output'
162
+ }
163
+ ],
164
+ description: 'Funding transaction',
165
+ options: { noSend: true, randomizeOutputs: false }
166
+ }
167
+ const fundingResult: CreateActionResult =
168
+ await wallet.createAction(fundingArgs)
169
+ expect(fundingResult.tx).toBeDefined()
170
+ expect(fundingResult.noSendChange).toBeDefined()
171
+ expect(fundingResult.noSendChange!.length).toBe(1)
172
+ log(
173
+ `noSendChange returned:${JSON.stringify(fundingResult.noSendChange, null, 2)}`
174
+ )
175
+ const outputSatoshis = 2
176
+ const estimatedFee = 1
177
+ const fundingBeef = Beef.fromBinary(fundingResult.tx!)
178
+ expect(fundingBeef).toBeDefined()
179
+ const spendingArgs: CreateActionArgs = {
180
+ inputs: [
181
+ {
182
+ outpoint: `${fundingResult.txid}.0`,
183
+ unlockingScript: '47304402207f2e9a',
184
+ inputDescription: 'desc3'
185
+ }
186
+ ],
187
+ inputBEEF: fundingBeef.toBinary(),
188
+ outputs: [
189
+ {
190
+ satoshis: outputSatoshis,
191
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
192
+ outputDescription: 'First spending Output for check on change '
193
+ }
194
+ ],
195
+ labels: ['spending transaction test'],
196
+ description: 'Explicit check on returned change',
197
+ options: {
198
+ noSend: true,
199
+ randomizeOutputs: false,
200
+ noSendChange: []
201
+ }
202
+ }
203
+ const spendingResult: CreateActionResult =
204
+ await wallet.createAction(spendingArgs)
205
+ expect(spendingResult.tx).toBeDefined()
206
+ log(
207
+ `Spending transaction created:${JSON.stringify(spendingResult, null, 2)}`
208
+ )
209
+ const spendingActionsResult = await wallet.listActions({
210
+ labels: ['spending transaction test'],
211
+ includeInputs: true,
212
+ includeOutputs: true,
213
+ includeInputSourceLockingScripts: true,
214
+ includeInputUnlockingScripts: true,
215
+ includeOutputLockingScripts: true,
216
+ includeLabels: true
217
+ })
218
+ const totalInputSatoshis =
219
+ spendingActionsResult.actions[0]?.inputs?.reduce(
220
+ (sum, input) => sum + input.sourceSatoshis,
221
+ 0
222
+ )
223
+ const expectedChange = totalInputSatoshis! - outputSatoshis - estimatedFee
224
+ const outputs = spendingActionsResult.actions[0]?.outputs || []
225
+ const changeOutput = outputs.find(output => output.basket === 'default')
226
+ expect(changeOutput!.satoshis).toBe(expectedChange)
227
+ const actualFee = totalInputSatoshis! - outputSatoshis - expectedChange
228
+ expect(actualFee).toBe(estimatedFee)
229
+ const rl1 = toLogString(spendingResult.tx!, spendingActionsResult)
230
+ expect(rl1.log).toBe(`transactions:5
231
+ txid:afa6713aab0957cf5bb00dee532ad7b895e919a99564ec2016b51cb3d472d87f version:1 lockTime:0 sats:1 status:nosend
232
+ outgoing:true desc:'Explicit check on returned change' labels:['spending transaction test']
233
+ inputs: 2
234
+ 0: sourceTXID:527ffe88f70d5b7de2b8b5ba9966b9c755e7da4de749d4fcd27140a03145a11d.0 sats:995
235
+ lock:(50)76a914ab2b66432503a3681fc5af1502207ca458c8752d88ac
236
+ unlock:(214)483045022100973a84555fa864e08313bda5c88e1991094db7b8d82586c899276155dabcbc9a0220... seq:4294967295
237
+ 1: sourceTXID:70afdc54187a1cdb8e35f7d00e5e111cbf5c43c4dc3f1da2cc44479133c75f9e.0 sats:4 desc:'Funding output'
238
+ lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac unlock:(16)47304402207f2e9a seq:4294967295
239
+ outputs: 2
240
+ 0: sats:2 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true desc:'First spending
241
+ Output for check on change '
242
+ 1: sats:996 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:1 spendable:true basket:'default'`)
243
+ }
244
+ })
245
+
246
+ test('4_transaction with custom options knownTxids and returnTXIDOnly false uses toLogString', async () => {
247
+ for (const { wallet } of ctxs) {
248
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
249
+ const fundingOutputSatoshis = 4
250
+ const fundingArgs: CreateActionArgs = {
251
+ outputs: [
252
+ {
253
+ satoshis: fundingOutputSatoshis,
254
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
255
+ outputDescription: 'Funding output'
256
+ }
257
+ ],
258
+ description: 'Funding transaction',
259
+ options: { noSend: true, randomizeOutputs: false }
260
+ }
261
+ const fundingResult: CreateActionResult =
262
+ await wallet.createAction(fundingArgs)
263
+ expect(fundingResult.tx).toBeDefined()
264
+ const spendingArgs: CreateActionArgs = {
265
+ description: 'Check knownTxids and returnTXIDOnly',
266
+ outputs: [
267
+ {
268
+ satoshis: 4,
269
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
270
+ outputDescription: 'returnTXIDOnly false test'
271
+ }
272
+ ],
273
+ labels: ['custom options test'],
274
+ options: {
275
+ knownTxids: ['tx123', 'tx456'],
276
+ returnTXIDOnly: false,
277
+ noSend: true,
278
+ randomizeOutputs: false
279
+ }
280
+ }
281
+ const spendingResult: CreateActionResult =
282
+ await wallet.createAction(spendingArgs)
283
+ expect(spendingArgs.options!.knownTxids).toEqual(
284
+ expect.arrayContaining(['tx123', 'tx456'])
285
+ )
286
+ const spendingActionsResult = await wallet.listActions({
287
+ labels: ['custom options test'],
288
+ includeInputs: true,
289
+ includeOutputs: true,
290
+ includeInputSourceLockingScripts: true,
291
+ includeInputUnlockingScripts: true,
292
+ includeOutputLockingScripts: true,
293
+ includeLabels: true
294
+ })
295
+ const rl1 = toLogString(spendingResult.tx!, spendingActionsResult)
296
+ expect(rl1.log).toBe(`transactions:2
297
+ txid:38ded69627603b30bd1f55eb3f88098dbf74f2ef0ff5e3cfe6a34f97ce2db9c2 version:1 lockTime:0 sats:-5 status:nosend
298
+ outgoing:true desc:'Check knownTxids and returnTXIDOnly' labels:['custom options test']
299
+ inputs: 1
300
+ 0: sourceTXID:527ffe88f70d5b7de2b8b5ba9966b9c755e7da4de749d4fcd27140a03145a11d.0 sats:995
301
+ lock:(50)76a914ab2b66432503a3681fc5af1502207ca458c8752d88ac
302
+ unlock:(212)4730440220113a6f72035a6ddcd6930db7e3f3d5c70486f9aaefb095e6fa3557afa916ec37022054... seq:4294967295
303
+ outputs: 2
304
+ 0: sats:4 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true desc:'returnTXIDOnly
305
+ false test'
306
+ 1: sats:990 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:1 spendable:true basket:'default'`)
307
+ }
308
+ })
309
+
310
+ test('5_transaction with custom options knownTxids and returnTXIDOnly true', async () => {
311
+ for (const { wallet } of ctxs) {
312
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
313
+ const fundingOutputSatoshis = 4
314
+ const fundingArgs: CreateActionArgs = {
315
+ outputs: [
316
+ {
317
+ satoshis: fundingOutputSatoshis,
318
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
319
+ outputDescription: 'Funding output'
320
+ }
321
+ ],
322
+ description: 'Funding transaction',
323
+ options: { noSend: true }
324
+ }
325
+ const fundingResult: CreateActionResult =
326
+ await wallet.createAction(fundingArgs)
327
+ expect(fundingResult.tx).toBeDefined()
328
+ const spendingArgs: CreateActionArgs = {
329
+ description: 'Check knownTxids and returnTXIDOnly',
330
+ outputs: [
331
+ {
332
+ satoshis: 4,
333
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
334
+ outputDescription: 'returnTXIDOnly true test'
335
+ }
336
+ ],
337
+ labels: ['custom options test'],
338
+ options: {
339
+ knownTxids: ['tx123', 'tx456'],
340
+ returnTXIDOnly: true,
341
+ noSend: true
342
+ }
343
+ }
344
+ const spendingResult: CreateActionResult =
345
+ await wallet.createAction(spendingArgs)
346
+ expect(spendingResult.tx).not.toBeDefined()
347
+ expect(spendingArgs.options!.knownTxids).toEqual(
348
+ expect.arrayContaining(['tx123', 'tx456'])
349
+ )
350
+ }
351
+ })
352
+
353
+ test('6_transaction with custom options knownTxids check returned BeefParty txids', async () => {
354
+ for (const { wallet } of ctxs) {
355
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
356
+ const fundingOutputSatoshis = 4
357
+ const fundingArgs: CreateActionArgs = {
358
+ outputs: [
359
+ {
360
+ satoshis: fundingOutputSatoshis,
361
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
362
+ outputDescription: 'Funding Output'
363
+ }
364
+ ],
365
+ description: 'Funding transaction',
366
+ options: { noSend: true }
367
+ }
368
+ const fundingResult: CreateActionResult =
369
+ await wallet.createAction(fundingArgs)
370
+ expect(fundingResult.tx).toBeDefined()
371
+ const spendingArgs: CreateActionArgs = {
372
+ description: 'Check knownTxids txids',
373
+ outputs: [
374
+ {
375
+ satoshis: 4,
376
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
377
+ outputDescription: 'Output for check txids'
378
+ }
379
+ ],
380
+ labels: ['custom options test'],
381
+ options: {
382
+ knownTxids: ['tx123', 'tx456'],
383
+ returnTXIDOnly: true,
384
+ noSend: true
385
+ }
386
+ }
387
+ const spendingResult: CreateActionResult =
388
+ await wallet.createAction(spendingArgs)
389
+ expect(spendingResult).toBeDefined()
390
+ expect(spendingArgs.options!.knownTxids).toEqual(
391
+ expect.arrayContaining(['tx123', 'tx456'])
392
+ )
393
+ const fundingBeef = Beef.fromBinary(fundingResult.tx!)
394
+ expect(fundingBeef).toBeDefined()
395
+ const BeefPartyTxids = fundingBeef.txs.map(tx => tx.txid)
396
+ const expectedTxids = ['tx123', 'tx456', ...BeefPartyTxids]
397
+ expect(spendingArgs.options!.knownTxids?.sort()).toEqual(
398
+ expectedTxids.sort()
399
+ )
400
+ }
401
+ })
402
+
403
+ test('7_transaction with custom options knownTxids check returned BeefParty txids with additional spend', async () => {
404
+ for (const { wallet } of ctxs) {
405
+ wallet.randomVals = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]
406
+ const fundingOutputSatoshis = 4
407
+ const fundingArgs: CreateActionArgs = {
408
+ outputs: [
409
+ {
410
+ satoshis: fundingOutputSatoshis,
411
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
412
+ outputDescription: 'Funding Output'
413
+ }
414
+ ],
415
+ description: 'Funding transaction',
416
+ options: { noSend: true }
417
+ }
418
+ const fundingResult: CreateActionResult =
419
+ await wallet.createAction(fundingArgs)
420
+ expect(fundingResult.tx).toBeDefined()
421
+ const spendingArgs: CreateActionArgs = {
422
+ description: 'Check knownTxids txids extra',
423
+ outputs: [
424
+ {
425
+ satoshis: 4,
426
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
427
+ outputDescription: 'Output for check txids extra'
428
+ }
429
+ ],
430
+ options: {
431
+ knownTxids: ['tx123', 'tx456'],
432
+ returnTXIDOnly: false,
433
+ noSend: true
434
+ }
435
+ }
436
+ const spendingResult: CreateActionResult =
437
+ await wallet.createAction(spendingArgs)
438
+ expect(spendingResult).toBeDefined()
439
+ expect(spendingArgs.options!.knownTxids).toEqual(
440
+ expect.arrayContaining(['tx123', 'tx456'])
441
+ )
442
+ const fundingBeef = Beef.fromBinary(fundingResult.tx!)
443
+ expect(fundingBeef).toBeDefined()
444
+ const partyBeefTxids = fundingBeef.txs.map(tx => tx.txid)
445
+ const expectedTxids = ['tx123', 'tx456', ...partyBeefTxids]
446
+ expect(spendingArgs.options!.knownTxids?.sort()).toEqual(
447
+ expectedTxids.sort()
448
+ )
449
+ const additionalSpendArgs: CreateActionArgs = {
450
+ description: 'Extra spend transaction',
451
+ outputs: [
452
+ {
453
+ satoshis: 4,
454
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
455
+ outputDescription: 'Extra spend output'
456
+ }
457
+ ],
458
+ labels: ['extra spend test'],
459
+ options: {
460
+ knownTxids: spendingArgs.options!.knownTxids,
461
+ returnTXIDOnly: true,
462
+ noSend: true
463
+ }
464
+ }
465
+ const additionalSpendResult: CreateActionResult =
466
+ await wallet.createAction(additionalSpendArgs)
467
+ expect(additionalSpendResult).toBeDefined()
468
+ const finalBeef = Beef.fromBinary(spendingResult.tx!)
469
+ expect(finalBeef).toBeDefined()
470
+ const finalPartyBeefTxids = finalBeef.txs.map(tx => tx.txid)
471
+ const finalExpectedTxids = [...expectedTxids, ...finalPartyBeefTxids]
472
+ expect(additionalSpendArgs.options!.knownTxids?.sort()).toEqual(
473
+ finalExpectedTxids.sort()
474
+ )
475
+ }
476
+ })
477
+
478
+ /* WIP
479
+
480
+ test('8_no-send transaction with zero satoshis output', async () => {
481
+ for (const { wallet, activeStorage: storage } of ctxs) {
482
+ const args: CreateActionArgs = {
483
+ outputs: [
484
+ {
485
+ satoshis: 0,
486
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
487
+ outputDescription: 'Invalid output'
488
+ }
489
+ ],
490
+ description: 'Valid transaction',
491
+ options: {
492
+ returnTXIDOnly: false,
493
+ randomizeOutputs: false,
494
+ noSend: true
495
+ }
496
+ }
497
+ const result: CreateActionResult = await wallet.createAction(args)
498
+ expect(result.tx).toBeDefined()
499
+ expect(result.signableTransaction).toBeUndefined()
500
+ }
501
+ })
502
+
503
+ test('9_no-send transaction without auth (should fail)', async () => {
504
+ for (const { wallet, activeStorage: storage } of ctxs) {
505
+ const args: CreateActionArgs = {
506
+ outputs: [
507
+ {
508
+ satoshis: 5,
509
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
510
+ outputDescription: 'Valid output'
511
+ }
512
+ ],
513
+ description: 'Valid transaction',
514
+ options: {
515
+ returnTXIDOnly: false,
516
+ randomizeOutputs: false,
517
+ noSend: true
518
+ }
519
+ }
520
+ await expect(wallet.createAction(args, undefined)).rejects.toThrow()
521
+ }
522
+ })
523
+
524
+ test('10_no-send transaction with malformed args (invalid destination)', async () => {
525
+ for (const { wallet, activeStorage: storage } of ctxs) {
526
+ const args: CreateActionArgs = {
527
+ outputs: [
528
+ {
529
+ satoshis: 6,
530
+ lockingScript: 'invalid_script',
531
+ outputDescription: 'Valid output'
532
+ }
533
+ ],
534
+ description: 'Valid transaction',
535
+ options: {
536
+ noSend: true
537
+ }
538
+ }
539
+ await expect(wallet.createAction(args)).rejects.toThrow()
540
+ }
541
+ })
542
+
543
+ test('11_transaction with OP_RETURN', async () => {
544
+ for (const { wallet, activeStorage: storage } of ctxs) {
545
+ const args: CreateActionArgs = {
546
+ outputs: [
547
+ {
548
+ satoshis: 0,
549
+ lockingScript: '6a0c48656c6c6f20576f726c64',
550
+ outputDescription: 'OP_RETURN data'
551
+ }
552
+ ],
553
+ description: 'Transaction embedding OP_RETURN data',
554
+ options: { noSend: true }
555
+ }
556
+ const result: CreateActionResult = await wallet.createAction(args)
557
+ expect(result.tx).toBeDefined()
558
+ expect(result.signableTransaction).toBeUndefined()
559
+ }
560
+ })
561
+
562
+ test('12_high fee transaction', async () => {
563
+ for (const { wallet, activeStorage: storage } of ctxs) {
564
+ const args: CreateActionArgs = {
565
+ inputs: [
566
+ {
567
+ outpoint: 'tx4.0',
568
+ unlockingScript: '47304402207f2e9a',
569
+ inputDescription: 'desc4'
570
+ }
571
+ ],
572
+ outputs: [
573
+ {
574
+ satoshis: 950,
575
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
576
+ outputDescription: 'Output D'
577
+ }
578
+ ],
579
+ description:
580
+ 'Transaction that results in high fees (insufficient change)',
581
+ options: { noSend: true }
582
+ }
583
+ await expect(wallet.createAction(args)).rejects.toThrow(
584
+ /WERR_INSUFFICIENT_FUNDS/
585
+ )
586
+ }
587
+ })
588
+
589
+ test('13_zero fee transaction', async () => {
590
+ for (const { wallet, activeStorage: storage } of ctxs) {
591
+ const args: CreateActionArgs = {
592
+ inputs: [
593
+ {
594
+ outpoint: 'tx5.0',
595
+ unlockingScript: '47304402207f2e9a',
596
+ inputDescription: 'desc5'
597
+ }
598
+ ],
599
+ outputs: [
600
+ {
601
+ satoshis: 500,
602
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
603
+ outputDescription: 'Output E'
604
+ }
605
+ ],
606
+ description: 'Zero-fee transaction attempt',
607
+ options: { noSend: true }
608
+ }
609
+ await expect(wallet.createAction(args)).rejects.toThrow(
610
+ /WERR_INSUFFICIENT_FUNDS/
611
+ )
612
+ }
613
+ })
614
+
615
+ test('14_dust transaction', async () => {
616
+ for (const { wallet, activeStorage: storage } of ctxs) {
617
+ const args: CreateActionArgs = {
618
+ outputs: [
619
+ {
620
+ satoshis: 1,
621
+ lockingScript: '76a914abcdef0123456789abcdef0123456789abcdef88ac',
622
+ outputDescription: 'Dust output'
623
+ }
624
+ ],
625
+ description: 'Transaction with dust output',
626
+ options: { noSend: true }
627
+ }
628
+ await expect(wallet.createAction(args)).rejects.toThrow(
629
+ /WERR_INVALID_PARAMETER/
630
+ )
631
+ }
632
+ })
633
+ */
634
+ })
635
+
636
+ // Helper functions
637
+
638
+ function getExpectedLog(
639
+ testName: string,
640
+ logFilePath: string
641
+ ): { log: string; logColor: string } | null {
642
+ if (!fs.existsSync(logFilePath)) {
643
+ return null
644
+ }
645
+
646
+ const fileContent = fs.readFileSync(logFilePath, 'utf8')
647
+ const sanitizedTestName = sanitizeTestName(testName)
648
+
649
+ // Use regex to extract the correct log constant
650
+ const logRegex = new RegExp(
651
+ `const\\s+${sanitizedTestName}\\s*=\\s*\\{\\s*log:\\s*['\`]([\\s\\S]*?)['\`]\\s*,\\s*logColor:\\s*['\`]([\\s\\S]*?)['\`]\\s*\\}`,
652
+ 'm'
653
+ )
654
+ const match = fileContent.match(logRegex)
655
+
656
+ if (match) {
657
+ return { log: match[1], logColor: match[2] }
658
+ }
659
+ return null
660
+ }
661
+
662
+ const normalizeVariableParts = (log: string): string => {
663
+ return log
664
+ .replace(/txid:[a-f0-9]{64}/g, 'txid:PLACEHOLDER') // Replace txids
665
+ .replace(
666
+ /unlock:\(\d+\)(?:483045022100[a-f0-9]{64}0220|[a-f0-9]+)/g,
667
+ 'unlock:PLACEHOLDER'
668
+ )
669
+ .replace(/lock:\(\d+\)76a914[a-f0-9]{40}/g, 'lock:PLACEHOLDER') // Replace locking script
670
+ .replace(/index:\d+ spendable:/g, 'index:PLACEHOLDER spendable:') // Normalize index
671
+ .trim()
672
+ }
673
+
674
+ /**
675
+ * Appends logs as a constant to a test file.
676
+ * @param {string} testName - The name of the test.
677
+ * @param {{ log: string; logColor: string }} rl - The log data.
678
+ */
679
+ function appendLogsAsConst(
680
+ testName: string,
681
+ rl: { log: string; logColor: string }
682
+ ) {
683
+ const normalizedTestName = testName
684
+ .replace(/[^a-zA-Z0-9_ ]/g, '')
685
+ .trim()
686
+ .replace(/\s+/g, '_')
687
+ const sanitizedTestName = sanitizeTestName(normalizedTestName)
688
+ const logFilePath = path.resolve(__dirname, 'createAction2.man.test.ts')
689
+ const logConst = `
690
+ // Auto-generated test log - ${new Date().toISOString()}
691
+ const ${sanitizedTestName} = {
692
+ log: \`${rl.log}\`,
693
+ logColor: \`${rl.logColor}\`
694
+ };
695
+ `.trim()
696
+
697
+ fs.appendFileSync(logFilePath, `\n${logConst}\n`, 'utf8')
698
+ }
699
+
700
+ /**
701
+ * Truncates a string to a maximum length of 80 characters.
702
+ * @param {string} s - The string to truncate.
703
+ * @returns {string} - The truncated string.
704
+ */ const truncate = (s: string) => (s.length > 80 ? s.slice(0, 80) + '...' : s)
705
+
706
+ /**
707
+ * Formats an optional field if it has a defined value.
708
+ * @param {string} fieldName - The name of the field.
709
+ * @param {any} value - The value of the field.
710
+ * @returns {string} - The formatted field string.
711
+ */
712
+ const formatOptionalField = (fieldName: string, value: any) =>
713
+ value !== undefined && value !== null && value !== ''
714
+ ? ` ${fieldName}:${value}`
715
+ : ''
716
+
717
+ /**
718
+ * Formats an optional field with quotes if it has a defined value.
719
+ * @param {string} fieldName - The name of the field.
720
+ * @param {any} value - The value of the field.
721
+ * @returns {string} - The formatted field string with quotes.
722
+ */
723
+ const formatOptionalFieldWithQuotes = (fieldName: string, value: any) =>
724
+ value !== undefined && value !== null && value !== ''
725
+ ? ` ${fieldName}:'${value}'`
726
+ : ''
727
+
728
+ /**
729
+ * Formats an optional field with color if it has a defined value.
730
+ * @param {string} fieldName - The name of the field.
731
+ * @param {any} value - The value of the field.
732
+ * @param {(val: string) => string} colorFunc - The function to apply color formatting.
733
+ * @returns {string} - The formatted field string with color.
734
+ */
735
+ const formatOptionalFieldWithColor = (
736
+ fieldName: string,
737
+ value: any,
738
+ colorFunc: (val: string) => string
739
+ ) =>
740
+ value !== undefined && value !== null && value !== ''
741
+ ? ` ${chalk.gray(fieldName + ':')}${colorFunc(typeof value === 'string' ? value : String(value))}`
742
+ : ''
743
+
744
+ /**
745
+ * Formats metadata if present.
746
+ * @param {any} metadata - The metadata object.
747
+ * @returns {string} - The formatted metadata string.
748
+ */
749
+ const formatMetadata = (metadata?: any) =>
750
+ metadata && !isEmptyObject(metadata)
751
+ ? `metadata:${JSON.stringify(metadata)}`
752
+ : ''
753
+
754
+ /**
755
+ * Formats the Merkle path if present.
756
+ * @param {MerklePath | string} [merklePath] - The Merkle path.
757
+ * @returns {string} - The formatted Merkle path string.
758
+ */
759
+ const formatMerklePath = (merklePath?: MerklePath | string) =>
760
+ merklePath ? `merklePath:${String(merklePath)}` : ''
761
+
762
+ const MAX_LOG_LINE_LENGTH = 120 // Define in the test
763
+
764
+ /**
765
+ * Wraps a log line to a specified max length.
766
+ * @param {string} text - The text to wrap.
767
+ * @param {number} indent - The indentation level.
768
+ * @param {number} [maxLength=120] - The maximum length of a line.
769
+ * @returns {string} - The wrapped log line.
770
+ */
771
+ const wrapLogLine = (
772
+ text: string,
773
+ indent: number,
774
+ maxLength: number = 120
775
+ ): string => {
776
+ const words = text.trim().split(' ')
777
+ let wrappedText = ' '.repeat(indent)
778
+ let currentLineLength = indent * 2
779
+
780
+ for (const word of words) {
781
+ if (currentLineLength + word.length + 1 > maxLength) {
782
+ wrappedText += '\n' + ' '.repeat(indent) + ' ' + word + ' '
783
+ currentLineLength = indent * 2 + word.length + 1
784
+ } else {
785
+ wrappedText += word + ' '
786
+ currentLineLength += word.length + 1
787
+ }
788
+ }
789
+
790
+ return wrappedText.trimEnd()
791
+ }
792
+
793
+ /**
794
+ * Formats an indented line.
795
+ * @param {number} indent - The indentation level.
796
+ * @param {string} content - The content of the line.
797
+ * @returns {string} - The formatted indented line.
798
+ */
799
+ const formatIndentedLineWithWrap = (
800
+ indent: number,
801
+ content: string,
802
+ maxLength: number = 120
803
+ ) => wrapLogLine(content.trim(), indent, maxLength)
804
+
805
+ /**
806
+ * Formats a list of wallet action inputs for logging.
807
+ * @param {WalletActionInput[]} [inputs] - The list of wallet action inputs.
808
+ * @returns {{ log: string; logColor: string }[]} - An array of formatted log strings and their colorized versions.
809
+ */
810
+ const formatInputs = (inputs: WalletActionInput[]) =>
811
+ inputs && inputs.length > 0
812
+ ? inputs
813
+ .sort((a, b) => a.sourceOutpoint.localeCompare(b.sourceOutpoint))
814
+ .map((input, i) => {
815
+ let line = `${i}: sourceTXID:${input.sourceOutpoint} sats:${input.sourceSatoshis}`
816
+ let color = `${chalk.gray(`${i}:`)} ${chalk.blue(input.sourceOutpoint)} ${chalk.green(`${input.sourceSatoshis} sats`)}`
817
+
818
+ line += formatOptionalFieldWithQuotes('desc', input.inputDescription)
819
+ color += formatOptionalFieldWithColor(
820
+ 'desc',
821
+ input.inputDescription,
822
+ chalk.white
823
+ )
824
+
825
+ if (input.sourceLockingScript) {
826
+ line += ` lock:(${input.sourceLockingScript.length})${truncate(input.sourceLockingScript)}`
827
+ color += ` ${chalk.gray('lock:')}(${input.sourceLockingScript.length})${chalk.cyan(truncate(input.sourceLockingScript))}`
828
+ }
829
+
830
+ if (input.unlockingScript) {
831
+ line += ` unlock:(${input.unlockingScript.length})${truncate(input.unlockingScript)}`
832
+ color += ` ${chalk.gray('unlock:')}(${input.unlockingScript.length})${chalk.cyan(truncate(input.unlockingScript))}`
833
+ }
834
+
835
+ line += ` seq:${input.sequenceNumber}`
836
+ color += ` ${chalk.gray('seq:')}${input.sequenceNumber}`
837
+
838
+ return {
839
+ log: formatIndentedLineWithWrap(2, line),
840
+ logColor: formatIndentedLineWithWrap(2, color)
841
+ }
842
+ })
843
+ : [
844
+ {
845
+ log: formatIndentedLineWithWrap(2, 'No inputs'),
846
+ logColor: formatIndentedLineWithWrap(2, chalk.gray('No inputs'))
847
+ }
848
+ ]
849
+
850
+ /**
851
+ * Formats a list of wallet action outputs for logging.
852
+ * @param {WalletActionOutput[]} [outputs] - The list of wallet action outputs.
853
+ * @returns {{ log: string; logColor: string }[]} - An array of formatted log strings and their colorized versions.
854
+ */
855
+ const formatOutputs = (outputs: WalletActionOutput[]) =>
856
+ outputs && outputs.length > 0
857
+ ? outputs
858
+ .sort((a, b) => a.satoshis - b.satoshis)
859
+ .map((output, i) => {
860
+ let line = `${i}: sats:${output.satoshis} lock:(${output.lockingScript?.length || ''})${truncate(output.lockingScript!) ?? 'N/A'}`
861
+ let color = `${chalk.gray(`${i}:`)} ${chalk.green(`${output.satoshis} sats`)} ${chalk.gray('lock:')}(${output.lockingScript?.length || ''})${chalk.cyan(truncate(output.lockingScript!) ?? 'N/A')}`
862
+
863
+ line += formatOptionalField('index', output.outputIndex)
864
+ color += formatOptionalFieldWithColor(
865
+ 'index',
866
+ output.outputIndex,
867
+ chalk.white
868
+ )
869
+
870
+ line += formatOptionalField('spendable', output.spendable)
871
+ color += formatOptionalFieldWithColor(
872
+ 'spendable',
873
+ output.spendable,
874
+ chalk.white
875
+ )
876
+
877
+ line += formatOptionalFieldWithQuotes(
878
+ 'custinst',
879
+ output.customInstructions
880
+ )
881
+ color += formatOptionalFieldWithColor(
882
+ 'custinst',
883
+ output.customInstructions,
884
+ chalk.white
885
+ )
886
+
887
+ line += formatOptionalFieldWithQuotes('basket', output.basket)
888
+ color += formatOptionalFieldWithColor(
889
+ 'basket',
890
+ output.basket,
891
+ chalk.white
892
+ )
893
+
894
+ line += formatOptionalFieldWithQuotes(
895
+ 'desc',
896
+ output.outputDescription
897
+ )
898
+ color += formatOptionalFieldWithColor(
899
+ 'desc',
900
+ output.outputDescription,
901
+ chalk.white
902
+ )
903
+
904
+ if (output.tags?.length) {
905
+ const tagsString = `[${output.tags.map(tag => `'${truncate(tag)}'`).join(',')}]`
906
+ line += ` tags:${tagsString}`
907
+ color += ` ${chalk.gray('tags:')}${chalk.white(tagsString)}`
908
+ }
909
+
910
+ return {
911
+ log: formatIndentedLineWithWrap(2, line),
912
+ logColor: formatIndentedLineWithWrap(2, color)
913
+ }
914
+ })
915
+ : [
916
+ {
917
+ log: formatIndentedLineWithWrap(2, 'No outputs'),
918
+ logColor: formatIndentedLineWithWrap(2, chalk.gray('No outputs'))
919
+ }
920
+ ]
921
+
922
+ /**
923
+ * Formats a list of labels into a string representation.
924
+ * @param {string[]} [labels] - The list of labels.
925
+ * @returns {string} - A formatted string of labels enclosed in brackets.
926
+ */
927
+ const formatLabels = (labels?: string[]) =>
928
+ labels && labels.length > 0
929
+ ? `[${labels.map(label => `'${truncate(label)}'`).join(',')}]`
930
+ : ''
931
+
932
+ /**
933
+ * Generates a formatted log string from an AtomicBEEF object.
934
+ * @param {AtomicBEEF} atomicBeef - The AtomicBEEF object containing transaction data.
935
+ * @param {ListActionsResult} [actionsResult] - The result of listing actions, used for additional transaction metadata.
936
+ * @param {boolean} [showKey=true] - Whether to display key transaction details.
937
+ * @returns {Promise<{ log: string; logColor: string }>} - An object containing the formatted log string and a colorized version.
938
+ */
939
+ export function toLogString(
940
+ atomicBeef: AtomicBEEF,
941
+ actionsResult?: ListActionsResult,
942
+ showKey: boolean = true
943
+ ): { log: string; logColor: string } {
944
+ const BEEF_V1 = 4022206465
945
+
946
+ try {
947
+ const beef = Beef.fromBinary(atomicBeef)
948
+ beef.version = BEEF_V1
949
+
950
+ let log = `transactions:${beef.txs.length}`
951
+ let logColor = chalk.gray(`transactions:${beef.txs.length}`)
952
+
953
+ if (showKey) {
954
+ logColor += ` ${chalk.gray(`key:`)} (${chalk.blue('txid/outpoint')} ${chalk.cyan('script')} ${chalk.green('sats')})`
955
+ }
956
+
957
+ const mainTxid = beef.txs.slice(-1)[0].txid
958
+ const mainTx: Transaction = beef.findAtomicTransaction(mainTxid)!
959
+
960
+ const action = actionsResult?.actions.find(a => a.txid === mainTxid)
961
+
962
+ const labelString = formatLabels(action?.labels)
963
+ const metadataString = formatMetadata(mainTx.metadata)
964
+ const merklePathString = formatMerklePath(mainTx.merklePath)
965
+
966
+ log += `\n${formatIndentedLineWithWrap(1, `txid:${mainTxid} version:${mainTx.version} lockTime:${mainTx.lockTime}${formatOptionalField('sats', action?.satoshis)}${formatOptionalField('status', action?.status)}${formatOptionalField('outgoing', action?.isOutgoing)}${formatOptionalFieldWithQuotes('desc', action?.description)}${metadataString}${merklePathString} labels:${labelString}`)}`
967
+ logColor += `\n${formatIndentedLineWithWrap(
968
+ 1,
969
+ [
970
+ chalk.blue(mainTxid),
971
+ ` ${chalk.gray('version:')}${mainTx.version}`,
972
+ ` ${chalk.gray('lockTime:')}${mainTx.lockTime}`,
973
+ ` ${chalk.green(`${action?.satoshis} sats`)}`,
974
+ formatOptionalFieldWithColor('status', action?.status, chalk.white),
975
+ formatOptionalFieldWithColor(
976
+ 'outgoing',
977
+ action?.isOutgoing,
978
+ chalk.white
979
+ ),
980
+ formatOptionalFieldWithColor('desc', action?.description, chalk.white),
981
+ metadataString ? chalk.gray(metadataString) : '',
982
+ merklePathString ? chalk.gray(merklePathString) : '',
983
+ ` ${chalk.gray('labels:')}${chalk.white(labelString)}`
984
+ ]
985
+ .filter(Boolean)
986
+ .join('')
987
+ )}`
988
+
989
+ log += `\n${formatIndentedLine(1, `inputs: ${action?.inputs?.length ?? 0}`)}`
990
+ logColor += `\n${formatIndentedLine(1, chalk.gray(`inputs: ${action?.inputs?.length ?? 0}`))}`
991
+
992
+ const sortedInputs = (action?.inputs ?? []).sort((a, b) =>
993
+ a.sourceOutpoint.localeCompare(b.sourceOutpoint)
994
+ )
995
+ const formattedInputs = formatInputs(sortedInputs)
996
+ formattedInputs.forEach(({ log: inputLog, logColor: inputLogColor }) => {
997
+ log += `\n${formatIndentedLine(2, inputLog)}`
998
+ logColor += `\n${formatIndentedLine(2, inputLogColor)}`
999
+ })
1000
+
1001
+ log += `\n${formatIndentedLineWithWrap(1, `outputs: ${action?.outputs?.length ?? 0}`)}`
1002
+ logColor += `\n${formatIndentedLineWithWrap(1, chalk.gray(`outputs: ${action?.outputs?.length ?? 0}`))}`
1003
+
1004
+ const sortedOutputs = action?.outputs
1005
+ ?.slice()
1006
+ .sort((a, b) => a.satoshis - b.satoshis)
1007
+ const formattedOutputs = formatOutputs(sortedOutputs!)
1008
+ formattedOutputs.forEach(({ log: outputLog, logColor: outputLogColor }) => {
1009
+ log += `\n${formatIndentedLine(2, outputLog)}`
1010
+ logColor += `\n${formatIndentedLine(2, outputLogColor)}`
1011
+ })
1012
+
1013
+ return { log, logColor }
1014
+ } catch (error) {
1015
+ return {
1016
+ log: `Error parsing transaction: ${(error as Error).message}`,
1017
+ logColor: chalk.red(
1018
+ `Error parsing transaction: ${(error as Error).message}`
1019
+ )
1020
+ }
1021
+ }
1022
+ }
1023
+
1024
+ export function createActionResultToTxLogString(
1025
+ createActionResult: CreateActionResult,
1026
+ actionsResult?: ListActionsResult,
1027
+ showKey: boolean = false
1028
+ ): { log: string; logColor: string } {
1029
+ const BEEF_V1 = 4022206465
1030
+
1031
+ const beef = Beef.fromBinary(createActionResult?.tx!)
1032
+ beef.version = BEEF_V1
1033
+ const mainTxid = beef.txs.slice(-1)[0].txid
1034
+
1035
+ return txToLogString(
1036
+ beef.findAtomicTransaction(mainTxid)!,
1037
+ 0,
1038
+ showKey,
1039
+ actionsResult
1040
+ )
1041
+ }
1042
+
1043
+ const MAX_RECURSION_DEPTH = 3
1044
+
1045
+ /**
1046
+ * Truncates a TXID, replacing the middle 48 characters with '...'.
1047
+ * @param {string} txid - The original transaction ID.
1048
+ * @returns {string} - The truncated TXID.
1049
+ */
1050
+ const truncateTxid = (txid: string): string => {
1051
+ if (txid.length <= 64) {
1052
+ return txid.slice(0, 8) + '...' + txid.slice(-8)
1053
+ }
1054
+ return txid
1055
+ }
1056
+
1057
+ /**
1058
+ * Formats a list of transaction outputs for logging.
1059
+ * @param {TransactionOutput[]} [outputs] - The list of transaction outputs.
1060
+ * @param {number} indent - The current indentation level.
1061
+ * @returns {{ log: string; logColor: string }[]} - A formatted log string array.
1062
+ */
1063
+ const formatTxOutputs = (outputs: TransactionOutput[], indent: number) =>
1064
+ outputs && outputs.length > 0
1065
+ ? outputs
1066
+ .sort((a, b) => a.satoshis! - b.satoshis!)
1067
+ .map((output, i) => {
1068
+ let line = formatIndentedLine(
1069
+ indent + 4,
1070
+ `${i}: lock:(${output.lockingScript.toHex().length || ''})${truncate(output.lockingScript.toHex())}`
1071
+ )
1072
+ let color = formatIndentedLine(
1073
+ indent + 4,
1074
+ `${chalk.gray(`${i}:`)} ${chalk.gray('lock:')}(${output.lockingScript.toHex().length || ''})${chalk.cyan(truncate(output.lockingScript.toHex()))}`
1075
+ )
1076
+
1077
+ if (output.satoshis) {
1078
+ line += ` sats:${output.satoshis}`
1079
+ color += ` ${chalk.green(`${output.satoshis} sats`)}`
1080
+ }
1081
+
1082
+ return { log: line, logColor: color }
1083
+ })
1084
+ : [
1085
+ {
1086
+ log: formatIndentedLine(indent + 4, 'No outputs'),
1087
+ logColor: formatIndentedLine(indent + 4, chalk.gray('No outputs'))
1088
+ }
1089
+ ]
1090
+
1091
+ /**
1092
+ * Formats transaction inputs with proper indentation.
1093
+ * @param {TransactionInput[]} inputs - The list of transaction inputs.
1094
+ * @param {number} indent - The current indentation level.
1095
+ * @returns {{ log: string; logColor: string }[]} - A formatted log string array.
1096
+ */
1097
+ const formatTxInputs = (inputs: TransactionInput[], indent: number) =>
1098
+ inputs && inputs.length > 0
1099
+ ? inputs
1100
+ .sort((a, b) => a.sourceTXID!.localeCompare(b.sourceTXID!))
1101
+ .map((input, i) => {
1102
+ let line = formatIndentedLine(
1103
+ indent + 4,
1104
+ `${i}: sourceTXID:${truncateTxid(input.sourceTXID!)}.${input.sourceOutputIndex}`
1105
+ )
1106
+ let color = formatIndentedLine(
1107
+ indent + 4,
1108
+ `${chalk.gray(`${i}:`)} ${chalk.blue(truncateTxid(input.sourceTXID!))}.${chalk.blue(input.sourceOutputIndex)}`
1109
+ )
1110
+
1111
+ if (input.unlockingScript) {
1112
+ line += `\n${formatIndentedLine(indent + 6, `unlock:(${input.unlockingScript.toHex().length})${truncate(input.unlockingScript.toHex())}`)}`
1113
+ color += `\n${formatIndentedLine(indent + 6, `${chalk.gray('unlock:')}(${input.unlockingScript.toHex().length})${chalk.cyan(truncate(input.unlockingScript.toHex()))}`)}`
1114
+ }
1115
+
1116
+ if (input.sequence) {
1117
+ line += `\n${formatIndentedLine(indent + 6, `seq:${input.sequence}`)}`
1118
+ color += `\n${formatIndentedLine(indent + 6, `${chalk.gray('seq:')}${input.sequence}`)}`
1119
+ }
1120
+
1121
+ if (input.sourceTransaction) {
1122
+ const { log: sourceTxLog, logColor: sourceTxLogColor } =
1123
+ txToLogString(input.sourceTransaction, indent + 6)
1124
+ const sourceTxLogTrimed = sourceTxLog.replace(
1125
+ /\s+Transaction/,
1126
+ 'Transaction'
1127
+ )
1128
+ const sourceTxLogColorTrimed = sourceTxLogColor.replace(
1129
+ /\s+Transaction/,
1130
+ 'Transaction'
1131
+ )
1132
+ line += `\n${formatIndentedLine(indent + 6, `sourceTx:`)}${sourceTxLogTrimed}`
1133
+ color += `\n${formatIndentedLine(indent + 6, `${chalk.gray('sourceTx:')}`)}${sourceTxLogColorTrimed}`
1134
+ } else {
1135
+ line += `\n${formatIndentedLine(indent + 6, `sourceTx:Transaction [Max Depth Reached]`)}`
1136
+ color += `\n${formatIndentedLine(indent + 6, chalk.gray(`sourceTx:Transaction [Max Depth Reached]`))}`
1137
+ }
1138
+
1139
+ return { log: line, logColor: color }
1140
+ })
1141
+ : [
1142
+ {
1143
+ log: formatIndentedLine(indent + 4, 'No inputs'),
1144
+ logColor: formatIndentedLine(indent + 4, chalk.gray('No inputs'))
1145
+ }
1146
+ ]
1147
+
1148
+ /**
1149
+ * Generates a formatted log string from a Transaction object.
1150
+ * Ensures proper indentation and prevents recursion errors.
1151
+ * @param {Transaction} tx - The Transaction object containing transaction data.
1152
+ * @param {number} indent - The current indentation level.
1153
+ * @param {boolean} [showKey=true] - Whether to display key transaction details.
1154
+ * @param {ListActionsResult} [actionsResult] - The result of listing actions.
1155
+ * @returns {{ log: string; logColor: string }} - A formatted log string and colorized version.
1156
+ */
1157
+ export function txToLogString(
1158
+ tx: Transaction,
1159
+ indent: number = 0,
1160
+ showKey: boolean = false,
1161
+ actionsResult?: ListActionsResult
1162
+ ): { log: string; logColor: string } {
1163
+ try {
1164
+ if (indent / 2 >= MAX_RECURSION_DEPTH) {
1165
+ return {
1166
+ log: formatIndentedLine(indent + 4, 'Transaction [Max Depth Reached]'),
1167
+ logColor: chalk.gray(
1168
+ formatIndentedLine(indent + 4, 'Transaction [Max Depth Reached]')
1169
+ )
1170
+ }
1171
+ }
1172
+ const beef = Beef.fromBinary(tx.toBEEF())
1173
+ const mainTxid = beef.txs.slice(-1)[0].txid
1174
+ const metadataString = formatMetadata(tx.metadata)
1175
+ const merklePathString = formatMerklePath(tx.merklePath)
1176
+ let log = formatIndentedLine(
1177
+ indent,
1178
+ `Transaction:${truncateTxid(mainTxid)}`
1179
+ )
1180
+ let logColor = formatIndentedLine(
1181
+ indent,
1182
+ `${chalk.gray('Transaction:')}${chalk.blue(truncateTxid(mainTxid))}`
1183
+ )
1184
+
1185
+ if (showKey) {
1186
+ logColor += ` ${chalk.gray(`key:`)} (${chalk.blue('txid/outpoint')} ${chalk.cyan('script')} ${chalk.green('sats')})`
1187
+ }
1188
+
1189
+ log += `\n${formatIndentedLine(indent + 2, `version:${tx.version} lockTime:${tx.lockTime}${metadataString}${merklePathString}`)}`
1190
+ logColor += `\n${formatIndentedLine(
1191
+ indent + 2,
1192
+ `${chalk.gray('version:')}${chalk.white(tx.version)} ${chalk.gray('lockTime:')}${chalk.white(tx.lockTime)}` +
1193
+ (metadataString ? chalk.gray(metadataString) : '') +
1194
+ (merklePathString ? chalk.gray(merklePathString) : '')
1195
+ )}`
1196
+
1197
+ log += `\n${formatIndentedLine(indent + 2, `inputs: ${tx?.inputs?.length ?? 0}`)}`
1198
+ logColor += `\n${formatIndentedLine(indent + 2, chalk.gray(`inputs: ${tx?.inputs?.length ?? 0}`))}`
1199
+
1200
+ const sortedInputs = (tx?.inputs ?? []).sort((a, b) =>
1201
+ a.sourceTXID!.localeCompare(b.sourceTXID!)
1202
+ )
1203
+ const formattedInputs = formatTxInputs(sortedInputs, indent)
1204
+ formattedInputs.forEach(({ log: inputLog, logColor: inputLogColor }) => {
1205
+ log += `\n${inputLog}`
1206
+ logColor += `\n${inputLogColor}`
1207
+ })
1208
+
1209
+ log += `\n${formatIndentedLine(indent + 2, `outputs: ${tx?.outputs?.length ?? 0}`)}`
1210
+ logColor += `\n${formatIndentedLine(indent + 2, chalk.gray(`outputs: ${tx?.outputs?.length ?? 0}`))}`
1211
+
1212
+ const sortedOutputs = tx?.outputs
1213
+ ?.slice()
1214
+ .sort((a, b) => a.satoshis! - b.satoshis!)
1215
+ const formattedTxOutputs = formatTxOutputs(sortedOutputs, indent)
1216
+ formattedTxOutputs.forEach(
1217
+ ({ log: outputLog, logColor: outputLogColor }) => {
1218
+ log += `\n${outputLog}`
1219
+ logColor += `\n${outputLogColor}`
1220
+ }
1221
+ )
1222
+
1223
+ return { log, logColor }
1224
+ } catch (error) {
1225
+ return {
1226
+ log: `Error parsing transaction: ${(error as Error).message}`,
1227
+ logColor: chalk.red(
1228
+ `Error parsing transaction: ${(error as Error).message}`
1229
+ )
1230
+ }
1231
+ }
1232
+ }
1233
+
1234
+ /**
1235
+ * Checks if an object is empty.
1236
+ * @param {unknown} obj - The object to check.
1237
+ * @returns {boolean} - Returns true if the object is empty, otherwise false.
1238
+ */
1239
+ export const isEmptyObject = (obj: unknown): boolean => {
1240
+ return !!obj && typeof obj === 'object' && Object.keys(obj).length === 0
1241
+ }
1242
+
1243
+ const formatIndentedLine = (indent: number, content: string) =>
1244
+ ' '.repeat(indent * 2) + content.trim() // Trim ensures no accidental double spacing
1245
+
1246
+ function log(s: string) {
1247
+ if (!noLog) console.log(s)
1248
+ //if (!noLog) process.stdout.write(s)
1249
+ }
1250
+
1251
+ function logWarn(s: string) {
1252
+ process.stdout.write(chalk.yellowBright(s))
1253
+ }
1254
+
1255
+ export function numberArrayToHexString(numbers: number[]): string {
1256
+ return numbers.map(num => num.toString(16).padStart(2, '0')).join('')
1257
+ }
1258
+
1259
+ /***Use these to generate the log string ***/
1260
+ //const testName = expect.getState().currentTestName ?? 'Unknown_Test'
1261
+ //appendLogsAsConst(testName, rl1)
1262
+
1263
+ // Auto-generated test log - 2025-02-05T13:04:29.906Z
1264
+ const LOG_createAction_nosend_transactions_1_transaction_with_single_output_checked_using_toLogString =
1265
+ {
1266
+ log: `transactions:3
1267
+ txid:30bdac0f5c6491f130820517802ff57e20e5a50c08b5c65e6976627fb82ae930 version:1 lockTime:0 sats:-4 status:nosend
1268
+ outgoing:true desc:'Funding transaction' labels:['funding transaction for createaction','this is an extra long test
1269
+ label that should be truncated at 80 chars when it is...']
1270
+ inputs: 1
1271
+ 0: sourceTXID:a3a8fe7f541c1383ff7b975af49b27284ae720af5f2705d8409baaf519190d26.2 sats:913
1272
+ lock:(50)76a914f7238871139f4926cbd592a03a737981e558245d88ac
1273
+ unlock:(214)483045022100cfef1f6d781af99a1de14efd6f24f2a14234a26097012f27121eb36f4e330c1d0220... seq:4294967295
1274
+ outputs: 2
1275
+ 0: sats:3 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true basket:'funding basket'
1276
+ desc:'Funding Output' tags:['funding transaction output','test tag']
1277
+ 1: sats:909 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:1 spendable:true basket:'default'`,
1278
+ logColor: `transactions:3 key: (txid/outpoint script sats)
1279
+ 30bdac0f5c6491f130820517802ff57e20e5a50c08b5c65e6976627fb82ae930 version:1 lockTime:0
1280
+ -4 sats status:nosend outgoing:true desc:Funding
1281
+ transaction labels:['funding transaction for createaction','this is an extra long test label that
1282
+ should be truncated at 80 chars when it is...']
1283
+ inputs: 1
1284
+ 0: a3a8fe7f541c1383ff7b975af49b27284ae720af5f2705d8409baaf519190d26.2 913 sats
1285
+ lock:(50)76a914f7238871139f4926cbd592a03a737981e558245d88ac
1286
+ unlock:(214)483045022100cfef1f6d781af99a1de14efd6f24f2a14234a26097012f27121eb36f4e330c1d0220...
1287
+ seq:4294967295
1288
+ outputs: 2
1289
+ 0: 3 sats lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac
1290
+ index:0 spendable:true basket:funding basket
1291
+ desc:Funding Output tags:['funding transaction output','test tag']
1292
+ 1: 909 sats lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac
1293
+ index:1 spendable:true basket:default`
1294
+ }
1295
+
1296
+ // Auto-generated test log - 2025-02-05T13:46:12.091Z
1297
+ const LOG_createAction_nosend_transactions_2_transaction_with_multiple_outputs_checked_using_toLogString =
1298
+ {
1299
+ log: `transactions:3
1300
+ txid:b3848f2cabf5887ec679ca60347a29f6ecad425fda738700265c2f9d22c18ab5 version:1 lockTime:0 sats:-12 status:nosend
1301
+ outgoing:true desc:'Funding transaction with multiple outputs' labels:['funding transaction for createaction','this
1302
+ is the extra label']
1303
+ inputs: 1
1304
+ 0: sourceTXID:a3a8fe7f541c1383ff7b975af49b27284ae720af5f2705d8409baaf519190d26.2 sats:913
1305
+ lock:(50)76a914f7238871139f4926cbd592a03a737981e558245d88ac
1306
+ unlock:(212)473044022079020cc8ea5ee6b3610806286e41567147d4b4b07d16bc1341311e00ce7647b0022034... seq:4294967295
1307
+ outputs: 3
1308
+ 0: sats:5 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true basket:'funding basket'
1309
+ desc:'Funding output' tags:['funding transaction for createaction','test tag']
1310
+ 1: sats:6 lock:(48)76a914fedcba9876543210fedcba9876543210fedcba88ac index:1 spendable:true basket:'extra basket'
1311
+ desc:'Extra Output' tags:['extra transaction output','extra test tag']
1312
+ 2: sats:901 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:2 spendable:true basket:'default'`,
1313
+ logColor: `transactions:3 key: (txid/outpoint script sats)
1314
+ b3848f2cabf5887ec679ca60347a29f6ecad425fda738700265c2f9d22c18ab5 version:1 lockTime:0
1315
+ -12 sats status:nosend outgoing:true desc:Funding
1316
+ transaction with multiple outputs labels:['funding transaction for createaction','this is the
1317
+ extra label']
1318
+ inputs: 1
1319
+ 0: a3a8fe7f541c1383ff7b975af49b27284ae720af5f2705d8409baaf519190d26.2 913 sats
1320
+ lock:(50)76a914f7238871139f4926cbd592a03a737981e558245d88ac
1321
+ unlock:(212)473044022079020cc8ea5ee6b3610806286e41567147d4b4b07d16bc1341311e00ce7647b0022034...
1322
+ seq:4294967295
1323
+ outputs: 3
1324
+ 0: 5 sats lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac
1325
+ index:0 spendable:true basket:funding basket
1326
+ desc:Funding output tags:['funding transaction for createaction','test
1327
+ tag']
1328
+ 1: 6 sats lock:(48)76a914fedcba9876543210fedcba9876543210fedcba88ac
1329
+ index:1 spendable:true basket:extra basket
1330
+ desc:Extra Output tags:['extra transaction output','extra test tag']
1331
+ 2: 901 sats lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac
1332
+ index:2 spendable:true basket:default`
1333
+ }
1334
+
1335
+ // Auto-generated test log - 2025-02-05T14:50:57.843Z
1336
+ const LOG_createAction_nosend_transactions_3_transaction_with_explicit_change_check_also_uses_toLogString_on_the_spend =
1337
+ {
1338
+ log: `transactions:5
1339
+ txid:afa6713aab0957cf5bb00dee532ad7b895e919a99564ec2016b51cb3d472d87f version:1 lockTime:0 sats:1 status:nosend
1340
+ outgoing:true desc:'Explicit check on returned change' labels:['spending transaction test']
1341
+ inputs: 2
1342
+ 0: sourceTXID:527ffe88f70d5b7de2b8b5ba9966b9c755e7da4de749d4fcd27140a03145a11d.0 sats:995
1343
+ lock:(50)76a914ab2b66432503a3681fc5af1502207ca458c8752d88ac
1344
+ unlock:(214)483045022100973a84555fa864e08313bda5c88e1991094db7b8d82586c899276155dabcbc9a0220... seq:4294967295
1345
+ 1: sourceTXID:70afdc54187a1cdb8e35f7d00e5e111cbf5c43c4dc3f1da2cc44479133c75f9e.0 sats:4 desc:'Funding output'
1346
+ lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac unlock:(16)47304402207f2e9a seq:4294967295
1347
+ outputs: 2
1348
+ 0: sats:2 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true desc:'First spending
1349
+ Output for check on change '
1350
+ 1: sats:996 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:1 spendable:true basket:'default'`,
1351
+ logColor: `transactions:5 key: (txid/outpoint script sats)
1352
+ afa6713aab0957cf5bb00dee532ad7b895e919a99564ec2016b51cb3d472d87f version:1 lockTime:0
1353
+ 1 sats status:nosend outgoing:true desc:Explicit
1354
+ check on returned change labels:['spending transaction test']
1355
+ inputs: 2
1356
+ 0: 527ffe88f70d5b7de2b8b5ba9966b9c755e7da4de749d4fcd27140a03145a11d.0 995 sats
1357
+ lock:(50)76a914ab2b66432503a3681fc5af1502207ca458c8752d88ac
1358
+ unlock:(214)483045022100973a84555fa864e08313bda5c88e1991094db7b8d82586c899276155dabcbc9a0220...
1359
+ seq:4294967295
1360
+ 1: 70afdc54187a1cdb8e35f7d00e5e111cbf5c43c4dc3f1da2cc44479133c75f9e.0 4 sats
1361
+ desc:Funding output
1362
+ lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac
1363
+ unlock:(16)47304402207f2e9a seq:4294967295
1364
+ outputs: 2
1365
+ 0: 2 sats lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac
1366
+ index:0 spendable:true desc:First spending Output for check
1367
+ on change 
1368
+ 1: 996 sats lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac
1369
+ index:1 spendable:true basket:default`
1370
+ }
1371
+
1372
+ // Auto-generated test log - 2025-02-05T15:22:24.388Z
1373
+ const LOG_createAction_nosend_transactions_4_transaction_with_custom_options_knownTxids_and_returnTXIDOnly_false_uses_toLogString =
1374
+ {
1375
+ log: `transactions:2
1376
+ txid:38ded69627603b30bd1f55eb3f88098dbf74f2ef0ff5e3cfe6a34f97ce2db9c2 version:1 lockTime:0 sats:-5 status:nosend
1377
+ outgoing:true desc:'Check knownTxids and returnTXIDOnly' labels:['custom options test']
1378
+ inputs: 1
1379
+ 0: sourceTXID:527ffe88f70d5b7de2b8b5ba9966b9c755e7da4de749d4fcd27140a03145a11d.0 sats:995
1380
+ lock:(50)76a914ab2b66432503a3681fc5af1502207ca458c8752d88ac
1381
+ unlock:(212)4730440220113a6f72035a6ddcd6930db7e3f3d5c70486f9aaefb095e6fa3557afa916ec37022054... seq:4294967295
1382
+ outputs: 2
1383
+ 0: sats:4 lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac index:0 spendable:true desc:'returnTXIDOnly
1384
+ false test'
1385
+ 1: sats:990 lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac index:1 spendable:true basket:'default'`,
1386
+ logColor: `transactions:2 key: (txid/outpoint script sats)
1387
+ 38ded69627603b30bd1f55eb3f88098dbf74f2ef0ff5e3cfe6a34f97ce2db9c2 version:1 lockTime:0
1388
+ -5 sats status:nosend outgoing:true desc:Check
1389
+ knownTxids and returnTXIDOnly labels:['custom options test']
1390
+ inputs: 1
1391
+ 0: 527ffe88f70d5b7de2b8b5ba9966b9c755e7da4de749d4fcd27140a03145a11d.0 995 sats
1392
+ lock:(50)76a914ab2b66432503a3681fc5af1502207ca458c8752d88ac
1393
+ unlock:(212)4730440220113a6f72035a6ddcd6930db7e3f3d5c70486f9aaefb095e6fa3557afa916ec37022054...
1394
+ seq:4294967295
1395
+ outputs: 2
1396
+ 0: 4 sats lock:(48)76a914abcdef0123456789abcdef0123456789abcdef88ac
1397
+ index:0 spendable:true desc:returnTXIDOnly false test
1398
+ 1: 990 sats lock:(50)76a9145947e66cdd43c70fb1780116b79e6f7d96e30e0888ac
1399
+ index:1 spendable:true basket:default`
1400
+ }