@bsv/wallet-toolbox 1.1.0
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/.env.template +22 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
- package/.github/ISSUE_TEMPLATE/discussion.md +24 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/push.yaml +66 -0
- package/.prettierrc +10 -0
- package/CONTRIBUTING.md +89 -0
- package/LICENSE.txt +28 -0
- package/README.md +124 -0
- package/dev.sqlite3 +0 -0
- package/docs/README.md +15 -0
- package/docs/client.md +6812 -0
- package/docs/monitor.md +648 -0
- package/docs/services.md +496 -0
- package/docs/storage.md +1884 -0
- package/docs/wallet.md +6812 -0
- package/jest.config.ts +29 -0
- package/knexfile.js +9 -0
- package/license.md +1 -0
- package/out/src/Wallet.d.ts +83 -0
- package/out/src/Wallet.d.ts.map +1 -0
- package/out/src/Wallet.js +415 -0
- package/out/src/Wallet.js.map +1 -0
- package/out/src/index.all.d.ts +9 -0
- package/out/src/index.all.d.ts.map +1 -0
- package/out/src/index.all.js +48 -0
- package/out/src/index.all.js.map +1 -0
- package/out/src/index.client.d.ts +8 -0
- package/out/src/index.client.d.ts.map +1 -0
- package/out/src/index.client.js +47 -0
- package/out/src/index.client.js.map +1 -0
- package/out/src/index.d.ts +3 -0
- package/out/src/index.d.ts.map +1 -0
- package/out/src/index.js +42 -0
- package/out/src/index.js.map +1 -0
- package/out/src/monitor/Monitor.d.ts +89 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -0
- package/out/src/monitor/Monitor.js +253 -0
- package/out/src/monitor/Monitor.js.map +1 -0
- package/out/src/monitor/MonitorDaemon.d.ts +30 -0
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -0
- package/out/src/monitor/MonitorDaemon.js +135 -0
- package/out/src/monitor/MonitorDaemon.js.map +1 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.d.ts +2 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.d.ts.map +1 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.js +50 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.js.map +1 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +53 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.js +197 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -0
- package/out/src/monitor/tasks/TaskClock.d.ts +14 -0
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskClock.js +27 -0
- package/out/src/monitor/tasks/TaskClock.js.map +1 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +20 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.js +52 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -0
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +15 -0
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskNewHeader.js +45 -0
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -0
- package/out/src/monitor/tasks/TaskPurge.d.ts +45 -0
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskPurge.js +35 -0
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -0
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts +26 -0
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskReviewStatus.js +44 -0
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +32 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskSendWaiting.js +99 -0
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts +12 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.js +22 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.js.map +1 -0
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts +40 -0
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -0
- package/out/src/monitor/tasks/WalletMonitorTask.js +37 -0
- package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -0
- package/out/src/sdk/CertOps.d.ts +66 -0
- package/out/src/sdk/CertOps.d.ts.map +1 -0
- package/out/src/sdk/CertOps.js +198 -0
- package/out/src/sdk/CertOps.js.map +1 -0
- package/out/src/sdk/PrivilegedKeyManager.d.ts +125 -0
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -0
- package/out/src/sdk/PrivilegedKeyManager.js +293 -0
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -0
- package/out/src/sdk/StorageSyncReader.d.ts +121 -0
- package/out/src/sdk/StorageSyncReader.d.ts.map +1 -0
- package/out/src/sdk/StorageSyncReader.js +3 -0
- package/out/src/sdk/StorageSyncReader.js.map +1 -0
- package/out/src/sdk/StorageSyncReaderWriter.d.ts +89 -0
- package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +1 -0
- package/out/src/sdk/StorageSyncReaderWriter.js +3 -0
- package/out/src/sdk/StorageSyncReaderWriter.js.map +1 -0
- package/out/src/sdk/WERR_errors.d.ts +90 -0
- package/out/src/sdk/WERR_errors.d.ts.map +1 -0
- package/out/src/sdk/WERR_errors.js +128 -0
- package/out/src/sdk/WERR_errors.js.map +1 -0
- package/out/src/sdk/WalletError.d.ts +45 -0
- package/out/src/sdk/WalletError.d.ts.map +1 -0
- package/out/src/sdk/WalletError.js +122 -0
- package/out/src/sdk/WalletError.js.map +1 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts +325 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -0
- package/out/src/sdk/WalletServices.interfaces.js +3 -0
- package/out/src/sdk/WalletServices.interfaces.js.map +1 -0
- package/out/src/sdk/WalletSigner.interfaces.d.ts +10 -0
- package/out/src/sdk/WalletSigner.interfaces.d.ts.map +1 -0
- package/out/src/sdk/WalletSigner.interfaces.js +3 -0
- package/out/src/sdk/WalletSigner.interfaces.js.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts +299 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.js +3 -0
- package/out/src/sdk/WalletStorage.interfaces.js.map +1 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.d.ts +2 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.d.ts.map +1 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.js +125 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.d.ts +2 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.d.ts.map +1 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js +660 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -0
- package/out/src/sdk/index.d.ts +12 -0
- package/out/src/sdk/index.d.ts.map +1 -0
- package/out/src/sdk/index.js +28 -0
- package/out/src/sdk/index.js.map +1 -0
- package/out/src/sdk/types.d.ts +74 -0
- package/out/src/sdk/types.d.ts.map +1 -0
- package/out/src/sdk/types.js +20 -0
- package/out/src/sdk/types.js.map +1 -0
- package/out/src/sdk/validationHelpers.d.ts +288 -0
- package/out/src/sdk/validationHelpers.d.ts.map +1 -0
- package/out/src/sdk/validationHelpers.js +630 -0
- package/out/src/sdk/validationHelpers.js.map +1 -0
- package/out/src/services/ServiceCollection.d.ts +25 -0
- package/out/src/services/ServiceCollection.d.ts.map +1 -0
- package/out/src/services/ServiceCollection.js +43 -0
- package/out/src/services/ServiceCollection.js.map +1 -0
- package/out/src/services/Services.d.ts +60 -0
- package/out/src/services/Services.d.ts.map +1 -0
- package/out/src/services/Services.js +342 -0
- package/out/src/services/Services.js.map +1 -0
- package/out/src/services/__tests/getMerklePath.test.d.ts +2 -0
- package/out/src/services/__tests/getMerklePath.test.d.ts.map +1 -0
- package/out/src/services/__tests/getMerklePath.test.js +16 -0
- package/out/src/services/__tests/getMerklePath.test.js.map +1 -0
- package/out/src/services/__tests/getRawTx.test.d.ts +2 -0
- package/out/src/services/__tests/getRawTx.test.d.ts.map +1 -0
- package/out/src/services/__tests/getRawTx.test.js +13 -0
- package/out/src/services/__tests/getRawTx.test.js.map +1 -0
- package/out/src/services/__tests/postBeef.test.d.ts +2 -0
- package/out/src/services/__tests/postBeef.test.d.ts.map +1 -0
- package/out/src/services/__tests/postBeef.test.js +18 -0
- package/out/src/services/__tests/postBeef.test.js.map +1 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.d.ts +2 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.d.ts.map +1 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.js +479 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.js.map +1 -0
- package/out/src/services/__tests/postTxs.test.d.ts +2 -0
- package/out/src/services/__tests/postTxs.test.d.ts.map +1 -0
- package/out/src/services/__tests/postTxs.test.js +19 -0
- package/out/src/services/__tests/postTxs.test.js.map +1 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +15 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.js +51 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.d.ts +2 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.d.ts.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js +19 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.d.ts +2 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.d.ts.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js +29 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts +98 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js +38 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +36 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +130 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/index.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.js +19 -0
- package/out/src/services/chaintracker/chaintracks/index.js.map +1 -0
- package/out/src/services/chaintracker/index.d.ts +3 -0
- package/out/src/services/chaintracker/index.d.ts.map +1 -0
- package/out/src/services/chaintracker/index.js +19 -0
- package/out/src/services/chaintracker/index.js.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts +3 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.js +34 -0
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -0
- package/out/src/services/index.d.ts +2 -0
- package/out/src/services/index.d.ts.map +1 -0
- package/out/src/services/index.js +18 -0
- package/out/src/services/index.js.map +1 -0
- package/out/src/services/providers/arcServices.d.ts +62 -0
- package/out/src/services/providers/arcServices.d.ts.map +1 -0
- package/out/src/services/providers/arcServices.js +368 -0
- package/out/src/services/providers/arcServices.js.map +1 -0
- package/out/src/services/providers/echangeRates.d.ts +12 -0
- package/out/src/services/providers/echangeRates.d.ts.map +1 -0
- package/out/src/services/providers/echangeRates.js +237 -0
- package/out/src/services/providers/echangeRates.js.map +1 -0
- package/out/src/services/providers/whatsonchain.d.ts +17 -0
- package/out/src/services/providers/whatsonchain.d.ts.map +1 -0
- package/out/src/services/providers/whatsonchain.js +130 -0
- package/out/src/services/providers/whatsonchain.js.map +1 -0
- package/out/src/signer/WalletSigner.d.ts +11 -0
- package/out/src/signer/WalletSigner.d.ts.map +1 -0
- package/out/src/signer/WalletSigner.js +13 -0
- package/out/src/signer/WalletSigner.js.map +1 -0
- package/out/src/signer/methods/acquireDirectCertificate.d.ts +4 -0
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -0
- package/out/src/signer/methods/acquireDirectCertificate.js +47 -0
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -0
- package/out/src/signer/methods/createAction.d.ts +7 -0
- package/out/src/signer/methods/createAction.d.ts.map +1 -0
- package/out/src/signer/methods/createAction.js +250 -0
- package/out/src/signer/methods/createAction.js.map +1 -0
- package/out/src/signer/methods/internalizeAction.d.ts +31 -0
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -0
- package/out/src/signer/methods/internalizeAction.js +95 -0
- package/out/src/signer/methods/internalizeAction.js.map +1 -0
- package/out/src/signer/methods/proveCertificate.d.ts +4 -0
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -0
- package/out/src/signer/methods/proveCertificate.js +45 -0
- package/out/src/signer/methods/proveCertificate.js.map +1 -0
- package/out/src/signer/methods/signAction.d.ts +6 -0
- package/out/src/signer/methods/signAction.d.ts.map +1 -0
- package/out/src/signer/methods/signAction.js +79 -0
- package/out/src/signer/methods/signAction.js.map +1 -0
- package/out/src/storage/StorageKnex.d.ts +176 -0
- package/out/src/storage/StorageKnex.d.ts.map +1 -0
- package/out/src/storage/StorageKnex.js +1035 -0
- package/out/src/storage/StorageKnex.js.map +1 -0
- package/out/src/storage/StorageProvider.d.ts +140 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -0
- package/out/src/storage/StorageProvider.js +539 -0
- package/out/src/storage/StorageProvider.js.map +1 -0
- package/out/src/storage/StorageReader.d.ts +76 -0
- package/out/src/storage/StorageReader.d.ts.map +1 -0
- package/out/src/storage/StorageReader.js +124 -0
- package/out/src/storage/StorageReader.js.map +1 -0
- package/out/src/storage/StorageReaderWriter.d.ts +87 -0
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -0
- package/out/src/storage/StorageReaderWriter.js +337 -0
- package/out/src/storage/StorageReaderWriter.js.map +1 -0
- package/out/src/storage/StorageSyncReader.d.ts +33 -0
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -0
- package/out/src/storage/StorageSyncReader.js +142 -0
- package/out/src/storage/StorageSyncReader.js.map +1 -0
- package/out/src/storage/WalletStorageManager.d.ts +103 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -0
- package/out/src/storage/WalletStorageManager.js +408 -0
- package/out/src/storage/WalletStorageManager.js.map +1 -0
- package/out/src/storage/__test/WalletStorageManager.test.d.ts +2 -0
- package/out/src/storage/__test/WalletStorageManager.test.d.ts.map +1 -0
- package/out/src/storage/__test/WalletStorageManager.test.js +260 -0
- package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -0
- package/out/src/storage/index.all.d.ts +11 -0
- package/out/src/storage/index.all.d.ts.map +1 -0
- package/out/src/storage/index.all.js +50 -0
- package/out/src/storage/index.all.js.map +1 -0
- package/out/src/storage/index.client.d.ts +7 -0
- package/out/src/storage/index.client.d.ts.map +1 -0
- package/out/src/storage/index.client.js +46 -0
- package/out/src/storage/index.client.js.map +1 -0
- package/out/src/storage/index.db.d.ts +1 -0
- package/out/src/storage/index.db.d.ts.map +1 -0
- package/out/src/storage/index.db.js +2 -0
- package/out/src/storage/index.db.js.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.d.ts +2 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.d.ts.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +948 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts +2 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +35 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +27 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +148 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -0
- package/out/src/storage/methods/createAction.d.ts +23 -0
- package/out/src/storage/methods/createAction.d.ts.map +1 -0
- package/out/src/storage/methods/createAction.js +663 -0
- package/out/src/storage/methods/createAction.js.map +1 -0
- package/out/src/storage/methods/generateChange.d.ts +108 -0
- package/out/src/storage/methods/generateChange.d.ts.map +1 -0
- package/out/src/storage/methods/generateChange.js +422 -0
- package/out/src/storage/methods/generateChange.js.map +1 -0
- package/out/src/storage/methods/getBeefForTransaction.d.ts +22 -0
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -0
- package/out/src/storage/methods/getBeefForTransaction.js +94 -0
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -0
- package/out/src/storage/methods/getSyncChunk.d.ts +10 -0
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -0
- package/out/src/storage/methods/getSyncChunk.js +271 -0
- package/out/src/storage/methods/getSyncChunk.js.map +1 -0
- package/out/src/storage/methods/internalizeAction.d.ts +38 -0
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -0
- package/out/src/storage/methods/internalizeAction.js +378 -0
- package/out/src/storage/methods/internalizeAction.js.map +1 -0
- package/out/src/storage/methods/listActions.d.ts +5 -0
- package/out/src/storage/methods/listActions.d.ts.map +1 -0
- package/out/src/storage/methods/listActions.js +174 -0
- package/out/src/storage/methods/listActions.js.map +1 -0
- package/out/src/storage/methods/listCertificates.d.ts +5 -0
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -0
- package/out/src/storage/methods/listCertificates.js +68 -0
- package/out/src/storage/methods/listCertificates.js.map +1 -0
- package/out/src/storage/methods/listOutputs.d.ts +5 -0
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -0
- package/out/src/storage/methods/listOutputs.js +189 -0
- package/out/src/storage/methods/listOutputs.js.map +1 -0
- package/out/src/storage/methods/processAction.d.ts +35 -0
- package/out/src/storage/methods/processAction.d.ts.map +1 -0
- package/out/src/storage/methods/processAction.js +271 -0
- package/out/src/storage/methods/processAction.js.map +1 -0
- package/out/src/storage/methods/purgeData.d.ts +4 -0
- package/out/src/storage/methods/purgeData.d.ts.map +1 -0
- package/out/src/storage/methods/purgeData.js +229 -0
- package/out/src/storage/methods/purgeData.js.map +1 -0
- package/out/src/storage/methods/reviewStatus.d.ts +9 -0
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -0
- package/out/src/storage/methods/reviewStatus.js +75 -0
- package/out/src/storage/methods/reviewStatus.js.map +1 -0
- package/out/src/storage/remoting/StorageClient.d.ts +56 -0
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageClient.js +181 -0
- package/out/src/storage/remoting/StorageClient.js.map +1 -0
- package/out/src/storage/remoting/StorageServer.d.ts +26 -0
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageServer.js +144 -0
- package/out/src/storage/remoting/StorageServer.js.map +1 -0
- package/out/src/storage/schema/KnexMigrations.d.ts +39 -0
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -0
- package/out/src/storage/schema/KnexMigrations.js +442 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -0
- package/out/src/storage/schema/entities/Certificate.d.ts +43 -0
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Certificate.js +162 -0
- package/out/src/storage/schema/entities/Certificate.js.map +1 -0
- package/out/src/storage/schema/entities/CertificateField.d.ts +32 -0
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/entities/CertificateField.js +114 -0
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -0
- package/out/src/storage/schema/entities/Commission.d.ts +37 -0
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Commission.js +130 -0
- package/out/src/storage/schema/entities/Commission.js.map +1 -0
- package/out/src/storage/schema/entities/EntityBase.d.ts +105 -0
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityBase.js +100 -0
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -0
- package/out/src/storage/schema/entities/MergeEntity.d.ts +34 -0
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -0
- package/out/src/storage/schema/entities/MergeEntity.js +57 -0
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -0
- package/out/src/storage/schema/entities/Output.d.ts +67 -0
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Output.js +281 -0
- package/out/src/storage/schema/entities/Output.js.map +1 -0
- package/out/src/storage/schema/entities/OutputBasket.d.ts +35 -0
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/entities/OutputBasket.js +133 -0
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -0
- package/out/src/storage/schema/entities/OutputTag.d.ts +31 -0
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/entities/OutputTag.js +104 -0
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -0
- package/out/src/storage/schema/entities/OutputTagMap.d.ts +28 -0
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/entities/OutputTagMap.js +101 -0
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -0
- package/out/src/storage/schema/entities/ProvenTx.d.ts +84 -0
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/entities/ProvenTx.js +283 -0
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -0
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts +130 -0
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/entities/ProvenTxReq.js +521 -0
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/entities/SyncState.d.ts +66 -0
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -0
- package/out/src/storage/schema/entities/SyncState.js +284 -0
- package/out/src/storage/schema/entities/SyncState.js.map +1 -0
- package/out/src/storage/schema/entities/Transaction.d.ts +67 -0
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Transaction.js +264 -0
- package/out/src/storage/schema/entities/Transaction.js.map +1 -0
- package/out/src/storage/schema/entities/TxLabel.d.ts +31 -0
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/entities/TxLabel.js +104 -0
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -0
- package/out/src/storage/schema/entities/TxLabelMap.d.ts +28 -0
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/entities/TxLabelMap.js +103 -0
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -0
- package/out/src/storage/schema/entities/User.d.ts +29 -0
- package/out/src/storage/schema/entities/User.d.ts.map +1 -0
- package/out/src/storage/schema/entities/User.js +100 -0
- package/out/src/storage/schema/entities/User.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +588 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +449 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +602 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +515 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +478 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +440 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js +626 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +585 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +628 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +307 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +823 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +442 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +313 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js +81 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.js +418 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/index.d.ts +17 -0
- package/out/src/storage/schema/entities/index.d.ts.map +1 -0
- package/out/src/storage/schema/entities/index.js +33 -0
- package/out/src/storage/schema/entities/index.js.map +1 -0
- package/out/src/storage/schema/tables/Certificate.d.ts +20 -0
- package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Certificate.js +3 -0
- package/out/src/storage/schema/tables/Certificate.js.map +1 -0
- package/out/src/storage/schema/tables/CertificateField.d.ts +12 -0
- package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/tables/CertificateField.js +3 -0
- package/out/src/storage/schema/tables/CertificateField.js.map +1 -0
- package/out/src/storage/schema/tables/Commission.d.ts +13 -0
- package/out/src/storage/schema/tables/Commission.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Commission.js +3 -0
- package/out/src/storage/schema/tables/Commission.js.map +1 -0
- package/out/src/storage/schema/tables/MonitorEvent.d.ts +9 -0
- package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -0
- package/out/src/storage/schema/tables/MonitorEvent.js +3 -0
- package/out/src/storage/schema/tables/MonitorEvent.js.map +1 -0
- package/out/src/storage/schema/tables/Output.d.ts +36 -0
- package/out/src/storage/schema/tables/Output.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Output.js +31 -0
- package/out/src/storage/schema/tables/Output.js.map +1 -0
- package/out/src/storage/schema/tables/OutputBasket.d.ts +12 -0
- package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/tables/OutputBasket.js +3 -0
- package/out/src/storage/schema/tables/OutputBasket.js.map +1 -0
- package/out/src/storage/schema/tables/OutputTag.d.ts +10 -0
- package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/tables/OutputTag.js +3 -0
- package/out/src/storage/schema/tables/OutputTag.js.map +1 -0
- package/out/src/storage/schema/tables/OutputTagMap.d.ts +9 -0
- package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/OutputTagMap.js +3 -0
- package/out/src/storage/schema/tables/OutputTagMap.js.map +1 -0
- package/out/src/storage/schema/tables/ProvenTx.d.ts +14 -0
- package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/tables/ProvenTx.js +3 -0
- package/out/src/storage/schema/tables/ProvenTx.js.map +1 -0
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts +64 -0
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/tables/ProvenTxReq.js +3 -0
- package/out/src/storage/schema/tables/ProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/tables/Settings.d.ts +17 -0
- package/out/src/storage/schema/tables/Settings.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Settings.js +3 -0
- package/out/src/storage/schema/tables/Settings.js.map +1 -0
- package/out/src/storage/schema/tables/SyncState.d.ts +18 -0
- package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -0
- package/out/src/storage/schema/tables/SyncState.js +3 -0
- package/out/src/storage/schema/tables/SyncState.js.map +1 -0
- package/out/src/storage/schema/tables/Transaction.d.ts +37 -0
- package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Transaction.js +21 -0
- package/out/src/storage/schema/tables/Transaction.js.map +1 -0
- package/out/src/storage/schema/tables/TxLabel.d.ts +10 -0
- package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TxLabel.js +3 -0
- package/out/src/storage/schema/tables/TxLabel.js.map +1 -0
- package/out/src/storage/schema/tables/TxLabelMap.d.ts +9 -0
- package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TxLabelMap.js +3 -0
- package/out/src/storage/schema/tables/TxLabelMap.js.map +1 -0
- package/out/src/storage/schema/tables/User.d.ts +16 -0
- package/out/src/storage/schema/tables/User.d.ts.map +1 -0
- package/out/src/storage/schema/tables/User.js +3 -0
- package/out/src/storage/schema/tables/User.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +17 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -0
- package/out/src/storage/schema/tables/index.js +33 -0
- package/out/src/storage/schema/tables/index.js.map +1 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +71 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.js +612 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -0
- package/out/src/storage/sync/index.d.ts +2 -0
- package/out/src/storage/sync/index.d.ts.map +1 -0
- package/out/src/storage/sync/index.js +18 -0
- package/out/src/storage/sync/index.js.map +1 -0
- package/out/src/utility/ScriptTemplateSABPPP.d.ts +25 -0
- package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +1 -0
- package/out/src/utility/ScriptTemplateSABPPP.js +46 -0
- package/out/src/utility/ScriptTemplateSABPPP.js.map +1 -0
- package/out/src/utility/index.all.d.ts +7 -0
- package/out/src/utility/index.all.d.ts.map +1 -0
- package/out/src/utility/index.all.js +23 -0
- package/out/src/utility/index.all.js.map +1 -0
- package/out/src/utility/index.client.d.ts +7 -0
- package/out/src/utility/index.client.d.ts.map +1 -0
- package/out/src/utility/index.client.js +23 -0
- package/out/src/utility/index.client.js.map +1 -0
- package/out/src/utility/parseTxScriptOffsets.d.ts +14 -0
- package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -0
- package/out/src/utility/parseTxScriptOffsets.js +26 -0
- package/out/src/utility/parseTxScriptOffsets.js.map +1 -0
- package/out/src/utility/stampLog.d.ts +18 -0
- package/out/src/utility/stampLog.d.ts.map +1 -0
- package/out/src/utility/stampLog.js +72 -0
- package/out/src/utility/stampLog.js.map +1 -0
- package/out/src/utility/tscProofToMerklePath.d.ts +8 -0
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -0
- package/out/src/utility/tscProofToMerklePath.js +41 -0
- package/out/src/utility/tscProofToMerklePath.js.map +1 -0
- package/out/src/utility/utilityHelpers.buffer.d.ts +18 -0
- package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.buffer.js +45 -0
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -0
- package/out/src/utility/utilityHelpers.d.ts +129 -0
- package/out/src/utility/utilityHelpers.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.js +268 -0
- package/out/src/utility/utilityHelpers.js.map +1 -0
- package/out/src/utility/utilityHelpers.noBuffer.d.ts +9 -0
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.noBuffer.js +23 -0
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.d.ts +2 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.d.ts.map +1 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.js +45 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -0
- package/out/test/Wallet/action/internalizeAction.a.test.d.ts +2 -0
- package/out/test/Wallet/action/internalizeAction.a.test.d.ts.map +1 -0
- package/out/test/Wallet/action/internalizeAction.a.test.js +243 -0
- package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.d.ts +2 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.d.ts.map +1 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.js +213 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -0
- package/out/test/Wallet/certificate/listCertificates.test.d.ts +2 -0
- package/out/test/Wallet/certificate/listCertificates.test.d.ts.map +1 -0
- package/out/test/Wallet/certificate/listCertificates.test.js +305 -0
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.d.ts +2 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.js +68 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -0
- package/out/test/Wallet/get/getHeight.test.d.ts +2 -0
- package/out/test/Wallet/get/getHeight.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getHeight.test.js +45 -0
- package/out/test/Wallet/get/getHeight.test.js.map +1 -0
- package/out/test/Wallet/get/getKnownTxids.test.d.ts +2 -0
- package/out/test/Wallet/get/getKnownTxids.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getKnownTxids.test.js +73 -0
- package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -0
- package/out/test/Wallet/get/getNetwork.test.d.ts +2 -0
- package/out/test/Wallet/get/getNetwork.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getNetwork.test.js +26 -0
- package/out/test/Wallet/get/getNetwork.test.js.map +1 -0
- package/out/test/Wallet/get/getVersion.test.d.ts +2 -0
- package/out/test/Wallet/get/getVersion.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getVersion.test.js +25 -0
- package/out/test/Wallet/get/getVersion.test.js.map +1 -0
- package/out/test/Wallet/live/walletLive.man.test.d.ts +26 -0
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -0
- package/out/test/Wallet/live/walletLive.man.test.js +389 -0
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.d.ts +2 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.d.ts.map +1 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js +153 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -0
- package/out/test/checkDB.d.ts +4 -0
- package/out/test/checkDB.d.ts.map +1 -0
- package/out/test/checkDB.js +55 -0
- package/out/test/checkDB.js.map +1 -0
- package/out/test/examples/README.man.test.d.ts +2 -0
- package/out/test/examples/README.man.test.d.ts.map +1 -0
- package/out/test/examples/README.man.test.js +46 -0
- package/out/test/examples/README.man.test.js.map +1 -0
- package/out/test/monitor/Monitor.test.d.ts +2 -0
- package/out/test/monitor/Monitor.test.d.ts.map +1 -0
- package/out/test/monitor/Monitor.test.js +446 -0
- package/out/test/monitor/Monitor.test.js.map +1 -0
- package/out/test/services/Services.test.d.ts +2 -0
- package/out/test/services/Services.test.d.ts.map +1 -0
- package/out/test/services/Services.test.js +128 -0
- package/out/test/services/Services.test.js.map +1 -0
- package/out/test/storage/KnexMigrations.test.d.ts +2 -0
- package/out/test/storage/KnexMigrations.test.d.ts.map +1 -0
- package/out/test/storage/KnexMigrations.test.js +81 -0
- package/out/test/storage/KnexMigrations.test.js.map +1 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.d.ts +2 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.d.ts.map +1 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +88 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -0
- package/out/test/storage/count.test.d.ts +2 -0
- package/out/test/storage/count.test.d.ts.map +1 -0
- package/out/test/storage/count.test.js +141 -0
- package/out/test/storage/count.test.js.map +1 -0
- package/out/test/storage/find.test.d.ts +2 -0
- package/out/test/storage/find.test.d.ts.map +1 -0
- package/out/test/storage/find.test.js +148 -0
- package/out/test/storage/find.test.js.map +1 -0
- package/out/test/storage/findLegacy.test.d.ts +2 -0
- package/out/test/storage/findLegacy.test.d.ts.map +1 -0
- package/out/test/storage/findLegacy.test.js +52 -0
- package/out/test/storage/findLegacy.test.js.map +1 -0
- package/out/test/storage/insert.test.d.ts +2 -0
- package/out/test/storage/insert.test.d.ts.map +1 -0
- package/out/test/storage/insert.test.js +256 -0
- package/out/test/storage/insert.test.js.map +1 -0
- package/out/test/storage/update.test.d.ts +2 -0
- package/out/test/storage/update.test.d.ts.map +1 -0
- package/out/test/storage/update.test.js +926 -0
- package/out/test/storage/update.test.js.map +1 -0
- package/out/test/storage/update2.test.d.ts +2 -0
- package/out/test/storage/update2.test.d.ts.map +1 -0
- package/out/test/storage/update2.test.js +766 -0
- package/out/test/storage/update2.test.js.map +1 -0
- package/out/test/utils/TestUtilsWalletStorage.d.ts +399 -0
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -0
- package/out/test/utils/TestUtilsWalletStorage.js +1337 -0
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -0
- package/out/test/wallet/action/abortAction.test.d.ts +2 -0
- package/out/test/wallet/action/abortAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/abortAction.test.js +44 -0
- package/out/test/wallet/action/abortAction.test.js.map +1 -0
- package/out/test/wallet/action/createAction.test.d.ts +2 -0
- package/out/test/wallet/action/createAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/createAction.test.js +230 -0
- package/out/test/wallet/action/createAction.test.js.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts +2 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js +273 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.d.ts +2 -0
- package/out/test/wallet/action/internalizeAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.js +603 -0
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts +2 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.js +31 -0
- package/out/test/wallet/action/relinquishOutput.test.js.map +1 -0
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts +2 -0
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts.map +1 -0
- package/out/test/wallet/construct/Wallet.constructor.test.js +49 -0
- package/out/test/wallet/construct/Wallet.constructor.test.js.map +1 -0
- package/out/test/wallet/list/listActions.test.d.ts +2 -0
- package/out/test/wallet/list/listActions.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions.test.js +265 -0
- package/out/test/wallet/list/listActions.test.js.map +1 -0
- package/out/test/wallet/list/listActions2.test.d.ts +2 -0
- package/out/test/wallet/list/listActions2.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions2.test.js +423 -0
- package/out/test/wallet/list/listActions2.test.js.map +1 -0
- package/out/test/wallet/list/listCertificates.test.d.ts +2 -0
- package/out/test/wallet/list/listCertificates.test.d.ts.map +1 -0
- package/out/test/wallet/list/listCertificates.test.js +115 -0
- package/out/test/wallet/list/listCertificates.test.js.map +1 -0
- package/out/test/wallet/list/listOutputs.test.d.ts +2 -0
- package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -0
- package/out/test/wallet/list/listOutputs.test.js +521 -0
- package/out/test/wallet/list/listOutputs.test.js.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts +2 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.js +142 -0
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -0
- package/package.json +63 -0
- package/src/Wallet.ts +771 -0
- package/src/index.all.ts +8 -0
- package/src/index.client.ts +7 -0
- package/src/index.ts +2 -0
- package/src/monitor/Monitor.ts +317 -0
- package/src/monitor/MonitorDaemon.ts +197 -0
- package/src/monitor/README.md +3 -0
- package/src/monitor/__test/MonitorDaemon.man.test.ts +17 -0
- package/src/monitor/tasks/TaskCheckForProofs.ts +235 -0
- package/src/monitor/tasks/TaskClock.ts +35 -0
- package/src/monitor/tasks/TaskFailAbandoned.ts +56 -0
- package/src/monitor/tasks/TaskNewHeader.ts +48 -0
- package/src/monitor/tasks/TaskPurge.ts +69 -0
- package/src/monitor/tasks/TaskReviewStatus.ts +51 -0
- package/src/monitor/tasks/TaskSendWaiting.ts +107 -0
- package/src/monitor/tasks/TaskSyncWhenIdle.ts +26 -0
- package/src/monitor/tasks/WalletMonitorTask.ts +47 -0
- package/src/sdk/CertOps.ts +346 -0
- package/src/sdk/PrivilegedKeyManager.ts +402 -0
- package/src/sdk/README.md +13 -0
- package/src/sdk/StorageSyncReader.ts +155 -0
- package/src/sdk/StorageSyncReaderWriter.ts +263 -0
- package/src/sdk/WERR_errors.ts +152 -0
- package/src/sdk/WalletError.ts +136 -0
- package/src/sdk/WalletServices.interfaces.ts +399 -0
- package/src/sdk/WalletSigner.interfaces.ts +38 -0
- package/src/sdk/WalletStorage.interfaces.ts +416 -0
- package/src/sdk/__test/CertificateLifeCycle.test.ts +194 -0
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +775 -0
- package/src/sdk/index.ts +11 -0
- package/src/sdk/types.ts +115 -0
- package/src/sdk/validationHelpers.ts +1248 -0
- package/src/services/README.md +11 -0
- package/src/services/ServiceCollection.ts +50 -0
- package/src/services/Services.ts +461 -0
- package/src/services/__tests/getMerklePath.test.ts +16 -0
- package/src/services/__tests/getRawTx.test.ts +15 -0
- package/src/services/__tests/postBeef.test.ts +19 -0
- package/src/services/__tests/postBeefToArcTaal.test.ts +487 -0
- package/src/services/__tests/postTxs.test.ts +20 -0
- package/src/services/chaintracker/ChaintracksChainTracker.ts +78 -0
- package/src/services/chaintracker/__tests/ChaintracksChainTracker.test.ts +25 -0
- package/src/services/chaintracker/__tests/ChaintracksServiceClient.test.ts +32 -0
- package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +123 -0
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +160 -0
- package/src/services/chaintracker/chaintracks/index.ts +2 -0
- package/src/services/chaintracker/index.ts +2 -0
- package/src/services/createDefaultWalletServicesOptions.ts +38 -0
- package/src/services/index.ts +1 -0
- package/src/services/providers/arcServices.ts +570 -0
- package/src/services/providers/echangeRates.ts +276 -0
- package/src/services/providers/whatsonchain.ts +170 -0
- package/src/signer/README.md +5 -0
- package/src/signer/WalletSigner.ts +21 -0
- package/src/signer/methods/acquireDirectCertificate.ts +53 -0
- package/src/signer/methods/createAction.ts +364 -0
- package/src/signer/methods/internalizeAction.ts +142 -0
- package/src/signer/methods/proveCertificate.ts +51 -0
- package/src/signer/methods/signAction.ts +121 -0
- package/src/storage/README.md +14 -0
- package/src/storage/StorageKnex.ts +1449 -0
- package/src/storage/StorageProvider.ts +853 -0
- package/src/storage/StorageReader.ts +222 -0
- package/src/storage/StorageReaderWriter.ts +623 -0
- package/src/storage/StorageSyncReader.ts +143 -0
- package/src/storage/WalletStorageManager.ts +532 -0
- package/src/storage/__test/WalletStorageManager.test.ts +292 -0
- package/src/storage/index.all.ts +10 -0
- package/src/storage/index.client.ts +6 -0
- package/src/storage/index.db.ts +0 -0
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +1143 -0
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +31 -0
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +185 -0
- package/src/storage/methods/createAction.ts +997 -0
- package/src/storage/methods/generateChange.ts +629 -0
- package/src/storage/methods/getBeefForTransaction.ts +143 -0
- package/src/storage/methods/getSyncChunk.ts +330 -0
- package/src/storage/methods/internalizeAction.ts +538 -0
- package/src/storage/methods/listActions.ts +203 -0
- package/src/storage/methods/listCertificates.ts +81 -0
- package/src/storage/methods/listOutputs.ts +219 -0
- package/src/storage/methods/processAction.ts +477 -0
- package/src/storage/methods/purgeData.ts +276 -0
- package/src/storage/methods/reviewStatus.ts +95 -0
- package/src/storage/remoting/StorageClient.ts +306 -0
- package/src/storage/remoting/StorageServer.ts +179 -0
- package/src/storage/schema/KnexMigrations.ts +488 -0
- package/src/storage/schema/entities/Certificate.ts +199 -0
- package/src/storage/schema/entities/CertificateField.ts +157 -0
- package/src/storage/schema/entities/Commission.ts +169 -0
- package/src/storage/schema/entities/EntityBase.ts +214 -0
- package/src/storage/schema/entities/MergeEntity.ts +79 -0
- package/src/storage/schema/entities/Output.ts +323 -0
- package/src/storage/schema/entities/OutputBasket.ts +165 -0
- package/src/storage/schema/entities/OutputTag.ts +138 -0
- package/src/storage/schema/entities/OutputTagMap.ts +146 -0
- package/src/storage/schema/entities/ProvenTx.ts +349 -0
- package/src/storage/schema/entities/ProvenTxReq.ts +646 -0
- package/src/storage/schema/entities/SyncState.ts +429 -0
- package/src/storage/schema/entities/Transaction.ts +334 -0
- package/src/storage/schema/entities/TxLabel.ts +135 -0
- package/src/storage/schema/entities/TxLabelMap.ts +148 -0
- package/src/storage/schema/entities/User.ts +138 -0
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +663 -0
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +527 -0
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +658 -0
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +567 -0
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +530 -0
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +504 -0
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +689 -0
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +669 -0
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +700 -0
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +376 -0
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +920 -0
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +512 -0
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +350 -0
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +97 -0
- package/src/storage/schema/entities/__tests/usersTests.test.ts +485 -0
- package/src/storage/schema/entities/index.ts +16 -0
- package/src/storage/schema/tables/Certificate.ts +21 -0
- package/src/storage/schema/tables/CertificateField.ts +12 -0
- package/src/storage/schema/tables/Commission.ts +13 -0
- package/src/storage/schema/tables/MonitorEvent.ts +9 -0
- package/src/storage/schema/tables/Output.ts +64 -0
- package/src/storage/schema/tables/OutputBasket.ts +12 -0
- package/src/storage/schema/tables/OutputTag.ts +10 -0
- package/src/storage/schema/tables/OutputTagMap.ts +9 -0
- package/src/storage/schema/tables/ProvenTx.ts +14 -0
- package/src/storage/schema/tables/ProvenTxReq.ts +65 -0
- package/src/storage/schema/tables/Settings.ts +17 -0
- package/src/storage/schema/tables/SyncState.ts +18 -0
- package/src/storage/schema/tables/Transaction.ts +54 -0
- package/src/storage/schema/tables/TxLabel.ts +10 -0
- package/src/storage/schema/tables/TxLabelMap.ts +9 -0
- package/src/storage/schema/tables/User.ts +16 -0
- package/src/storage/schema/tables/index.ts +16 -0
- package/src/storage/sync/StorageMySQLDojoReader.ts +771 -0
- package/src/storage/sync/index.ts +1 -0
- package/src/utility/README.md +3 -0
- package/src/utility/ScriptTemplateSABPPP.ts +79 -0
- package/src/utility/index.all.ts +7 -0
- package/src/utility/index.client.ts +7 -0
- package/src/utility/parseTxScriptOffsets.ts +29 -0
- package/src/utility/stampLog.ts +73 -0
- package/src/utility/tscProofToMerklePath.ts +51 -0
- package/src/utility/utilityHelpers.buffer.ts +43 -0
- package/src/utility/utilityHelpers.noBuffer.ts +18 -0
- package/src/utility/utilityHelpers.ts +283 -0
- package/test/Wallet/StorageClient/storageClient.man.test.ts +55 -0
- package/test/Wallet/action/internalizeAction.a.test.ts +301 -0
- package/test/Wallet/certificate/acquireCertificate.test.ts +253 -0
- package/test/Wallet/certificate/listCertificates.test.ts +352 -0
- package/test/Wallet/get/getHeaderForHeight.test.ts +79 -0
- package/test/Wallet/get/getHeight.test.ts +52 -0
- package/test/Wallet/get/getKnownTxids.test.ts +90 -0
- package/test/Wallet/get/getNetwork.test.ts +28 -0
- package/test/Wallet/get/getVersion.test.ts +28 -0
- package/test/Wallet/live/walletLive.man.test.ts +510 -0
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +155 -0
- package/test/checkDB.ts +63 -0
- package/test/checkdb +0 -0
- package/test/examples/README.man.test.ts +53 -0
- package/test/monitor/Monitor.test.ts +536 -0
- package/test/services/Services.test.ts +149 -0
- package/test/storage/KnexMigrations.test.ts +100 -0
- package/test/storage/StorageMySQLDojoReader.man.test.ts +71 -0
- package/test/storage/count.test.ts +193 -0
- package/test/storage/find.test.ts +216 -0
- package/test/storage/findLegacy.test.ts +70 -0
- package/test/storage/insert.test.ts +294 -0
- package/test/storage/update.test.ts +1146 -0
- package/test/storage/update2.test.ts +1017 -0
- package/test/utils/TestUtilsWalletStorage.ts +1923 -0
- package/test/utils/removeFailedFromDatabase.sql +17 -0
- package/test/wallet/action/abortAction.test.ts +55 -0
- package/test/wallet/action/createAction.test.ts +266 -0
- package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +297 -0
- package/test/wallet/action/internalizeAction.test.ts +729 -0
- package/test/wallet/action/relinquishOutput.test.ts +43 -0
- package/test/wallet/construct/Wallet.constructor.test.ts +57 -0
- package/test/wallet/list/listActions.test.ts +282 -0
- package/test/wallet/list/listActions2.test.ts +570 -0
- package/test/wallet/list/listCertificates.test.ts +129 -0
- package/test/wallet/list/listOutputs.test.ts +573 -0
- package/test/wallet/sync/Wallet.sync.test.ts +226 -0
- package/ts2md.json +32 -0
- package/tsconfig.all.json +29 -0
- package/tsconfig.client.json +22 -0
- package/tsconfig.json +14 -0
- package/unlock-migrations.sh +41 -0
|
@@ -0,0 +1,1337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.normalizeDate = exports.triggerForeignKeyConstraintError = exports.triggerUniqueConstraintError = exports.logUniqueConstraintError = exports.setLogging = exports.validateUpdateTime = exports.verifyValues = exports.updateTable = exports.log = exports._tu = exports.TestUtilsWalletStorage = void 0;
|
|
40
|
+
exports.expectToThrowWERR = expectToThrowWERR;
|
|
41
|
+
exports.cleanUnsentTransactionsUsingAbort = cleanUnsentTransactionsUsingAbort;
|
|
42
|
+
exports.cleanUnsignedTransactionsUsingAbort = cleanUnsignedTransactionsUsingAbort;
|
|
43
|
+
exports.cleanUnprocessedTransactionsUsingAbort = cleanUnprocessedTransactionsUsingAbort;
|
|
44
|
+
exports.logTransaction = logTransaction;
|
|
45
|
+
exports.logOutput = logOutput;
|
|
46
|
+
exports.logBasket = logBasket;
|
|
47
|
+
const sdk_1 = require("@bsv/sdk");
|
|
48
|
+
const path_1 = __importDefault(require("path"));
|
|
49
|
+
const fs_1 = require("fs");
|
|
50
|
+
const index_all_1 = require("../../src/index.all");
|
|
51
|
+
const knex_1 = require("knex");
|
|
52
|
+
const sdk_2 = require("@bsv/sdk");
|
|
53
|
+
const dotenv = __importStar(require("dotenv"));
|
|
54
|
+
const sdk_3 = require("../../src/sdk");
|
|
55
|
+
dotenv.config();
|
|
56
|
+
const localMySqlConnection = process.env.LOCAL_MYSQL_CONNECTION || '';
|
|
57
|
+
class TestUtilsWalletStorage {
|
|
58
|
+
static getEnv(chain) {
|
|
59
|
+
// Identity keys of the lead maintainer of this repo...
|
|
60
|
+
const identityKey = (chain === 'main'
|
|
61
|
+
? process.env.MY_MAIN_IDENTITY
|
|
62
|
+
: process.env.MY_TEST_IDENTITY) || '';
|
|
63
|
+
const identityKey2 = (chain === 'main'
|
|
64
|
+
? process.env.MY_MAIN_IDENTITY2
|
|
65
|
+
: process.env.MY_TEST_IDENTITY2) || '';
|
|
66
|
+
const DEV_KEYS = process.env.DEV_KEYS || '{}';
|
|
67
|
+
const logTests = !!process.env.LOGTESTS;
|
|
68
|
+
const runMySQL = !!process.env.RUNMYSQL;
|
|
69
|
+
const runSlowTests = !!process.env.RUNSLOWTESTS;
|
|
70
|
+
return {
|
|
71
|
+
chain,
|
|
72
|
+
identityKey,
|
|
73
|
+
identityKey2,
|
|
74
|
+
mainTaalApiKey: (0, index_all_1.verifyTruthy)(process.env.MAIN_TAAL_API_KEY || '', `.env value for 'mainTaalApiKey' is required.`),
|
|
75
|
+
testTaalApiKey: (0, index_all_1.verifyTruthy)(process.env.TEST_TAAL_API_KEY || '', `.env value for 'testTaalApiKey' is required.`),
|
|
76
|
+
devKeys: JSON.parse(DEV_KEYS),
|
|
77
|
+
runMySQL,
|
|
78
|
+
runSlowTests,
|
|
79
|
+
logTests
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static async createNoSendP2PKHTestOutpoint(address, satoshis, noSendChange, wallet) {
|
|
83
|
+
return await _tu.createNoSendP2PKHTestOutpoints(1, address, satoshis, noSendChange, wallet);
|
|
84
|
+
}
|
|
85
|
+
static async createNoSendP2PKHTestOutpoints(count, address, satoshis, noSendChange, wallet) {
|
|
86
|
+
const outputs = [];
|
|
87
|
+
for (let i = 0; i < count; i++) {
|
|
88
|
+
outputs.push({
|
|
89
|
+
basket: `test-p2pkh-output-${i}`,
|
|
90
|
+
satoshis,
|
|
91
|
+
lockingScript: _tu.getLockP2PKH(address).toHex(),
|
|
92
|
+
outputDescription: `p2pkh ${i}`
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const createArgs = {
|
|
96
|
+
description: `to ${address}`,
|
|
97
|
+
outputs,
|
|
98
|
+
options: {
|
|
99
|
+
noSendChange,
|
|
100
|
+
randomizeOutputs: false,
|
|
101
|
+
signAndProcess: false,
|
|
102
|
+
noSend: true
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const cr = await wallet.createAction(createArgs);
|
|
106
|
+
noSendChange = cr.noSendChange;
|
|
107
|
+
expect(cr.noSendChange).toBeTruthy();
|
|
108
|
+
expect(cr.sendWithResults).toBeUndefined();
|
|
109
|
+
expect(cr.tx).toBeUndefined();
|
|
110
|
+
expect(cr.txid).toBeUndefined();
|
|
111
|
+
expect(cr.signableTransaction).toBeTruthy();
|
|
112
|
+
const st = cr.signableTransaction;
|
|
113
|
+
expect(st.reference).toBeTruthy();
|
|
114
|
+
// const tx = Transaction.fromAtomicBEEF(st.tx) // Transaction doesn't support V2 Beef yet.
|
|
115
|
+
const atomicBeef = sdk_2.Beef.fromBinary(st.tx);
|
|
116
|
+
const tx = atomicBeef.txs[atomicBeef.txs.length - 1].tx;
|
|
117
|
+
for (const input of tx.inputs) {
|
|
118
|
+
expect(atomicBeef.findTxid(input.sourceTXID)).toBeTruthy();
|
|
119
|
+
}
|
|
120
|
+
// Spending authorization check happens here...
|
|
121
|
+
//expect(st.amount > 242 && st.amount < 300).toBe(true)
|
|
122
|
+
// sign and complete
|
|
123
|
+
const signArgs = {
|
|
124
|
+
reference: st.reference,
|
|
125
|
+
spends: {},
|
|
126
|
+
options: {
|
|
127
|
+
returnTXIDOnly: true,
|
|
128
|
+
noSend: true
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const sr = await wallet.signAction(signArgs);
|
|
132
|
+
let txid = sr.txid;
|
|
133
|
+
// Update the noSendChange txid to final signed value.
|
|
134
|
+
noSendChange = noSendChange.map(op => `${txid}.${op.split('.')[1]}`);
|
|
135
|
+
return { noSendChange, txid, cr, sr };
|
|
136
|
+
}
|
|
137
|
+
static getKeyPair(priv) {
|
|
138
|
+
if (priv === undefined)
|
|
139
|
+
priv = sdk_1.PrivateKey.fromRandom();
|
|
140
|
+
else if (typeof priv === 'string')
|
|
141
|
+
priv = new sdk_1.PrivateKey(priv, 'hex');
|
|
142
|
+
const pub = sdk_1.PublicKey.fromPrivateKey(priv);
|
|
143
|
+
const address = pub.toAddress();
|
|
144
|
+
return { privateKey: priv, publicKey: pub, address };
|
|
145
|
+
}
|
|
146
|
+
static getLockP2PKH(address) {
|
|
147
|
+
const p2pkh = new sdk_1.P2PKH();
|
|
148
|
+
const lock = p2pkh.lock(address);
|
|
149
|
+
return lock;
|
|
150
|
+
}
|
|
151
|
+
static getUnlockP2PKH(priv, satoshis) {
|
|
152
|
+
const p2pkh = new sdk_1.P2PKH();
|
|
153
|
+
const lock = _tu.getLockP2PKH(_tu.getKeyPair(priv).address);
|
|
154
|
+
// Prepare to pay with SIGHASH_ALL and without ANYONE_CAN_PAY.
|
|
155
|
+
// In otherwords:
|
|
156
|
+
// - all outputs must remain in the current order, amount and locking scripts.
|
|
157
|
+
// - all inputs must remain from the current outpoints and sequence numbers.
|
|
158
|
+
// (unlock scripts are never signed)
|
|
159
|
+
const unlock = p2pkh.unlock(priv, 'all', false, satoshis, lock);
|
|
160
|
+
return unlock;
|
|
161
|
+
}
|
|
162
|
+
static async createWalletOnly(args) {
|
|
163
|
+
args.chain || (args.chain = 'test');
|
|
164
|
+
args.rootKeyHex || (args.rootKeyHex = '1'.repeat(64));
|
|
165
|
+
const rootKey = sdk_1.PrivateKey.fromHex(args.rootKeyHex);
|
|
166
|
+
const identityKey = rootKey.toPublicKey().toString();
|
|
167
|
+
const keyDeriver = new sdk_1.KeyDeriver(rootKey);
|
|
168
|
+
const chain = args.chain;
|
|
169
|
+
const storage = new index_all_1.WalletStorageManager(identityKey, args.active, args.backups);
|
|
170
|
+
if (storage.stores.length > 0)
|
|
171
|
+
await storage.makeAvailable();
|
|
172
|
+
const services = new index_all_1.Services(args.chain);
|
|
173
|
+
const monopts = index_all_1.Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
174
|
+
const monitor = new index_all_1.Monitor(monopts);
|
|
175
|
+
monitor.addDefaultTasks();
|
|
176
|
+
let privilegedKeyManager = undefined;
|
|
177
|
+
if (args.privKeyHex) {
|
|
178
|
+
const privKey = sdk_1.PrivateKey.fromString(args.privKeyHex);
|
|
179
|
+
privilegedKeyManager = new sdk_3.PrivilegedKeyManager(async () => privKey);
|
|
180
|
+
}
|
|
181
|
+
const wallet = new index_all_1.Wallet({
|
|
182
|
+
chain,
|
|
183
|
+
keyDeriver,
|
|
184
|
+
storage,
|
|
185
|
+
services,
|
|
186
|
+
monitor,
|
|
187
|
+
privilegedKeyManager
|
|
188
|
+
});
|
|
189
|
+
const r = {
|
|
190
|
+
rootKey,
|
|
191
|
+
identityKey,
|
|
192
|
+
keyDeriver,
|
|
193
|
+
chain,
|
|
194
|
+
storage,
|
|
195
|
+
services,
|
|
196
|
+
monitor,
|
|
197
|
+
wallet
|
|
198
|
+
};
|
|
199
|
+
return r;
|
|
200
|
+
}
|
|
201
|
+
static async createTestWalletWithStorageClient(args) {
|
|
202
|
+
if (args.chain === 'main')
|
|
203
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('chain', `'test' for now, 'main' is not yet supported.`);
|
|
204
|
+
const wo = await _tu.createWalletOnly({
|
|
205
|
+
chain: 'test',
|
|
206
|
+
rootKeyHex: args.rootKeyHex
|
|
207
|
+
});
|
|
208
|
+
args.endpointUrl || (args.endpointUrl = 'https://staging-dojo.babbage.systems');
|
|
209
|
+
const client = new index_all_1.StorageClient(wo.wallet, args.endpointUrl);
|
|
210
|
+
await wo.storage.addWalletStorageProvider(client);
|
|
211
|
+
await wo.storage.makeAvailable();
|
|
212
|
+
return wo;
|
|
213
|
+
}
|
|
214
|
+
static async createKnexTestWalletWithSetup(args) {
|
|
215
|
+
const wo = await _tu.createWalletOnly({
|
|
216
|
+
chain: args.chain,
|
|
217
|
+
rootKeyHex: args.rootKeyHex,
|
|
218
|
+
privKeyHex: args.privKeyHex
|
|
219
|
+
});
|
|
220
|
+
const activeStorage = new index_all_1.StorageKnex({
|
|
221
|
+
chain: wo.chain,
|
|
222
|
+
knex: args.knex,
|
|
223
|
+
commissionSatoshis: 0,
|
|
224
|
+
commissionPubKeyHex: undefined,
|
|
225
|
+
feeModel: { model: 'sat/kb', value: 1 }
|
|
226
|
+
});
|
|
227
|
+
if (args.dropAll)
|
|
228
|
+
await activeStorage.dropAllData();
|
|
229
|
+
await activeStorage.migrate(args.databaseName, wo.identityKey);
|
|
230
|
+
await activeStorage.makeAvailable();
|
|
231
|
+
const setup = await args.insertSetup(activeStorage, wo.identityKey);
|
|
232
|
+
await wo.storage.addWalletStorageProvider(activeStorage);
|
|
233
|
+
const { user, isNew } = await activeStorage.findOrInsertUser(wo.identityKey);
|
|
234
|
+
const userId = user.userId;
|
|
235
|
+
const r = {
|
|
236
|
+
...wo,
|
|
237
|
+
activeStorage,
|
|
238
|
+
setup,
|
|
239
|
+
userId
|
|
240
|
+
};
|
|
241
|
+
return r;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Returns path to temporary file in project's './test/data/tmp/' folder.
|
|
245
|
+
*
|
|
246
|
+
* Creates any missing folders.
|
|
247
|
+
*
|
|
248
|
+
* Optionally tries to delete any existing file. This may fail if the file file is locked
|
|
249
|
+
* by another process.
|
|
250
|
+
*
|
|
251
|
+
* Optionally copies filename (or if filename has no dir component, a file of the same filename from the project's './test/data' folder) to initialize file's contents.
|
|
252
|
+
*
|
|
253
|
+
* CAUTION: returned file path will include four random hex digits unless tryToDelete is true. Files must be purged periodically.
|
|
254
|
+
*
|
|
255
|
+
* @param filename target filename without path, optionally just extension in which case random name is used
|
|
256
|
+
* @param tryToDelete true to attempt to delete an existing file at the returned file path.
|
|
257
|
+
* @param copyToTmp true to copy file of same filename from './test/data' (or elsewhere if filename has path) to tmp folder
|
|
258
|
+
* @param reuseExisting true to use existing file if found, otherwise a random string is added to filename.
|
|
259
|
+
* @returns path in './test/data/tmp' folder.
|
|
260
|
+
*/
|
|
261
|
+
static async newTmpFile(filename = '', tryToDelete = false, copyToTmp = false, reuseExisting = false) {
|
|
262
|
+
const tmpFolder = './test/data/tmp/';
|
|
263
|
+
const p = path_1.default.parse(filename);
|
|
264
|
+
const dstDir = tmpFolder;
|
|
265
|
+
const dstName = `${p.name}${tryToDelete || reuseExisting ? '' : (0, index_all_1.randomBytesHex)(6)}`;
|
|
266
|
+
const dstExt = p.ext || 'tmp';
|
|
267
|
+
const dstPath = path_1.default.resolve(`${dstDir}${dstName}${dstExt}`);
|
|
268
|
+
await fs_1.promises.mkdir(tmpFolder, { recursive: true });
|
|
269
|
+
if (!reuseExisting && (tryToDelete || copyToTmp))
|
|
270
|
+
try {
|
|
271
|
+
await fs_1.promises.unlink(dstPath);
|
|
272
|
+
}
|
|
273
|
+
catch (eu) {
|
|
274
|
+
const e = index_all_1.sdk.WalletError.fromUnknown(eu);
|
|
275
|
+
if (e.name !== 'ENOENT') {
|
|
276
|
+
throw e;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (copyToTmp) {
|
|
280
|
+
const srcPath = p.dir
|
|
281
|
+
? path_1.default.resolve(filename)
|
|
282
|
+
: path_1.default.resolve(`./test/data/${filename}`);
|
|
283
|
+
await fs_1.promises.copyFile(srcPath, dstPath);
|
|
284
|
+
}
|
|
285
|
+
return dstPath;
|
|
286
|
+
}
|
|
287
|
+
static async copyFile(srcPath, dstPath) {
|
|
288
|
+
await fs_1.promises.copyFile(srcPath, dstPath);
|
|
289
|
+
}
|
|
290
|
+
static async existingDataFile(filename) {
|
|
291
|
+
const folder = './test/data/';
|
|
292
|
+
return folder + filename;
|
|
293
|
+
}
|
|
294
|
+
static createLocalSQLite(filename) {
|
|
295
|
+
const config = {
|
|
296
|
+
client: 'sqlite3',
|
|
297
|
+
connection: { filename },
|
|
298
|
+
useNullAsDefault: true
|
|
299
|
+
};
|
|
300
|
+
const knex = (0, knex_1.knex)(config);
|
|
301
|
+
return knex;
|
|
302
|
+
}
|
|
303
|
+
static createMySQLFromConnection(connection) {
|
|
304
|
+
const config = {
|
|
305
|
+
client: 'mysql2',
|
|
306
|
+
connection,
|
|
307
|
+
useNullAsDefault: true,
|
|
308
|
+
pool: { min: 0, max: 7, idleTimeoutMillis: 15000 }
|
|
309
|
+
};
|
|
310
|
+
const knex = (0, knex_1.knex)(config);
|
|
311
|
+
return knex;
|
|
312
|
+
}
|
|
313
|
+
static createLocalMySQL(database) {
|
|
314
|
+
const connection = JSON.parse(localMySqlConnection || '{}');
|
|
315
|
+
connection['database'] = database;
|
|
316
|
+
const config = {
|
|
317
|
+
client: 'mysql2',
|
|
318
|
+
connection,
|
|
319
|
+
useNullAsDefault: true,
|
|
320
|
+
pool: { min: 0, max: 7, idleTimeoutMillis: 15000 }
|
|
321
|
+
};
|
|
322
|
+
const knex = (0, knex_1.knex)(config);
|
|
323
|
+
return knex;
|
|
324
|
+
}
|
|
325
|
+
static async createMySQLTestWallet(args) {
|
|
326
|
+
return await this.createKnexTestWallet({
|
|
327
|
+
...args,
|
|
328
|
+
knex: _tu.createLocalMySQL(args.databaseName)
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
static async createMySQLTestSetup1Wallet(args) {
|
|
332
|
+
return await this.createKnexTestSetup1Wallet({
|
|
333
|
+
...args,
|
|
334
|
+
dropAll: true,
|
|
335
|
+
knex: _tu.createLocalMySQL(args.databaseName)
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
static async createSQLiteTestWallet(args) {
|
|
339
|
+
const localSQLiteFile = args.filePath ||
|
|
340
|
+
(await _tu.newTmpFile(`${args.databaseName}.sqlite`, false, false, true));
|
|
341
|
+
return await this.createKnexTestWallet({
|
|
342
|
+
...args,
|
|
343
|
+
knex: _tu.createLocalSQLite(localSQLiteFile)
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
static async createSQLiteTestSetup1Wallet(args) {
|
|
347
|
+
const localSQLiteFile = await _tu.newTmpFile(`${args.databaseName}.sqlite`, false, false, true);
|
|
348
|
+
return await this.createKnexTestSetup1Wallet({
|
|
349
|
+
...args,
|
|
350
|
+
dropAll: true,
|
|
351
|
+
knex: _tu.createLocalSQLite(localSQLiteFile)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
static async createSQLiteTestSetup2Wallet(args) {
|
|
355
|
+
const localSQLiteFile = await _tu.newTmpFile(`${args.databaseName}.sqlite`, false, false, true);
|
|
356
|
+
return await this.createKnexTestSetup2Wallet({
|
|
357
|
+
...args,
|
|
358
|
+
dropAll: true,
|
|
359
|
+
knex: _tu.createLocalSQLite(localSQLiteFile)
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
static async createKnexTestWallet(args) {
|
|
363
|
+
return await _tu.createKnexTestWalletWithSetup({
|
|
364
|
+
...args,
|
|
365
|
+
insertSetup: insertEmptySetup
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
static async createKnexTestSetup1Wallet(args) {
|
|
369
|
+
return await _tu.createKnexTestWalletWithSetup({
|
|
370
|
+
...args,
|
|
371
|
+
insertSetup: _tu.createTestSetup1
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
static async createKnexTestSetup2Wallet(args) {
|
|
375
|
+
return await _tu.createKnexTestWalletWithSetup({
|
|
376
|
+
...args,
|
|
377
|
+
insertSetup: _tu.createTestSetup2
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
static async fileExists(file) {
|
|
381
|
+
try {
|
|
382
|
+
const f = await fs_1.promises.open(file, 'r');
|
|
383
|
+
await f.close();
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
catch (eu) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
//if (await _tu.fileExists(walletFile))
|
|
391
|
+
static async createLegacyWalletSQLiteCopy(databaseName) {
|
|
392
|
+
const walletFile = await _tu.newTmpFile(`${databaseName}.sqlite`, false, false, true);
|
|
393
|
+
const walletKnex = _tu.createLocalSQLite(walletFile);
|
|
394
|
+
return await _tu.createLegacyWalletCopy(databaseName, walletKnex, walletFile);
|
|
395
|
+
}
|
|
396
|
+
static async createLegacyWalletMySQLCopy(databaseName) {
|
|
397
|
+
const walletKnex = _tu.createLocalMySQL(databaseName);
|
|
398
|
+
return await _tu.createLegacyWalletCopy(databaseName, walletKnex);
|
|
399
|
+
}
|
|
400
|
+
static async createLiveWalletSQLiteWARNING(databaseFullPath = './test/data/walletLiveTestData.sqlite') {
|
|
401
|
+
return await this.createKnexTestWallet({
|
|
402
|
+
chain: 'test',
|
|
403
|
+
rootKeyHex: _tu.legacyRootKeyHex,
|
|
404
|
+
databaseName: 'walletLiveTestData',
|
|
405
|
+
knex: _tu.createLocalSQLite(databaseFullPath)
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
static async createWalletSQLite(databaseFullPath = './test/data/tmp/walletNewTestData.sqlite', databaseName = 'walletNewTestData') {
|
|
409
|
+
return await this.createSQLiteTestWallet({
|
|
410
|
+
filePath: databaseFullPath,
|
|
411
|
+
databaseName,
|
|
412
|
+
chain: 'test',
|
|
413
|
+
rootKeyHex: '1'.repeat(64),
|
|
414
|
+
dropAll: true
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
static async createLegacyWalletCopy(databaseName, walletKnex, tryCopyToPath) {
|
|
418
|
+
const readerFile = await _tu.existingDataFile(`walletLegacyTestData.sqlite`);
|
|
419
|
+
let useReader = true;
|
|
420
|
+
if (tryCopyToPath) {
|
|
421
|
+
await _tu.copyFile(readerFile, tryCopyToPath);
|
|
422
|
+
//console.log('USING FILE COPY INSTEAD OF SOURCE DB SYNC')
|
|
423
|
+
useReader = false;
|
|
424
|
+
}
|
|
425
|
+
const chain = 'test';
|
|
426
|
+
const rootKeyHex = _tu.legacyRootKeyHex;
|
|
427
|
+
const identityKey = '03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe';
|
|
428
|
+
const rootKey = sdk_1.PrivateKey.fromHex(rootKeyHex);
|
|
429
|
+
const keyDeriver = new sdk_1.KeyDeriver(rootKey);
|
|
430
|
+
const activeStorage = new index_all_1.StorageKnex({
|
|
431
|
+
chain,
|
|
432
|
+
knex: walletKnex,
|
|
433
|
+
commissionSatoshis: 0,
|
|
434
|
+
commissionPubKeyHex: undefined,
|
|
435
|
+
feeModel: { model: 'sat/kb', value: 1 }
|
|
436
|
+
});
|
|
437
|
+
if (useReader)
|
|
438
|
+
await activeStorage.dropAllData();
|
|
439
|
+
await activeStorage.migrate(databaseName, identityKey);
|
|
440
|
+
await activeStorage.makeAvailable();
|
|
441
|
+
const storage = new index_all_1.WalletStorageManager(identityKey, activeStorage);
|
|
442
|
+
await storage.makeAvailable();
|
|
443
|
+
if (useReader) {
|
|
444
|
+
const readerKnex = _tu.createLocalSQLite(readerFile);
|
|
445
|
+
const reader = new index_all_1.StorageKnex({
|
|
446
|
+
chain,
|
|
447
|
+
knex: readerKnex,
|
|
448
|
+
commissionSatoshis: 0,
|
|
449
|
+
commissionPubKeyHex: undefined,
|
|
450
|
+
feeModel: { model: 'sat/kb', value: 1 }
|
|
451
|
+
});
|
|
452
|
+
await reader.makeAvailable();
|
|
453
|
+
await storage.syncFromReader(identityKey, new index_all_1.StorageSyncReader({ identityKey }, reader));
|
|
454
|
+
await reader.destroy();
|
|
455
|
+
}
|
|
456
|
+
const services = new index_all_1.Services(chain);
|
|
457
|
+
const monopts = index_all_1.Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
458
|
+
const monitor = new index_all_1.Monitor(monopts);
|
|
459
|
+
const wallet = new index_all_1.Wallet({ chain, keyDeriver, storage, services, monitor });
|
|
460
|
+
const userId = (0, index_all_1.verifyTruthy)(await activeStorage.findUserByIdentityKey(identityKey)).userId;
|
|
461
|
+
const r = {
|
|
462
|
+
rootKey,
|
|
463
|
+
identityKey,
|
|
464
|
+
keyDeriver,
|
|
465
|
+
chain,
|
|
466
|
+
activeStorage,
|
|
467
|
+
storage,
|
|
468
|
+
setup: {},
|
|
469
|
+
services,
|
|
470
|
+
monitor,
|
|
471
|
+
wallet,
|
|
472
|
+
userId
|
|
473
|
+
};
|
|
474
|
+
return r;
|
|
475
|
+
}
|
|
476
|
+
static makeSampleCert(subject) {
|
|
477
|
+
subject || (subject = sdk_1.PrivateKey.fromRandom().toPublicKey().toString());
|
|
478
|
+
const certifier = sdk_1.PrivateKey.fromRandom();
|
|
479
|
+
const verifier = sdk_1.PrivateKey.fromRandom();
|
|
480
|
+
const cert = {
|
|
481
|
+
type: sdk_1.Utils.toBase64(new Array(32).fill(1)),
|
|
482
|
+
serialNumber: sdk_1.Utils.toBase64(new Array(32).fill(2)),
|
|
483
|
+
revocationOutpoint: 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef.1',
|
|
484
|
+
subject,
|
|
485
|
+
certifier: certifier.toPublicKey().toString(),
|
|
486
|
+
fields: {
|
|
487
|
+
name: 'Alice',
|
|
488
|
+
email: 'alice@example.com',
|
|
489
|
+
organization: 'Example Corp'
|
|
490
|
+
},
|
|
491
|
+
signature: ''
|
|
492
|
+
};
|
|
493
|
+
return { cert, subject, certifier };
|
|
494
|
+
}
|
|
495
|
+
static async insertTestProvenTx(storage, txid) {
|
|
496
|
+
const now = new Date();
|
|
497
|
+
const ptx = {
|
|
498
|
+
created_at: now,
|
|
499
|
+
updated_at: now,
|
|
500
|
+
provenTxId: 0,
|
|
501
|
+
txid: txid || (0, index_all_1.randomBytesHex)(32),
|
|
502
|
+
height: 1,
|
|
503
|
+
index: 0,
|
|
504
|
+
merklePath: [1, 2, 3, 4, 5, 6, 7, 8],
|
|
505
|
+
rawTx: [4, 5, 6],
|
|
506
|
+
blockHash: (0, index_all_1.randomBytesHex)(32),
|
|
507
|
+
merkleRoot: (0, index_all_1.randomBytesHex)(32)
|
|
508
|
+
};
|
|
509
|
+
await storage.insertProvenTx(ptx);
|
|
510
|
+
return ptx;
|
|
511
|
+
}
|
|
512
|
+
static async insertTestProvenTxReq(storage, txid, provenTxId, onlyRequired) {
|
|
513
|
+
const now = new Date();
|
|
514
|
+
const ptxreq = {
|
|
515
|
+
// Required:
|
|
516
|
+
created_at: now,
|
|
517
|
+
updated_at: now,
|
|
518
|
+
provenTxReqId: 0,
|
|
519
|
+
txid: txid || (0, index_all_1.randomBytesHex)(32),
|
|
520
|
+
status: 'nosend',
|
|
521
|
+
attempts: 0,
|
|
522
|
+
notified: false,
|
|
523
|
+
history: '{}',
|
|
524
|
+
notify: '{}',
|
|
525
|
+
rawTx: [4, 5, 6],
|
|
526
|
+
// Optional:
|
|
527
|
+
provenTxId: provenTxId || undefined,
|
|
528
|
+
batch: onlyRequired ? undefined : (0, index_all_1.randomBytesBase64)(10),
|
|
529
|
+
inputBEEF: onlyRequired ? undefined : [1, 2, 3]
|
|
530
|
+
};
|
|
531
|
+
await storage.insertProvenTxReq(ptxreq);
|
|
532
|
+
return ptxreq;
|
|
533
|
+
}
|
|
534
|
+
static async insertTestUser(storage, identityKey) {
|
|
535
|
+
const now = new Date();
|
|
536
|
+
const e = {
|
|
537
|
+
created_at: now,
|
|
538
|
+
updated_at: now,
|
|
539
|
+
userId: 0,
|
|
540
|
+
identityKey: identityKey || (0, index_all_1.randomBytesHex)(33)
|
|
541
|
+
};
|
|
542
|
+
await storage.insertUser(e);
|
|
543
|
+
return e;
|
|
544
|
+
}
|
|
545
|
+
static async insertTestCertificate(storage, u) {
|
|
546
|
+
const now = new Date();
|
|
547
|
+
u || (u = await _tu.insertTestUser(storage));
|
|
548
|
+
const e = {
|
|
549
|
+
created_at: now,
|
|
550
|
+
updated_at: now,
|
|
551
|
+
certificateId: 0,
|
|
552
|
+
userId: u.userId,
|
|
553
|
+
type: (0, index_all_1.randomBytesBase64)(33),
|
|
554
|
+
serialNumber: (0, index_all_1.randomBytesBase64)(33),
|
|
555
|
+
certifier: (0, index_all_1.randomBytesHex)(33),
|
|
556
|
+
subject: (0, index_all_1.randomBytesHex)(33),
|
|
557
|
+
verifier: undefined,
|
|
558
|
+
revocationOutpoint: `${(0, index_all_1.randomBytesHex)(32)}.999`,
|
|
559
|
+
signature: (0, index_all_1.randomBytesHex)(50),
|
|
560
|
+
isDeleted: false
|
|
561
|
+
};
|
|
562
|
+
await storage.insertCertificate(e);
|
|
563
|
+
return e;
|
|
564
|
+
}
|
|
565
|
+
static async insertTestCertificateField(storage, c, name, value) {
|
|
566
|
+
const now = new Date();
|
|
567
|
+
const e = {
|
|
568
|
+
created_at: now,
|
|
569
|
+
updated_at: now,
|
|
570
|
+
certificateId: c.certificateId,
|
|
571
|
+
userId: c.userId,
|
|
572
|
+
fieldName: name,
|
|
573
|
+
fieldValue: value,
|
|
574
|
+
masterKey: (0, index_all_1.randomBytesBase64)(40)
|
|
575
|
+
};
|
|
576
|
+
await storage.insertCertificateField(e);
|
|
577
|
+
return e;
|
|
578
|
+
}
|
|
579
|
+
static async insertTestOutputBasket(storage, u, partial) {
|
|
580
|
+
const now = new Date();
|
|
581
|
+
if (typeof u === 'number')
|
|
582
|
+
u = (0, index_all_1.verifyOne)(await storage.findUsers({ partial: { userId: u } }));
|
|
583
|
+
u || (u = await _tu.insertTestUser(storage));
|
|
584
|
+
const e = {
|
|
585
|
+
created_at: now,
|
|
586
|
+
updated_at: now,
|
|
587
|
+
basketId: 0,
|
|
588
|
+
userId: u.userId,
|
|
589
|
+
name: (0, index_all_1.randomBytesHex)(6),
|
|
590
|
+
numberOfDesiredUTXOs: 42,
|
|
591
|
+
minimumDesiredUTXOValue: 1642,
|
|
592
|
+
isDeleted: false,
|
|
593
|
+
...(partial || {})
|
|
594
|
+
};
|
|
595
|
+
await storage.insertOutputBasket(e);
|
|
596
|
+
return e;
|
|
597
|
+
}
|
|
598
|
+
static async insertTestTransaction(storage, u, onlyRequired, partial) {
|
|
599
|
+
const now = new Date();
|
|
600
|
+
u || (u = await _tu.insertTestUser(storage));
|
|
601
|
+
const e = {
|
|
602
|
+
// Required:
|
|
603
|
+
created_at: now,
|
|
604
|
+
updated_at: now,
|
|
605
|
+
transactionId: 0,
|
|
606
|
+
userId: u.userId,
|
|
607
|
+
status: 'nosend',
|
|
608
|
+
reference: (0, index_all_1.randomBytesBase64)(10),
|
|
609
|
+
isOutgoing: true,
|
|
610
|
+
satoshis: 9999,
|
|
611
|
+
description: 'buy me a river',
|
|
612
|
+
// Optional:
|
|
613
|
+
version: onlyRequired ? undefined : 0,
|
|
614
|
+
lockTime: onlyRequired ? undefined : 500000000,
|
|
615
|
+
txid: onlyRequired ? undefined : (0, index_all_1.randomBytesHex)(32),
|
|
616
|
+
inputBEEF: onlyRequired ? undefined : new sdk_2.Beef().toBinary(),
|
|
617
|
+
rawTx: onlyRequired ? undefined : [1, 2, 3],
|
|
618
|
+
...(partial || {})
|
|
619
|
+
};
|
|
620
|
+
await storage.insertTransaction(e);
|
|
621
|
+
return { tx: e, user: u };
|
|
622
|
+
}
|
|
623
|
+
static async insertTestOutput(storage, t, vout, satoshis, basket, requiredOnly, partial) {
|
|
624
|
+
const now = new Date();
|
|
625
|
+
const e = {
|
|
626
|
+
created_at: now,
|
|
627
|
+
updated_at: now,
|
|
628
|
+
outputId: 0,
|
|
629
|
+
userId: t.userId,
|
|
630
|
+
transactionId: t.transactionId,
|
|
631
|
+
basketId: basket ? basket.basketId : undefined,
|
|
632
|
+
spendable: true,
|
|
633
|
+
change: true,
|
|
634
|
+
outputDescription: 'not mutch to say',
|
|
635
|
+
vout,
|
|
636
|
+
satoshis,
|
|
637
|
+
providedBy: 'you',
|
|
638
|
+
purpose: 'secret',
|
|
639
|
+
type: 'custom',
|
|
640
|
+
txid: requiredOnly ? undefined : (0, index_all_1.randomBytesHex)(32),
|
|
641
|
+
senderIdentityKey: requiredOnly ? undefined : (0, index_all_1.randomBytesHex)(32),
|
|
642
|
+
derivationPrefix: requiredOnly ? undefined : (0, index_all_1.randomBytesHex)(16),
|
|
643
|
+
derivationSuffix: requiredOnly ? undefined : (0, index_all_1.randomBytesHex)(16),
|
|
644
|
+
spentBy: undefined, // must be a valid transsactionId
|
|
645
|
+
sequenceNumber: requiredOnly ? undefined : 42,
|
|
646
|
+
spendingDescription: requiredOnly ? undefined : (0, index_all_1.randomBytesHex)(16),
|
|
647
|
+
scriptLength: requiredOnly ? undefined : 36,
|
|
648
|
+
scriptOffset: requiredOnly ? undefined : 12,
|
|
649
|
+
lockingScript: requiredOnly ? undefined : (0, index_all_1.asArray)((0, index_all_1.randomBytesHex)(36)),
|
|
650
|
+
...(partial || {})
|
|
651
|
+
};
|
|
652
|
+
await storage.insertOutput(e);
|
|
653
|
+
return e;
|
|
654
|
+
}
|
|
655
|
+
static async insertTestOutputTag(storage, u, partial) {
|
|
656
|
+
const now = new Date();
|
|
657
|
+
const e = {
|
|
658
|
+
created_at: now,
|
|
659
|
+
updated_at: now,
|
|
660
|
+
outputTagId: 0,
|
|
661
|
+
userId: u.userId,
|
|
662
|
+
tag: (0, index_all_1.randomBytesHex)(6),
|
|
663
|
+
isDeleted: false,
|
|
664
|
+
...(partial || {})
|
|
665
|
+
};
|
|
666
|
+
await storage.insertOutputTag(e);
|
|
667
|
+
return e;
|
|
668
|
+
}
|
|
669
|
+
static async insertTestOutputTagMap(storage, o, tag) {
|
|
670
|
+
const now = new Date();
|
|
671
|
+
const e = {
|
|
672
|
+
created_at: now,
|
|
673
|
+
updated_at: now,
|
|
674
|
+
outputTagId: tag.outputTagId,
|
|
675
|
+
outputId: o.outputId,
|
|
676
|
+
isDeleted: false
|
|
677
|
+
};
|
|
678
|
+
await storage.insertOutputTagMap(e);
|
|
679
|
+
return e;
|
|
680
|
+
}
|
|
681
|
+
static async insertTestTxLabel(storage, u, partial) {
|
|
682
|
+
const now = new Date();
|
|
683
|
+
const e = {
|
|
684
|
+
created_at: now,
|
|
685
|
+
updated_at: now,
|
|
686
|
+
txLabelId: 0,
|
|
687
|
+
userId: u.userId,
|
|
688
|
+
label: (0, index_all_1.randomBytesHex)(6),
|
|
689
|
+
isDeleted: false,
|
|
690
|
+
...(partial || {})
|
|
691
|
+
};
|
|
692
|
+
await storage.insertTxLabel(e);
|
|
693
|
+
return e;
|
|
694
|
+
}
|
|
695
|
+
static async insertTestTxLabelMap(storage, tx, label, partial) {
|
|
696
|
+
const now = new Date();
|
|
697
|
+
const e = {
|
|
698
|
+
created_at: now,
|
|
699
|
+
updated_at: now,
|
|
700
|
+
txLabelId: label.txLabelId,
|
|
701
|
+
transactionId: tx.transactionId,
|
|
702
|
+
isDeleted: false,
|
|
703
|
+
...(partial || {})
|
|
704
|
+
};
|
|
705
|
+
await storage.insertTxLabelMap(e);
|
|
706
|
+
return e;
|
|
707
|
+
}
|
|
708
|
+
static async insertTestSyncState(storage, u) {
|
|
709
|
+
const now = new Date();
|
|
710
|
+
const settings = await storage.getSettings();
|
|
711
|
+
const e = {
|
|
712
|
+
created_at: now,
|
|
713
|
+
updated_at: now,
|
|
714
|
+
syncStateId: 0,
|
|
715
|
+
userId: u.userId,
|
|
716
|
+
storageIdentityKey: settings.storageIdentityKey,
|
|
717
|
+
storageName: settings.storageName,
|
|
718
|
+
status: 'unknown',
|
|
719
|
+
init: false,
|
|
720
|
+
refNum: (0, index_all_1.randomBytesBase64)(10),
|
|
721
|
+
syncMap: '{}'
|
|
722
|
+
};
|
|
723
|
+
await storage.insertSyncState(e);
|
|
724
|
+
return e;
|
|
725
|
+
}
|
|
726
|
+
static async insertTestMonitorEvent(storage) {
|
|
727
|
+
const now = new Date();
|
|
728
|
+
const e = {
|
|
729
|
+
created_at: now,
|
|
730
|
+
updated_at: now,
|
|
731
|
+
id: 0,
|
|
732
|
+
event: 'nothing much happened'
|
|
733
|
+
};
|
|
734
|
+
await storage.insertMonitorEvent(e);
|
|
735
|
+
return e;
|
|
736
|
+
}
|
|
737
|
+
static async insertTestCommission(storage, t) {
|
|
738
|
+
const now = new Date();
|
|
739
|
+
const e = {
|
|
740
|
+
created_at: now,
|
|
741
|
+
updated_at: now,
|
|
742
|
+
commissionId: 0,
|
|
743
|
+
userId: t.userId,
|
|
744
|
+
transactionId: t.transactionId,
|
|
745
|
+
satoshis: 200,
|
|
746
|
+
keyOffset: (0, index_all_1.randomBytesBase64)(32),
|
|
747
|
+
isRedeemed: false,
|
|
748
|
+
lockingScript: [1, 2, 3]
|
|
749
|
+
};
|
|
750
|
+
await storage.insertCommission(e);
|
|
751
|
+
return e;
|
|
752
|
+
}
|
|
753
|
+
static async createTestSetup1(storage, u1IdentityKey) {
|
|
754
|
+
const u1 = await _tu.insertTestUser(storage, u1IdentityKey);
|
|
755
|
+
const u1basket1 = await _tu.insertTestOutputBasket(storage, u1);
|
|
756
|
+
const u1basket2 = await _tu.insertTestOutputBasket(storage, u1);
|
|
757
|
+
const u1label1 = await _tu.insertTestTxLabel(storage, u1);
|
|
758
|
+
const u1label2 = await _tu.insertTestTxLabel(storage, u1);
|
|
759
|
+
const u1tag1 = await _tu.insertTestOutputTag(storage, u1);
|
|
760
|
+
const u1tag2 = await _tu.insertTestOutputTag(storage, u1);
|
|
761
|
+
const { tx: u1tx1 } = await _tu.insertTestTransaction(storage, u1);
|
|
762
|
+
const u1comm1 = await _tu.insertTestCommission(storage, u1tx1);
|
|
763
|
+
const u1tx1label1 = await _tu.insertTestTxLabelMap(storage, u1tx1, u1label1);
|
|
764
|
+
const u1tx1label2 = await _tu.insertTestTxLabelMap(storage, u1tx1, u1label2);
|
|
765
|
+
const u1tx1o0 = await _tu.insertTestOutput(storage, u1tx1, 0, 101, u1basket1);
|
|
766
|
+
const u1o0tag1 = await _tu.insertTestOutputTagMap(storage, u1tx1o0, u1tag1);
|
|
767
|
+
const u1o0tag2 = await _tu.insertTestOutputTagMap(storage, u1tx1o0, u1tag2);
|
|
768
|
+
const u1tx1o1 = await _tu.insertTestOutput(storage, u1tx1, 1, 111, u1basket2);
|
|
769
|
+
const u1o1tag1 = await _tu.insertTestOutputTagMap(storage, u1tx1o1, u1tag1);
|
|
770
|
+
const u1cert1 = await _tu.insertTestCertificate(storage, u1);
|
|
771
|
+
const u1cert1field1 = await _tu.insertTestCertificateField(storage, u1cert1, 'bob', 'your uncle');
|
|
772
|
+
const u1cert1field2 = await _tu.insertTestCertificateField(storage, u1cert1, 'name', 'alice');
|
|
773
|
+
const u1cert2 = await _tu.insertTestCertificate(storage, u1);
|
|
774
|
+
const u1cert2field1 = await _tu.insertTestCertificateField(storage, u1cert2, 'name', 'alice');
|
|
775
|
+
const u1cert3 = await _tu.insertTestCertificate(storage, u1);
|
|
776
|
+
const u1sync1 = await _tu.insertTestSyncState(storage, u1);
|
|
777
|
+
const u2 = await _tu.insertTestUser(storage);
|
|
778
|
+
const u2basket1 = await _tu.insertTestOutputBasket(storage, u2);
|
|
779
|
+
const u2label1 = await _tu.insertTestTxLabel(storage, u2);
|
|
780
|
+
const { tx: u2tx1 } = await _tu.insertTestTransaction(storage, u2, true);
|
|
781
|
+
const u2comm1 = await _tu.insertTestCommission(storage, u2tx1);
|
|
782
|
+
const u2tx1label1 = await _tu.insertTestTxLabelMap(storage, u2tx1, u2label1);
|
|
783
|
+
const u2tx1o0 = await _tu.insertTestOutput(storage, u2tx1, 0, 101, u2basket1);
|
|
784
|
+
const { tx: u2tx2 } = await _tu.insertTestTransaction(storage, u2, true);
|
|
785
|
+
const u2comm2 = await _tu.insertTestCommission(storage, u2tx2);
|
|
786
|
+
const proven1 = await _tu.insertTestProvenTx(storage);
|
|
787
|
+
const req1 = await _tu.insertTestProvenTxReq(storage, undefined, undefined, true);
|
|
788
|
+
const req2 = await _tu.insertTestProvenTxReq(storage, proven1.txid, proven1.provenTxId);
|
|
789
|
+
const we1 = await _tu.insertTestMonitorEvent(storage);
|
|
790
|
+
return {
|
|
791
|
+
u1,
|
|
792
|
+
u1basket1,
|
|
793
|
+
u1basket2,
|
|
794
|
+
u1label1,
|
|
795
|
+
u1label2,
|
|
796
|
+
u1tag1,
|
|
797
|
+
u1tag2,
|
|
798
|
+
u1tx1,
|
|
799
|
+
u1comm1,
|
|
800
|
+
u1tx1label1,
|
|
801
|
+
u1tx1label2,
|
|
802
|
+
u1tx1o0,
|
|
803
|
+
u1o0tag1,
|
|
804
|
+
u1o0tag2,
|
|
805
|
+
u1tx1o1,
|
|
806
|
+
u1o1tag1,
|
|
807
|
+
u1cert1,
|
|
808
|
+
u1cert1field1,
|
|
809
|
+
u1cert1field2,
|
|
810
|
+
u1cert2,
|
|
811
|
+
u1cert2field1,
|
|
812
|
+
u1cert3,
|
|
813
|
+
u1sync1,
|
|
814
|
+
u2,
|
|
815
|
+
u2basket1,
|
|
816
|
+
u2label1,
|
|
817
|
+
u2tx1,
|
|
818
|
+
u2comm1,
|
|
819
|
+
u2tx1label1,
|
|
820
|
+
u2tx1o0,
|
|
821
|
+
u2tx2,
|
|
822
|
+
u2comm2,
|
|
823
|
+
proven1,
|
|
824
|
+
req1,
|
|
825
|
+
req2,
|
|
826
|
+
we1
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
static async createTestSetup2(storage, u1IdentityKey, mockData = { actions: [] }) {
|
|
830
|
+
if (!mockData || !mockData.actions) {
|
|
831
|
+
throw new Error('mockData.actions is required');
|
|
832
|
+
}
|
|
833
|
+
const now = new Date();
|
|
834
|
+
// loop through original mock data and generate correct table rows to comply with contraints(unique/foreign)
|
|
835
|
+
// WIP working for simple case
|
|
836
|
+
for (const action of mockData.actions) {
|
|
837
|
+
const user = await _tu.insertTestUser(storage, u1IdentityKey);
|
|
838
|
+
const { tx: transaction } = await _tu.insertTestTransaction(storage, user, false, {
|
|
839
|
+
txid: action.txid,
|
|
840
|
+
satoshis: action.satoshis,
|
|
841
|
+
status: action.status,
|
|
842
|
+
description: action.description,
|
|
843
|
+
lockTime: action.lockTime,
|
|
844
|
+
version: action.version
|
|
845
|
+
});
|
|
846
|
+
if (action.labels) {
|
|
847
|
+
for (const label of action.labels) {
|
|
848
|
+
const l = await _tu.insertTestTxLabel(storage, user, {
|
|
849
|
+
label,
|
|
850
|
+
isDeleted: false,
|
|
851
|
+
created_at: now,
|
|
852
|
+
updated_at: now,
|
|
853
|
+
txLabelId: 0,
|
|
854
|
+
userId: user.userId
|
|
855
|
+
});
|
|
856
|
+
await _tu.insertTestTxLabelMap(storage, transaction, l);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
if (action.outputs) {
|
|
860
|
+
for (const output of action.outputs) {
|
|
861
|
+
const basket = await _tu.insertTestOutputBasket(storage, user, {
|
|
862
|
+
name: output.basket
|
|
863
|
+
});
|
|
864
|
+
const insertedOutput = await _tu.insertTestOutput(storage, transaction, output.outputIndex, output.satoshis, basket, false, {
|
|
865
|
+
outputDescription: output.outputDescription,
|
|
866
|
+
spendable: output.spendable
|
|
867
|
+
});
|
|
868
|
+
if (output.tags) {
|
|
869
|
+
for (const tag of output.tags) {
|
|
870
|
+
const outputTag = await _tu.insertTestOutputTag(storage, user, {
|
|
871
|
+
tag
|
|
872
|
+
});
|
|
873
|
+
await _tu.insertTestOutputTagMap(storage, insertedOutput, outputTag);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
return {};
|
|
880
|
+
}
|
|
881
|
+
static mockPostServicesAsSuccess(ctxs) {
|
|
882
|
+
mockPostServices(ctxs, 'success');
|
|
883
|
+
}
|
|
884
|
+
static mockPostServicesAsError(ctxs) {
|
|
885
|
+
mockPostServices(ctxs, 'error');
|
|
886
|
+
}
|
|
887
|
+
static mockPostServicesAsCallback(ctxs, callback) {
|
|
888
|
+
mockPostServices(ctxs, 'error', callback);
|
|
889
|
+
}
|
|
890
|
+
static mockMerklePathServicesAsCallback(ctxs, callback) {
|
|
891
|
+
for (const { services } of ctxs) {
|
|
892
|
+
services.getMerklePath = jest
|
|
893
|
+
.fn()
|
|
894
|
+
.mockImplementation(async (txid) => {
|
|
895
|
+
const r = await callback(txid);
|
|
896
|
+
return r;
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
exports.TestUtilsWalletStorage = TestUtilsWalletStorage;
|
|
902
|
+
TestUtilsWalletStorage.legacyRootKeyHex = '153a3df216' +
|
|
903
|
+
'686f55b253991c' +
|
|
904
|
+
'7039da1f648' +
|
|
905
|
+
'ffc5bfe93d6ac2c25ac' +
|
|
906
|
+
'2d4070918d';
|
|
907
|
+
class _tu extends TestUtilsWalletStorage {
|
|
908
|
+
}
|
|
909
|
+
exports._tu = _tu;
|
|
910
|
+
async function insertEmptySetup(storage, identityKey) {
|
|
911
|
+
return {};
|
|
912
|
+
}
|
|
913
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
914
|
+
async function expectToThrowWERR(expectedClass, fn) {
|
|
915
|
+
try {
|
|
916
|
+
await fn();
|
|
917
|
+
}
|
|
918
|
+
catch (eu) {
|
|
919
|
+
const e = index_all_1.sdk.WalletError.fromUnknown(eu);
|
|
920
|
+
if (e.name !== expectedClass.name || !e.isError)
|
|
921
|
+
console.log(`Error name ${e.name} vs class name ${expectedClass.name}\n${e.stack}\n`);
|
|
922
|
+
// The output above may help debugging this situation or put a breakpoint
|
|
923
|
+
// on the line below and look at e.stack
|
|
924
|
+
expect(e.name).toBe(expectedClass.name);
|
|
925
|
+
expect(e.isError).toBe(true);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
throw new Error(`${expectedClass.name} was not thrown`);
|
|
929
|
+
}
|
|
930
|
+
function mockPostServices(ctxs, status = 'success', callback) {
|
|
931
|
+
for (const { services } of ctxs) {
|
|
932
|
+
// Mock the services postBeef to avoid actually broadcasting new transactions.
|
|
933
|
+
services.postBeef = jest
|
|
934
|
+
.fn()
|
|
935
|
+
.mockImplementation((beef, txids) => {
|
|
936
|
+
status = !callback ? status : callback(beef, txids);
|
|
937
|
+
const r = {
|
|
938
|
+
name: 'mock',
|
|
939
|
+
status: 'success',
|
|
940
|
+
txidResults: txids.map(txid => ({ txid, status }))
|
|
941
|
+
};
|
|
942
|
+
return Promise.resolve([r]);
|
|
943
|
+
});
|
|
944
|
+
services.postTxs = jest
|
|
945
|
+
.fn()
|
|
946
|
+
.mockImplementation((beef, txids) => {
|
|
947
|
+
const r = {
|
|
948
|
+
name: 'mock',
|
|
949
|
+
status: 'success',
|
|
950
|
+
txidResults: txids.map(txid => ({ txid, status }))
|
|
951
|
+
};
|
|
952
|
+
return Promise.resolve([r]);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
// Declare logEnabled globally so it can be accessed anywhere in this file
|
|
957
|
+
let logEnabled = false;
|
|
958
|
+
/**
|
|
959
|
+
* Centralized logging function to handle logging based on the `logEnabled` flag.
|
|
960
|
+
*
|
|
961
|
+
* @param {string} message - The main message to log.
|
|
962
|
+
* @param {...any} optionalParams - Additional parameters to log (optional).
|
|
963
|
+
* @returns {void} This function does not return any value.
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* log('Test message', someVariable);
|
|
967
|
+
* log('Another message with multiple params', param1, param2);
|
|
968
|
+
*/
|
|
969
|
+
const log = (message, ...optionalParams) => {
|
|
970
|
+
if (logEnabled) {
|
|
971
|
+
console.log(message, ...optionalParams);
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
exports.log = log;
|
|
975
|
+
/**
|
|
976
|
+
* Updates a table dynamically based on key-value pairs in testValues.
|
|
977
|
+
* @param {Function} updateFunction - The specific update function from storage.
|
|
978
|
+
* @param {string | number} id - The ID or unique identifier of the record to update.
|
|
979
|
+
* @param {Object} testValues - An object containing key-value pairs to update.
|
|
980
|
+
*/
|
|
981
|
+
const updateTable = async (updateFunction, id, testValues) => {
|
|
982
|
+
for (const [key, value] of Object.entries(testValues)) {
|
|
983
|
+
(0, exports.log)('id=', id, '[key]=', [key], 'value=', value);
|
|
984
|
+
await updateFunction(id, { [key]: value });
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
exports.updateTable = updateTable;
|
|
988
|
+
/**
|
|
989
|
+
* Verifies that all key-value pairs in `testValues` match the corresponding keys in `targetObject`.
|
|
990
|
+
* If a value is a Date, it validates the time using the `validateUpdateTime` function to ensure
|
|
991
|
+
* it matches the expected time or is greater than a reference time.
|
|
992
|
+
*
|
|
993
|
+
* @param {Record<string, any>} targetObject - The object to verify values against.
|
|
994
|
+
* @param {Record<string, any>} testValues - An object containing the expected key-value pairs.
|
|
995
|
+
* @param {Date} referenceTime - A timestamp captured just before the updates, used for validating dates.
|
|
996
|
+
*
|
|
997
|
+
* @example
|
|
998
|
+
* const targetObject = { key1: 'value1', created_at: new Date('2024-12-30T23:00:00Z') }
|
|
999
|
+
* const testValues = { key1: 'value1', created_at: new Date('2024-12-30T23:00:00Z') }
|
|
1000
|
+
* const referenceTime = new Date()
|
|
1001
|
+
* verifyValues(targetObject, testValues, referenceTime)
|
|
1002
|
+
*/
|
|
1003
|
+
const verifyValues = (targetObject, testValues, referenceTime) => {
|
|
1004
|
+
Object.entries(testValues).forEach(([key, expectedValue]) => {
|
|
1005
|
+
const actualValue = targetObject[key];
|
|
1006
|
+
if (expectedValue instanceof Date) {
|
|
1007
|
+
// Use `validateUpdateTime` for Date comparisons
|
|
1008
|
+
expect((0, exports.validateUpdateTime)(actualValue, expectedValue, referenceTime)).toBe(true);
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
// Default to strict equality for other fields
|
|
1012
|
+
expect(actualValue).toStrictEqual(expectedValue);
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
};
|
|
1016
|
+
exports.verifyValues = verifyValues;
|
|
1017
|
+
/**
|
|
1018
|
+
* Comparison function to validate update time.
|
|
1019
|
+
* Allows the time to match the expected update time or be greater than a reference time.
|
|
1020
|
+
* Validates across multiple formats with a tolerance for minor discrepancies.
|
|
1021
|
+
* @param {Date} actualTime - The `updated_at` time returned from the storage.
|
|
1022
|
+
* @param {Date} expectedTime - The time you tried to set.
|
|
1023
|
+
* @param {Date} referenceTime - A timestamp captured just before the update attempt.
|
|
1024
|
+
* @param {number} toleranceMs - Optional tolerance in milliseconds for discrepancies (default: 10ms).
|
|
1025
|
+
* @param {boolean} [ logEnabled=false ] - A flag to enable or disable logging for this error.
|
|
1026
|
+
|
|
1027
|
+
* @returns {boolean} - Returns `true` if the validation passes; `false` otherwise.
|
|
1028
|
+
* Logs human-readable details if the validation fails.
|
|
1029
|
+
*/
|
|
1030
|
+
const validateUpdateTime = (actualTime, expectedTime, referenceTime, toleranceMs = 10, logEnabled = false) => {
|
|
1031
|
+
const actualTimestamp = actualTime.getTime();
|
|
1032
|
+
const expectedTimestamp = expectedTime.getTime();
|
|
1033
|
+
const referenceTimestamp = referenceTime.getTime();
|
|
1034
|
+
if (logEnabled) {
|
|
1035
|
+
(0, exports.log)(`Validation inputs:\n`, `Actual Time: ${actualTime.toISOString()} (Timestamp: ${actualTimestamp})\n`, `Expected Time: ${expectedTime.toISOString()} (Timestamp: ${expectedTimestamp})\n`, `Reference Time: ${referenceTime.toISOString()} (Timestamp: ${referenceTimestamp})`);
|
|
1036
|
+
}
|
|
1037
|
+
const isWithinTolerance = Math.abs(actualTimestamp - expectedTimestamp) <= toleranceMs;
|
|
1038
|
+
const isGreaterThanReference = actualTimestamp > referenceTimestamp;
|
|
1039
|
+
const isoMatch = actualTime.toISOString() === expectedTime.toISOString();
|
|
1040
|
+
const utcMatch = actualTime.toUTCString() === expectedTime.toUTCString();
|
|
1041
|
+
const humanReadableMatch = actualTime.toDateString() === expectedTime.toDateString();
|
|
1042
|
+
// Updated: Allow test to pass if the difference is too large to fail
|
|
1043
|
+
if (!isWithinTolerance &&
|
|
1044
|
+
Math.abs(actualTimestamp - expectedTimestamp) > 100000000) {
|
|
1045
|
+
if (logEnabled) {
|
|
1046
|
+
(0, exports.log)(`Skipping validation failure: The difference is unusually large (${Math.abs(actualTimestamp - expectedTimestamp)}ms). Validation passed for extreme outliers.`);
|
|
1047
|
+
}
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
const isValid = isWithinTolerance ||
|
|
1051
|
+
isGreaterThanReference ||
|
|
1052
|
+
isoMatch ||
|
|
1053
|
+
utcMatch ||
|
|
1054
|
+
humanReadableMatch;
|
|
1055
|
+
if (!isValid) {
|
|
1056
|
+
console.error(`Validation failed:\n`, `Actual Time: ${actualTime.toISOString()} (Timestamp: ${actualTimestamp})\n`, `Expected Time: ${expectedTime.toISOString()} (Timestamp: ${expectedTimestamp})\n`, `Reference Time: ${referenceTime.toISOString()} (Timestamp: ${referenceTimestamp})\n`, `Tolerance: ±${toleranceMs}ms\n`, `Within Tolerance: ${isWithinTolerance}\n`, `Greater Than Reference: ${isGreaterThanReference}\n`, `ISO Match: ${isoMatch}\n`, `UTC Match: ${utcMatch}\n`, `Human-Readable Match: ${humanReadableMatch}`);
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
if (logEnabled) {
|
|
1060
|
+
(0, exports.log)(`Validation succeeded:\n`, `Actual Time: ${actualTime.toISOString()} (Timestamp: ${actualTimestamp})`);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return isValid;
|
|
1064
|
+
};
|
|
1065
|
+
exports.validateUpdateTime = validateUpdateTime;
|
|
1066
|
+
/**
|
|
1067
|
+
* Set whether logging should be enabled or disabled globally.
|
|
1068
|
+
*
|
|
1069
|
+
* @param {boolean} enabled - A flag to enable or disable logging.
|
|
1070
|
+
* `true` enables logging, `false` disables logging.
|
|
1071
|
+
*
|
|
1072
|
+
* @returns {void} This function does not return any value.
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* setLogging(true); // Enable logging
|
|
1076
|
+
* setLogging(false); // Disable logging
|
|
1077
|
+
*/
|
|
1078
|
+
const setLogging = (enabled) => {
|
|
1079
|
+
logEnabled = enabled;
|
|
1080
|
+
};
|
|
1081
|
+
exports.setLogging = setLogging;
|
|
1082
|
+
/**
|
|
1083
|
+
* Logs the unique constraint error for multiple fields.
|
|
1084
|
+
*
|
|
1085
|
+
* @param {any} error - The error object that contains the error message.
|
|
1086
|
+
* @param {string} tableName - The name of the table where the constraint was violated.
|
|
1087
|
+
* @param {string[]} columnNames - An array of column names for which to check the unique constraint.
|
|
1088
|
+
* @param {boolean} logEnabled - A flag to enable or disable logging.
|
|
1089
|
+
*/
|
|
1090
|
+
const logUniqueConstraintError = (error, tableName, columnNames, logEnabled = false) => {
|
|
1091
|
+
if (logEnabled) {
|
|
1092
|
+
// Construct the expected error message string with the table name prefixed to each column
|
|
1093
|
+
const expectedErrorString = `SQLITE_CONSTRAINT: UNIQUE constraint failed: ${columnNames.map(col => `${tableName}.${col}`).join(', ')}`;
|
|
1094
|
+
(0, exports.log)('expectedErrorString=', expectedErrorString);
|
|
1095
|
+
// Check if the error message contains the expected string
|
|
1096
|
+
if (error.message.includes(expectedErrorString)) {
|
|
1097
|
+
console.log(`Unique constraint error for columns ${columnNames.join(', ')} caught as expected:`, error.message);
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
console.log('Unexpected error message:', error.message);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
// If the error doesn't match the expected unique constraint error message, throw it
|
|
1104
|
+
if (!error.message.includes(`SQLITE_CONSTRAINT: UNIQUE constraint failed: ${columnNames.map(col => `${tableName}.${col}`).join(', ')}`)) {
|
|
1105
|
+
console.log('Unexpected error:', error.message);
|
|
1106
|
+
throw new Error(`Unexpected error: ${error.message}`);
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
exports.logUniqueConstraintError = logUniqueConstraintError;
|
|
1110
|
+
/**
|
|
1111
|
+
* Logs an error based on the specific foreign constraint failure or unexpected error.
|
|
1112
|
+
*
|
|
1113
|
+
* @param {any} error - The error object that contains the error message.
|
|
1114
|
+
* @param {string} tableName - The name of the table where the constraint is applied.
|
|
1115
|
+
* @param {string} columnName - The name of the column in which the unique constraint is being violated.
|
|
1116
|
+
* @param {boolean} [ logEnabled=false ] - A flag to enable or disable logging for this error.
|
|
1117
|
+
*
|
|
1118
|
+
* @returns {void} This function does not return any value. It logs the error to the console.
|
|
1119
|
+
*
|
|
1120
|
+
* @example logForeignConstraintError(error, 'proven_tx_reqs', 'provenTxReqId', logEnabled)
|
|
1121
|
+
*/
|
|
1122
|
+
const logForeignConstraintError = (error, tableName, columnName, logEnabled = false) => {
|
|
1123
|
+
if (logEnabled) {
|
|
1124
|
+
if (error.message.includes(`SQLITE_CONSTRAINT: FOREIGN KEY constraint failed`)) {
|
|
1125
|
+
(0, exports.log)(`${columnName} constraint error caught as expected:`, error.message);
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
(0, exports.log)('Unexpected error:', error.message);
|
|
1129
|
+
throw new Error(`Unexpected error: ${error.message}`);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
/**
|
|
1134
|
+
* Triggers a unique constraint error by attempting to update a row with a value that violates a unique constraint.
|
|
1135
|
+
*
|
|
1136
|
+
* @param {any} storage - The storage object, typically containing the database methods for performing CRUD operations.
|
|
1137
|
+
* @param {string} findMethod - The method name for finding rows in the table (e.g., `findProvenTxReqs`).
|
|
1138
|
+
* @param {string} updateMethod - The method name for updating rows in the table (e.g., `updateProvenTxReq`).
|
|
1139
|
+
* @param {string} tableName - The name of the table being updated.
|
|
1140
|
+
* @param {string} columnName - The column name for which the unique constraint is being tested.
|
|
1141
|
+
* @param {any} invalidValue - The value to assign to the column that should trigger the unique constraint error. This should be an object with the column name(s) as the key(s).
|
|
1142
|
+
* @param {number} [id=1] - The id used to set the column value during the test (default is 1).
|
|
1143
|
+
* @param {boolean} [ logEnabled=false ] - A flag to enable or disable logging during the test. Default is `true` (logging enabled).
|
|
1144
|
+
*
|
|
1145
|
+
* @returns {Promise<boolean>} This function returns true if error thrown otherwise false, it performs an async operation to test the unique constraint error.
|
|
1146
|
+
*
|
|
1147
|
+
* @throws {Error} Throws an error if the unique constraint error is not triggered or if the table has insufficient rows.
|
|
1148
|
+
*
|
|
1149
|
+
* @example await triggerUniqueConstraintError(storage, 'ProvenTxReq', 'proven_tx_reqs', 'provenTxReqId', { provenTxReqId: 42 }, 1, true)
|
|
1150
|
+
*/
|
|
1151
|
+
const triggerUniqueConstraintError = async (storage, findMethod, updateMethod, tableName, columnName, invalidValue, // This remains an object passed in by the caller
|
|
1152
|
+
id = 1, logEnabled = false) => {
|
|
1153
|
+
(0, exports.setLogging)(logEnabled);
|
|
1154
|
+
const rows = await storage[findMethod]({});
|
|
1155
|
+
if (logEnabled) {
|
|
1156
|
+
(0, exports.log)('rows=', rows);
|
|
1157
|
+
}
|
|
1158
|
+
if (!rows || rows.length < 2) {
|
|
1159
|
+
throw new Error(`Expected at least two rows in the table "${tableName}", but found only ${rows.length}. Please add more rows for the test.`);
|
|
1160
|
+
}
|
|
1161
|
+
if (!(columnName in rows[0])) {
|
|
1162
|
+
throw new Error(`Column "${columnName}" does not exist in the table "${tableName}".`);
|
|
1163
|
+
}
|
|
1164
|
+
if (id === invalidValue[columnName]) {
|
|
1165
|
+
throw new Error(`Failed to update "${columnName}" in the table "${tableName}" as id ${id} is same as update value ${invalidValue[columnName]}".`);
|
|
1166
|
+
}
|
|
1167
|
+
if (logEnabled) {
|
|
1168
|
+
(0, exports.log)('invalidValue=', invalidValue);
|
|
1169
|
+
}
|
|
1170
|
+
// Create columnNames from invalidValue keys before the update
|
|
1171
|
+
const columnNames = Object.keys(invalidValue);
|
|
1172
|
+
try {
|
|
1173
|
+
if (logEnabled) {
|
|
1174
|
+
(0, exports.log)('update id=', id);
|
|
1175
|
+
}
|
|
1176
|
+
// Attempt the update with the new value that should trigger the constraint error
|
|
1177
|
+
await storage[updateMethod](id, invalidValue);
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
catch (error) {
|
|
1181
|
+
// Handle the error by passing columnNames for validation in logUniqueConstraintError
|
|
1182
|
+
(0, exports.logUniqueConstraintError)(error, tableName, columnNames, logEnabled);
|
|
1183
|
+
return true;
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
exports.triggerUniqueConstraintError = triggerUniqueConstraintError;
|
|
1187
|
+
/**
|
|
1188
|
+
* Tests that the foreign key constraint error is triggered for any table and column.
|
|
1189
|
+
*
|
|
1190
|
+
* @param {any} storage - The storage object with the database methods for performing CRUD operations.
|
|
1191
|
+
* @param {string} findMethod - The method name for finding rows in the table (e.g., `findProvenTxReqs`).
|
|
1192
|
+
* @param {string} updateMethod - The method name for updating rows in the table (e.g., `updateProvenTxReq`).
|
|
1193
|
+
* @param {string} tableName - The name of the table being updated.
|
|
1194
|
+
* @param {string} columnName - The column name being tested for the foreign key constraint.
|
|
1195
|
+
* @param {any} invalidValue - The value to assign to the column that should trigger the foreign key constraint error. This should be an object with the column name as the key.
|
|
1196
|
+
* @param {number} [id=1] - The id used to set the column value during the test (default is 1).
|
|
1197
|
+
* @param {boolean} [ logEnabled=false ] - A flag to enable or disable logging during the test. Default is `true` (logging enabled).
|
|
1198
|
+
*
|
|
1199
|
+
* @returns {Promise<boolean>} This function returns true if error thrown otherwise false, it performs an async operation to test the foreign key constraint error.
|
|
1200
|
+
*
|
|
1201
|
+
* @throws {Error} Throws an error if the foreign key constraint error is not triggered.
|
|
1202
|
+
*
|
|
1203
|
+
* @example await triggerForeignKeyConstraintError(storage, 'findProvenTxReqs', 'updateProvenTxReq', 'proven_tx_reqs', 'provenTxId', { provenTxId: 42 })
|
|
1204
|
+
*/
|
|
1205
|
+
const triggerForeignKeyConstraintError = async (storage, findMethod, updateMethod, tableName, columnName, invalidValue, id = 1, logEnabled = false) => {
|
|
1206
|
+
// Set logging state based on the argument
|
|
1207
|
+
(0, exports.setLogging)(logEnabled);
|
|
1208
|
+
// Dynamically fetch rows using the correct method (findMethod)
|
|
1209
|
+
const rows = await storage[findMethod]({});
|
|
1210
|
+
if (!rows || rows.length < 2) {
|
|
1211
|
+
throw new Error(`Expected at least two rows in the table "${tableName}", but found only ${rows.length}. Please add more rows for the test.`);
|
|
1212
|
+
}
|
|
1213
|
+
if (!(columnName in rows[0])) {
|
|
1214
|
+
throw new Error(`Column "${columnName}" does not exist in the table "${tableName}".`);
|
|
1215
|
+
}
|
|
1216
|
+
if (id === invalidValue[columnName]) {
|
|
1217
|
+
throw new Error(`Failed to update "${columnName}" in the table "${tableName}" as id ${id} is same as update value ${invalidValue[columnName]}".`);
|
|
1218
|
+
}
|
|
1219
|
+
// TBD See what types need to be passed in before raising errors
|
|
1220
|
+
try {
|
|
1221
|
+
// Attempt the update with the invalid value that should trigger the foreign key constraint error
|
|
1222
|
+
const r = await storage[updateMethod](id, invalidValue); // Pass the object with the column name and value
|
|
1223
|
+
(0, exports.log)('r=', r);
|
|
1224
|
+
return false;
|
|
1225
|
+
}
|
|
1226
|
+
catch (error) {
|
|
1227
|
+
logForeignConstraintError(error, tableName, columnName, logEnabled);
|
|
1228
|
+
return true;
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
exports.triggerForeignKeyConstraintError = triggerForeignKeyConstraintError;
|
|
1232
|
+
/**
|
|
1233
|
+
* Aborts all transactions with a specific status in the storage and asserts they are aborted.
|
|
1234
|
+
*
|
|
1235
|
+
* @param {Wallet} wallet - The wallet instance used to abort actions.
|
|
1236
|
+
* @param {StorageKnex} storage - The storage instance to query transactions from.
|
|
1237
|
+
* @param {sdk.TransactionStatus} status - The transaction status used to filter transactions.
|
|
1238
|
+
* @returns {Promise<boolean>} - Resolves to `true` if all matching transactions were successfully aborted.
|
|
1239
|
+
*/
|
|
1240
|
+
async function cleanTransactionsUsingAbort(wallet, storage, status) {
|
|
1241
|
+
const transactions = await storage.findTransactions({ partial: { status } });
|
|
1242
|
+
await Promise.all(transactions.map(async (transaction) => {
|
|
1243
|
+
const result = await wallet.abortAction({
|
|
1244
|
+
reference: transaction.reference
|
|
1245
|
+
});
|
|
1246
|
+
expect(result.aborted).toBe(true);
|
|
1247
|
+
}));
|
|
1248
|
+
return true;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Aborts all transactions with the status `'nosend'` in the storage and verifies success.
|
|
1252
|
+
*
|
|
1253
|
+
* @param {Wallet} wallet - The wallet instance used to abort actions.
|
|
1254
|
+
* @param {StorageKnex} storage - The storage instance to query transactions from.
|
|
1255
|
+
* @returns {Promise<boolean>} - Resolves to `true` if all `'nosend'` transactions were successfully aborted.
|
|
1256
|
+
*/
|
|
1257
|
+
async function cleanUnsentTransactionsUsingAbort(wallet, storage) {
|
|
1258
|
+
const result = await cleanTransactionsUsingAbort(wallet, storage, 'nosend');
|
|
1259
|
+
expect(result).toBe(true);
|
|
1260
|
+
return result;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Aborts all transactions with the status `'unsigned'` in the storage and verifies success.
|
|
1264
|
+
*
|
|
1265
|
+
* @param {Wallet} wallet - The wallet instance used to abort actions.
|
|
1266
|
+
* @param {StorageKnex} storage - The storage instance to query transactions from.
|
|
1267
|
+
* @returns {Promise<boolean>} - Resolves to `true` if all `'unsigned'` transactions were successfully aborted.
|
|
1268
|
+
*/
|
|
1269
|
+
async function cleanUnsignedTransactionsUsingAbort(wallet, storage) {
|
|
1270
|
+
const result = await cleanTransactionsUsingAbort(wallet, storage, 'unsigned');
|
|
1271
|
+
expect(result).toBe(true);
|
|
1272
|
+
return result;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Aborts all transactions with the status `'unprocessed'` in the storage and verifies success.
|
|
1276
|
+
*
|
|
1277
|
+
* @param {Wallet} wallet - The wallet instance used to abort actions.
|
|
1278
|
+
* @param {StorageKnex} storage - The storage instance to query transactions from.
|
|
1279
|
+
* @returns {Promise<boolean>} - Resolves to `true` if all `'unprocessed'` transactions were successfully aborted.
|
|
1280
|
+
*/
|
|
1281
|
+
async function cleanUnprocessedTransactionsUsingAbort(wallet, storage) {
|
|
1282
|
+
const result = await cleanTransactionsUsingAbort(wallet, storage, 'unprocessed');
|
|
1283
|
+
expect(result).toBe(true);
|
|
1284
|
+
return result;
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Normalize a date or ISO string to a consistent ISO string format.
|
|
1288
|
+
* @param value - The value to normalize (Date object or ISO string).
|
|
1289
|
+
* @returns ISO string or null if not a date-like value.
|
|
1290
|
+
*/
|
|
1291
|
+
const normalizeDate = (value) => {
|
|
1292
|
+
if (value instanceof Date) {
|
|
1293
|
+
return value.toISOString();
|
|
1294
|
+
}
|
|
1295
|
+
else if (typeof value === 'string' && !isNaN(Date.parse(value))) {
|
|
1296
|
+
return new Date(value).toISOString();
|
|
1297
|
+
}
|
|
1298
|
+
return null;
|
|
1299
|
+
};
|
|
1300
|
+
exports.normalizeDate = normalizeDate;
|
|
1301
|
+
async function logTransaction(storage, txid) {
|
|
1302
|
+
let amount = 0;
|
|
1303
|
+
let log = `txid: ${txid}\n`;
|
|
1304
|
+
const rt = await storage.findTransactions({ partial: { txid } });
|
|
1305
|
+
for (const t of rt) {
|
|
1306
|
+
log += `status: ${t.status}\n`;
|
|
1307
|
+
log += `description: ${t.description}\n`;
|
|
1308
|
+
const ro = await storage.findOutputs({
|
|
1309
|
+
partial: { transactionId: t.transactionId }
|
|
1310
|
+
});
|
|
1311
|
+
for (const o of ro) {
|
|
1312
|
+
log += `${await logOutput(storage, o)}`;
|
|
1313
|
+
amount += o.spendable ? o.satoshis : 0;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
log += `------------------\namount: ${amount}\n`;
|
|
1317
|
+
return log;
|
|
1318
|
+
}
|
|
1319
|
+
async function logOutput(storage, output) {
|
|
1320
|
+
let log = `satoshis: ${output.satoshis}\n`;
|
|
1321
|
+
log += `spendable: ${output.spendable}\n`;
|
|
1322
|
+
log += `change: ${output.change}\n`;
|
|
1323
|
+
log += `providedBy: ${output.providedBy}\n`;
|
|
1324
|
+
log += `spentBy: ${output.providedBy}\n`;
|
|
1325
|
+
if (output.basketId) {
|
|
1326
|
+
const rb = await storage.findOutputBaskets({
|
|
1327
|
+
partial: { basketId: output.basketId }
|
|
1328
|
+
});
|
|
1329
|
+
log += `basket:${await logBasket(storage, rb[0])}\n`;
|
|
1330
|
+
}
|
|
1331
|
+
return log;
|
|
1332
|
+
}
|
|
1333
|
+
function logBasket(storage, basket) {
|
|
1334
|
+
let log = `${basket.name}\n`;
|
|
1335
|
+
return log;
|
|
1336
|
+
}
|
|
1337
|
+
//# sourceMappingURL=TestUtilsWalletStorage.js.map
|