@bsv/wallet-toolbox 1.2.33 → 1.2.36
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/docs/client.md +458 -1816
- package/docs/monitor.md +7 -7
- package/docs/services.md +236 -2
- package/docs/wallet.md +458 -1816
- package/out/src/Setup.d.ts +1 -2
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +17 -18
- package/out/src/Setup.js.map +1 -1
- package/out/src/Wallet.d.ts +4 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +111 -51
- package/out/src/Wallet.js.map +1 -1
- package/out/src/index.client.d.ts +5 -6
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +5 -6
- package/out/src/index.client.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts +4 -2
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +45 -13
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +3 -0
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +6 -4
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +3 -3
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts +2 -2
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts +2 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.js +2 -2
- package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +19 -18
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletSigner.interfaces.d.ts +2 -2
- package/out/src/sdk/WalletSigner.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +57 -53
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/types.d.ts +12 -0
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +16 -1
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +3 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +58 -23
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +40 -6
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/local/localWallet2.man.test.js +74 -5
- package/out/test/Wallet/local/localWallet2.man.test.js.map +1 -1
- package/out/test/Wallet/specOps/specOps.man.test.js +37 -5
- package/out/test/Wallet/specOps/specOps.man.test.js.map +1 -1
- package/out/test/Wallet/support/opers1.man.test.d.ts +2 -0
- package/out/test/Wallet/support/opers1.man.test.d.ts.map +1 -0
- package/out/test/Wallet/support/opers1.man.test.js +200 -0
- package/out/test/Wallet/support/opers1.man.test.js.map +1 -0
- package/out/test/WalletClient/LocalKVStore.man.test.d.ts +2 -0
- package/out/test/WalletClient/LocalKVStore.man.test.d.ts.map +1 -0
- package/out/test/WalletClient/LocalKVStore.man.test.js +99 -0
- package/out/test/WalletClient/LocalKVStore.man.test.js.map +1 -0
- package/out/test/WalletClient/WERR.man.test.d.ts +2 -0
- package/out/test/WalletClient/WERR.man.test.d.ts.map +1 -0
- package/out/test/WalletClient/WERR.man.test.js +21 -0
- package/out/test/WalletClient/WERR.man.test.js.map +1 -0
- package/out/test/services/Services.test.js +3 -1
- package/out/test/services/Services.test.js.map +1 -1
- package/out/test/{Wallet/local → utils}/localWalletMethods.d.ts +2 -2
- package/out/test/utils/localWalletMethods.d.ts.map +1 -0
- package/out/test/{Wallet/local → utils}/localWalletMethods.js +4 -4
- package/out/test/utils/localWalletMethods.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Setup.ts +2 -2
- package/src/Wallet.ts +41 -9
- package/src/index.client.ts +5 -6
- package/src/monitor/Monitor.ts +10 -9
- package/src/monitor/MonitorDaemon.ts +4 -0
- package/src/monitor/tasks/TaskCheckForProofs.ts +6 -2
- package/src/monitor/tasks/TaskCheckNoSends.ts +0 -1
- package/src/monitor/tasks/TaskNewHeader.ts +3 -4
- package/src/monitor/tasks/TaskPurge.ts +2 -2
- package/src/monitor/tasks/TaskReviewStatus.ts +0 -1
- package/src/monitor/tasks/TaskUnFail.ts +2 -1
- package/src/sdk/WalletServices.interfaces.ts +19 -18
- package/src/sdk/WalletSigner.interfaces.ts +3 -30
- package/src/sdk/WalletStorage.interfaces.ts +74 -66
- package/src/sdk/types.ts +16 -0
- package/src/storage/StorageKnex.ts +1 -1
- package/src/storage/WalletStorageManager.ts +6 -10
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +2 -1
- package/test/Wallet/local/localWallet.man.test.ts +1 -3
- package/test/Wallet/local/localWallet2.man.test.ts +71 -4
- package/test/Wallet/specOps/specOps.man.test.ts +41 -1
- package/test/Wallet/support/opers1.man.test.ts +183 -0
- package/test/WalletClient/LocalKVStore.man.test.ts +114 -0
- package/test/WalletClient/WERR.man.test.ts +20 -0
- package/test/services/Services.test.ts +3 -1
- package/test/{Wallet/local → utils}/localWalletMethods.ts +4 -5
- package/out/test/Wallet/local/localWalletMethods.d.ts.map +0 -1
- package/out/test/Wallet/local/localWalletMethods.js.map +0 -1
|
@@ -15,26 +15,34 @@ import {
|
|
|
15
15
|
TXIDHexString
|
|
16
16
|
} from '@bsv/sdk'
|
|
17
17
|
import {
|
|
18
|
-
sdk,
|
|
19
|
-
TableSettings,
|
|
20
|
-
TableOutputBasket,
|
|
21
|
-
TableCertificateX,
|
|
22
|
-
TableSyncState,
|
|
23
|
-
TableUser,
|
|
24
18
|
TableCertificate,
|
|
25
|
-
TableOutput,
|
|
26
|
-
TableProvenTxReq,
|
|
27
|
-
TableProvenTx,
|
|
28
19
|
TableCertificateField,
|
|
20
|
+
TableCertificateX,
|
|
29
21
|
TableCommission,
|
|
30
|
-
|
|
22
|
+
TableMonitorEvent,
|
|
23
|
+
TableOutput,
|
|
24
|
+
TableOutputBasket,
|
|
31
25
|
TableOutputTag,
|
|
26
|
+
TableOutputTagMap,
|
|
27
|
+
TableProvenTx,
|
|
28
|
+
TableProvenTxReq,
|
|
29
|
+
TableSettings,
|
|
30
|
+
TableSyncState,
|
|
32
31
|
TableTransaction,
|
|
33
|
-
TableTxLabelMap,
|
|
34
32
|
TableTxLabel,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
TableTxLabelMap,
|
|
34
|
+
TableUser
|
|
35
|
+
} from '../storage/schema/tables'
|
|
36
|
+
import { WalletServices } from './WalletServices.interfaces'
|
|
37
|
+
import {
|
|
38
|
+
ValidCreateActionArgs,
|
|
39
|
+
ValidCreateActionOutput,
|
|
40
|
+
ValidListActionsArgs,
|
|
41
|
+
ValidListCertificatesArgs,
|
|
42
|
+
ValidListOutputsArgs
|
|
43
|
+
} from './validationHelpers'
|
|
44
|
+
import { Chain, Paged, ProvenTxReqStatus, TransactionStatus } from './types'
|
|
45
|
+
import { WalletError } from './WalletError'
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
48
|
* This is the `WalletStorage` interface implemented by a class such as `WalletStorageManager`,
|
|
@@ -54,26 +62,26 @@ export interface WalletStorage {
|
|
|
54
62
|
migrate(storageName: string, storageIdentityKey: string): Promise<string>
|
|
55
63
|
destroy(): Promise<void>
|
|
56
64
|
|
|
57
|
-
setServices(v:
|
|
58
|
-
getServices():
|
|
65
|
+
setServices(v: WalletServices): void
|
|
66
|
+
getServices(): WalletServices
|
|
59
67
|
getSettings(): TableSettings
|
|
60
68
|
|
|
61
|
-
getAuth(): Promise<
|
|
69
|
+
getAuth(): Promise<AuthId>
|
|
62
70
|
|
|
63
71
|
findOrInsertUser(identityKey: string): Promise<{ user: TableUser; isNew: boolean }>
|
|
64
72
|
|
|
65
73
|
abortAction(args: AbortActionArgs): Promise<AbortActionResult>
|
|
66
|
-
createAction(args:
|
|
67
|
-
processAction(args:
|
|
74
|
+
createAction(args: ValidCreateActionArgs): Promise<StorageCreateActionResult>
|
|
75
|
+
processAction(args: StorageProcessActionArgs): Promise<StorageProcessActionResults>
|
|
68
76
|
internalizeAction(args: InternalizeActionArgs): Promise<InternalizeActionResult>
|
|
69
77
|
|
|
70
|
-
findCertificates(args:
|
|
71
|
-
findOutputBaskets(args:
|
|
72
|
-
findOutputs(args:
|
|
73
|
-
findProvenTxReqs(args:
|
|
78
|
+
findCertificates(args: FindCertificatesArgs): Promise<TableCertificateX[]>
|
|
79
|
+
findOutputBaskets(args: FindOutputBasketsArgs): Promise<TableOutputBasket[]>
|
|
80
|
+
findOutputs(args: FindOutputsArgs): Promise<TableOutput[]>
|
|
81
|
+
findProvenTxReqs(args: FindProvenTxReqsArgs): Promise<TableProvenTxReq[]>
|
|
74
82
|
|
|
75
83
|
listActions(args: ListActionsArgs): Promise<ListActionsResult>
|
|
76
|
-
listCertificates(args:
|
|
84
|
+
listCertificates(args: ValidListCertificatesArgs): Promise<ListCertificatesResult>
|
|
77
85
|
listOutputs(args: ListOutputsArgs): Promise<ListOutputsResult>
|
|
78
86
|
|
|
79
87
|
insertCertificate(certificate: TableCertificateX): Promise<number>
|
|
@@ -91,12 +99,12 @@ export interface WalletStorageProvider extends WalletStorageSync {
|
|
|
91
99
|
* @returns true if this object's interface can be extended to the full `StorageProvider` interface
|
|
92
100
|
*/
|
|
93
101
|
isStorageProvider(): boolean
|
|
94
|
-
setServices(v:
|
|
102
|
+
setServices(v: WalletServices): void
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
export interface WalletStorageSync extends WalletStorageWriter {
|
|
98
106
|
findOrInsertSyncStateAuth(
|
|
99
|
-
auth:
|
|
107
|
+
auth: AuthId,
|
|
100
108
|
storageIdentityKey: string,
|
|
101
109
|
storageName: string
|
|
102
110
|
): Promise<{ syncState: TableSyncState; isNew: boolean }>
|
|
@@ -106,10 +114,10 @@ export interface WalletStorageSync extends WalletStorageWriter {
|
|
|
106
114
|
* @param auth
|
|
107
115
|
* @param newActiveStorageIdentityKey
|
|
108
116
|
*/
|
|
109
|
-
setActive(auth:
|
|
117
|
+
setActive(auth: AuthId, newActiveStorageIdentityKey: string): Promise<number>
|
|
110
118
|
|
|
111
|
-
getSyncChunk(args:
|
|
112
|
-
processSyncChunk(args:
|
|
119
|
+
getSyncChunk(args: RequestSyncChunkArgs): Promise<SyncChunk>
|
|
120
|
+
processSyncChunk(args: RequestSyncChunkArgs, chunk: SyncChunk): Promise<ProcessSyncChunkResult>
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
/**
|
|
@@ -127,31 +135,31 @@ export interface WalletStorageWriter extends WalletStorageReader {
|
|
|
127
135
|
|
|
128
136
|
findOrInsertUser(identityKey: string): Promise<{ user: TableUser; isNew: boolean }>
|
|
129
137
|
|
|
130
|
-
abortAction(auth:
|
|
131
|
-
createAction(auth:
|
|
132
|
-
processAction(auth:
|
|
133
|
-
internalizeAction(auth:
|
|
138
|
+
abortAction(auth: AuthId, args: AbortActionArgs): Promise<AbortActionResult>
|
|
139
|
+
createAction(auth: AuthId, args: ValidCreateActionArgs): Promise<StorageCreateActionResult>
|
|
140
|
+
processAction(auth: AuthId, args: StorageProcessActionArgs): Promise<StorageProcessActionResults>
|
|
141
|
+
internalizeAction(auth: AuthId, args: InternalizeActionArgs): Promise<InternalizeActionResult>
|
|
134
142
|
|
|
135
|
-
insertCertificateAuth(auth:
|
|
143
|
+
insertCertificateAuth(auth: AuthId, certificate: TableCertificateX): Promise<number>
|
|
136
144
|
|
|
137
|
-
relinquishCertificate(auth:
|
|
138
|
-
relinquishOutput(auth:
|
|
145
|
+
relinquishCertificate(auth: AuthId, args: RelinquishCertificateArgs): Promise<number>
|
|
146
|
+
relinquishOutput(auth: AuthId, args: RelinquishOutputArgs): Promise<number>
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
export interface WalletStorageReader {
|
|
142
150
|
isAvailable(): boolean
|
|
143
151
|
|
|
144
|
-
getServices():
|
|
152
|
+
getServices(): WalletServices
|
|
145
153
|
getSettings(): TableSettings
|
|
146
154
|
|
|
147
|
-
findCertificatesAuth(auth:
|
|
148
|
-
findOutputBasketsAuth(auth:
|
|
149
|
-
findOutputsAuth(auth:
|
|
150
|
-
findProvenTxReqs(args:
|
|
155
|
+
findCertificatesAuth(auth: AuthId, args: FindCertificatesArgs): Promise<TableCertificateX[]>
|
|
156
|
+
findOutputBasketsAuth(auth: AuthId, args: FindOutputBasketsArgs): Promise<TableOutputBasket[]>
|
|
157
|
+
findOutputsAuth(auth: AuthId, args: FindOutputsArgs): Promise<TableOutput[]>
|
|
158
|
+
findProvenTxReqs(args: FindProvenTxReqsArgs): Promise<TableProvenTxReq[]>
|
|
151
159
|
|
|
152
|
-
listActions(auth:
|
|
153
|
-
listCertificates(auth:
|
|
154
|
-
listOutputs(auth:
|
|
160
|
+
listActions(auth: AuthId, vargs: ValidListActionsArgs): Promise<ListActionsResult>
|
|
161
|
+
listCertificates(auth: AuthId, vargs: ValidListCertificatesArgs): Promise<ListCertificatesResult>
|
|
162
|
+
listOutputs(auth: AuthId, vargs: ValidListOutputsArgs): Promise<ListOutputsResult>
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
export interface AuthId {
|
|
@@ -162,8 +170,8 @@ export interface AuthId {
|
|
|
162
170
|
|
|
163
171
|
export interface FindSincePagedArgs {
|
|
164
172
|
since?: Date
|
|
165
|
-
paged?:
|
|
166
|
-
trx?:
|
|
173
|
+
paged?: Paged
|
|
174
|
+
trx?: TrxToken
|
|
167
175
|
}
|
|
168
176
|
|
|
169
177
|
export interface FindForUserSincePagedArgs extends FindSincePagedArgs {
|
|
@@ -188,7 +196,7 @@ export interface FindOutputBasketsArgs extends FindSincePagedArgs {
|
|
|
188
196
|
export interface FindOutputsArgs extends FindSincePagedArgs {
|
|
189
197
|
partial: Partial<TableOutput>
|
|
190
198
|
noScript?: boolean
|
|
191
|
-
txStatus?:
|
|
199
|
+
txStatus?: TransactionStatus[]
|
|
192
200
|
}
|
|
193
201
|
|
|
194
202
|
export type StorageProvidedBy = 'you' | 'storage' | 'you-and-storage'
|
|
@@ -212,7 +220,7 @@ export interface StorageCreateTransactionSdkInput {
|
|
|
212
220
|
senderIdentityKey?: string
|
|
213
221
|
}
|
|
214
222
|
|
|
215
|
-
export interface StorageCreateTransactionSdkOutput extends
|
|
223
|
+
export interface StorageCreateTransactionSdkOutput extends ValidCreateActionOutput {
|
|
216
224
|
vout: number
|
|
217
225
|
providedBy: StorageProvidedBy
|
|
218
226
|
purpose?: string
|
|
@@ -345,50 +353,50 @@ export interface StorageGetBeefOptions {
|
|
|
345
353
|
}
|
|
346
354
|
|
|
347
355
|
export interface StorageSyncReaderOptions {
|
|
348
|
-
chain:
|
|
356
|
+
chain: Chain
|
|
349
357
|
}
|
|
350
358
|
|
|
351
|
-
export interface FindCertificateFieldsArgs extends
|
|
359
|
+
export interface FindCertificateFieldsArgs extends FindSincePagedArgs {
|
|
352
360
|
partial: Partial<TableCertificateField>
|
|
353
361
|
}
|
|
354
362
|
|
|
355
|
-
export interface FindCommissionsArgs extends
|
|
363
|
+
export interface FindCommissionsArgs extends FindSincePagedArgs {
|
|
356
364
|
partial: Partial<TableCommission>
|
|
357
365
|
}
|
|
358
|
-
export interface FindOutputTagMapsArgs extends
|
|
366
|
+
export interface FindOutputTagMapsArgs extends FindSincePagedArgs {
|
|
359
367
|
partial: Partial<TableOutputTagMap>
|
|
360
368
|
tagIds?: number[]
|
|
361
369
|
}
|
|
362
|
-
export interface FindOutputTagsArgs extends
|
|
370
|
+
export interface FindOutputTagsArgs extends FindSincePagedArgs {
|
|
363
371
|
partial: Partial<TableOutputTag>
|
|
364
372
|
}
|
|
365
|
-
export interface FindProvenTxReqsArgs extends
|
|
373
|
+
export interface FindProvenTxReqsArgs extends FindSincePagedArgs {
|
|
366
374
|
partial: Partial<TableProvenTxReq>
|
|
367
|
-
status?:
|
|
375
|
+
status?: ProvenTxReqStatus[]
|
|
368
376
|
txids?: string[]
|
|
369
377
|
}
|
|
370
|
-
export interface FindProvenTxsArgs extends
|
|
378
|
+
export interface FindProvenTxsArgs extends FindSincePagedArgs {
|
|
371
379
|
partial: Partial<TableProvenTx>
|
|
372
380
|
}
|
|
373
|
-
export interface FindSyncStatesArgs extends
|
|
381
|
+
export interface FindSyncStatesArgs extends FindSincePagedArgs {
|
|
374
382
|
partial: Partial<TableSyncState>
|
|
375
383
|
}
|
|
376
|
-
export interface FindTransactionsArgs extends
|
|
384
|
+
export interface FindTransactionsArgs extends FindSincePagedArgs {
|
|
377
385
|
partial: Partial<TableTransaction>
|
|
378
|
-
status?:
|
|
386
|
+
status?: TransactionStatus[]
|
|
379
387
|
noRawTx?: boolean
|
|
380
388
|
}
|
|
381
|
-
export interface FindTxLabelMapsArgs extends
|
|
389
|
+
export interface FindTxLabelMapsArgs extends FindSincePagedArgs {
|
|
382
390
|
partial: Partial<TableTxLabelMap>
|
|
383
391
|
labelIds?: number[]
|
|
384
392
|
}
|
|
385
|
-
export interface FindTxLabelsArgs extends
|
|
393
|
+
export interface FindTxLabelsArgs extends FindSincePagedArgs {
|
|
386
394
|
partial: Partial<TableTxLabel>
|
|
387
395
|
}
|
|
388
|
-
export interface FindUsersArgs extends
|
|
396
|
+
export interface FindUsersArgs extends FindSincePagedArgs {
|
|
389
397
|
partial: Partial<TableUser>
|
|
390
398
|
}
|
|
391
|
-
export interface FindMonitorEventsArgs extends
|
|
399
|
+
export interface FindMonitorEventsArgs extends FindSincePagedArgs {
|
|
392
400
|
partial: Partial<TableMonitorEvent>
|
|
393
401
|
}
|
|
394
402
|
/**
|
|
@@ -401,7 +409,7 @@ export interface UpdateProvenTxReqWithNewProvenTxArgs {
|
|
|
401
409
|
provenTxReqId: number
|
|
402
410
|
txid: string
|
|
403
411
|
attempts: number
|
|
404
|
-
status:
|
|
412
|
+
status: ProvenTxReqStatus
|
|
405
413
|
history: string
|
|
406
414
|
height: number
|
|
407
415
|
index: number
|
|
@@ -411,7 +419,7 @@ export interface UpdateProvenTxReqWithNewProvenTxArgs {
|
|
|
411
419
|
}
|
|
412
420
|
|
|
413
421
|
export interface UpdateProvenTxReqWithNewProvenTxResult {
|
|
414
|
-
status:
|
|
422
|
+
status: ProvenTxReqStatus
|
|
415
423
|
history: string
|
|
416
424
|
provenTxId: number
|
|
417
425
|
log?: string
|
|
@@ -513,5 +521,5 @@ export interface ProcessSyncChunkResult {
|
|
|
513
521
|
maxUpdated_at: Date | undefined
|
|
514
522
|
updates: number
|
|
515
523
|
inserts: number
|
|
516
|
-
error?:
|
|
524
|
+
error?: WalletError
|
|
517
525
|
}
|
package/src/sdk/types.ts
CHANGED
|
@@ -196,3 +196,19 @@ export const specOpFailedActions = '97d4eb1e49215e3374cc2c1939a7c43a55e95c7427bf
|
|
|
196
196
|
export function isListActionsSpecOp(label: string): boolean {
|
|
197
197
|
return [specOpNoSendActions, specOpFailedActions].indexOf(label) >= 0
|
|
198
198
|
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* `createAction` special operation label name value.
|
|
202
|
+
*
|
|
203
|
+
* Causes WERR_REVIEW_ACTIONS throw with dummy properties.
|
|
204
|
+
*
|
|
205
|
+
*/
|
|
206
|
+
export const specOpThrowReviewActions = 'a496e747fc3ad5fabdd4ae8f91184e71f87539bd3d962aa2548942faaaf0047a'
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param label Action / Transaction label name value.
|
|
210
|
+
* @returns true iff the `label` name is a reserved `createAction` special operation identifier.
|
|
211
|
+
*/
|
|
212
|
+
export function isCreateActionSpecOp(label: string): boolean {
|
|
213
|
+
return [specOpThrowReviewActions].indexOf(label) >= 0
|
|
214
|
+
}
|
|
@@ -3,29 +3,25 @@ import {
|
|
|
3
3
|
AbortActionResult,
|
|
4
4
|
InternalizeActionArgs,
|
|
5
5
|
InternalizeActionResult,
|
|
6
|
-
ListActionsArgs,
|
|
7
6
|
ListActionsResult,
|
|
8
7
|
ListCertificatesResult,
|
|
9
|
-
ListOutputsArgs,
|
|
10
8
|
ListOutputsResult,
|
|
11
9
|
RelinquishCertificateArgs,
|
|
12
10
|
RelinquishOutputArgs
|
|
13
11
|
} from '@bsv/sdk'
|
|
12
|
+
import { EntitySyncState } from '../storage/schema/entities'
|
|
13
|
+
import * as sdk from '../sdk'
|
|
14
14
|
import {
|
|
15
|
-
EntitySyncState,
|
|
16
|
-
sdk,
|
|
17
|
-
StorageProvider,
|
|
18
|
-
StorageSyncReader,
|
|
19
15
|
TableCertificate,
|
|
20
16
|
TableCertificateX,
|
|
21
17
|
TableOutput,
|
|
22
18
|
TableOutputBasket,
|
|
23
19
|
TableProvenTxReq,
|
|
24
20
|
TableSettings,
|
|
25
|
-
TableUser
|
|
26
|
-
|
|
27
|
-
} from '../
|
|
28
|
-
import {
|
|
21
|
+
TableUser
|
|
22
|
+
} from '../storage/schema/tables'
|
|
23
|
+
import { wait } from '../utility/utilityHelpers'
|
|
24
|
+
import { StorageProvider } from './StorageProvider'
|
|
29
25
|
|
|
30
26
|
class ManagedStorage {
|
|
31
27
|
isAvailable: boolean
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Beef, Transaction } from '@bsv/sdk'
|
|
2
2
|
import { StorageProvider } from '../StorageProvider'
|
|
3
3
|
import { EntityProvenTxReq } from '../schema/entities'
|
|
4
|
-
import
|
|
4
|
+
import * as sdk from '../../sdk'
|
|
5
5
|
import { ReqHistoryNote } from '../../sdk'
|
|
6
|
+
import { wait } from '../../utility/utilityHelpers'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Attempt to post one or more `ProvenTxReq` with status 'unsent'
|
|
@@ -2,12 +2,10 @@ import { EntitySyncState, sdk } from '../../../src'
|
|
|
2
2
|
import { _tu } from '../../utils/TestUtilsWalletStorage'
|
|
3
3
|
import { specOpInvalidChange } from '../../../src/sdk'
|
|
4
4
|
import {
|
|
5
|
-
burnOneSatTestOutput,
|
|
6
5
|
createOneSatTestOutput,
|
|
7
6
|
createSetup,
|
|
8
7
|
LocalWalletTestOptions,
|
|
9
|
-
|
|
10
|
-
} from './localWalletMethods'
|
|
8
|
+
} from '../../utils/localWalletMethods'
|
|
11
9
|
|
|
12
10
|
const chain: sdk.Chain = 'test'
|
|
13
11
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Beef, WalletOutput } from '@bsv/sdk'
|
|
2
|
+
import { sdk, Services, Setup, StorageKnex, TableUser } from '../../../src'
|
|
2
3
|
import { _tu, TuEnv } from '../../utils/TestUtilsWalletStorage'
|
|
3
4
|
import { specOpInvalidChange, ValidListOutputsArgs, WERR_REVIEW_ACTIONS } from '../../../src/sdk'
|
|
4
5
|
import {
|
|
@@ -8,11 +9,9 @@ import {
|
|
|
8
9
|
doubleSpendOldChange,
|
|
9
10
|
LocalWalletTestOptions,
|
|
10
11
|
recoverOneSatTestOutputs
|
|
11
|
-
} from '
|
|
12
|
-
import { abort } from 'process'
|
|
12
|
+
} from '../../utils/localWalletMethods'
|
|
13
13
|
|
|
14
14
|
import * as dotenv from 'dotenv'
|
|
15
|
-
import { WalletOutput } from '@bsv/sdk'
|
|
16
15
|
dotenv.config()
|
|
17
16
|
|
|
18
17
|
const chain: sdk.Chain = 'main'
|
|
@@ -144,6 +143,71 @@ describe('localWallet2 tests', () => {
|
|
|
144
143
|
}
|
|
145
144
|
await storage.destroy()
|
|
146
145
|
})
|
|
146
|
+
|
|
147
|
+
test('6 review and unfail false doubleSpends', async () => {
|
|
148
|
+
const { env, storage, services } = await createMainReviewSetup()
|
|
149
|
+
let offset = 1100
|
|
150
|
+
const limit = 100
|
|
151
|
+
let allUnfails: number[] = []
|
|
152
|
+
for (;;) {
|
|
153
|
+
let log = ''
|
|
154
|
+
const unfails: number[] = []
|
|
155
|
+
const reqs = await storage.findProvenTxReqs({ partial: { status: 'doubleSpend' }, paged: { limit, offset } })
|
|
156
|
+
for (const req of reqs) {
|
|
157
|
+
const gsr = await services.getStatusForTxids([req.txid])
|
|
158
|
+
if (gsr.results[0].status !== 'unknown') {
|
|
159
|
+
log += `unfail ${req.provenTxReqId} ${req.txid}\n`
|
|
160
|
+
unfails.push(req.provenTxReqId)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
console.log(`OFFSET: ${offset} ${unfails.length} unfails\n${log}`)
|
|
164
|
+
allUnfails = allUnfails.concat(unfails)
|
|
165
|
+
if (reqs.length < limit) break
|
|
166
|
+
offset += reqs.length
|
|
167
|
+
}
|
|
168
|
+
debugger
|
|
169
|
+
for (const id of allUnfails) {
|
|
170
|
+
await storage.updateProvenTxReq(id, { status: 'unfail' })
|
|
171
|
+
}
|
|
172
|
+
await storage.destroy()
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test('7 review and unfail false invalids', async () => {
|
|
176
|
+
const { env, storage, services } = await createMainReviewSetup()
|
|
177
|
+
let offset = 400
|
|
178
|
+
const limit = 100
|
|
179
|
+
let allUnfails: number[] = []
|
|
180
|
+
for (;;) {
|
|
181
|
+
let log = ''
|
|
182
|
+
const unfails: number[] = []
|
|
183
|
+
const reqs = await storage.findProvenTxReqs({ partial: { status: 'invalid' }, paged: { limit, offset } })
|
|
184
|
+
for (const req of reqs) {
|
|
185
|
+
if (!req.txid || !req.rawTx) continue
|
|
186
|
+
const gsr = await services.getStatusForTxids([req.txid])
|
|
187
|
+
if (gsr.results[0].status !== 'unknown') {
|
|
188
|
+
log += `unfail ${req.provenTxReqId} ${req.txid}\n`
|
|
189
|
+
unfails.push(req.provenTxReqId)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
console.log(`OFFSET: ${offset} ${unfails.length} unfails\n${log}`)
|
|
193
|
+
allUnfails = allUnfails.concat(unfails)
|
|
194
|
+
if (reqs.length < limit) break
|
|
195
|
+
offset += reqs.length
|
|
196
|
+
}
|
|
197
|
+
debugger
|
|
198
|
+
for (const id of allUnfails) {
|
|
199
|
+
await storage.updateProvenTxReq(id, { status: 'unfail' })
|
|
200
|
+
}
|
|
201
|
+
await storage.destroy()
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
test('8 jackie Beef', async () => {
|
|
205
|
+
const setup = await createSetup(chain, options)
|
|
206
|
+
const beef = Beef.fromBinary(beefJackie)
|
|
207
|
+
console.log(beef.toLogString())
|
|
208
|
+
const ok = beef.verify(await setup.services.getChainTracker())
|
|
209
|
+
await setup.wallet.destroy()
|
|
210
|
+
})
|
|
147
211
|
})
|
|
148
212
|
|
|
149
213
|
async function createMainReviewSetup(): Promise<{
|
|
@@ -167,3 +231,6 @@ async function createMainReviewSetup(): Promise<{
|
|
|
167
231
|
await storage.makeAvailable()
|
|
168
232
|
return { env, storage, services }
|
|
169
233
|
}
|
|
234
|
+
|
|
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]
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { WalletClient } from '@bsv/sdk'
|
|
1
2
|
import { sdk, verifyOne } from '../../../src'
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
specOpInvalidChange,
|
|
5
|
+
specOpSetWalletChangeParams,
|
|
6
|
+
specOpThrowReviewActions,
|
|
7
|
+
specOpWalletBalance
|
|
8
|
+
} from '../../../src/sdk'
|
|
3
9
|
import { _tu, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
4
10
|
|
|
5
11
|
describe('specOps tests', () => {
|
|
@@ -156,6 +162,40 @@ describe('specOps tests', () => {
|
|
|
156
162
|
|
|
157
163
|
await setup.wallet.destroy()
|
|
158
164
|
})
|
|
165
|
+
|
|
166
|
+
test('5 Wallet specOpThrowReviewActions', async () => {
|
|
167
|
+
const setup = await createSetup('test')
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const r = await setup.wallet.createAction({
|
|
171
|
+
labels: [specOpThrowReviewActions],
|
|
172
|
+
description: 'must throw'
|
|
173
|
+
})
|
|
174
|
+
expect(true).toBe(false)
|
|
175
|
+
} catch (eu: unknown) {
|
|
176
|
+
const e = sdk.WalletError.fromUnknown(eu) as sdk.WERR_REVIEW_ACTIONS
|
|
177
|
+
expect(e.code).toBe('WERR_REVIEW_ACTIONS')
|
|
178
|
+
expect(e.reviewActionResults).toBeTruthy()
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
await setup.wallet.destroy()
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test('6 WalletClient specOpThrowReviewActions', async () => {
|
|
185
|
+
const wallet = new WalletClient(undefined, '6.specOps.man.test')
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
const r = await wallet.createAction({
|
|
189
|
+
labels: [specOpThrowReviewActions],
|
|
190
|
+
description: 'must throw'
|
|
191
|
+
})
|
|
192
|
+
expect(true).toBe(false)
|
|
193
|
+
} catch (eu: unknown) {
|
|
194
|
+
const e = sdk.WalletError.fromUnknown(eu) as sdk.WERR_REVIEW_ACTIONS
|
|
195
|
+
expect(e.code).toBe('WERR_REVIEW_ACTIONS')
|
|
196
|
+
expect(e.reviewActionResults).toBeTruthy()
|
|
197
|
+
}
|
|
198
|
+
})
|
|
159
199
|
})
|
|
160
200
|
|
|
161
201
|
async function createSetup(chain: sdk.Chain): Promise<TestWalletNoSetup> {
|