@bsv/wallet-toolbox 1.1.60 → 1.1.62
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/ARC.test.js +9 -0
- package/out/src/services/__tests/ARC.test.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 +2 -3
- 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 +5 -12
- 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 +39 -31
- 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/ARC.test.ts +14 -1
- 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/processingErrors/arcSuccessError.json +76 -0
- package/src/services/providers/ARC.ts +6 -25
- 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 +15 -69
- 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 +45 -102
- 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
|
@@ -27,10 +27,10 @@ import {
|
|
|
27
27
|
} from '../../../src'
|
|
28
28
|
import { _tu, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
29
29
|
import { monitorEventLoopDelay } from 'perf_hooks'
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
import { specOpInvalidChange, validateCreateActionArgs, ValidCreateActionArgs } from '../../../src/sdk'
|
|
31
|
+
|
|
32
|
+
const setActiveClient = true
|
|
33
|
+
const useMySQLConnectionForClient = true
|
|
34
34
|
|
|
35
35
|
describe('localWallet tests', () => {
|
|
36
36
|
jest.setTimeout(99999999)
|
|
@@ -39,148 +39,111 @@ describe('localWallet tests', () => {
|
|
|
39
39
|
if (_tu.noTestEnv('test')) return
|
|
40
40
|
if (_tu.noTestEnv('main')) return
|
|
41
41
|
|
|
42
|
-
test('0
|
|
42
|
+
test('0 monitor runOnce', async () => {
|
|
43
43
|
const setup = await createSetup('test')
|
|
44
|
-
|
|
45
|
-
const car = await createOneSatTestOutput(setup, {}, 1)
|
|
46
|
-
|
|
47
|
-
//await trackReqByTxid(setup, car.txid!)
|
|
48
|
-
|
|
44
|
+
await setup.monitor.runOnce()
|
|
49
45
|
await setup.wallet.destroy()
|
|
50
46
|
})
|
|
51
47
|
|
|
52
|
-
test('
|
|
48
|
+
test('1 recover 1 sat outputs', async () => {
|
|
53
49
|
const setup = await createSetup('test')
|
|
54
|
-
|
|
55
|
-
const car = await createOneSatTestOutput(
|
|
56
|
-
setup,
|
|
57
|
-
{ acceptDelayedBroadcast: false },
|
|
58
|
-
1
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
await trackReqByTxid(setup, car.txid!)
|
|
62
|
-
|
|
50
|
+
await recoverOneSatTestOutputs(setup)
|
|
63
51
|
await setup.wallet.destroy()
|
|
64
52
|
})
|
|
65
53
|
|
|
66
|
-
test('
|
|
54
|
+
test('2 create 1 sat delayed', async () => {
|
|
67
55
|
const setup = await createSetup('test')
|
|
68
|
-
|
|
69
|
-
const car = await createOneSatTestOutput(setup, { noSend: true }, 2)
|
|
70
|
-
|
|
56
|
+
const car = await createOneSatTestOutput(setup, {}, 1)
|
|
71
57
|
//await trackReqByTxid(setup, car.txid!)
|
|
72
|
-
|
|
73
58
|
await setup.wallet.destroy()
|
|
74
59
|
})
|
|
75
60
|
|
|
76
|
-
test('
|
|
61
|
+
test('2a create 1 sat immediate', async () => {
|
|
77
62
|
const setup = await createSetup('test')
|
|
78
|
-
|
|
79
|
-
await
|
|
80
|
-
|
|
63
|
+
const car = await createOneSatTestOutput(setup, { acceptDelayedBroadcast: false }, 1)
|
|
64
|
+
// await trackReqByTxid(setup, car.txid!)
|
|
81
65
|
await setup.wallet.destroy()
|
|
82
66
|
})
|
|
83
67
|
|
|
84
|
-
test('2
|
|
68
|
+
test('2b create 2 nosend and sendWith', async () => {
|
|
85
69
|
const setup = await createSetup('test')
|
|
86
|
-
|
|
87
|
-
await setup.
|
|
88
|
-
|
|
70
|
+
const car = await createOneSatTestOutput(setup, { noSend: true }, 2)
|
|
71
|
+
//await trackReqByTxid(setup, car.txid!)
|
|
89
72
|
await setup.wallet.destroy()
|
|
90
73
|
})
|
|
91
74
|
|
|
92
75
|
test('3 return active to cloud client', async () => {
|
|
93
76
|
const setup = await createSetup('test')
|
|
94
|
-
|
|
95
77
|
const localBalance = await setup.wallet.balance()
|
|
96
|
-
|
|
97
78
|
const log = await setup.storage.setActive(setup.clientStorageIdentityKey!)
|
|
98
79
|
console.log(log)
|
|
99
|
-
|
|
100
80
|
console.log(`ACTIVE STORAGE: ${setup.storage.getActiveStoreName()}`)
|
|
101
|
-
|
|
102
81
|
const clientBalance = await setup.wallet.balance()
|
|
103
|
-
|
|
104
82
|
expect(localBalance.total).toBe(clientBalance.total)
|
|
105
|
-
|
|
106
83
|
await setup.wallet.destroy()
|
|
107
84
|
})
|
|
108
85
|
|
|
109
86
|
test('4 review change utxos', async () => {
|
|
110
87
|
const setup = await createSetup('test')
|
|
111
|
-
|
|
88
|
+
const lor = await setup.wallet.listOutputs({
|
|
89
|
+
basket: specOpInvalidChange,
|
|
90
|
+
limit: 1000
|
|
91
|
+
})
|
|
92
|
+
if (lor.totalOutputs > 0) {
|
|
93
|
+
debugger
|
|
94
|
+
const lor = await setup.wallet.listOutputs({
|
|
95
|
+
basket: specOpInvalidChange,
|
|
96
|
+
tags: ['release']
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
/*
|
|
112
100
|
const storage = setup.activeStorage
|
|
113
101
|
const services = setup.services
|
|
114
|
-
|
|
115
|
-
const {
|
|
116
|
-
storage,
|
|
117
|
-
services
|
|
118
|
-
)
|
|
119
|
-
const outputsToUpdate = notUtxos.map(o => ({
|
|
120
|
-
id: o.outputId,
|
|
121
|
-
satoshis: o.satoshis
|
|
122
|
-
}))
|
|
123
|
-
|
|
102
|
+
const { invalidSpendableOutputs: notUtxos } = await confirmSpendableOutputs(storage, services)
|
|
103
|
+
const outputsToUpdate = notUtxos.map(o => ({ id: o.outputId, satoshis: o.satoshis }))
|
|
124
104
|
const total: number = outputsToUpdate.reduce((t, o) => t + o.satoshis, 0)
|
|
125
|
-
|
|
126
105
|
debugger
|
|
127
|
-
// *** About set spendable = false for outputs
|
|
106
|
+
// *** About set spendable = false for outputs ***
|
|
128
107
|
for (const o of outputsToUpdate) {
|
|
129
108
|
await storage.updateOutput(o.id, { spendable: false })
|
|
130
109
|
}
|
|
131
|
-
|
|
110
|
+
*/
|
|
132
111
|
await setup.wallet.destroy()
|
|
133
112
|
})
|
|
134
113
|
|
|
135
114
|
test('5 review synchunk', async () => {
|
|
136
115
|
const setup = await createSetup('test')
|
|
137
|
-
|
|
138
116
|
const identityKey = setup.identityKey
|
|
139
117
|
const reader = setup.activeStorage
|
|
140
118
|
const readerSettings = reader.getSettings()
|
|
141
119
|
const writer = setup.storage._backups![0].storage
|
|
142
120
|
const writerSettings = writer.getSettings()
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
writer,
|
|
146
|
-
identityKey,
|
|
147
|
-
readerSettings
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
const args = ss.makeRequestSyncChunkArgs(
|
|
151
|
-
identityKey,
|
|
152
|
-
writerSettings.storageIdentityKey
|
|
153
|
-
)
|
|
154
|
-
|
|
121
|
+
const ss = await EntitySyncState.fromStorage(writer, identityKey, readerSettings)
|
|
122
|
+
const args = ss.makeRequestSyncChunkArgs(identityKey, writerSettings.storageIdentityKey)
|
|
155
123
|
const chunk = await reader.getSyncChunk(args)
|
|
156
|
-
|
|
157
124
|
await setup.wallet.destroy()
|
|
158
125
|
})
|
|
159
126
|
|
|
160
127
|
test('6 backup', async () => {
|
|
161
128
|
const setup = await createSetup('test')
|
|
162
|
-
|
|
163
129
|
const log = await setup.storage.updateBackups()
|
|
164
130
|
console.log(log)
|
|
165
|
-
|
|
166
131
|
await setup.wallet.destroy()
|
|
167
132
|
})
|
|
168
133
|
})
|
|
169
134
|
|
|
170
135
|
async function createSetup(chain: sdk.Chain): Promise<TestWalletNoSetup> {
|
|
171
136
|
const env = _tu.getEnv(chain)
|
|
172
|
-
if (!env.testIdentityKey)
|
|
173
|
-
|
|
174
|
-
if (!env.testFilePath)
|
|
175
|
-
throw new sdk.WERR_INVALID_PARAMETER('env.testFilePath', 'valid')
|
|
137
|
+
if (!env.testIdentityKey) throw new sdk.WERR_INVALID_PARAMETER('env.testIdentityKey', 'valid')
|
|
138
|
+
if (!env.testFilePath) throw new sdk.WERR_INVALID_PARAMETER('env.testFilePath', 'valid')
|
|
176
139
|
|
|
177
140
|
const setup = await _tu.createTestWallet({
|
|
178
141
|
chain,
|
|
179
142
|
rootKeyHex: env.devKeys[env.testIdentityKey],
|
|
180
143
|
filePath: env.testFilePath,
|
|
181
|
-
setActiveClient
|
|
144
|
+
setActiveClient,
|
|
182
145
|
addLocalBackup: false,
|
|
183
|
-
useMySQLConnectionForClient
|
|
146
|
+
useMySQLConnectionForClient
|
|
184
147
|
})
|
|
185
148
|
|
|
186
149
|
console.log(`ACTIVE STORAGE: ${setup.storage.getActiveStoreName()}`)
|
|
@@ -205,9 +168,7 @@ async function createOneSatTestOutput(
|
|
|
205
168
|
const args: CreateActionArgs = {
|
|
206
169
|
outputs: [
|
|
207
170
|
{
|
|
208
|
-
lockingScript: new P2PKH()
|
|
209
|
-
.lock(PublicKey.fromString(setup.identityKey).toAddress())
|
|
210
|
-
.toHex(),
|
|
171
|
+
lockingScript: new P2PKH().lock(PublicKey.fromString(setup.identityKey).toAddress()).toHex(),
|
|
211
172
|
satoshis: 1,
|
|
212
173
|
outputDescription: 'test output',
|
|
213
174
|
customInstructions: JSON.stringify({
|
|
@@ -229,10 +190,7 @@ async function createOneSatTestOutput(
|
|
|
229
190
|
txids.push(car.txid!)
|
|
230
191
|
noSendChange = car.noSendChange
|
|
231
192
|
|
|
232
|
-
const req = await EntityProvenTxReq.fromStorageTxid(
|
|
233
|
-
setup.activeStorage,
|
|
234
|
-
car.txid!
|
|
235
|
-
)
|
|
193
|
+
const req = await EntityProvenTxReq.fromStorageTxid(setup.activeStorage, car.txid!)
|
|
236
194
|
expect(req !== undefined && req.history.notes !== undefined)
|
|
237
195
|
if (req && req.history.notes) {
|
|
238
196
|
if (vargs.isNoSend) {
|
|
@@ -265,9 +223,7 @@ async function createOneSatTestOutput(
|
|
|
265
223
|
return car
|
|
266
224
|
}
|
|
267
225
|
|
|
268
|
-
async function recoverOneSatTestOutputs(
|
|
269
|
-
setup: TestWalletNoSetup
|
|
270
|
-
): Promise<void> {
|
|
226
|
+
async function recoverOneSatTestOutputs(setup: TestWalletNoSetup): Promise<void> {
|
|
271
227
|
const outputs = await setup.wallet.listOutputs({
|
|
272
228
|
basket: 'test-output',
|
|
273
229
|
include: 'entire transactions',
|
|
@@ -309,10 +265,7 @@ async function recoverOneSatTestOutputs(
|
|
|
309
265
|
}
|
|
310
266
|
}
|
|
311
267
|
|
|
312
|
-
async function trackReqByTxid(
|
|
313
|
-
setup: TestWalletNoSetup,
|
|
314
|
-
txid: string
|
|
315
|
-
): Promise<void> {
|
|
268
|
+
async function trackReqByTxid(setup: TestWalletNoSetup, txid: string): Promise<void> {
|
|
316
269
|
const req = await EntityProvenTxReq.fromStorageTxid(setup.activeStorage, txid)
|
|
317
270
|
|
|
318
271
|
expect(req !== undefined && req.history.notes !== undefined)
|
|
@@ -356,9 +309,7 @@ export async function confirmSpendableOutputs(
|
|
|
356
309
|
const users = await storage.findUsers({ partial })
|
|
357
310
|
|
|
358
311
|
for (const { userId } of users) {
|
|
359
|
-
const defaultBasket = verifyOne(
|
|
360
|
-
await storage.findOutputBaskets({ partial: { userId, name: 'default' } })
|
|
361
|
-
)
|
|
312
|
+
const defaultBasket = verifyOne(await storage.findOutputBaskets({ partial: { userId, name: 'default' } }))
|
|
362
313
|
const where: Partial<TableOutput> = {
|
|
363
314
|
userId,
|
|
364
315
|
basketId: defaultBasket.basketId,
|
|
@@ -375,10 +326,7 @@ export async function confirmSpendableOutputs(
|
|
|
375
326
|
let ok = false
|
|
376
327
|
|
|
377
328
|
if (o.lockingScript && o.lockingScript.length > 0) {
|
|
378
|
-
const r = await services.getUtxoStatus(
|
|
379
|
-
asString(o.lockingScript),
|
|
380
|
-
'script'
|
|
381
|
-
)
|
|
329
|
+
const r = await services.getUtxoStatus(asString(o.lockingScript), 'script')
|
|
382
330
|
|
|
383
331
|
if (r.status === 'success' && r.isUtxo && r.details?.length > 0) {
|
|
384
332
|
const tx = await storage.findTransactionById(o.transactionId)
|
|
@@ -386,12 +334,7 @@ export async function confirmSpendableOutputs(
|
|
|
386
334
|
if (
|
|
387
335
|
tx &&
|
|
388
336
|
tx.txid &&
|
|
389
|
-
r.details.some(
|
|
390
|
-
d =>
|
|
391
|
-
d.txid === tx.txid &&
|
|
392
|
-
d.satoshis === o.satoshis &&
|
|
393
|
-
d.index === o.vout
|
|
394
|
-
)
|
|
337
|
+
r.details.some(d => d.txid === tx.txid && d.satoshis === o.satoshis && d.index === o.vout)
|
|
395
338
|
) {
|
|
396
339
|
ok = true
|
|
397
340
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { sdk, verifyOne } from '../../../src'
|
|
2
|
-
import {
|
|
3
|
-
specOpInvalidChange,
|
|
4
|
-
specOpSetWalletChangeParams,
|
|
5
|
-
specOpWalletBalance
|
|
6
|
-
} from '../../../src/sdk'
|
|
2
|
+
import { specOpInvalidChange, specOpSetWalletChangeParams, specOpWalletBalance } from '../../../src/sdk'
|
|
7
3
|
import { _tu, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
8
4
|
|
|
9
5
|
describe('specOps tests', () => {
|
|
@@ -66,10 +62,7 @@ describe('specOps tests', () => {
|
|
|
66
62
|
// Restore original values...
|
|
67
63
|
await setup.wallet.listOutputs({
|
|
68
64
|
basket: specOpSetWalletChangeParams,
|
|
69
|
-
tags: [
|
|
70
|
-
before.numberOfDesiredUTXOs.toString(),
|
|
71
|
-
before.minimumDesiredUTXOValue.toString()
|
|
72
|
-
]
|
|
65
|
+
tags: [before.numberOfDesiredUTXOs.toString(), before.minimumDesiredUTXOValue.toString()]
|
|
73
66
|
})
|
|
74
67
|
|
|
75
68
|
await setup.wallet.destroy()
|
|
@@ -78,10 +71,8 @@ describe('specOps tests', () => {
|
|
|
78
71
|
|
|
79
72
|
async function createSetup(chain: sdk.Chain): Promise<TestWalletNoSetup> {
|
|
80
73
|
const env = _tu.getEnv(chain)
|
|
81
|
-
if (!env.testIdentityKey)
|
|
82
|
-
|
|
83
|
-
if (!env.testFilePath)
|
|
84
|
-
throw new sdk.WERR_INVALID_PARAMETER('env.testFilePath', 'valid')
|
|
74
|
+
if (!env.testIdentityKey) throw new sdk.WERR_INVALID_PARAMETER('env.testIdentityKey', 'valid')
|
|
75
|
+
if (!env.testFilePath) throw new sdk.WERR_INVALID_PARAMETER('env.testFilePath', 'valid')
|
|
85
76
|
|
|
86
77
|
const setup = await _tu.createTestWallet({
|
|
87
78
|
chain,
|
|
@@ -19,13 +19,8 @@ describe('janitor tests', () => {
|
|
|
19
19
|
|
|
20
20
|
const services = new Services(env.chain)
|
|
21
21
|
|
|
22
|
-
const identityKey =
|
|
23
|
-
|
|
24
|
-
const { invalidSpendableOutputs: notUtxos } = await confirmSpendableOutputs(
|
|
25
|
-
storage,
|
|
26
|
-
services,
|
|
27
|
-
identityKey
|
|
28
|
-
)
|
|
22
|
+
const identityKey = '0304985aa632dde471d3bf1ffb030d0af253fe65f5d186bb4cf878ca0fbee54c1c'
|
|
23
|
+
const { invalidSpendableOutputs: notUtxos } = await confirmSpendableOutputs(storage, services, identityKey)
|
|
29
24
|
const outputsToUpdate = notUtxos.map(o => ({
|
|
30
25
|
id: o.outputId,
|
|
31
26
|
satoshis: o.satoshis
|
|
@@ -39,8 +39,7 @@ describe('Wallet sync tests', () => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const env = _tu.getEnv('test')
|
|
42
|
-
const identityKeyTone =
|
|
43
|
-
'03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe'
|
|
42
|
+
const identityKeyTone = '03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe'
|
|
44
43
|
const rootKeyHex = env.devKeys[identityKeyTone]
|
|
45
44
|
|
|
46
45
|
test('0 sync staging dojo to local MySQL', async () => {
|
|
@@ -57,10 +56,7 @@ describe('Wallet sync tests', () => {
|
|
|
57
56
|
})
|
|
58
57
|
|
|
59
58
|
const identityKey = writer.identityKey
|
|
60
|
-
await writer.storage.syncFromReader(
|
|
61
|
-
identityKey,
|
|
62
|
-
new StorageSyncReader({ identityKey }, reader)
|
|
63
|
-
)
|
|
59
|
+
await writer.storage.syncFromReader(identityKey, new StorageSyncReader({ identityKey }, reader))
|
|
64
60
|
|
|
65
61
|
await reader.destroy()
|
|
66
62
|
await writer.activeStorage.destroy()
|
|
@@ -68,12 +64,9 @@ describe('Wallet sync tests', () => {
|
|
|
68
64
|
})
|
|
69
65
|
|
|
70
66
|
test.skip('0a sync production dojo to local MySQL', async () => {
|
|
71
|
-
console.log(
|
|
72
|
-
'Importing from production dojo to local MySQL productiondojotone'
|
|
73
|
-
)
|
|
67
|
+
console.log('Importing from production dojo to local MySQL productiondojotone')
|
|
74
68
|
// production faucet key
|
|
75
|
-
const identityKey =
|
|
76
|
-
'030b78da8101cd8929ec355c694c275fbaf4f73d4eaa104873463779cac69a2a01' // process.env.MY_MAIN_IDENTITY || ''
|
|
69
|
+
const identityKey = '030b78da8101cd8929ec355c694c275fbaf4f73d4eaa104873463779cac69a2a01' // process.env.MY_MAIN_IDENTITY || ''
|
|
77
70
|
const rootKeyHex = env.devKeys[identityKey]
|
|
78
71
|
const chain: sdk.Chain = 'main'
|
|
79
72
|
const connection = JSON.parse(process.env.MAIN_DOJO_CONNECTION || '')
|
|
@@ -86,10 +79,7 @@ describe('Wallet sync tests', () => {
|
|
|
86
79
|
dropAll: true
|
|
87
80
|
})
|
|
88
81
|
|
|
89
|
-
await writer.storage.syncFromReader(
|
|
90
|
-
identityKey,
|
|
91
|
-
new StorageSyncReader({ identityKey }, reader)
|
|
92
|
-
)
|
|
82
|
+
await writer.storage.syncFromReader(identityKey, new StorageSyncReader({ identityKey }, reader))
|
|
93
83
|
|
|
94
84
|
await reader.destroy()
|
|
95
85
|
await writer.activeStorage.destroy()
|
|
@@ -97,8 +87,7 @@ describe('Wallet sync tests', () => {
|
|
|
97
87
|
|
|
98
88
|
test.skip('0b sweep mysql dojo sync to new sqlite', async () => {
|
|
99
89
|
const chain: sdk.Chain = 'main'
|
|
100
|
-
const identityKey =
|
|
101
|
-
'030b78da8101cd8929ec355c694c275fbaf4f73d4eaa104873463779cac69a2a01' // prod faucet
|
|
90
|
+
const identityKey = '030b78da8101cd8929ec355c694c275fbaf4f73d4eaa104873463779cac69a2a01' // prod faucet
|
|
102
91
|
//const identityKeyTone = process.env.MY_MAIN_IDENTITY || ''
|
|
103
92
|
const rootKeyHex = env.devKeys[identityKey]
|
|
104
93
|
|
|
@@ -154,9 +143,7 @@ describe('Wallet sync tests', () => {
|
|
|
154
143
|
|
|
155
144
|
test.skip('2 sync pruned MySQL stagingdojotone to SQLite walletLegacyTestData', async () => {
|
|
156
145
|
await waitFor1()
|
|
157
|
-
console.log(
|
|
158
|
-
'syncing local MySQL stagingdojotone to local SQLite walletLegacyTestData in tmp folder'
|
|
159
|
-
)
|
|
146
|
+
console.log('syncing local MySQL stagingdojotone to local SQLite walletLegacyTestData in tmp folder')
|
|
160
147
|
const reader = await _tu.createMySQLTestWallet({
|
|
161
148
|
databaseName: 'stagingdojotone',
|
|
162
149
|
chain: 'test',
|
|
@@ -170,25 +157,18 @@ describe('Wallet sync tests', () => {
|
|
|
170
157
|
})
|
|
171
158
|
|
|
172
159
|
const identityKey = writer.identityKey
|
|
173
|
-
await writer.storage.syncFromReader(
|
|
174
|
-
identityKey,
|
|
175
|
-
new StorageSyncReader({ identityKey }, reader.activeStorage)
|
|
176
|
-
)
|
|
160
|
+
await writer.storage.syncFromReader(identityKey, new StorageSyncReader({ identityKey }, reader.activeStorage))
|
|
177
161
|
|
|
178
162
|
await reader.activeStorage.destroy()
|
|
179
163
|
await writer.activeStorage.destroy()
|
|
180
164
|
|
|
181
|
-
console.log(
|
|
182
|
-
'REMEMBER: copy walletLegacyTestData.sqlite from tmp up to data!'
|
|
183
|
-
)
|
|
165
|
+
console.log('REMEMBER: copy walletLegacyTestData.sqlite from tmp up to data!')
|
|
184
166
|
done2 = true
|
|
185
167
|
})
|
|
186
168
|
|
|
187
169
|
test.skip('3 sync pruned MySQL stagingdojotone to MySQL walletLegacyTestData', async () => {
|
|
188
170
|
await waitFor2()
|
|
189
|
-
console.log(
|
|
190
|
-
'syncing local MySQL stagingdojotone to local SQLite walletLegacyTestData in tmp folder'
|
|
191
|
-
)
|
|
171
|
+
console.log('syncing local MySQL stagingdojotone to local SQLite walletLegacyTestData in tmp folder')
|
|
192
172
|
const reader = await _tu.createMySQLTestWallet({
|
|
193
173
|
databaseName: 'stagingdojotone',
|
|
194
174
|
chain: 'test',
|
|
@@ -202,10 +182,7 @@ describe('Wallet sync tests', () => {
|
|
|
202
182
|
})
|
|
203
183
|
|
|
204
184
|
const identityKey = writer.identityKey
|
|
205
|
-
await writer.storage.syncFromReader(
|
|
206
|
-
identityKey,
|
|
207
|
-
new StorageSyncReader({ identityKey }, reader.activeStorage)
|
|
208
|
-
)
|
|
185
|
+
await writer.storage.syncFromReader(identityKey, new StorageSyncReader({ identityKey }, reader.activeStorage))
|
|
209
186
|
|
|
210
187
|
await reader.activeStorage.destroy()
|
|
211
188
|
await writer.activeStorage.destroy()
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import knex from 'knex'
|
|
2
|
-
import { sdk, Setup, StorageKnex } from '../../../src'
|
|
3
|
-
import { _tu, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
4
|
-
|
|
2
|
+
import { sdk, Setup, StorageKnex, wait } from '../../../src'
|
|
3
|
+
import { _tu, logger, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
4
|
+
|
|
5
|
+
let done0 = false
|
|
6
|
+
const waitFor0 = async () => {
|
|
7
|
+
while (!done0) await wait(100)
|
|
8
|
+
}
|
|
9
|
+
let done1 = false
|
|
10
|
+
const waitFor1 = async () => {
|
|
11
|
+
while (!done1) await wait(100)
|
|
12
|
+
}
|
|
13
|
+
let done2 = false
|
|
14
|
+
const waitFor2 = async () => {
|
|
15
|
+
while (!done2) await wait(100)
|
|
16
|
+
}
|
|
5
17
|
|
|
6
18
|
describe('setActive tests', () => {
|
|
7
19
|
jest.setTimeout(99999999)
|
|
@@ -64,24 +76,61 @@ describe('setActive tests', () => {
|
|
|
64
76
|
expect(s.storage.isAvailable() === true)
|
|
65
77
|
expect(s.storage.isActiveEnabled === !first)
|
|
66
78
|
const log = await s.storage.setActive(active)
|
|
67
|
-
|
|
79
|
+
logger(log)
|
|
68
80
|
expect(s.storage.getActiveStore()).toBe(active)
|
|
69
81
|
expect(s.storage.isActiveEnabled === true)
|
|
70
82
|
first = false
|
|
71
83
|
}
|
|
72
84
|
})
|
|
73
85
|
|
|
74
|
-
test('1 setActive on main storage wallet with local backup', async () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
test.skip('1 setActive on main storage wallet with local backup', async () => {
|
|
87
|
+
const chain: sdk.Chain = 'main'
|
|
88
|
+
if (Setup.noEnv(chain)) return
|
|
89
|
+
const env = _tu.getEnv(chain)
|
|
90
|
+
if (!env.filePath) return
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
const s = await _tu.createTestWallet({
|
|
94
|
+
chain,
|
|
95
|
+
rootKeyHex: env.devKeys[env.identityKey],
|
|
96
|
+
filePath: env.filePath,
|
|
97
|
+
setActiveClient: true,
|
|
98
|
+
addLocalBackup: false,
|
|
99
|
+
useMySQLConnectionForClient: true
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
const log = await s.storage.setActive(s.clientStorageIdentityKey!)
|
|
104
|
+
logger(log)
|
|
105
|
+
}
|
|
106
|
+
{
|
|
107
|
+
const log = await s.storage.setActive(s.localStorageIdentityKey!)
|
|
108
|
+
logger(log)
|
|
109
|
+
}
|
|
110
|
+
{
|
|
111
|
+
const log = await s.storage.setActive(s.clientStorageIdentityKey!)
|
|
112
|
+
logger(log)
|
|
113
|
+
}
|
|
114
|
+
expect(s.storage.isActiveEnabled)
|
|
115
|
+
|
|
116
|
+
await s.wallet.destroy()
|
|
117
|
+
} finally {
|
|
118
|
+
done1 = true
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test.skip('2 setActive between two local backups', async () => {
|
|
123
|
+
await waitFor1()
|
|
124
|
+
try {
|
|
125
|
+
if (Setup.noEnv('main')) return
|
|
126
|
+
const env = _tu.getEnv('main')
|
|
127
|
+
const s = await _tu.createKnexTestWallet({
|
|
128
|
+
knex: _tu.createLocalSQLite(env.filePath!),
|
|
129
|
+
databaseName: `envFilePath for ${env.identityKey}`,
|
|
130
|
+
chain: env.chain
|
|
131
|
+
})
|
|
132
|
+
const envStorageIdentityKey = s.storage.getActiveStore()
|
|
133
|
+
const filePath = '/Users/tone/Kz/tone42_backup.sqlite'
|
|
85
134
|
const localStore = (
|
|
86
135
|
await _tu.createKnexTestWallet({
|
|
87
136
|
knex: _tu.createLocalSQLite(filePath),
|
|
@@ -91,61 +140,26 @@ describe('setActive tests', () => {
|
|
|
91
140
|
).activeStorage
|
|
92
141
|
await s.storage.addWalletStorageProvider(localStore)
|
|
93
142
|
{
|
|
94
|
-
const log = await s.storage.setActive(
|
|
95
|
-
|
|
143
|
+
const log = await s.storage.setActive(envStorageIdentityKey)
|
|
144
|
+
logger(log)
|
|
96
145
|
}
|
|
97
146
|
{
|
|
98
|
-
const log = await s.storage.setActive(
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
console.log(log)
|
|
147
|
+
const log = await s.storage.setActive(localStore._settings!.storageIdentityKey)
|
|
148
|
+
logger(log)
|
|
102
149
|
}
|
|
103
150
|
{
|
|
104
|
-
const log = await s.storage.setActive(
|
|
105
|
-
|
|
151
|
+
const log = await s.storage.setActive(envStorageIdentityKey)
|
|
152
|
+
logger(log)
|
|
106
153
|
}
|
|
107
154
|
expect(s.storage.isActiveEnabled)
|
|
155
|
+
await s.wallet.destroy()
|
|
156
|
+
} finally {
|
|
157
|
+
done2 = true
|
|
108
158
|
}
|
|
109
|
-
await s.wallet.destroy()
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
test('2 setActive between two local backups', async () => {
|
|
113
|
-
if (Setup.noEnv('main')) return
|
|
114
|
-
const env = _tu.getEnv('main')
|
|
115
|
-
const s = await _tu.createKnexTestWallet({
|
|
116
|
-
knex: _tu.createLocalSQLite(env.filePath!),
|
|
117
|
-
databaseName: `envFilePath for ${env.identityKey}`,
|
|
118
|
-
chain: env.chain
|
|
119
|
-
})
|
|
120
|
-
const envStorageIdentityKey = s.storage.getActiveStore()
|
|
121
|
-
const filePath = '/Users/tone/Kz/tone42_backup.sqlite'
|
|
122
|
-
const localStore = (
|
|
123
|
-
await _tu.createKnexTestWallet({
|
|
124
|
-
knex: _tu.createLocalSQLite(filePath),
|
|
125
|
-
databaseName: `sqlite for ${env.identityKey}`,
|
|
126
|
-
chain: env.chain
|
|
127
|
-
})
|
|
128
|
-
).activeStorage
|
|
129
|
-
await s.storage.addWalletStorageProvider(localStore)
|
|
130
|
-
{
|
|
131
|
-
const log = await s.storage.setActive(envStorageIdentityKey)
|
|
132
|
-
console.log(log)
|
|
133
|
-
}
|
|
134
|
-
{
|
|
135
|
-
const log = await s.storage.setActive(
|
|
136
|
-
localStore._settings!.storageIdentityKey
|
|
137
|
-
)
|
|
138
|
-
console.log(log)
|
|
139
|
-
}
|
|
140
|
-
{
|
|
141
|
-
const log = await s.storage.setActive(envStorageIdentityKey)
|
|
142
|
-
console.log(log)
|
|
143
|
-
}
|
|
144
|
-
expect(s.storage.isActiveEnabled)
|
|
145
|
-
await s.wallet.destroy()
|
|
146
159
|
})
|
|
147
160
|
|
|
148
|
-
test('3 compare wallet balances', async () => {
|
|
161
|
+
test.skip('3 compare wallet balances', async () => {
|
|
162
|
+
await waitFor2()
|
|
149
163
|
const chain: sdk.Chain = 'test'
|
|
150
164
|
if (Setup.noEnv(chain)) return
|
|
151
165
|
|
package/test/checkDB.ts
CHANGED
|
@@ -17,10 +17,7 @@ const runTest = async () => {
|
|
|
17
17
|
if (err) {
|
|
18
18
|
console.error('Error running PRAGMA foreign_keys:', err.message)
|
|
19
19
|
} else {
|
|
20
|
-
console.log(
|
|
21
|
-
'Foreign key enforcement:',
|
|
22
|
-
row.foreign_keys === 1 ? 'Enabled' : 'Disabled'
|
|
23
|
-
)
|
|
20
|
+
console.log('Foreign key enforcement:', row.foreign_keys === 1 ? 'Enabled' : 'Disabled')
|
|
24
21
|
}
|
|
25
22
|
})
|
|
26
23
|
|
|
@@ -29,10 +26,7 @@ const runTest = async () => {
|
|
|
29
26
|
for (const table of tables) {
|
|
30
27
|
db.all(`PRAGMA foreign_key_list('${table}');`, (err, rows) => {
|
|
31
28
|
if (err) {
|
|
32
|
-
console.error(
|
|
33
|
-
`Error querying foreign key list for table '${table}':`,
|
|
34
|
-
err.message
|
|
35
|
-
)
|
|
29
|
+
console.error(`Error querying foreign key list for table '${table}':`, err.message)
|
|
36
30
|
} else {
|
|
37
31
|
console.log(`Foreign key constraints for table '${table}':`)
|
|
38
32
|
if (rows.length === 0) {
|
|
@@ -29,10 +29,7 @@ export async function backup(): Promise<void> {
|
|
|
29
29
|
/**
|
|
30
30
|
* @publicbody
|
|
31
31
|
*/
|
|
32
|
-
export async function backupWalletClient(
|
|
33
|
-
env: SetupEnv,
|
|
34
|
-
identityKey: string
|
|
35
|
-
): Promise<void> {
|
|
32
|
+
export async function backupWalletClient(env: SetupEnv, identityKey: string): Promise<void> {
|
|
36
33
|
const setup = await Setup.createWalletClient({
|
|
37
34
|
env,
|
|
38
35
|
rootKeyHex: env.devKeys[identityKey]
|
|
@@ -44,11 +41,7 @@ export async function backupWalletClient(
|
|
|
44
41
|
/**
|
|
45
42
|
* @publicbody
|
|
46
43
|
*/
|
|
47
|
-
export async function backupToSQLite(
|
|
48
|
-
setup: SetupWallet,
|
|
49
|
-
filePath?: string,
|
|
50
|
-
databaseName?: string
|
|
51
|
-
): Promise<void> {
|
|
44
|
+
export async function backupToSQLite(setup: SetupWallet, filePath?: string, databaseName?: string): Promise<void> {
|
|
52
45
|
const env = Setup.getEnv(setup.chain)
|
|
53
46
|
filePath ||= `backup_${setup.identityKey}.sqlite`
|
|
54
47
|
databaseName ||= `${setup.identityKey} backup`
|