@bsv/wallet-toolbox 1.1.60 → 1.1.61
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/.prettierrc +1 -1
- package/docs/client.md +39 -5
- package/docs/services.md +1 -0
- package/docs/setup.md +9 -26
- package/docs/storage.md +35 -0
- package/docs/wallet.md +39 -5
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +6 -16
- package/out/src/Setup.js.map +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +4 -11
- package/out/src/Wallet.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- 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 +1 -3
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -10
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskClock.js +1 -1
- package/out/src/monitor/tasks/TaskClock.js.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +1 -2
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js +1 -2
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js +1 -2
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/sdk/CertOps.d.ts.map +1 -1
- package/out/src/sdk/CertOps.js +4 -12
- package/out/src/sdk/CertOps.js.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +1 -4
- package/out/src/sdk/WalletError.js.map +1 -1
- 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.map +1 -1
- package/out/src/sdk/__test/CertificateLifeCycle.test.js +1 -3
- package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -1
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js +13 -26
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -1
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +2 -10
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/sdk/validationHelpers.d.ts.map +1 -1
- package/out/src/sdk/validationHelpers.js +5 -12
- package/out/src/sdk/validationHelpers.js.map +1 -1
- package/out/src/services/Services.d.ts +1 -0
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +29 -38
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/__tests/bitrails.test.js.map +1 -1
- package/out/src/services/__tests/getMerklePath.test.js.map +1 -1
- package/out/src/services/__tests/getRawTx.test.js.map +1 -1
- package/out/src/services/__tests/verifyBeef.test.js +2 -1
- package/out/src/services/__tests/verifyBeef.test.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +1 -3
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +1 -2
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +62 -134
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +6 -21
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/__tests/WhatsOnChain.test.js +1 -2
- package/out/src/services/providers/__tests/WhatsOnChain.test.js.map +1 -1
- package/out/src/services/providers/echangeRates.d.ts.map +1 -1
- package/out/src/services/providers/echangeRates.js.map +1 -1
- package/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/out/src/signer/WalletSigner.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js +1 -3
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +3 -11
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +3 -10
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +2 -7
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +15 -44
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +9 -34
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +5 -10
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/__test/WalletStorageManager.test.js +2 -8
- package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +10 -30
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +17 -28
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +6 -20
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +4 -9
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +7 -18
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +1 -3
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +2 -9
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActions.d.ts.map +1 -1
- package/out/src/storage/methods/listActions.js +3 -15
- package/out/src/storage/methods/listActions.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputs.js +4 -11
- package/out/src/storage/methods/listOutputs.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +4 -10
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +8 -32
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +1 -3
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +15 -41
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +2 -5
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +24 -130
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Certificate.js +1 -1
- package/out/src/storage/schema/entities/Certificate.js.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.js +2 -5
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Commission.js +2 -5
- package/out/src/storage/schema/entities/Commission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +14 -9
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Output.js +8 -25
- package/out/src/storage/schema/entities/Output.js.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.js +1 -1
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.js +3 -7
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.js +10 -20
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.js +8 -18
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/SyncState.d.ts +1 -0
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/SyncState.js +41 -6
- package/out/src/storage/schema/entities/SyncState.js.map +1 -1
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Transaction.js +4 -13
- package/out/src/storage/schema/entities/Transaction.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.js +1 -1
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.js +3 -9
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/User.d.ts.map +1 -1
- package/out/src/storage/schema/entities/User.js +3 -5
- package/out/src/storage/schema/entities/User.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -2
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +2 -2
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +1 -3
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +1 -2
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +1 -3
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -1
- package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -1
- package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -1
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
- package/out/test/Wallet/get/getHeaderForHeight.test.js +2 -6
- package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -1
- package/out/test/Wallet/get/getNetwork.test.js.map +1 -1
- package/out/test/Wallet/get/getVersion.test.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +3 -9
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +15 -22
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/specOps/specOps.man.test.js +1 -4
- package/out/test/Wallet/specOps/specOps.man.test.js.map +1 -1
- package/out/test/Wallet/support/janitor.man.test.js.map +1 -1
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -1
- package/out/test/Wallet/sync/setActive.test.js +73 -50
- package/out/test/Wallet/sync/setActive.test.js.map +1 -1
- package/out/test/checkDB.d.ts.map +1 -1
- package/out/test/checkDB.js.map +1 -1
- package/out/test/examples/backup.man.test.d.ts.map +1 -1
- package/out/test/examples/backup.man.test.js.map +1 -1
- package/out/test/examples/pushdrop.test.d.ts.map +1 -1
- package/out/test/examples/pushdrop.test.js +5 -4
- package/out/test/examples/pushdrop.test.js.map +1 -1
- package/out/test/monitor/Monitor.test.js.map +1 -1
- package/out/test/services/Services.test.js.map +1 -1
- package/out/test/storage/KnexMigrations.test.js.map +1 -1
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -3
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
- package/out/test/storage/count.test.js.map +1 -1
- package/out/test/storage/find.test.js +5 -10
- package/out/test/storage/find.test.js.map +1 -1
- package/out/test/storage/findLegacy.test.js.map +1 -1
- package/out/test/storage/insert.test.js.map +1 -1
- package/out/test/storage/update.test.js +7 -19
- package/out/test/storage/update.test.js.map +1 -1
- package/out/test/storage/update2.test.js +22 -24
- package/out/test/storage/update2.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +3 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +52 -76
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/abortAction.test.js.map +1 -1
- package/out/test/wallet/action/createAction.test.js +1 -2
- package/out/test/wallet/action/createAction.test.js.map +1 -1
- package/out/test/wallet/action/createAction2.test.d.ts.map +1 -1
- package/out/test/wallet/action/createAction2.test.js +6 -16
- package/out/test/wallet/action/createAction2.test.js.map +1 -1
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -1
- package/out/test/wallet/action/relinquishOutput.test.js.map +1 -1
- package/out/test/wallet/list/listActions.test.js.map +1 -1
- package/out/test/wallet/list/listActions2.test.js.map +1 -1
- package/out/test/wallet/list/listCertificates.test.js +2 -6
- package/out/test/wallet/list/listCertificates.test.js.map +1 -1
- package/out/test/wallet/list/listOutputs.test.js +2 -10
- package/out/test/wallet/list/listOutputs.test.js.map +1 -1
- package/out/test/wallet/sync/Wallet.sync.test.js +4 -6
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Setup.ts +15 -52
- package/src/Wallet.ts +58 -161
- package/src/monitor/Monitor.ts +7 -22
- package/src/monitor/MonitorDaemon.ts +6 -23
- package/src/monitor/tasks/TaskCheckForProofs.ts +4 -23
- package/src/monitor/tasks/TaskClock.ts +1 -3
- package/src/monitor/tasks/TaskFailAbandoned.ts +1 -3
- package/src/monitor/tasks/TaskNewHeader.ts +1 -4
- package/src/monitor/tasks/TaskPurge.ts +1 -2
- package/src/monitor/tasks/TaskReviewStatus.ts +1 -3
- package/src/monitor/tasks/TaskSendWaiting.ts +3 -10
- package/src/sdk/CertOps.ts +31 -103
- package/src/sdk/PrivilegedKeyManager.ts +18 -48
- package/src/sdk/WERR_errors.ts +6 -25
- package/src/sdk/WalletError.ts +5 -21
- package/src/sdk/WalletServices.interfaces.ts +11 -33
- package/src/sdk/WalletStorage.interfaces.ts +25 -91
- package/src/sdk/__test/CertificateLifeCycle.test.ts +9 -27
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +29 -66
- package/src/sdk/types.ts +6 -26
- package/src/sdk/validationHelpers.ts +111 -402
- package/src/services/Services.ts +51 -114
- package/src/services/__tests/bitrails.test.ts +4 -15
- package/src/services/__tests/getMerklePath.test.ts +1 -2
- package/src/services/__tests/getRawTx.test.ts +1 -3
- package/src/services/__tests/verifyBeef.test.ts +2 -1
- package/src/services/chaintracker/ChaintracksChainTracker.ts +3 -13
- package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +4 -12
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +9 -27
- package/src/services/createDefaultWalletServicesOptions.ts +2 -5
- package/src/services/providers/ARC.ts +5 -24
- package/src/services/providers/Bitails.ts +61 -159
- package/src/services/providers/SdkWhatsOnChain.ts +4 -17
- package/src/services/providers/WhatsOnChain.ts +31 -100
- package/src/services/providers/__tests/WhatsOnChain.test.ts +5 -15
- package/src/services/providers/echangeRates.ts +7 -22
- package/src/signer/WalletSigner.ts +1 -5
- package/src/signer/methods/acquireDirectCertificate.ts +1 -4
- package/src/signer/methods/buildSignableTransaction.ts +5 -20
- package/src/signer/methods/createAction.ts +15 -54
- package/src/signer/methods/internalizeAction.ts +10 -39
- package/src/signer/methods/proveCertificate.ts +2 -5
- package/src/signer/methods/signAction.ts +9 -39
- package/src/storage/StorageKnex.ts +166 -499
- package/src/storage/StorageProvider.ts +75 -291
- package/src/storage/StorageReader.ts +20 -65
- package/src/storage/StorageReaderWriter.ts +67 -264
- package/src/storage/StorageSyncReader.ts +2 -5
- package/src/storage/WalletStorageManager.ts +33 -108
- package/src/storage/__test/WalletStorageManager.test.ts +6 -23
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +53 -171
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +17 -28
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +9 -37
- package/src/storage/methods/createAction.ts +45 -181
- package/src/storage/methods/generateChange.ts +33 -114
- package/src/storage/methods/getBeefForTransaction.ts +7 -37
- package/src/storage/methods/getSyncChunk.ts +18 -69
- package/src/storage/methods/internalizeAction.ts +18 -70
- package/src/storage/methods/listActions.ts +6 -23
- package/src/storage/methods/listCertificates.ts +5 -14
- package/src/storage/methods/listOutputs.ts +14 -68
- package/src/storage/methods/processAction.ts +29 -104
- package/src/storage/methods/purgeData.ts +11 -45
- package/src/storage/methods/reviewStatus.ts +3 -9
- package/src/storage/remoting/StorageClient.ts +43 -146
- package/src/storage/remoting/StorageServer.ts +21 -59
- package/src/storage/schema/KnexMigrations.ts +34 -165
- package/src/storage/schema/entities/Certificate.ts +3 -14
- package/src/storage/schema/entities/CertificateField.ts +6 -28
- package/src/storage/schema/entities/Commission.ts +6 -23
- package/src/storage/schema/entities/EntityBase.ts +1 -6
- package/src/storage/schema/entities/MergeEntity.ts +14 -21
- package/src/storage/schema/entities/Output.ts +10 -39
- package/src/storage/schema/entities/OutputBasket.ts +4 -16
- package/src/storage/schema/entities/OutputTag.ts +4 -17
- package/src/storage/schema/entities/OutputTagMap.ts +7 -30
- package/src/storage/schema/entities/ProvenTx.ts +16 -57
- package/src/storage/schema/entities/ProvenTxReq.ts +29 -93
- package/src/storage/schema/entities/SyncState.ts +64 -116
- package/src/storage/schema/entities/Transaction.ts +10 -35
- package/src/storage/schema/entities/TxLabel.ts +4 -17
- package/src/storage/schema/entities/TxLabelMap.ts +6 -28
- package/src/storage/schema/entities/User.ts +8 -31
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +23 -54
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +26 -59
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +2 -11
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +1 -4
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +3 -14
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +4 -16
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +5 -18
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +5 -26
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +12 -48
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +4 -22
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +3 -10
- package/src/storage/schema/entities/__tests/usersTests.test.ts +4 -7
- package/src/storage/schema/tables/TableSettings.ts +1 -3
- package/src/storage/sync/StorageMySQLDojoReader.ts +47 -148
- package/src/utility/ScriptTemplateBRC29.ts +2 -11
- package/src/utility/stampLog.ts +2 -6
- package/src/utility/tscProofToMerklePath.ts +1 -4
- package/src/utility/utilityHelpers.buffer.ts +3 -12
- package/src/utility/utilityHelpers.ts +14 -49
- package/test/Wallet/StorageClient/storageClient.man.test.ts +2 -8
- package/test/Wallet/action/internalizeAction.a.test.ts +8 -23
- package/test/Wallet/certificate/acquireCertificate.test.ts +10 -24
- package/test/Wallet/certificate/listCertificates.test.ts +8 -18
- package/test/Wallet/get/getHeaderForHeight.test.ts +4 -15
- package/test/Wallet/get/getHeight.test.ts +2 -6
- package/test/Wallet/get/getKnownTxids.test.ts +1 -5
- package/test/Wallet/get/getNetwork.test.ts +1 -2
- package/test/Wallet/get/getVersion.test.ts +1 -2
- package/test/Wallet/live/walletLive.man.test.ts +14 -41
- package/test/Wallet/local/localWallet.man.test.ts +26 -99
- package/test/Wallet/specOps/specOps.man.test.ts +4 -13
- package/test/Wallet/support/janitor.man.test.ts +2 -7
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +11 -34
- package/test/Wallet/sync/setActive.test.ts +75 -61
- package/test/checkDB.ts +2 -8
- package/test/examples/backup.man.test.ts +2 -9
- package/test/examples/pushdrop.test.ts +7 -20
- package/test/monitor/Monitor.test.ts +33 -87
- package/test/services/Services.test.ts +8 -19
- package/test/storage/KnexMigrations.test.ts +3 -18
- package/test/storage/StorageMySQLDojoReader.man.test.ts +4 -15
- package/test/storage/count.test.ts +7 -24
- package/test/storage/find.test.ts +7 -29
- package/test/storage/findLegacy.test.ts +2 -5
- package/test/storage/insert.test.ts +3 -19
- package/test/storage/update.test.ts +47 -179
- package/test/storage/update2.test.ts +54 -176
- package/test/utils/TestUtilsWalletStorage.ts +139 -372
- package/test/wallet/action/abortAction.test.ts +4 -12
- package/test/wallet/action/createAction.test.ts +4 -14
- package/test/wallet/action/createAction2.test.ts +74 -208
- package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +8 -11
- package/test/wallet/action/internalizeAction.test.ts +20 -72
- package/test/wallet/action/relinquishOutput.test.ts +3 -9
- package/test/wallet/list/listActions.test.ts +2 -9
- package/test/wallet/list/listActions2.test.ts +8 -34
- package/test/wallet/list/listCertificates.test.ts +5 -16
- package/test/wallet/list/listOutputs.test.ts +15 -54
- package/test/wallet/sync/Wallet.sync.test.ts +18 -49
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
defaultHttpClient,
|
|
4
|
-
HexString,
|
|
5
|
-
HttpClient,
|
|
6
|
-
MerklePath,
|
|
7
|
-
Utils
|
|
8
|
-
} from '@bsv/sdk'
|
|
9
|
-
import {
|
|
10
|
-
convertProofToMerklePath,
|
|
11
|
-
doubleSha256BE,
|
|
12
|
-
sdk,
|
|
13
|
-
wait
|
|
14
|
-
} from '../../index.client'
|
|
1
|
+
import { Beef, defaultHttpClient, HexString, HttpClient, Utils } from '@bsv/sdk'
|
|
2
|
+
import { convertProofToMerklePath, doubleSha256BE, sdk, wait } from '../../index.client'
|
|
15
3
|
import { ReqHistoryNote } from '../../sdk'
|
|
16
4
|
|
|
17
5
|
export interface BitailsConfig {
|
|
@@ -33,10 +21,7 @@ export class Bitails {
|
|
|
33
21
|
constructor(chain: sdk.Chain = 'main', config: BitailsConfig = {}) {
|
|
34
22
|
const { apiKey, httpClient } = config
|
|
35
23
|
this.chain = chain
|
|
36
|
-
this.URL =
|
|
37
|
-
chain === 'main'
|
|
38
|
-
? `https://api.bitails.io/`
|
|
39
|
-
: `https://test-api.bitails.io/`
|
|
24
|
+
this.URL = chain === 'main' ? `https://api.bitails.io/` : `https://test-api.bitails.io/`
|
|
40
25
|
this.httpClient = httpClient ?? defaultHttpClient()
|
|
41
26
|
this.apiKey = apiKey ?? ''
|
|
42
27
|
}
|
|
@@ -80,8 +65,7 @@ export class Bitails {
|
|
|
80
65
|
const r = await this.postRaws(raws)
|
|
81
66
|
|
|
82
67
|
r.notes!.unshift(note)
|
|
83
|
-
if (r.status !== 'success')
|
|
84
|
-
r.notes!.push({ ...nne(), what: 'postBeefError' })
|
|
68
|
+
if (r.status !== 'success') r.notes!.push({ ...nne(), what: 'postBeefError' })
|
|
85
69
|
else r.notes!.push({ ...nn(), what: 'postBeefSuccess' })
|
|
86
70
|
|
|
87
71
|
return r
|
|
@@ -112,7 +96,6 @@ export class Bitails {
|
|
|
112
96
|
headers['Content-Type'] = 'application/json'
|
|
113
97
|
//headers['Accept'] = 'text/json'
|
|
114
98
|
|
|
115
|
-
//const data = JSON.stringify({ raws })
|
|
116
99
|
const data = { raws: raws }
|
|
117
100
|
const requestOptions = {
|
|
118
101
|
method: 'POST',
|
|
@@ -132,72 +115,38 @@ export class Bitails {
|
|
|
132
115
|
url
|
|
133
116
|
})
|
|
134
117
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
rt.status = 'error'
|
|
154
|
-
rt.notes!.push({
|
|
155
|
-
...nne(),
|
|
156
|
-
what: 'postRawsMissingResult',
|
|
157
|
-
txid: rt.txid
|
|
158
|
-
})
|
|
159
|
-
} else if (btr.error) {
|
|
160
|
-
// code: -25, message: 'missing-inputs'
|
|
161
|
-
rt.status = 'error'
|
|
162
|
-
rt.notes!.push({
|
|
163
|
-
...nne(),
|
|
164
|
-
what: 'postRawsError',
|
|
165
|
-
txid: rt.txid,
|
|
166
|
-
code: btr.error.code,
|
|
167
|
-
message: btr.error.message
|
|
168
|
-
})
|
|
169
|
-
} else {
|
|
170
|
-
rt.notes!.push({ ...nn(), what: 'postRawsSuccess' })
|
|
171
|
-
}
|
|
172
|
-
if (rt.status !== 'success' && r.status === 'success')
|
|
173
|
-
r.status = 'error'
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
r.status = 'error'
|
|
177
|
-
const n: ReqHistoryNote = {
|
|
178
|
-
...nne(),
|
|
179
|
-
what: 'postRawsError'
|
|
118
|
+
try {
|
|
119
|
+
const response = await this.httpClient.request<BitailsPostRawsResult[]>(url, requestOptions)
|
|
120
|
+
if (response.ok) {
|
|
121
|
+
// status: 201, statusText: 'Created'
|
|
122
|
+
const btrs: BitailsPostRawsResult[] = response.data
|
|
123
|
+
for (const rt of r.txidResults) {
|
|
124
|
+
const btr = btrs.find(btr => (btr.txid = rt.txid))
|
|
125
|
+
const txid = rt.txid
|
|
126
|
+
if (!btr) {
|
|
127
|
+
rt.status = 'error'
|
|
128
|
+
rt.notes!.push({ ...nne(), what: 'postRawsMissingResult', txid })
|
|
129
|
+
} else if (btr.error) {
|
|
130
|
+
// code: -25, message: 'missing-inputs'
|
|
131
|
+
rt.status = 'error'
|
|
132
|
+
const { code, message } = btr.error
|
|
133
|
+
rt.notes!.push({ ...nne(), what: 'postRawsError', txid, code, message })
|
|
134
|
+
} else {
|
|
135
|
+
rt.notes!.push({ ...nn(), what: 'postRawsSuccess' })
|
|
180
136
|
}
|
|
181
|
-
r.
|
|
137
|
+
if (rt.status !== 'success' && r.status === 'success') r.status = 'error'
|
|
182
138
|
}
|
|
183
|
-
}
|
|
139
|
+
} else {
|
|
184
140
|
r.status = 'error'
|
|
185
|
-
const
|
|
186
|
-
r.notes!.push(
|
|
187
|
-
...nne(),
|
|
188
|
-
what: 'postRawsCatch',
|
|
189
|
-
code: e.code,
|
|
190
|
-
description: e.description
|
|
191
|
-
})
|
|
141
|
+
const n: ReqHistoryNote = { ...nne(), what: 'postRawsError' }
|
|
142
|
+
r.notes!.push(n)
|
|
192
143
|
}
|
|
193
|
-
|
|
144
|
+
} catch (eu: unknown) {
|
|
145
|
+
r.status = 'error'
|
|
146
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
147
|
+
const { code, description } = e
|
|
148
|
+
r.notes!.push({ ...nne(), what: 'postRawsCatch', code, description })
|
|
194
149
|
}
|
|
195
|
-
r.status = 'error'
|
|
196
|
-
r.notes!.push({
|
|
197
|
-
...nne(),
|
|
198
|
-
what: 'postRawsRetryLimit',
|
|
199
|
-
retryLimit
|
|
200
|
-
})
|
|
201
150
|
return r
|
|
202
151
|
}
|
|
203
152
|
|
|
@@ -207,92 +156,45 @@ export class Bitails {
|
|
|
207
156
|
* @param services
|
|
208
157
|
* @returns
|
|
209
158
|
*/
|
|
210
|
-
async getMerklePath(
|
|
211
|
-
txid: string,
|
|
212
|
-
services: sdk.WalletServices
|
|
213
|
-
): Promise<sdk.GetMerklePathResult> {
|
|
159
|
+
async getMerklePath(txid: string, services: sdk.WalletServices): Promise<sdk.GetMerklePathResult> {
|
|
214
160
|
const r: sdk.GetMerklePathResult = { name: 'BitailsTsc', notes: [] }
|
|
215
161
|
|
|
216
|
-
const url = `${this.URL}
|
|
162
|
+
const url = `${this.URL}tx/${txid}/proof/tsc`
|
|
217
163
|
|
|
218
|
-
const nn = () => ({
|
|
219
|
-
name: 'BitailsProofTsc',
|
|
220
|
-
when: new Date().toISOString(),
|
|
221
|
-
txid,
|
|
222
|
-
url
|
|
223
|
-
})
|
|
164
|
+
const nn = () => ({ name: 'BitailsProofTsc', when: new Date().toISOString(), txid, url })
|
|
224
165
|
|
|
225
166
|
const headers = this.getHttpHeaders()
|
|
226
|
-
const requestOptions = {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
r.notes!.push({ ...nne(), what: 'getMerklePathRetry' })
|
|
248
|
-
await wait(2000)
|
|
249
|
-
continue
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (response.status === 404 && response.statusText === 'Not Found') {
|
|
253
|
-
r.notes!.push({ ...nne(), what: 'getMerklePathNotFound' })
|
|
254
|
-
} else if (
|
|
255
|
-
!response.ok ||
|
|
256
|
-
response.status !== 200 ||
|
|
257
|
-
response.statusText !== 'OK'
|
|
258
|
-
) {
|
|
259
|
-
r.notes!.push({ ...nne(), what: 'getMerklePathBadStatus' })
|
|
260
|
-
} else if (!response.data) {
|
|
261
|
-
// Unmined, proof not yet available.
|
|
262
|
-
r.notes!.push({ ...nne(), what: 'getMerklePathNoData' })
|
|
167
|
+
const requestOptions = { method: 'GET', headers }
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const response = await this.httpClient.request<BitailsMerkleProof>(url, requestOptions)
|
|
171
|
+
|
|
172
|
+
const nne = () => ({ ...nn(), txid, url, status: response.status, statusText: response.statusText })
|
|
173
|
+
|
|
174
|
+
if (response.status === 404 && response.statusText === 'Not Found') {
|
|
175
|
+
r.notes!.push({ ...nn(), what: 'getMerklePathNotFound' })
|
|
176
|
+
} else if (!response.ok || response.status !== 200 || response.statusText !== 'OK') {
|
|
177
|
+
r.notes!.push({ ...nne(), what: 'getMerklePathBadStatus' })
|
|
178
|
+
} else if (!response.data) {
|
|
179
|
+
r.notes!.push({ ...nne(), what: 'getMerklePathNoData' })
|
|
180
|
+
} else {
|
|
181
|
+
const p = response.data
|
|
182
|
+
const header = await services.hashToHeader(p.target)
|
|
183
|
+
if (header) {
|
|
184
|
+
const proof = { index: p.index, nodes: p.nodes, height: header.height }
|
|
185
|
+
r.merklePath = convertProofToMerklePath(txid, proof)
|
|
186
|
+
r.header = header
|
|
187
|
+
r.notes!.push({ ...nne(), what: 'getMerklePathSuccess' })
|
|
263
188
|
} else {
|
|
264
|
-
|
|
265
|
-
const header = await services.hashToHeader(p.target)
|
|
266
|
-
if (header) {
|
|
267
|
-
const proof = {
|
|
268
|
-
index: p.index,
|
|
269
|
-
nodes: p.nodes,
|
|
270
|
-
height: header.height
|
|
271
|
-
}
|
|
272
|
-
r.merklePath = convertProofToMerklePath(txid, proof)
|
|
273
|
-
r.header = header
|
|
274
|
-
r.notes!.push({ ...nne(), what: 'getMerklePathSuccess' })
|
|
275
|
-
} else {
|
|
276
|
-
r.notes!.push({
|
|
277
|
-
...nne(),
|
|
278
|
-
what: 'getMerklePathNoHeader',
|
|
279
|
-
target: p.target
|
|
280
|
-
})
|
|
281
|
-
}
|
|
189
|
+
r.notes!.push({ ...nne(), what: 'getMerklePathNoHeader', target: p.target })
|
|
282
190
|
}
|
|
283
|
-
} catch (eu: unknown) {
|
|
284
|
-
const e = sdk.WalletError.fromUnknown(eu)
|
|
285
|
-
r.notes!.push({
|
|
286
|
-
...nn(),
|
|
287
|
-
what: 'getMerklePathError',
|
|
288
|
-
code: e.code,
|
|
289
|
-
description: e.description
|
|
290
|
-
})
|
|
291
|
-
r.error = e
|
|
292
191
|
}
|
|
293
|
-
|
|
192
|
+
} catch (eu: unknown) {
|
|
193
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
194
|
+
const { code, description } = e
|
|
195
|
+
r.notes!.push({ ...nn(), what: 'getMerklePathCatch', code, description })
|
|
196
|
+
r.error = e
|
|
294
197
|
}
|
|
295
|
-
r.notes!.push({ ...nn(), what: 'getMerklePathInternal' })
|
|
296
198
|
return r
|
|
297
199
|
}
|
|
298
200
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChainTracker,
|
|
3
|
-
defaultHttpClient,
|
|
4
|
-
HttpClient,
|
|
5
|
-
WhatsOnChainConfig
|
|
6
|
-
} from '@bsv/sdk'
|
|
1
|
+
import { ChainTracker, defaultHttpClient, HttpClient, WhatsOnChainConfig } from '@bsv/sdk'
|
|
7
2
|
|
|
8
3
|
interface WhatsOnChainBlockHeader {
|
|
9
4
|
merkleroot: string
|
|
@@ -24,10 +19,7 @@ export default class SdkWhatsOnChain implements ChainTracker {
|
|
|
24
19
|
* @param {'main' | 'test' | 'stn'} network - The BSV network to use when calling the WhatsOnChain API.
|
|
25
20
|
* @param {WhatsOnChainConfig} config - Configuration options for the WhatsOnChain ChainTracker.
|
|
26
21
|
*/
|
|
27
|
-
constructor(
|
|
28
|
-
network: 'main' | 'test' | 'stn' = 'main',
|
|
29
|
-
config: WhatsOnChainConfig = {}
|
|
30
|
-
) {
|
|
22
|
+
constructor(network: 'main' | 'test' | 'stn' = 'main', config: WhatsOnChainConfig = {}) {
|
|
31
23
|
const { apiKey, httpClient } = config
|
|
32
24
|
this.network = network
|
|
33
25
|
this.URL = `https://api.whatsonchain.com/v1/bsv/${network}`
|
|
@@ -64,16 +56,11 @@ export default class SdkWhatsOnChain implements ChainTracker {
|
|
|
64
56
|
headers: this.getHttpHeaders()
|
|
65
57
|
}
|
|
66
58
|
|
|
67
|
-
const response = await this.httpClient.request<{ height: number }>(
|
|
68
|
-
`${this.URL}/block/headers`,
|
|
69
|
-
requestOptions
|
|
70
|
-
)
|
|
59
|
+
const response = await this.httpClient.request<{ height: number }>(`${this.URL}/block/headers`, requestOptions)
|
|
71
60
|
if (response.ok) {
|
|
72
61
|
return response.data[0].height
|
|
73
62
|
} else {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`Failed to get current height because of an error: ${JSON.stringify(response.data)} `
|
|
76
|
-
)
|
|
63
|
+
throw new Error(`Failed to get current height because of an error: ${JSON.stringify(response.data)} `)
|
|
77
64
|
}
|
|
78
65
|
} catch (error) {
|
|
79
66
|
throw new Error(
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { Beef, HexString, Utils, WhatsOnChainConfig } from '@bsv/sdk'
|
|
2
|
-
import {
|
|
3
|
-
asArray,
|
|
4
|
-
asString,
|
|
5
|
-
doubleSha256BE,
|
|
6
|
-
sdk,
|
|
7
|
-
validateScriptHash,
|
|
8
|
-
wait
|
|
9
|
-
} from '../../index.client'
|
|
2
|
+
import { asArray, asString, doubleSha256BE, sdk, validateScriptHash, wait } from '../../index.client'
|
|
10
3
|
import { convertProofToMerklePath } from '../../utility/tscProofToMerklePath'
|
|
11
4
|
import SdkWhatsOnChain from './SdkWhatsOnChain'
|
|
12
5
|
import { ReqHistoryNote } from '../../sdk'
|
|
@@ -30,21 +23,10 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
30
23
|
headers: this.getHttpHeaders()
|
|
31
24
|
}
|
|
32
25
|
|
|
33
|
-
const response = await this.httpClient.request<string>(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
!response.data ||
|
|
40
|
-
!response.ok ||
|
|
41
|
-
response.status !== 200 ||
|
|
42
|
-
response.statusText !== 'OK'
|
|
43
|
-
)
|
|
44
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
45
|
-
'txid',
|
|
46
|
-
`valid transaction. '${txid}' response ${response.statusText}`
|
|
47
|
-
)
|
|
26
|
+
const response = await this.httpClient.request<string>(`${this.URL}/tx/hash/${txid}/propagation`, requestOptions)
|
|
27
|
+
|
|
28
|
+
if (!response.data || !response.ok || response.status !== 200 || response.statusText !== 'OK')
|
|
29
|
+
throw new sdk.WERR_INVALID_PARAMETER('txid', `valid transaction. '${txid}' response ${response.statusText}`)
|
|
48
30
|
|
|
49
31
|
return 0
|
|
50
32
|
}
|
|
@@ -64,28 +46,16 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
64
46
|
}
|
|
65
47
|
|
|
66
48
|
for (let retry = 0; retry < 2; retry++) {
|
|
67
|
-
const response = await this.httpClient.request<string>(
|
|
68
|
-
`${this.URL}/tx/${txid}/hex`,
|
|
69
|
-
requestOptions
|
|
70
|
-
)
|
|
49
|
+
const response = await this.httpClient.request<string>(`${this.URL}/tx/${txid}/hex`, requestOptions)
|
|
71
50
|
if (response.statusText === 'Too Many Requests' && retry < 2) {
|
|
72
51
|
await wait(2000)
|
|
73
52
|
continue
|
|
74
53
|
}
|
|
75
54
|
|
|
76
|
-
if (response.status === 404 && response.statusText === 'Not Found')
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
!response.data ||
|
|
81
|
-
!response.ok ||
|
|
82
|
-
response.status !== 200 ||
|
|
83
|
-
response.statusText !== 'OK'
|
|
84
|
-
)
|
|
85
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
86
|
-
'txid',
|
|
87
|
-
`valid transaction. '${txid}' response ${response.statusText}`
|
|
88
|
-
)
|
|
55
|
+
if (response.status === 404 && response.statusText === 'Not Found') return undefined
|
|
56
|
+
|
|
57
|
+
if (!response.data || !response.ok || response.status !== 200 || response.statusText !== 'OK')
|
|
58
|
+
throw new sdk.WERR_INVALID_PARAMETER('txid', `valid transaction. '${txid}' response ${response.statusText}`)
|
|
89
59
|
|
|
90
60
|
return response.data
|
|
91
61
|
}
|
|
@@ -138,9 +108,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
138
108
|
|
|
139
109
|
const tr = await this.postRawTx(rawTx)
|
|
140
110
|
if (txid !== tr.txid) {
|
|
141
|
-
throw new sdk.WERR_INTERNAL(
|
|
142
|
-
`woc returned txid ${tr.txid}, expected ${txid}`
|
|
143
|
-
)
|
|
111
|
+
throw new sdk.WERR_INTERNAL(`woc returned txid ${tr.txid}, expected ${txid}`)
|
|
144
112
|
}
|
|
145
113
|
|
|
146
114
|
r.txidResults.push(tr)
|
|
@@ -186,10 +154,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
186
154
|
const retryLimit = 5
|
|
187
155
|
for (let retry = 0; retry < retryLimit; retry++) {
|
|
188
156
|
try {
|
|
189
|
-
const response = await this.httpClient.request<string>(
|
|
190
|
-
url,
|
|
191
|
-
requestOptions
|
|
192
|
-
)
|
|
157
|
+
const response = await this.httpClient.request<string>(url, requestOptions)
|
|
193
158
|
if (response.statusText === 'Too Many Requests' && retry < 2) {
|
|
194
159
|
r.notes!.push({ ...nn(), what: 'postRawTxRateLimit' })
|
|
195
160
|
await wait(2000)
|
|
@@ -212,10 +177,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
212
177
|
n.statusText = response.data.slice(0, 128)
|
|
213
178
|
r.data = `${r.data || ''} ${response.statusText}`
|
|
214
179
|
}
|
|
215
|
-
if (
|
|
216
|
-
typeof response.status === 'string' ||
|
|
217
|
-
typeof response.status === 'number'
|
|
218
|
-
) {
|
|
180
|
+
if (typeof response.status === 'string' || typeof response.status === 'number') {
|
|
219
181
|
n.status = response.data.slice(0, 128)
|
|
220
182
|
r.data = `${r.data || ''} ${response.status}`
|
|
221
183
|
}
|
|
@@ -247,10 +209,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
247
209
|
* @param txid
|
|
248
210
|
* @returns
|
|
249
211
|
*/
|
|
250
|
-
async getMerklePath(
|
|
251
|
-
txid: string,
|
|
252
|
-
services: sdk.WalletServices
|
|
253
|
-
): Promise<sdk.GetMerklePathResult> {
|
|
212
|
+
async getMerklePath(txid: string, services: sdk.WalletServices): Promise<sdk.GetMerklePathResult> {
|
|
254
213
|
const r: sdk.GetMerklePathResult = { name: 'WoCTsc', notes: [] }
|
|
255
214
|
|
|
256
215
|
const headers = this.getHttpHeaders()
|
|
@@ -261,9 +220,10 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
261
220
|
|
|
262
221
|
for (let retry = 0; retry < 2; retry++) {
|
|
263
222
|
try {
|
|
264
|
-
const response = await this.httpClient.request<
|
|
265
|
-
|
|
266
|
-
|
|
223
|
+
const response = await this.httpClient.request<WhatsOnChainTscProof | WhatsOnChainTscProof[]>(
|
|
224
|
+
`${this.URL}/tx/${txid}/proof/tsc`,
|
|
225
|
+
requestOptions
|
|
226
|
+
)
|
|
267
227
|
if (response.statusText === 'Too Many Requests' && retry < 2) {
|
|
268
228
|
r.notes!.push({
|
|
269
229
|
what: 'getMerklePathRetry',
|
|
@@ -285,21 +245,14 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
285
245
|
return r
|
|
286
246
|
}
|
|
287
247
|
|
|
288
|
-
if (
|
|
289
|
-
!response.ok ||
|
|
290
|
-
response.status !== 200 ||
|
|
291
|
-
response.statusText !== 'OK'
|
|
292
|
-
) {
|
|
248
|
+
if (!response.ok || response.status !== 200 || response.statusText !== 'OK') {
|
|
293
249
|
r.notes!.push({
|
|
294
250
|
what: 'getMerklePathBadStatus',
|
|
295
251
|
name: r.name,
|
|
296
252
|
status: response.status,
|
|
297
253
|
statusText: response.statusText
|
|
298
254
|
})
|
|
299
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
300
|
-
'txid',
|
|
301
|
-
`valid transaction. '${txid}' response ${response.statusText}`
|
|
302
|
-
)
|
|
255
|
+
throw new sdk.WERR_INVALID_PARAMETER('txid', `valid transaction. '${txid}' response ${response.statusText}`)
|
|
303
256
|
}
|
|
304
257
|
|
|
305
258
|
if (!response.data) {
|
|
@@ -341,10 +294,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
341
294
|
status: response.status,
|
|
342
295
|
statusText: response.statusText
|
|
343
296
|
})
|
|
344
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
345
|
-
'blockhash',
|
|
346
|
-
'a valid on-chain block hash'
|
|
347
|
-
)
|
|
297
|
+
throw new sdk.WERR_INVALID_PARAMETER('blockhash', 'a valid on-chain block hash')
|
|
348
298
|
}
|
|
349
299
|
} catch (eu: unknown) {
|
|
350
300
|
const e = sdk.WalletError.fromUnknown(eu)
|
|
@@ -362,10 +312,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
362
312
|
throw new sdk.WERR_INTERNAL()
|
|
363
313
|
}
|
|
364
314
|
|
|
365
|
-
async updateBsvExchangeRate(
|
|
366
|
-
rate?: sdk.BsvExchangeRate,
|
|
367
|
-
updateMsecs?: number
|
|
368
|
-
): Promise<sdk.BsvExchangeRate> {
|
|
315
|
+
async updateBsvExchangeRate(rate?: sdk.BsvExchangeRate, updateMsecs?: number): Promise<sdk.BsvExchangeRate> {
|
|
369
316
|
if (rate) {
|
|
370
317
|
// Check if the rate we know is stale enough to update.
|
|
371
318
|
updateMsecs ||= 1000 * 60 * 15
|
|
@@ -388,15 +335,8 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
388
335
|
continue
|
|
389
336
|
}
|
|
390
337
|
|
|
391
|
-
if (
|
|
392
|
-
|
|
393
|
-
!response.ok ||
|
|
394
|
-
response.status !== 200 ||
|
|
395
|
-
response.statusText !== 'OK'
|
|
396
|
-
)
|
|
397
|
-
throw new sdk.WERR_INVALID_OPERATION(
|
|
398
|
-
`WoC exchangerate response ${response.statusText}`
|
|
399
|
-
)
|
|
338
|
+
if (!response.data || !response.ok || response.status !== 200 || response.statusText !== 'OK')
|
|
339
|
+
throw new sdk.WERR_INVALID_OPERATION(`WoC exchangerate response ${response.statusText}`)
|
|
400
340
|
|
|
401
341
|
const wocrate = response.data
|
|
402
342
|
if (wocrate.currency !== 'USD') wocrate.rate = NaN
|
|
@@ -412,10 +352,7 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
412
352
|
throw new sdk.WERR_INTERNAL()
|
|
413
353
|
}
|
|
414
354
|
|
|
415
|
-
async getUtxoStatus(
|
|
416
|
-
output: string,
|
|
417
|
-
outputFormat?: sdk.GetUtxoStatusOutputFormat
|
|
418
|
-
): Promise<sdk.GetUtxoStatusResult> {
|
|
355
|
+
async getUtxoStatus(output: string, outputFormat?: sdk.GetUtxoStatusOutputFormat): Promise<sdk.GetUtxoStatusResult> {
|
|
419
356
|
const r: sdk.GetUtxoStatusResult = {
|
|
420
357
|
name: 'WoC',
|
|
421
358
|
status: 'error',
|
|
@@ -434,23 +371,17 @@ export class WhatsOnChain extends SdkWhatsOnChain {
|
|
|
434
371
|
headers: this.getHttpHeaders()
|
|
435
372
|
}
|
|
436
373
|
|
|
437
|
-
const response = await this.httpClient.request<
|
|
438
|
-
|
|
439
|
-
|
|
374
|
+
const response = await this.httpClient.request<WhatsOnChainUtxoStatus[]>(
|
|
375
|
+
`${this.URL}/script/${scriptHash}/unspent`,
|
|
376
|
+
requestOptions
|
|
377
|
+
)
|
|
440
378
|
if (response.statusText === 'Too Many Requests' && retry < 2) {
|
|
441
379
|
await wait(2000)
|
|
442
380
|
continue
|
|
443
381
|
}
|
|
444
382
|
|
|
445
|
-
if (
|
|
446
|
-
|
|
447
|
-
!response.ok ||
|
|
448
|
-
response.status !== 200 ||
|
|
449
|
-
response.statusText !== 'OK'
|
|
450
|
-
)
|
|
451
|
-
throw new sdk.WERR_INVALID_OPERATION(
|
|
452
|
-
`WoC exchangerate response ${response.statusText}`
|
|
453
|
-
)
|
|
383
|
+
if (!response.data || !response.ok || response.status !== 200 || response.statusText !== 'OK')
|
|
384
|
+
throw new sdk.WERR_INVALID_OPERATION(`WoC exchangerate response ${response.statusText}`)
|
|
454
385
|
|
|
455
386
|
if (Array.isArray(response.data)) {
|
|
456
387
|
const data = response.data
|
|
@@ -20,9 +20,7 @@ describe('whatsonchain tests', () => {
|
|
|
20
20
|
if (_tu.noTestEnv('test')) return
|
|
21
21
|
|
|
22
22
|
test('0 getRawTx testnet', async () => {
|
|
23
|
-
const rawTx = await wocTest.getRawTx(
|
|
24
|
-
'7e5b797b86abd31a654bf296900d6cb14d04ef0811568ff4675494af2d92166b'
|
|
25
|
-
)
|
|
23
|
+
const rawTx = await wocTest.getRawTx('7e5b797b86abd31a654bf296900d6cb14d04ef0811568ff4675494af2d92166b')
|
|
26
24
|
expect(
|
|
27
25
|
rawTx ===
|
|
28
26
|
'010000000158EED5DBBB7E2F7D70C79A11B9B61AABEECFA5A7CEC679BEDD00F42C48A4BD45010000006B483045022100AE8BB45498A40E2AC797775C405C108168804CD84E8C09A9D42D280D18EDDB6D022024863BFAAC5FF3C24CA65E2F3677EDA092BC3CC5D2EFABA73264B8FF55CF416B412102094AAF520E14E1C4D68496822800BCC7D3B3B26CA368E004A2CB70B398D82FACFFFFFFFF0203000000000000007421020A624B72B34BC192851C5D8890926BBB70B31BC10FDD4E3BC6534E41B1C81B93AC03010203030405064630440220013B4984F4054C2FBCD2F448AB896CCA5C4E234BF765B0C7FB27EDE572A7F7DA02201A5C8D0D023F94C209046B9A2B96B2882C5E43B72D8115561DF8C07442010EEA6D7592090000000000001976A9146511FCE2F7EF785A2102142FBF381AD1291C918688AC00000000'
|
|
@@ -32,9 +30,7 @@ describe('whatsonchain tests', () => {
|
|
|
32
30
|
})
|
|
33
31
|
|
|
34
32
|
test('1 getRawTx mainnet', async () => {
|
|
35
|
-
const rawTx = await wocMain.getRawTx(
|
|
36
|
-
'd9978ffc6676523208f7b33bebf1b176388bbeace2c7ef67ce35c2eababa1805'
|
|
37
|
-
)
|
|
33
|
+
const rawTx = await wocMain.getRawTx('d9978ffc6676523208f7b33bebf1b176388bbeace2c7ef67ce35c2eababa1805')
|
|
38
34
|
expect(
|
|
39
35
|
rawTx ===
|
|
40
36
|
'0100000001026A66A5F724EB490A55E0E08553286F08AD57E92C4BF34B5C44EA6BC0A49828020000006B483045022100C3D9A5ACA30C1F2E1A54532162E7AFE5AA69150E4C06D760414A16D1EA1BABD602205E0D9191838B0911A1E7328554A2B22EFAA80CF52B15FBA37C3046A0996C7AAD412103FA3CF488CA98D9F2DB91843F36BAF6BE39F6C947976C02394602D09FBC5F4CF4FFFFFFFF0210270000000000001976A91444C04354E88975C4BEF30CFE89D300CC7659F7E588AC96BC0000000000001976A9149A53E5CF5F1876924D98A8B35CA0BC693618682488AC00000000'
|
|
@@ -99,9 +95,7 @@ describe('whatsonchain tests', () => {
|
|
|
99
95
|
test('5 getTxPropagation testnet', async () => {
|
|
100
96
|
return
|
|
101
97
|
// throwing internal server error 500 when tested.
|
|
102
|
-
const count = await wocTest.getTxPropagation(
|
|
103
|
-
'7e5b797b86abd31a654bf296900d6cb14d04ef0811568ff4675494af2d92166b'
|
|
104
|
-
)
|
|
98
|
+
const count = await wocTest.getTxPropagation('7e5b797b86abd31a654bf296900d6cb14d04ef0811568ff4675494af2d92166b')
|
|
105
99
|
expect(count > 0)
|
|
106
100
|
|
|
107
101
|
expect((await wocTest.getTxPropagation('1'.repeat(64))) === 0)
|
|
@@ -186,8 +180,7 @@ describe('whatsonchain tests', () => {
|
|
|
186
180
|
} catch (eu: unknown) {
|
|
187
181
|
const e = sdk.WalletError.fromUnknown(eu)
|
|
188
182
|
expect(
|
|
189
|
-
e.message ===
|
|
190
|
-
'The rawTx parameter must be valid. unexpected response code 500: 258: txn-mempool-conflict' ||
|
|
183
|
+
e.message === 'The rawTx parameter must be valid. unexpected response code 500: 258: txn-mempool-conflict' ||
|
|
191
184
|
'The rawTx parameter must be valid. unexpected response code 500: Missing inputs'
|
|
192
185
|
)
|
|
193
186
|
}
|
|
@@ -237,10 +230,7 @@ describe('whatsonchain tests', () => {
|
|
|
237
230
|
if (!Setup.getEnv('main').filePath) return
|
|
238
231
|
|
|
239
232
|
const c = await _tu.createWalletSetupEnv('main')
|
|
240
|
-
const client = new StorageClient(
|
|
241
|
-
c.wallet,
|
|
242
|
-
'https://storage.babbage.systems'
|
|
243
|
-
)
|
|
233
|
+
const client = new StorageClient(c.wallet, 'https://storage.babbage.systems')
|
|
244
234
|
await c.storage.addWalletStorageProvider(client)
|
|
245
235
|
await c.storage.updateBackups()
|
|
246
236
|
|
|
@@ -7,10 +7,7 @@ export async function updateChaintracksFiatExchangeRates(
|
|
|
7
7
|
): Promise<sdk.FiatExchangeRates> {
|
|
8
8
|
const url = options.chaintracksFiatExchangeRatesUrl
|
|
9
9
|
|
|
10
|
-
if (!url)
|
|
11
|
-
throw new sdk.WERR_MISSING_PARAMETER(
|
|
12
|
-
'options.chaintracksFiatExchangeRatesUrl'
|
|
13
|
-
)
|
|
10
|
+
if (!url) throw new sdk.WERR_MISSING_PARAMETER('options.chaintracksFiatExchangeRatesUrl')
|
|
14
11
|
|
|
15
12
|
const r = await axios.get(url)
|
|
16
13
|
|
|
@@ -28,20 +25,14 @@ export async function updateExchangeratesapi(
|
|
|
28
25
|
targetCurrencies: string[],
|
|
29
26
|
options: sdk.WalletServicesOptions
|
|
30
27
|
): Promise<sdk.FiatExchangeRates> {
|
|
31
|
-
if (!options.exchangeratesapiKey)
|
|
32
|
-
throw new sdk.WERR_MISSING_PARAMETER('options.exchangeratesapiKey')
|
|
28
|
+
if (!options.exchangeratesapiKey) throw new sdk.WERR_MISSING_PARAMETER('options.exchangeratesapiKey')
|
|
33
29
|
|
|
34
30
|
const iorates = await getExchangeRatesIo(options.exchangeratesapiKey)
|
|
35
31
|
|
|
36
|
-
if (!iorates.success)
|
|
37
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
38
|
-
`getExchangeRatesIo returned success ${iorates.success}`
|
|
39
|
-
)
|
|
32
|
+
if (!iorates.success) throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo returned success ${iorates.success}`)
|
|
40
33
|
|
|
41
34
|
if (!iorates.rates['USD'] || !iorates.rates[iorates.base])
|
|
42
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
43
|
-
`getExchangeRatesIo missing rates for 'USD' or base`
|
|
44
|
-
)
|
|
35
|
+
throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo missing rates for 'USD' or base`)
|
|
45
36
|
|
|
46
37
|
const r: sdk.FiatExchangeRates = {
|
|
47
38
|
timestamp: new Date(iorates.timestamp * 1000),
|
|
@@ -60,9 +51,7 @@ export async function updateExchangeratesapi(
|
|
|
60
51
|
}
|
|
61
52
|
|
|
62
53
|
if (updates !== targetCurrencies.length)
|
|
63
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
64
|
-
`getExchangeRatesIo failed to update all target currencies`
|
|
65
|
-
)
|
|
54
|
+
throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo failed to update all target currencies`)
|
|
66
55
|
|
|
67
56
|
//console.log(`new fiat rates=${JSON.stringify(r)}`)
|
|
68
57
|
|
|
@@ -77,17 +66,13 @@ export interface ExchangeRatesIoApi {
|
|
|
77
66
|
rates: Record<string, number>
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
export async function getExchangeRatesIo(
|
|
81
|
-
key: string
|
|
82
|
-
): Promise<ExchangeRatesIoApi> {
|
|
69
|
+
export async function getExchangeRatesIo(key: string): Promise<ExchangeRatesIoApi> {
|
|
83
70
|
const url = `http://api.exchangeratesapi.io/v1/latest?access_key=${key}`
|
|
84
71
|
|
|
85
72
|
const r = await axios.get(url)
|
|
86
73
|
|
|
87
74
|
if (r.status !== 200 || !r.data) {
|
|
88
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
89
|
-
`getExchangeRatesIo returned status ${r.status}`
|
|
90
|
-
)
|
|
75
|
+
throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo returned status ${r.status}`)
|
|
91
76
|
}
|
|
92
77
|
|
|
93
78
|
const rates = <ExchangeRatesIoApi>r.data
|