@bsv/wallet-toolbox 1.2.36 → 1.2.38

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.
@@ -305,7 +305,7 @@ describe('CWIStyleWalletManager Tests', () => {
305
305
 
306
306
  test('Throws if no token found by recovery key hash', async () => {
307
307
  ;(mockUMPTokenInteractor.findByRecoveryKeyHash as any).mockResolvedValueOnce(undefined)
308
- await expect(manager.provideRecoveryKey(recoveryKey)).rejects.toThrow('No user found with this key')
308
+ await expect(manager.provideRecoveryKey(recoveryKey)).rejects.toThrow('No user found with this recovery key')
309
309
  })
310
310
  })
311
311
 
@@ -349,7 +349,7 @@ describe('CWIStyleWalletManager Tests', () => {
349
349
 
350
350
  test('Throws error if saving snapshot while no primary key or token set', async () => {
351
351
  // Manager is not yet authenticated
352
- expect(() => manager.saveSnapshot()).toThrow('No primary key or current UMP token set')
352
+ expect(() => manager.saveSnapshot()).toThrow('No root primary key or current UMP token set')
353
353
  })
354
354
 
355
355
  test('Throws if snapshot is corrupt or cannot be decrypted', async () => {
@@ -380,7 +380,7 @@ describe('CWIStyleWalletManager Tests', () => {
380
380
  })
381
381
 
382
382
  test('Throws if not authenticated', async () => {
383
- await expect(manager.changePassword('test-password')).rejects.toThrow('Not authenticated.')
383
+ await expect(manager.changePassword('test-password')).rejects.toThrow('Not authenticated or missing required data.')
384
384
  })
385
385
  })
386
386
 
@@ -407,7 +407,7 @@ describe('CWIStyleWalletManager Tests', () => {
407
407
  })
408
408
 
409
409
  test('Throws if not authenticated', async () => {
410
- await expect(manager.changeRecoveryKey()).rejects.toThrow('Not authenticated.')
410
+ await expect(manager.changeRecoveryKey()).rejects.toThrow('Not authenticated or missing required data.')
411
411
  })
412
412
  })
413
413
 
@@ -581,7 +581,7 @@ describe('CWIStyleWalletManager Tests', () => {
581
581
 
582
582
  // Call the underlying privileged key manager’s decrypt twice.
583
583
  // (For example, we use the ciphertext from one of the token’s encrypted fields.)
584
- await (manager as any).underlyingPrivilegedKeyManager.decrypt({
584
+ await (manager as any).rootPrivilegedKeyManager.decrypt({
585
585
  ciphertext: (manager as any).currentUMPToken.passwordKeyEncrypted,
586
586
  protocolID: [2, 'admin key wrapping'],
587
587
  keyID: '1'
@@ -590,7 +590,7 @@ describe('CWIStyleWalletManager Tests', () => {
590
590
  // Key expires after 2 minutes
591
591
  jest.advanceTimersByTime(121_000)
592
592
 
593
- await (manager as any).underlyingPrivilegedKeyManager.decrypt({
593
+ await (manager as any).rootPrivilegedKeyManager.decrypt({
594
594
  ciphertext: (manager as any).currentUMPToken.passwordKeyEncrypted,
595
595
  protocolID: [2, 'admin key wrapping'],
596
596
  keyID: '1'
@@ -1,11 +1,7 @@
1
1
  import { EntitySyncState, sdk } from '../../../src'
2
2
  import { _tu } from '../../utils/TestUtilsWalletStorage'
3
3
  import { specOpInvalidChange } from '../../../src/sdk'
4
- import {
5
- createOneSatTestOutput,
6
- createSetup,
7
- LocalWalletTestOptions,
8
- } from '../../utils/localWalletMethods'
4
+ import { createOneSatTestOutput, createSetup, LocalWalletTestOptions } from '../../utils/localWalletMethods'
9
5
 
10
6
  const chain: sdk.Chain = 'test'
11
7
 
@@ -201,13 +201,14 @@ describe('localWallet2 tests', () => {
201
201
  await storage.destroy()
202
202
  })
203
203
 
204
- test('8 jackie Beef', async () => {
204
+ test('8 jackie Beef', async () => {
205
205
  const setup = await createSetup(chain, options)
206
206
  const beef = Beef.fromBinary(beefJackie)
207
207
  console.log(beef.toLogString())
208
- const ok = beef.verify(await setup.services.getChainTracker())
208
+ const ok = await beef.verify(await setup.services.getChainTracker())
209
209
  await setup.wallet.destroy()
210
210
  })
211
+
211
212
  })
212
213
 
213
214
  async function createMainReviewSetup(): Promise<{
@@ -232,5 +233,15 @@ async function createMainReviewSetup(): Promise<{
232
233
  return { env, storage, services }
233
234
  }
234
235
 
235
- const beefJackie = [
236
- 1, 1, 1, 1, 196, 222, 98, 76, 119, 112, 138, 49, 125, 79, 3, 8, 17, 96, 88, 134, 18, 94, 233, 6, 43, 58, 55, 200, 53, 21, 225, 58, 243, 130, 114, 64, 2, 0, 190, 239, 0, 1, 0, 1, 0, 0, 0, 1, 157, 193, 59, 124, 10, 214, 21, 108, 182, 51, 203, 122, 124, 52, 230, 65, 248, 166, 3, 136, 224, 45, 213, 116, 91, 81, 101, 168, 142, 252, 196, 20, 110, 0, 0, 0, 107, 72, 48, 69, 2, 33, 0, 144, 86, 132, 240, 56, 253, 101, 20, 254, 1, 184, 144, 98, 236, 225, 242, 239, 88, 99, 196, 58, 33, 141, 79, 234, 140, 7, 22, 254, 140, 65, 83, 2, 32, 113, 198, 86, 176, 19, 16, 165, 168, 5, 227, 70, 44, 5, 22, 144, 179, 172, 170, 13, 148, 3, 236, 35, 2, 74, 238, 235, 84, 148, 192, 102, 138, 65, 33, 3, 15, 101, 106, 207, 42, 192, 187, 51, 59, 128, 27, 240, 244, 240, 4, 224, 230, 41, 166, 89, 216, 46, 7, 24, 242, 180, 20, 90, 12, 57, 59, 144, 255, 255, 255, 255, 2, 136, 19, 0, 0, 0, 0, 0, 0, 25, 118, 169, 20, 240, 178, 178, 204, 51, 126, 211, 251, 43, 177, 154, 94, 189, 29, 53, 41, 220, 136, 142, 80, 136, 172, 208, 140, 0, 0, 0, 0, 0, 0, 25, 118, 169, 20, 217, 48, 110, 108, 236, 100, 116, 90, 181, 114, 45, 176, 198, 216, 150, 134, 16, 251, 10, 177, 136, 172, 0, 0, 0, 0]
236
+ const beefJackie = [
237
+ 1, 1, 1, 1, 196, 222, 98, 76, 119, 112, 138, 49, 125, 79, 3, 8, 17, 96, 88, 134, 18, 94, 233, 6, 43, 58, 55, 200, 53,
238
+ 21, 225, 58, 243, 130, 114, 64, 2, 0, 190, 239, 0, 1, 0, 1, 0, 0, 0, 1, 157, 193, 59, 124, 10, 214, 21, 108, 182, 51,
239
+ 203, 122, 124, 52, 230, 65, 248, 166, 3, 136, 224, 45, 213, 116, 91, 81, 101, 168, 142, 252, 196, 20, 110, 0, 0, 0,
240
+ 107, 72, 48, 69, 2, 33, 0, 144, 86, 132, 240, 56, 253, 101, 20, 254, 1, 184, 144, 98, 236, 225, 242, 239, 88, 99, 196,
241
+ 58, 33, 141, 79, 234, 140, 7, 22, 254, 140, 65, 83, 2, 32, 113, 198, 86, 176, 19, 16, 165, 168, 5, 227, 70, 44, 5, 22,
242
+ 144, 179, 172, 170, 13, 148, 3, 236, 35, 2, 74, 238, 235, 84, 148, 192, 102, 138, 65, 33, 3, 15, 101, 106, 207, 42,
243
+ 192, 187, 51, 59, 128, 27, 240, 244, 240, 4, 224, 230, 41, 166, 89, 216, 46, 7, 24, 242, 180, 20, 90, 12, 57, 59, 144,
244
+ 255, 255, 255, 255, 2, 136, 19, 0, 0, 0, 0, 0, 0, 25, 118, 169, 20, 240, 178, 178, 204, 51, 126, 211, 251, 43, 177,
245
+ 154, 94, 189, 29, 53, 41, 220, 136, 142, 80, 136, 172, 208, 140, 0, 0, 0, 0, 0, 0, 25, 118, 169, 20, 217, 48, 110,
246
+ 108, 236, 100, 116, 90, 181, 114, 45, 176, 198, 216, 150, 134, 16, 251, 10, 177, 136, 172, 0, 0, 0, 0
247
+ ]
@@ -67,7 +67,7 @@ describe('operations1 tests', () => {
67
67
  let offset = 2200
68
68
  const limit = 100
69
69
  let allUnfails: number[] = []
70
- for (; ;) {
70
+ for (;;) {
71
71
  let log = ''
72
72
  const unfails: number[] = []
73
73
  const reqs = await storage.findProvenTxReqs({ partial: { status: 'doubleSpend' }, paged: { limit, offset } })
@@ -91,10 +91,10 @@ describe('operations1 tests', () => {
91
91
 
92
92
  test('7 review and unfail false invalids', async () => {
93
93
  const { env, storage, services } = await createMainReviewSetup()
94
- let offset = 400
94
+ let offset = 500
95
95
  const limit = 100
96
96
  let allUnfails: number[] = []
97
- for (; ;) {
97
+ for (;;) {
98
98
  let log = ''
99
99
  const unfails: number[] = []
100
100
  const reqs = await storage.findProvenTxReqs({ partial: { status: 'invalid' }, paged: { limit, offset } })
@@ -128,36 +128,41 @@ describe('operations1 tests', () => {
128
128
  and JSON_EXTRACT(f.customInstructions, '$.payee') = '${identityKey}'
129
129
  and not exists(select * from outputs as r where r.userId = ${userId} and r.txid = f.txid)
130
130
  `)
131
- if (outputs.length > 0)
132
- console.log(`userId ${userId} ${identityKey} ${outputs.length} outputs`)
131
+ if (outputs.length > 0) console.log(`userId ${userId} ${identityKey} ${outputs.length} outputs`)
133
132
  for (const output of outputs) {
134
- const req = verifyOneOrNone(await storage.findProvenTxReqs({ partial: { txid: output.txid, status: 'completed' } }))
133
+ const req = verifyOneOrNone(
134
+ await storage.findProvenTxReqs({ partial: { txid: output.txid, status: 'completed' } })
135
+ )
135
136
  const { type, derivationPrefix, derivationSuffix, payee } = JSON.parse(output.customInstructions!)
136
137
  if (req && type === 'BRC29' && derivationPrefix && derivationSuffix) {
137
138
  const beef = await storage.getBeefForTransaction(req.txid, {})
138
139
  // {"type":"BRC29","derivationPrefix":"LDFooHSsXzw=","derivationSuffix":"4f4ixKv+6SY=","payee":"0352caa755d5b6279e15e47e096db908e7c4a73a31775e7e8720bdd4cf2d44873a"}
139
- await storage.internalizeAction({ userId, identityKey: user.identityKey }, {
140
- tx: beef.toBinaryAtomic(req.txid),
141
- outputs: [{
142
- outputIndex: 0,
143
- protocol: 'wallet payment',
144
- paymentRemittance: {
145
- derivationPrefix: derivationPrefix,
146
- derivationSuffix: derivationSuffix,
147
- senderIdentityKey: user0.identityKey,
148
- }
149
- }],
150
- description: 'Internalizing export funds tx into foreign wallet'
151
- })
140
+ await storage.internalizeAction(
141
+ { userId, identityKey: user.identityKey },
142
+ {
143
+ tx: beef.toBinaryAtomic(req.txid),
144
+ outputs: [
145
+ {
146
+ outputIndex: 0,
147
+ protocol: 'wallet payment',
148
+ paymentRemittance: {
149
+ derivationPrefix: derivationPrefix,
150
+ derivationSuffix: derivationSuffix,
151
+ senderIdentityKey: user0.identityKey
152
+ }
153
+ }
154
+ ],
155
+ description: 'Internalizing export funds tx into foreign wallet'
156
+ }
157
+ )
152
158
  console.log('internalize', userId, output.txid)
153
159
  }
154
160
  }
155
161
  }
156
- /*
157
- */
162
+ /*
163
+ */
158
164
  await storage.destroy()
159
165
  })
160
-
161
166
  })
162
167
 
163
168
  async function createMainReviewSetup(): Promise<{