@bsv/wallet-toolbox 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +8 -2
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +3 -0
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/storage/__test/getBeefForTransaction.test.js +0 -3
- package/out/src/storage/__test/getBeefForTransaction.test.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +0 -5
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/utility/identityUtils.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.d.ts +1 -4
- package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +4 -55
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/support/janitor.man.test.js +13 -10
- package/out/test/Wallet/support/janitor.man.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +2 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/wallet/action/createAction2.test.d.ts.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/providers/Bitails.ts +7 -2
- package/src/services/providers/WhatsOnChain.ts +3 -0
- package/src/storage/__test/getBeefForTransaction.test.ts +0 -3
- package/src/storage/remoting/StorageClient.ts +0 -6
- package/test/Wallet/local/localWallet.man.test.ts +5 -85
- package/test/Wallet/support/janitor.man.test.ts +3 -2
package/package.json
CHANGED
|
@@ -128,9 +128,14 @@ export class Bitails {
|
|
|
128
128
|
rt.notes!.push({ ...nne(), what: 'postRawsMissingResult', txid })
|
|
129
129
|
} else if (btr.error) {
|
|
130
130
|
// code: -25, message: 'missing-inputs'
|
|
131
|
-
|
|
131
|
+
// code: -27, message: 'already-in-mempool'
|
|
132
132
|
const { code, message } = btr.error
|
|
133
|
-
|
|
133
|
+
if (code === -27) {
|
|
134
|
+
rt.notes!.push({ ...nne(), what: 'postRawsSuccessAlreadyInMempool' })
|
|
135
|
+
} else {
|
|
136
|
+
rt.status = 'error'
|
|
137
|
+
rt.notes!.push({ ...nne(), what: 'postRawsError', txid, code, message })
|
|
138
|
+
}
|
|
134
139
|
} else {
|
|
135
140
|
rt.notes!.push({ ...nn(), what: 'postRawsSuccess' })
|
|
136
141
|
}
|
|
@@ -167,6 +167,9 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
167
167
|
if (response.ok) {
|
|
168
168
|
const txid = response.data
|
|
169
169
|
r.notes!.push({ ...nn(), what: 'postRawTxSuccess' })
|
|
170
|
+
}
|
|
171
|
+
if (response.statusText === 'unexpected response code 500: Transaction already in the mempool') {
|
|
172
|
+
r.notes!.push({ ...nne(), what: 'postRawTxSuccessAlreadyInMempool' })
|
|
170
173
|
} else {
|
|
171
174
|
r.status = 'error'
|
|
172
175
|
const n: ReqHistoryNote = {
|
|
@@ -82,9 +82,6 @@ class ProtoStorage extends StorageProvider {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
async getBeefForTxid(txid: string): Promise<Beef> {
|
|
85
|
-
const s = this._services!
|
|
86
|
-
const rr = await s.getRawTx(txid)
|
|
87
|
-
console.log(rr.name)
|
|
88
85
|
const beef = this.getBeefForTransaction(txid, this.gbo)
|
|
89
86
|
return beef
|
|
90
87
|
}
|
|
@@ -110,12 +110,6 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
114
|
-
// In a real environment, you might do lazy or real "makeAvailable" logic
|
|
115
|
-
// For demonstration, we assume that the remote store might return its "settings"
|
|
116
|
-
// and we store them locally in `this.settings`.
|
|
117
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
118
|
-
|
|
119
113
|
/**
|
|
120
114
|
* @returns true once storage `TableSettings` have been retreived from remote storage.
|
|
121
115
|
*/
|
|
@@ -5,28 +5,11 @@ import {
|
|
|
5
5
|
CreateActionResult,
|
|
6
6
|
OutpointString,
|
|
7
7
|
P2PKH,
|
|
8
|
-
PrivateKey,
|
|
9
8
|
PublicKey,
|
|
10
|
-
Script,
|
|
11
9
|
SignActionArgs
|
|
12
10
|
} from '@bsv/sdk'
|
|
13
|
-
import {
|
|
14
|
-
asString,
|
|
15
|
-
EntityProvenTxReq,
|
|
16
|
-
EntitySyncState,
|
|
17
|
-
Monitor,
|
|
18
|
-
sdk,
|
|
19
|
-
Services,
|
|
20
|
-
Setup,
|
|
21
|
-
StorageKnex,
|
|
22
|
-
TableOutput,
|
|
23
|
-
TableUser,
|
|
24
|
-
verifyId,
|
|
25
|
-
verifyOne,
|
|
26
|
-
wait
|
|
27
|
-
} from '../../../src'
|
|
11
|
+
import { EntityProvenTxReq, EntitySyncState, sdk, wait } from '../../../src'
|
|
28
12
|
import { _tu, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
29
|
-
import { monitorEventLoopDelay } from 'perf_hooks'
|
|
30
13
|
import { specOpInvalidChange, validateCreateActionArgs, ValidCreateActionArgs } from '../../../src/sdk'
|
|
31
14
|
|
|
32
15
|
const chain: sdk.Chain = 'test'
|
|
@@ -38,11 +21,13 @@ const useIdentityKey2 = false
|
|
|
38
21
|
describe('localWallet tests', () => {
|
|
39
22
|
jest.setTimeout(99999999)
|
|
40
23
|
|
|
41
|
-
test('00', () => {})
|
|
42
|
-
if (_tu.noTestEnv(chain)) return
|
|
24
|
+
// test('00', () => {})
|
|
25
|
+
// if (_tu.noTestEnv(chain)) return
|
|
43
26
|
|
|
44
27
|
test('0 monitor runOnce', async () => {
|
|
45
28
|
const setup = await createSetup(chain)
|
|
29
|
+
const key = await setup.wallet.getPublicKey({ identityKey: true })
|
|
30
|
+
expect(key.publicKey.toString()).toBe(setup.identityKey)
|
|
46
31
|
await setup.monitor.runOnce()
|
|
47
32
|
await setup.wallet.destroy()
|
|
48
33
|
})
|
|
@@ -97,18 +82,6 @@ describe('localWallet tests', () => {
|
|
|
97
82
|
tags: ['release']
|
|
98
83
|
})
|
|
99
84
|
}
|
|
100
|
-
/*
|
|
101
|
-
const storage = setup.activeStorage
|
|
102
|
-
const services = setup.services
|
|
103
|
-
const { invalidSpendableOutputs: notUtxos } = await confirmSpendableOutputs(storage, services)
|
|
104
|
-
const outputsToUpdate = notUtxos.map(o => ({ id: o.outputId, satoshis: o.satoshis }))
|
|
105
|
-
const total: number = outputsToUpdate.reduce((t, o) => t + o.satoshis, 0)
|
|
106
|
-
debugger
|
|
107
|
-
// *** About set spendable = false for outputs ***
|
|
108
|
-
for (const o of outputsToUpdate) {
|
|
109
|
-
await storage.updateOutput(o.id, { spendable: false })
|
|
110
|
-
}
|
|
111
|
-
*/
|
|
112
85
|
await setup.wallet.destroy()
|
|
113
86
|
})
|
|
114
87
|
|
|
@@ -311,56 +284,3 @@ async function trackReqByTxid(setup: TestWalletNoSetup, txid: string): Promise<v
|
|
|
311
284
|
lastHeight = height
|
|
312
285
|
}
|
|
313
286
|
}
|
|
314
|
-
|
|
315
|
-
export async function confirmSpendableOutputs(
|
|
316
|
-
storage: StorageKnex,
|
|
317
|
-
services: Services,
|
|
318
|
-
identityKey?: string
|
|
319
|
-
): Promise<{ invalidSpendableOutputs: TableOutput[] }> {
|
|
320
|
-
const invalidSpendableOutputs: TableOutput[] = []
|
|
321
|
-
const partial: Partial<TableUser> = {}
|
|
322
|
-
if (identityKey) partial.identityKey = identityKey
|
|
323
|
-
const users = await storage.findUsers({ partial })
|
|
324
|
-
|
|
325
|
-
for (const { userId } of users) {
|
|
326
|
-
const defaultBasket = verifyOne(await storage.findOutputBaskets({ partial: { userId, name: 'default' } }))
|
|
327
|
-
const where: Partial<TableOutput> = {
|
|
328
|
-
userId,
|
|
329
|
-
basketId: defaultBasket.basketId,
|
|
330
|
-
spendable: true
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const outputs = await storage.findOutputs({ partial: where })
|
|
334
|
-
|
|
335
|
-
for (let i = outputs.length - 1; i >= 0; i--) {
|
|
336
|
-
const o = outputs[i]
|
|
337
|
-
const oid = verifyId(o.outputId)
|
|
338
|
-
|
|
339
|
-
if (o.spendable) {
|
|
340
|
-
let ok = false
|
|
341
|
-
|
|
342
|
-
if (o.lockingScript && o.lockingScript.length > 0) {
|
|
343
|
-
const r = await services.getUtxoStatus(asString(o.lockingScript), 'script')
|
|
344
|
-
|
|
345
|
-
if (r.status === 'success' && r.isUtxo && r.details?.length > 0) {
|
|
346
|
-
const tx = await storage.findTransactionById(o.transactionId)
|
|
347
|
-
|
|
348
|
-
if (
|
|
349
|
-
tx &&
|
|
350
|
-
tx.txid &&
|
|
351
|
-
r.details.some(d => d.txid === tx.txid && d.satoshis === o.satoshis && d.index === o.vout)
|
|
352
|
-
) {
|
|
353
|
-
ok = true
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (!ok) {
|
|
359
|
-
invalidSpendableOutputs.push(o)
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return { invalidSpendableOutputs }
|
|
366
|
-
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Services, StorageKnex } from '../../../src'
|
|
2
2
|
import { _tu } from '../../utils/TestUtilsWalletStorage'
|
|
3
|
-
import { confirmSpendableOutputs } from '../local/localWallet.man.test'
|
|
4
3
|
|
|
5
4
|
describe('janitor tests', () => {
|
|
6
5
|
jest.setTimeout(99999999)
|
|
@@ -19,6 +18,7 @@ describe('janitor tests', () => {
|
|
|
19
18
|
|
|
20
19
|
const services = new Services(env.chain)
|
|
21
20
|
|
|
21
|
+
/*
|
|
22
22
|
const identityKey = '0304985aa632dde471d3bf1ffb030d0af253fe65f5d186bb4cf878ca0fbee54c1c'
|
|
23
23
|
const { invalidSpendableOutputs: notUtxos } = await confirmSpendableOutputs(storage, services, identityKey)
|
|
24
24
|
const outputsToUpdate = notUtxos.map(o => ({
|
|
@@ -29,10 +29,11 @@ describe('janitor tests', () => {
|
|
|
29
29
|
const total: number = outputsToUpdate.reduce((t, o) => t + o.satoshis, 0)
|
|
30
30
|
|
|
31
31
|
debugger
|
|
32
|
-
// *** About set spendable = false for outputs
|
|
32
|
+
// *** About set spendable = false for outputs ***
|
|
33
33
|
for (const o of outputsToUpdate) {
|
|
34
34
|
await storage.updateOutput(o.id, { spendable: false })
|
|
35
35
|
}
|
|
36
|
+
*/
|
|
36
37
|
|
|
37
38
|
await storage.destroy()
|
|
38
39
|
})
|