@bsv/wallet-toolbox 1.3.23 → 1.3.25
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 +99 -59
- package/docs/storage.md +55 -75
- package/docs/wallet.md +99 -59
- package/mobile/out/src/Wallet.d.ts +1 -1
- package/mobile/out/src/Wallet.d.ts.map +1 -1
- package/mobile/out/src/Wallet.js +16 -6
- package/mobile/out/src/Wallet.js.map +1 -1
- package/mobile/out/src/monitor/Monitor.d.ts.map +1 -1
- package/mobile/out/src/monitor/Monitor.js +6 -4
- package/mobile/out/src/monitor/Monitor.js.map +1 -1
- package/mobile/out/src/monitor/tasks/TaskNewHeader.d.ts +1 -1
- package/mobile/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/mobile/out/src/monitor/tasks/TaskServiceCallHistory.d.ts +12 -0
- package/mobile/out/src/monitor/tasks/TaskServiceCallHistory.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskServiceCallHistory.js +23 -0
- package/mobile/out/src/monitor/tasks/TaskServiceCallHistory.js.map +1 -0
- package/mobile/out/src/sdk/WalletServices.interfaces.d.ts +2 -0
- package/mobile/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/mobile/out/src/sdk/WalletStorage.interfaces.d.ts +19 -1
- package/mobile/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/mobile/out/src/services/ServiceCollection.d.ts +38 -0
- package/mobile/out/src/services/ServiceCollection.d.ts.map +1 -1
- package/mobile/out/src/services/ServiceCollection.js +85 -0
- package/mobile/out/src/services/ServiceCollection.js.map +1 -1
- package/mobile/out/src/services/Services.d.ts +11 -2
- package/mobile/out/src/services/Services.d.ts.map +1 -1
- package/mobile/out/src/services/Services.js +159 -68
- package/mobile/out/src/services/Services.js.map +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/index.d.ts +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/index.d.ts.map +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/index.js +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/index.js.map +1 -1
- package/mobile/out/src/services/createDefaultWalletServicesOptions.d.ts +1 -0
- package/mobile/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/mobile/out/src/services/createDefaultWalletServicesOptions.js +15 -1
- package/mobile/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/mobile/out/src/services/providers/ARC.d.ts +3 -2
- package/mobile/out/src/services/providers/ARC.d.ts.map +1 -1
- package/mobile/out/src/services/providers/ARC.js +5 -4
- package/mobile/out/src/services/providers/ARC.js.map +1 -1
- package/mobile/out/src/signer/methods/internalizeAction.d.ts +2 -2
- package/mobile/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/internalizeAction.js +3 -13
- package/mobile/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/mobile/out/src/storage/StorageProvider.d.ts +5 -6
- package/mobile/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/mobile/out/src/storage/StorageProvider.js +75 -101
- package/mobile/out/src/storage/StorageProvider.js.map +1 -1
- package/mobile/out/src/storage/WalletStorageManager.d.ts +2 -2
- package/mobile/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/createAction.js +5 -1
- package/mobile/out/src/storage/methods/createAction.js.map +1 -1
- package/mobile/out/src/storage/methods/generateChange.d.ts +0 -24
- package/mobile/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/generateChange.js +2 -50
- package/mobile/out/src/storage/methods/generateChange.js.map +1 -1
- package/mobile/out/src/storage/methods/getBeefForTransaction.js +3 -2
- package/mobile/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/mobile/out/src/storage/methods/internalizeAction.d.ts +2 -10
- package/mobile/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/internalizeAction.js +17 -1
- package/mobile/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/mobile/out/src/storage/methods/processAction.d.ts +16 -1
- package/mobile/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/processAction.js +4 -1
- package/mobile/out/src/storage/methods/processAction.js.map +1 -1
- package/mobile/out/src/storage/methods/utils.d.ts +25 -0
- package/mobile/out/src/storage/methods/utils.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/utils.js +53 -0
- package/mobile/out/src/storage/methods/utils.js.map +1 -0
- package/mobile/out/src/storage/remoting/StorageClient.d.ts +2 -2
- package/mobile/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/mobile/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/mobile/out/src/storage/remoting/StorageMobile.d.ts +2 -2
- package/mobile/out/src/storage/remoting/StorageMobile.d.ts.map +1 -1
- package/mobile/out/src/storage/remoting/StorageMobile.js.map +1 -1
- package/mobile/out/src/utility/utilityHelpers.d.ts +1 -1
- package/mobile/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/mobile/out/src/utility/utilityHelpers.js +3 -3
- package/mobile/out/src/utility/utilityHelpers.js.map +1 -1
- package/mobile/package-lock.json +7 -6
- package/mobile/package.json +2 -2
- package/out/src/Wallet.d.ts +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +16 -6
- package/out/src/Wallet.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +6 -4
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskServiceCallHistory.d.ts +12 -0
- package/out/src/monitor/tasks/TaskServiceCallHistory.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskServiceCallHistory.js +23 -0
- package/out/src/monitor/tasks/TaskServiceCallHistory.js.map +1 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts +2 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +19 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.d.ts +38 -0
- package/out/src/services/ServiceCollection.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.js +85 -0
- package/out/src/services/ServiceCollection.js.map +1 -1
- package/out/src/services/Services.d.ts +11 -2
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +159 -68
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/__tests/ArcGorillaPool.man.test.d.ts +2 -0
- package/out/src/services/__tests/ArcGorillaPool.man.test.d.ts.map +1 -0
- package/out/src/services/__tests/ArcGorillaPool.man.test.js +93 -0
- package/out/src/services/__tests/ArcGorillaPool.man.test.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.d.ts +1 -1
- package/out/src/services/chaintracker/chaintracks/index.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.js +1 -1
- package/out/src/services/chaintracker/chaintracks/index.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +144 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +463 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts +20 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js +31 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js +15 -1
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts +3 -2
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +5 -4
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts +2 -2
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js +3 -13
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +50 -2
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +5 -6
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +75 -101
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +2 -2
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/__test/StorageIdb.test.js +1 -0
- package/out/src/storage/__test/StorageIdb.test.js.map +1 -1
- package/out/src/storage/__test/adminStats.man.test.js +2 -0
- package/out/src/storage/__test/adminStats.man.test.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +5 -1
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts +0 -24
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +2 -50
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +3 -2
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts +2 -10
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +17 -1
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts +16 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +4 -1
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/utils.Buffer.d.ts +21 -0
- package/out/src/storage/methods/utils.Buffer.d.ts.map +1 -0
- package/out/src/storage/methods/utils.Buffer.js +37 -0
- package/out/src/storage/methods/utils.Buffer.js.map +1 -0
- package/out/src/storage/methods/utils.d.ts +25 -0
- package/out/src/storage/methods/utils.d.ts.map +1 -0
- package/out/src/storage/methods/utils.js +53 -0
- package/out/src/storage/methods/utils.js.map +1 -0
- package/out/src/storage/remoting/StorageClient.d.ts +2 -2
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageMobile.d.ts +2 -2
- package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageMobile.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +12 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/utility/Format.d.ts +14 -0
- package/out/src/utility/Format.d.ts.map +1 -0
- package/out/src/utility/Format.js +167 -0
- package/out/src/utility/Format.js.map +1 -0
- package/out/src/utility/utilityHelpers.d.ts +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +3 -3
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +12 -16
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/support/operations.man.test.js +105 -135
- package/out/test/Wallet/support/operations.man.test.js.map +1 -1
- package/out/test/Wallet/support/reqErrorReview.2025.05.06.man.test.d.ts +2 -0
- package/out/test/Wallet/support/reqErrorReview.2025.05.06.man.test.d.ts.map +1 -0
- package/out/test/Wallet/support/reqErrorReview.2025.05.06.man.test.js +385 -0
- package/out/test/Wallet/support/reqErrorReview.2025.05.06.man.test.js.map +1 -0
- package/out/test/storage/KnexMigrations.test.js +1 -1
- package/out/test/storage/KnexMigrations.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +5 -0
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +20 -0
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Wallet.ts +25 -10
- package/src/monitor/Monitor.ts +6 -4
- package/src/monitor/tasks/TaskNewHeader.ts +1 -1
- package/src/monitor/tasks/TaskServiceCallHistory.ts +26 -0
- package/src/sdk/WalletServices.interfaces.ts +2 -0
- package/src/sdk/WalletStorage.interfaces.ts +21 -1
- package/src/services/ServiceCollection.ts +121 -0
- package/src/services/Services.ts +157 -71
- package/src/services/__tests/ArcGorillaPool.man.test.ts +108 -0
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +1 -1
- package/src/services/chaintracker/chaintracks/index.ts +1 -1
- package/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.ts +490 -0
- package/src/services/chaintracker/chaintracks/util/dirtyHashes.ts +29 -0
- package/src/services/createDefaultWalletServicesOptions.ts +16 -1
- package/src/services/providers/ARC.ts +8 -6
- package/src/signer/methods/internalizeAction.ts +6 -16
- package/src/storage/StorageKnex.ts +25 -1
- package/src/storage/StorageProvider.ts +44 -32
- package/src/storage/WalletStorageManager.ts +1 -1
- package/src/storage/__test/StorageIdb.test.ts +1 -0
- package/src/storage/__test/adminStats.man.test.ts +2 -0
- package/src/storage/methods/createAction.ts +5 -3
- package/src/storage/methods/generateChange.ts +1 -54
- package/src/storage/methods/getBeefForTransaction.ts +10 -2
- package/src/storage/methods/internalizeAction.ts +23 -14
- package/src/storage/methods/processAction.ts +5 -2
- package/src/storage/methods/utils.Buffer.ts +33 -0
- package/src/storage/methods/utils.ts +56 -0
- package/src/storage/remoting/StorageClient.ts +2 -2
- package/src/storage/remoting/StorageMobile.ts +2 -2
- package/src/storage/schema/KnexMigrations.ts +13 -0
- package/src/utility/Format.ts +133 -0
- package/src/utility/utilityHelpers.ts +2 -2
- package/test/Wallet/local/localWallet.man.test.ts +13 -16
- package/test/Wallet/support/operations.man.test.ts +118 -123
- package/test/Wallet/support/reqErrorReview.2025.05.06.man.test.ts +359 -0
- package/test/storage/KnexMigrations.test.ts +1 -1
- package/test/utils/TestUtilsWalletStorage.ts +23 -0
- package/mobile/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +0 -1
- package/mobile/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +0 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +0 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +0 -1
- /package/mobile/out/src/services/chaintracker/chaintracks/{BlockHeaderApi.d.ts → Api/BlockHeaderApi.d.ts} +0 -0
- /package/mobile/out/src/services/chaintracker/chaintracks/{BlockHeaderApi.js → Api/BlockHeaderApi.js} +0 -0
- /package/out/src/services/chaintracker/chaintracks/{BlockHeaderApi.d.ts → Api/BlockHeaderApi.d.ts} +0 -0
- /package/out/src/services/chaintracker/chaintracks/{BlockHeaderApi.js → Api/BlockHeaderApi.js} +0 -0
- /package/src/services/chaintracker/chaintracks/{BlockHeaderApi.ts → Api/BlockHeaderApi.ts} +0 -0
package/src/services/Services.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction as BsvTransaction, Beef, ChainTracker, Utils } from '@bsv/sdk'
|
|
2
2
|
import { asArray, asString, doubleSha256BE, sdk, sha256Hash, TableOutput, wait } from '../index.client'
|
|
3
|
-
import { ServiceCollection } from './ServiceCollection'
|
|
3
|
+
import { ServiceCall, ServiceCollection } from './ServiceCollection'
|
|
4
4
|
import { createDefaultWalletServicesOptions } from './createDefaultWalletServicesOptions'
|
|
5
5
|
import { ChaintracksChainTracker } from './chaintracker'
|
|
6
6
|
import { WhatsOnChain } from './providers/WhatsOnChain'
|
|
@@ -16,7 +16,8 @@ export class Services implements sdk.WalletServices {
|
|
|
16
16
|
|
|
17
17
|
options: sdk.WalletServicesOptions
|
|
18
18
|
whatsonchain: WhatsOnChain
|
|
19
|
-
|
|
19
|
+
arcTaal: ARC
|
|
20
|
+
arcGorillaPool?: ARC
|
|
20
21
|
bitails: Bitails
|
|
21
22
|
|
|
22
23
|
getMerklePathServices: ServiceCollection<sdk.GetMerklePathService>
|
|
@@ -36,7 +37,10 @@ export class Services implements sdk.WalletServices {
|
|
|
36
37
|
|
|
37
38
|
this.whatsonchain = new WhatsOnChain(this.chain, { apiKey: this.options.whatsOnChainApiKey }, this)
|
|
38
39
|
|
|
39
|
-
this.
|
|
40
|
+
this.arcTaal = new ARC(this.options.arcUrl, this.options.arcConfig, 'arcTaal')
|
|
41
|
+
if (this.options.arcGorillaPoolUrl) {
|
|
42
|
+
//this.arcGorillaPool = new ARC(this.options.arcGorillaPoolUrl, this.options.arcGorillaPoolConfig, 'arcGorillaPool')
|
|
43
|
+
}
|
|
40
44
|
|
|
41
45
|
this.bitails = new Bitails(this.chain)
|
|
42
46
|
|
|
@@ -49,11 +53,17 @@ export class Services implements sdk.WalletServices {
|
|
|
49
53
|
this.getRawTxServices = new ServiceCollection<sdk.GetRawTxService>()
|
|
50
54
|
.add({ name: 'WhatsOnChain', service: this.whatsonchain.getRawTxResult.bind(this.whatsonchain) })
|
|
51
55
|
|
|
52
|
-
//prettier-ignore
|
|
53
56
|
this.postBeefServices = new ServiceCollection<sdk.PostBeefService>()
|
|
54
|
-
|
|
57
|
+
if (this.arcGorillaPool) {
|
|
58
|
+
//prettier-ignore
|
|
59
|
+
this.postBeefServices.add({ name: 'GorillaPool', service: this.arcGorillaPool.postBeef.bind(this.arcGorillaPool) })
|
|
60
|
+
}
|
|
61
|
+
//prettier-ignore
|
|
62
|
+
this.postBeefServices
|
|
63
|
+
.add({ name: 'TaalArcBeef', service: this.arcTaal.postBeef.bind(this.arcTaal) })
|
|
55
64
|
.add({ name: 'WhatsOnChain', service: this.whatsonchain.postBeef.bind(this.whatsonchain) })
|
|
56
65
|
.add({ name: 'Bitails', service: this.bitails.postBeef.bind(this.bitails) })
|
|
66
|
+
;
|
|
57
67
|
|
|
58
68
|
//prettier-ignore
|
|
59
69
|
this.getUtxoStatusServices = new ServiceCollection<sdk.GetUtxoStatusService>()
|
|
@@ -73,6 +83,18 @@ export class Services implements sdk.WalletServices {
|
|
|
73
83
|
.add({ name: 'exchangeratesapi', service: updateExchangeratesapi })
|
|
74
84
|
}
|
|
75
85
|
|
|
86
|
+
getServicesCallHistory(reset?: boolean) {
|
|
87
|
+
return {
|
|
88
|
+
version: 1,
|
|
89
|
+
getMerklePath: this.getMerklePathServices.getServiceCallHistory(reset),
|
|
90
|
+
getRawTx: this.getRawTxServices.getServiceCallHistory(reset),
|
|
91
|
+
postBeef: this.postBeefServices.getServiceCallHistory(reset),
|
|
92
|
+
getUtxoStatus: this.getUtxoStatusServices.getServiceCallHistory(reset),
|
|
93
|
+
getStatusForTxids: this.getStatusForTxidsServices.getServiceCallHistory(reset),
|
|
94
|
+
getScriptHashHistory: this.getScriptHashHistoryServices.getServiceCallHistory(reset)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
76
98
|
async getChainTracker(): Promise<ChainTracker> {
|
|
77
99
|
if (!this.options.chaintracks)
|
|
78
100
|
throw new sdk.WERR_INVALID_PARAMETER('options.chaintracks', `valid to enable 'getChainTracker' service.`)
|
|
@@ -123,11 +145,22 @@ export class Services implements sdk.WalletServices {
|
|
|
123
145
|
}
|
|
124
146
|
|
|
125
147
|
for (let tries = 0; tries < services.count; tries++) {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
148
|
+
const stc = services.serviceToCall
|
|
149
|
+
try {
|
|
150
|
+
const r = await stc.service(txids)
|
|
151
|
+
if (r.status === 'success') {
|
|
152
|
+
services.addServiceCallSuccess(stc)
|
|
153
|
+
r0 = r
|
|
154
|
+
break
|
|
155
|
+
} else {
|
|
156
|
+
if (r.error)
|
|
157
|
+
services.addServiceCallError(stc, r.error)
|
|
158
|
+
else
|
|
159
|
+
services.addServiceCallFailure(stc)
|
|
160
|
+
}
|
|
161
|
+
} catch (eu: unknown) {
|
|
162
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
163
|
+
services.addServiceCallError(stc, e)
|
|
131
164
|
}
|
|
132
165
|
services.next()
|
|
133
166
|
}
|
|
@@ -174,11 +207,22 @@ export class Services implements sdk.WalletServices {
|
|
|
174
207
|
|
|
175
208
|
for (let retry = 0; retry < 2; retry++) {
|
|
176
209
|
for (let tries = 0; tries < services.count; tries++) {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
210
|
+
const stc = services.serviceToCall
|
|
211
|
+
try {
|
|
212
|
+
const r = await stc.service(output, outputFormat, outpoint)
|
|
213
|
+
if (r.status === 'success') {
|
|
214
|
+
services.addServiceCallSuccess(stc)
|
|
215
|
+
r0 = r
|
|
216
|
+
break
|
|
217
|
+
} else {
|
|
218
|
+
if (r.error)
|
|
219
|
+
services.addServiceCallError(stc, r.error)
|
|
220
|
+
else
|
|
221
|
+
services.addServiceCallFailure(stc)
|
|
222
|
+
}
|
|
223
|
+
} catch (eu: unknown) {
|
|
224
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
225
|
+
services.addServiceCallError(stc, e)
|
|
182
226
|
}
|
|
183
227
|
services.next()
|
|
184
228
|
}
|
|
@@ -200,19 +244,27 @@ export class Services implements sdk.WalletServices {
|
|
|
200
244
|
}
|
|
201
245
|
|
|
202
246
|
for (let tries = 0; tries < services.count; tries++) {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
247
|
+
const stc = services.serviceToCall
|
|
248
|
+
try {
|
|
249
|
+
const r = await stc.service(hash)
|
|
250
|
+
if (r.status === 'success') {
|
|
251
|
+
r0 = r
|
|
252
|
+
break
|
|
253
|
+
} else {
|
|
254
|
+
if (r.error)
|
|
255
|
+
services.addServiceCallError(stc, r.error)
|
|
256
|
+
else
|
|
257
|
+
services.addServiceCallFailure(stc)
|
|
258
|
+
}
|
|
259
|
+
} catch (eu: unknown) {
|
|
260
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
261
|
+
services.addServiceCallError(stc, e)
|
|
208
262
|
}
|
|
209
263
|
services.next()
|
|
210
264
|
}
|
|
211
265
|
return r0
|
|
212
266
|
}
|
|
213
267
|
|
|
214
|
-
postBeefCount = 0
|
|
215
|
-
|
|
216
268
|
/**
|
|
217
269
|
*
|
|
218
270
|
* @param beef
|
|
@@ -220,15 +272,20 @@ export class Services implements sdk.WalletServices {
|
|
|
220
272
|
* @returns
|
|
221
273
|
*/
|
|
222
274
|
async postBeef(beef: Beef, txids: string[]): Promise<sdk.PostBeefResult[]> {
|
|
223
|
-
this.
|
|
224
|
-
const
|
|
225
|
-
for (let i = this.postBeefCount % services.length; i > 0; i--) {
|
|
226
|
-
// roll the array of services so the providers aren't always called in the same order.
|
|
227
|
-
services.unshift(services.pop()!)
|
|
228
|
-
}
|
|
275
|
+
const services = this.postBeefServices
|
|
276
|
+
const stcs = services.allServicesToCall
|
|
229
277
|
let rs = await Promise.all(
|
|
230
|
-
|
|
231
|
-
const r = await service(beef, txids)
|
|
278
|
+
stcs.map(async stc => {
|
|
279
|
+
const r = await stc.service(beef, txids)
|
|
280
|
+
if (r.status === 'success') {
|
|
281
|
+
services.addServiceCallSuccess(stc)
|
|
282
|
+
} else {
|
|
283
|
+
if (r.error) {
|
|
284
|
+
services.addServiceCallError(stc, r.error)
|
|
285
|
+
} else {
|
|
286
|
+
services.addServiceCallFailure(stc)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
232
289
|
return r
|
|
233
290
|
})
|
|
234
291
|
)
|
|
@@ -236,31 +293,44 @@ export class Services implements sdk.WalletServices {
|
|
|
236
293
|
}
|
|
237
294
|
|
|
238
295
|
async getRawTx(txid: string, useNext?: boolean): Promise<sdk.GetRawTxResult> {
|
|
239
|
-
|
|
296
|
+
const services = this.getRawTxServices
|
|
297
|
+
if (useNext) services.next()
|
|
240
298
|
|
|
241
299
|
const r0: sdk.GetRawTxResult = { txid }
|
|
242
300
|
|
|
243
|
-
for (let tries = 0; tries <
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
301
|
+
for (let tries = 0; tries < services.count; tries++) {
|
|
302
|
+
const stc = services.serviceToCall
|
|
303
|
+
try {
|
|
304
|
+
const r = await stc.service(txid, this.chain)
|
|
305
|
+
if (r.rawTx) {
|
|
306
|
+
const hash = asString(doubleSha256BE(r.rawTx!))
|
|
307
|
+
// Confirm transaction hash matches txid
|
|
308
|
+
if (hash === asString(txid)) {
|
|
309
|
+
// If we have a match, call it done.
|
|
310
|
+
r0.rawTx = r.rawTx
|
|
311
|
+
r0.name = r.name
|
|
312
|
+
r0.error = undefined
|
|
313
|
+
services.addServiceCallSuccess(stc)
|
|
314
|
+
break
|
|
315
|
+
}
|
|
316
|
+
r.error = new sdk.WERR_INTERNAL(`computed txid ${hash} doesn't match requested value ${txid}`)
|
|
317
|
+
r.rawTx = undefined
|
|
255
318
|
}
|
|
256
|
-
r.error = new sdk.WERR_INTERNAL(`computed txid ${hash} doesn't match requested value ${txid}`)
|
|
257
|
-
r.rawTx = undefined
|
|
258
|
-
}
|
|
259
|
-
if (r.error && !r0.error && !r0.rawTx)
|
|
260
|
-
// If we have an error and didn't before...
|
|
261
|
-
r0.error = r.error
|
|
262
319
|
|
|
263
|
-
|
|
320
|
+
if (r.error)
|
|
321
|
+
services.addServiceCallError(stc, r.error)
|
|
322
|
+
else
|
|
323
|
+
services.addServiceCallFailure(stc)
|
|
324
|
+
|
|
325
|
+
if (r.error && !r0.error && !r0.rawTx)
|
|
326
|
+
// If we have an error and didn't before...
|
|
327
|
+
r0.error = r.error
|
|
328
|
+
|
|
329
|
+
} catch (eu: unknown) {
|
|
330
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
331
|
+
services.addServiceCallError(stc, e)
|
|
332
|
+
}
|
|
333
|
+
services.next()
|
|
264
334
|
}
|
|
265
335
|
return r0
|
|
266
336
|
}
|
|
@@ -307,28 +377,41 @@ export class Services implements sdk.WalletServices {
|
|
|
307
377
|
}
|
|
308
378
|
|
|
309
379
|
async getMerklePath(txid: string, useNext?: boolean): Promise<sdk.GetMerklePathResult> {
|
|
310
|
-
|
|
380
|
+
const services = this.getMerklePathServices
|
|
381
|
+
if (useNext) services.next()
|
|
311
382
|
|
|
312
383
|
const r0: sdk.GetMerklePathResult = { notes: [] }
|
|
313
384
|
|
|
314
|
-
for (let tries = 0; tries <
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
385
|
+
for (let tries = 0; tries < services.count; tries++) {
|
|
386
|
+
const stc = services.serviceToCall
|
|
387
|
+
try {
|
|
388
|
+
const r = await stc.service(txid, this)
|
|
389
|
+
if (r.notes) r0.notes!.push(...r.notes)
|
|
390
|
+
if (!r0.name) r0.name = r.name
|
|
391
|
+
if (r.merklePath) {
|
|
392
|
+
// If we have a proof, call it done.
|
|
393
|
+
r0.merklePath = r.merklePath
|
|
394
|
+
r0.header = r.header
|
|
395
|
+
r0.name = r.name
|
|
396
|
+
r0.error = undefined
|
|
397
|
+
services.addServiceCallSuccess(stc)
|
|
398
|
+
break
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (r.error)
|
|
402
|
+
services.addServiceCallError(stc, r.error)
|
|
403
|
+
else
|
|
404
|
+
services.addServiceCallFailure(stc)
|
|
405
|
+
|
|
406
|
+
if (r.error && !r0.error) {
|
|
407
|
+
// If we have an error and didn't before...
|
|
408
|
+
r0.error = r.error
|
|
409
|
+
}
|
|
410
|
+
} catch (eu: unknown) {
|
|
411
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
412
|
+
services.addServiceCallError(stc, e)
|
|
329
413
|
}
|
|
330
|
-
|
|
331
|
-
this.getMerklePathServices.next()
|
|
414
|
+
services.next()
|
|
332
415
|
}
|
|
333
416
|
return r0
|
|
334
417
|
}
|
|
@@ -350,16 +433,19 @@ export class Services implements sdk.WalletServices {
|
|
|
350
433
|
let r0: sdk.FiatExchangeRates | undefined
|
|
351
434
|
|
|
352
435
|
for (let tries = 0; tries < services.count; tries++) {
|
|
353
|
-
const
|
|
436
|
+
const stc = services.serviceToCall
|
|
354
437
|
try {
|
|
355
|
-
const r = await service(this.targetCurrencies, this.options)
|
|
438
|
+
const r = await stc.service(this.targetCurrencies, this.options)
|
|
356
439
|
if (this.targetCurrencies.every(c => typeof r.rates[c] === 'number')) {
|
|
440
|
+
services.addServiceCallSuccess(stc)
|
|
357
441
|
r0 = r
|
|
358
442
|
break
|
|
443
|
+
} else {
|
|
444
|
+
services.addServiceCallFailure(stc)
|
|
359
445
|
}
|
|
360
446
|
} catch (eu: unknown) {
|
|
361
447
|
const e = sdk.WalletError.fromUnknown(eu)
|
|
362
|
-
|
|
448
|
+
services.addServiceCallError(stc, e)
|
|
363
449
|
}
|
|
364
450
|
services.next()
|
|
365
451
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { _tu, logger } from '../../../test/utils/TestUtilsWalletStorage'
|
|
2
|
+
import { sdk, wait } from '../../index.client'
|
|
3
|
+
import { ARC } from '../providers/ARC'
|
|
4
|
+
import { Beef, BeefTx } from '@bsv/sdk'
|
|
5
|
+
import { arcDefaultUrl, arcGorillaPoolUrl } from '../createDefaultWalletServicesOptions'
|
|
6
|
+
import { Setup } from '../../index.all'
|
|
7
|
+
|
|
8
|
+
describe('ArcGorillaPool tests', () => {
|
|
9
|
+
jest.setTimeout(99999999)
|
|
10
|
+
|
|
11
|
+
const env = _tu.getEnv('main')
|
|
12
|
+
const arc = new ARC(arcGorillaPoolUrl(env.chain)!, {
|
|
13
|
+
apiKey: ''
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test.skip('0 double spend', async () => {
|
|
17
|
+
const beef = Beef.fromString(testnetDoubleSpendBeef)
|
|
18
|
+
const txids = [beef.txs.slice(-1)[0].txid]
|
|
19
|
+
const r = await arc.postBeef(beef, txids)
|
|
20
|
+
expect(r.status === 'error').toBe(true)
|
|
21
|
+
expect(r.txidResults[0].doubleSpend).toBe(true)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test.skip('1 postRawTx', async () => {
|
|
25
|
+
const r = await postRawTxTest('main', arc)
|
|
26
|
+
logger(`2 postBeef mainnet done ${r}`)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('2 postBeef', async () => {
|
|
30
|
+
const r = await postBeefTest('main', arc)
|
|
31
|
+
logger(`2 postBeef mainnet done ${r}`)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
async function postBeefTest(chain: sdk.Chain, arc: ARC): Promise<string> {
|
|
36
|
+
if (Setup.noEnv(chain)) return 'skipped'
|
|
37
|
+
const c = await _tu.createNoSendTxPair(chain)
|
|
38
|
+
|
|
39
|
+
const txids = [c.txidDo, c.txidUndo]
|
|
40
|
+
|
|
41
|
+
const r = await arc.postBeef(c.beef, txids)
|
|
42
|
+
expect(r.status).toBe('success')
|
|
43
|
+
for (const txid of txids) {
|
|
44
|
+
const tr = r.txidResults.find(tx => tx.txid === txid)
|
|
45
|
+
expect(tr).not.toBeUndefined()
|
|
46
|
+
expect(tr!.status).toBe('success')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// replace Undo transaction with double spend transaction and send again.
|
|
50
|
+
const beef2 = c.beef.clone()
|
|
51
|
+
beef2.txs[beef2.txs.length - 1] = BeefTx.fromTx(c.doubleSpendTx)
|
|
52
|
+
const txids2 = [c.txidDo, c.doubleSpendTx.id('hex')]
|
|
53
|
+
|
|
54
|
+
const r2 = await arc.postBeef(beef2, txids2)
|
|
55
|
+
expect(r2.status).toBe('error')
|
|
56
|
+
for (const txid of txids2) {
|
|
57
|
+
const tr = r2.txidResults.find(tx => tx.txid === txid)
|
|
58
|
+
expect(tr).not.toBeUndefined()
|
|
59
|
+
if (txid === c.txidDo) {
|
|
60
|
+
expect(tr!.status).toBe('success')
|
|
61
|
+
} else {
|
|
62
|
+
expect(tr!.status).toBe('error')
|
|
63
|
+
expect(tr!.doubleSpend).toBe(true)
|
|
64
|
+
expect(tr!.competingTxs).toEqual([c.txidUndo])
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return 'passed'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function postRawTxTest(chain: sdk.Chain, arc: ARC): Promise<void> {
|
|
71
|
+
if (Setup.noEnv(chain)) return
|
|
72
|
+
const c = await _tu.createNoSendTxPair(chain)
|
|
73
|
+
|
|
74
|
+
const rawTxDo = c.beef.findTxid(c.txidDo)!.tx!.toHex()
|
|
75
|
+
const rawTxUndo = c.beef.findTxid(c.txidUndo)!.tx!.toHex()
|
|
76
|
+
|
|
77
|
+
const rDo = await arc.postRawTx(rawTxDo)
|
|
78
|
+
expect(rDo.status).toBe('success')
|
|
79
|
+
expect(rDo.txid).toBe(c.txidDo)
|
|
80
|
+
|
|
81
|
+
await wait(1000)
|
|
82
|
+
|
|
83
|
+
const rUndo = await arc.postRawTx(rawTxUndo)
|
|
84
|
+
expect(rUndo.status).toBe('success')
|
|
85
|
+
expect(rUndo.txid).toBe(c.txidUndo)
|
|
86
|
+
expect(rUndo.doubleSpend).not.toBe(true)
|
|
87
|
+
|
|
88
|
+
await wait(1000)
|
|
89
|
+
|
|
90
|
+
{
|
|
91
|
+
// Send same transaction again...
|
|
92
|
+
const rUndo = await arc.postRawTx(rawTxUndo)
|
|
93
|
+
expect(rUndo.status).toBe('success')
|
|
94
|
+
expect(rUndo.txid).toBe(c.txidUndo)
|
|
95
|
+
expect(rUndo.doubleSpend).not.toBe(true)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
await wait(1000)
|
|
99
|
+
|
|
100
|
+
// Confirm double spend detection.
|
|
101
|
+
const rDouble = await arc.postRawTx(c.doubleSpendTx.toHex())
|
|
102
|
+
expect(rDouble.status).toBe('error')
|
|
103
|
+
expect(rDouble.doubleSpend).toBe(true)
|
|
104
|
+
expect(rDouble.competingTxs![0]).toBe(c.txidUndo)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const testnetDoubleSpendBeef =
|
|
108
|
+
'0100beef01fe65631900020200009df812619ae232d2363d91516ab3e811211192933526bbc2aee71b54ccb236d10102462876eec65d9aa26d957421c5cc8dd9119b61177242b9dd814fb190fd0a361801010076a3297928f6841bcb656e91225540e87c65f67d8ec12bc768d7656eb7561b3d02010000000159617a9d17562f7c9765e5dfa6a9a393aa2809ca6166a3d7a31c09efcc5070141f0000006a47304402200a528145a67ba1879b88a093cb711f79f04413a81d5678f314302e36a7f59e43022010bc4bb3c2574052c50bbdc8a05c31fb39e69280656b34f5dc22e2ceadc3bb4a412102fd4200bf389d16479b3d06f97fee0752f2c3b9dc29fb3ddce2b327d851b8902bffffffff0204000000000000001976a9140df1a69c834bb7d9bb5b2b7d6a34e5a401db3e1688ac01000000000000001976a91423f2562a8092ed24eddc77c74387b44c561692a188ac0000000001000100000001462876eec65d9aa26d957421c5cc8dd9119b61177242b9dd814fb190fd0a3618000000006a47304402204183bbfdcf11d50907b91f5e70ea8f81228501ce84e24af75c8d984682d094dc022029caa8f7e5acb4990bbeafee523a3c4a99b78e98b9e5c41349147b099679d4ae412103b76389eea6494c2c30443cba9d59b9dba05fb04e467bc94272629615b87a429fffffffff0202000000000000001976a91476d851e59fcb4ee0ebe6947496db3a393b08e49c88ac01000000000000001976a91423f2562a8092ed24eddc77c74387b44c561692a188ac0000000000'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { asString, sdk } from '../../../index.client'
|
|
3
3
|
|
|
4
|
-
import { BaseBlockHeader, BlockHeader, isBaseBlockHeader } from './BlockHeaderApi'
|
|
4
|
+
import { BaseBlockHeader, BlockHeader, isBaseBlockHeader } from './Api/BlockHeaderApi'
|
|
5
5
|
|
|
6
6
|
interface FetchStatus<T> {
|
|
7
7
|
status: 'success' | 'error'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './ChaintracksServiceClient'
|
|
2
|
-
export * from './BlockHeaderApi'
|
|
2
|
+
export * from './Api/BlockHeaderApi'
|