@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,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StorageServer.ts
|
|
3
|
+
*
|
|
4
|
+
* A server-side class that "has a" local WalletStorage (like a StorageKnex instance),
|
|
5
|
+
* and exposes it via a JSON-RPC POST endpoint using Express.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { WalletInterface } from '@bsv/sdk'
|
|
9
|
+
import express, { Request, Response } from 'express'
|
|
10
|
+
import {
|
|
11
|
+
AuthMiddlewareOptions,
|
|
12
|
+
createAuthMiddleware
|
|
13
|
+
} from '@bsv/auth-express-middleware'
|
|
14
|
+
import { createPaymentMiddleware } from '@bsv/payment-express-middleware'
|
|
15
|
+
import { sdk, Wallet, StorageProvider } from '../../index.all'
|
|
16
|
+
|
|
17
|
+
import { StorageKnex } from '../StorageKnex'
|
|
18
|
+
|
|
19
|
+
export interface WalletStorageServerOptions {
|
|
20
|
+
port: number
|
|
21
|
+
wallet: Wallet
|
|
22
|
+
monetize: boolean
|
|
23
|
+
calculateRequestPrice?: (req: Request) => number | Promise<number>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class StorageServer {
|
|
27
|
+
private app = express()
|
|
28
|
+
private port: number
|
|
29
|
+
private storage: StorageProvider
|
|
30
|
+
private wallet: Wallet
|
|
31
|
+
private monetize: boolean
|
|
32
|
+
private calculateRequestPrice?: (req: Request) => number | Promise<number>
|
|
33
|
+
|
|
34
|
+
constructor(storage: StorageProvider, options: WalletStorageServerOptions) {
|
|
35
|
+
this.storage = storage
|
|
36
|
+
this.port = options.port
|
|
37
|
+
this.wallet = options.wallet
|
|
38
|
+
this.monetize = options.monetize
|
|
39
|
+
this.calculateRequestPrice = options.calculateRequestPrice
|
|
40
|
+
|
|
41
|
+
this.setupRoutes()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private setupRoutes(): void {
|
|
45
|
+
this.app.use(express.json({ limit: '30mb' }))
|
|
46
|
+
|
|
47
|
+
// This allows the API to be used everywhere when CORS is enforced
|
|
48
|
+
this.app.use((req, res, next) => {
|
|
49
|
+
res.header('Access-Control-Allow-Origin', '*')
|
|
50
|
+
res.header('Access-Control-Allow-Headers', '*')
|
|
51
|
+
res.header('Access-Control-Allow-Methods', '*')
|
|
52
|
+
res.header('Access-Control-Expose-Headers', '*')
|
|
53
|
+
res.header('Access-Control-Allow-Private-Network', 'true')
|
|
54
|
+
if (req.method === 'OPTIONS') {
|
|
55
|
+
// Handle CORS preflight requests to allow cross-origin POST/PUT requests
|
|
56
|
+
res.sendStatus(200)
|
|
57
|
+
} else {
|
|
58
|
+
next()
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const options: AuthMiddlewareOptions = {
|
|
63
|
+
wallet: this.wallet as WalletInterface
|
|
64
|
+
}
|
|
65
|
+
this.app.use(createAuthMiddleware(options))
|
|
66
|
+
if (this.monetize) {
|
|
67
|
+
this.app.use(
|
|
68
|
+
createPaymentMiddleware({
|
|
69
|
+
wallet: this.wallet,
|
|
70
|
+
calculateRequestPrice: this.calculateRequestPrice || (() => 100)
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// A single POST endpoint for JSON-RPC:
|
|
76
|
+
this.app.post('/', async (req: Request, res: Response) => {
|
|
77
|
+
let { jsonrpc, method, params, id } = req.body
|
|
78
|
+
|
|
79
|
+
// Basic JSON-RPC protocol checks:
|
|
80
|
+
if (jsonrpc !== '2.0' || !method || typeof method !== 'string') {
|
|
81
|
+
return res
|
|
82
|
+
.status(400)
|
|
83
|
+
.json({ error: { code: -32600, message: 'Invalid Request' } })
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
// Dispatch the method call:
|
|
88
|
+
if (typeof (this as any)[method] === 'function') {
|
|
89
|
+
// if you wanted to handle certain methods on the server class itself
|
|
90
|
+
// e.g. this['someServerMethod'](params)
|
|
91
|
+
throw new Error('Server method dispatch not used in this approach.')
|
|
92
|
+
} else if (typeof (this.storage as any)[method] === 'function') {
|
|
93
|
+
// method is on the walletStorage:
|
|
94
|
+
// Find user
|
|
95
|
+
switch (method) {
|
|
96
|
+
case 'destroy': {
|
|
97
|
+
console.log(`StorageServer: method=${method} IGNORED`)
|
|
98
|
+
return res.json({ jsonrpc: '2.0', result: undefined, id })
|
|
99
|
+
}
|
|
100
|
+
case 'getSettings':
|
|
101
|
+
{
|
|
102
|
+
/** */
|
|
103
|
+
}
|
|
104
|
+
break
|
|
105
|
+
case 'findOrInsertUser':
|
|
106
|
+
{
|
|
107
|
+
if (params[0] !== req.auth.identityKey)
|
|
108
|
+
throw new sdk.WERR_UNAUTHORIZED(
|
|
109
|
+
'function may only access authenticated user.'
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
break
|
|
113
|
+
default:
|
|
114
|
+
{
|
|
115
|
+
if (typeof params[0] !== 'object' || !params[0]) {
|
|
116
|
+
params = [{}]
|
|
117
|
+
}
|
|
118
|
+
if (
|
|
119
|
+
params[0]['identityKey'] &&
|
|
120
|
+
params[0]['identityKey'] !== req.auth.identityKey
|
|
121
|
+
)
|
|
122
|
+
throw new sdk.WERR_UNAUTHORIZED(
|
|
123
|
+
'identityKey does not match authentiation'
|
|
124
|
+
)
|
|
125
|
+
console.log(
|
|
126
|
+
'looking up user with identityKey:',
|
|
127
|
+
req.auth.identityKey
|
|
128
|
+
)
|
|
129
|
+
const { user, isNew } = await this.storage.findOrInsertUser(
|
|
130
|
+
req.auth.identityKey
|
|
131
|
+
)
|
|
132
|
+
params[0].reqAuthUserId = user.userId
|
|
133
|
+
if (params[0]['identityKey']) params[0].userId = user.userId
|
|
134
|
+
}
|
|
135
|
+
break
|
|
136
|
+
}
|
|
137
|
+
console.log(
|
|
138
|
+
`StorageServer: method=${method} params=${JSON.stringify(params).slice(0, 512)}`
|
|
139
|
+
)
|
|
140
|
+
const result = await (this.storage as any)[method](...(params || []))
|
|
141
|
+
console.log(
|
|
142
|
+
`StorageServer: method=${method} result=${JSON.stringify(result || 'void').slice(0, 512)}`
|
|
143
|
+
)
|
|
144
|
+
return res.json({ jsonrpc: '2.0', result, id })
|
|
145
|
+
} else {
|
|
146
|
+
// Unknown method
|
|
147
|
+
return res.status(400).json({
|
|
148
|
+
jsonrpc: '2.0',
|
|
149
|
+
error: { code: -32601, message: `Method not found: ${method}` },
|
|
150
|
+
id
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
// Catch any thrown errors from the local walletStorage method
|
|
155
|
+
const err = error as Error
|
|
156
|
+
return res.status(200).json({
|
|
157
|
+
jsonrpc: '2.0',
|
|
158
|
+
error: {
|
|
159
|
+
code: -32000,
|
|
160
|
+
message: err.message,
|
|
161
|
+
data: {
|
|
162
|
+
name: err.name,
|
|
163
|
+
stack: err.stack
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
id
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public start(): void {
|
|
173
|
+
this.app.listen(this.port, () => {
|
|
174
|
+
console.log(
|
|
175
|
+
`WalletStorageServer listening at http://localhost:${this.port}`
|
|
176
|
+
)
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { Knex } from 'knex'
|
|
3
|
+
import { sdk } from '../../index.all'
|
|
4
|
+
import { DBType } from '../StorageReader'
|
|
5
|
+
|
|
6
|
+
interface Migration {
|
|
7
|
+
up: (knex: Knex) => Promise<void>
|
|
8
|
+
down?: (knex: Knex) => Promise<void>
|
|
9
|
+
config?: object
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface MigrationSource<TMigrationSpec> {
|
|
13
|
+
getMigrations(loadExtensions: readonly string[]): Promise<TMigrationSpec[]>
|
|
14
|
+
getMigrationName(migration: TMigrationSpec): string
|
|
15
|
+
getMigration(migration: TMigrationSpec): Promise<Migration>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class KnexMigrations implements MigrationSource<string> {
|
|
19
|
+
migrations: Record<string, Migration> = {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param chain
|
|
23
|
+
* @param storageName human readable name for this storage instance
|
|
24
|
+
* @param maxOutputScriptLength limit for scripts kept in outputs table, longer scripts will be pulled from rawTx
|
|
25
|
+
*/
|
|
26
|
+
constructor(
|
|
27
|
+
public chain: sdk.Chain,
|
|
28
|
+
public storageName: string,
|
|
29
|
+
public storageIdentityKey: string,
|
|
30
|
+
public maxOutputScriptLength: number
|
|
31
|
+
) {
|
|
32
|
+
this.migrations = this.setupMigrations(
|
|
33
|
+
chain,
|
|
34
|
+
storageName,
|
|
35
|
+
storageIdentityKey,
|
|
36
|
+
maxOutputScriptLength
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async getMigrations(): Promise<string[]> {
|
|
41
|
+
return Object.keys(this.migrations).sort()
|
|
42
|
+
}
|
|
43
|
+
getMigrationName(migration: string) {
|
|
44
|
+
return migration
|
|
45
|
+
}
|
|
46
|
+
async getMigration(migration: string): Promise<Migration> {
|
|
47
|
+
return this.migrations[migration]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async getLatestMigration(): Promise<string> {
|
|
51
|
+
const ms = await this.getMigrations()
|
|
52
|
+
return ms[ms.length - 1]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static async latestMigration(): Promise<string> {
|
|
56
|
+
const km = new KnexMigrations('test', 'dummy', '1'.repeat(64), 100)
|
|
57
|
+
return await km.getLatestMigration()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setupMigrations(
|
|
61
|
+
chain: string,
|
|
62
|
+
storageName: string,
|
|
63
|
+
storageIdentityKey: string,
|
|
64
|
+
maxOutputScriptLength: number
|
|
65
|
+
): Record<string, Migration> {
|
|
66
|
+
const migrations: Record<string, Migration> = {}
|
|
67
|
+
|
|
68
|
+
const addTimeStamps = (
|
|
69
|
+
knex: Knex<any, any[]>,
|
|
70
|
+
table: Knex.CreateTableBuilder,
|
|
71
|
+
dbtype: DBType
|
|
72
|
+
) => {
|
|
73
|
+
if (dbtype === 'MySQL') {
|
|
74
|
+
table
|
|
75
|
+
.timestamp('created_at', { precision: 3 })
|
|
76
|
+
.defaultTo(knex.fn.now(3))
|
|
77
|
+
.notNullable()
|
|
78
|
+
table
|
|
79
|
+
.timestamp('updated_at', { precision: 3 })
|
|
80
|
+
.defaultTo(knex.fn.now(3))
|
|
81
|
+
.notNullable()
|
|
82
|
+
} else {
|
|
83
|
+
table
|
|
84
|
+
.timestamp('created_at', { precision: 3 })
|
|
85
|
+
.defaultTo(knex.fn.now())
|
|
86
|
+
.notNullable()
|
|
87
|
+
table
|
|
88
|
+
.timestamp('updated_at', { precision: 3 })
|
|
89
|
+
.defaultTo(knex.fn.now())
|
|
90
|
+
.notNullable()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
migrations['2025-01-21-001 add activeStorage to users'] = {
|
|
95
|
+
async up(knex) {
|
|
96
|
+
await knex.schema.alterTable('users', table => {
|
|
97
|
+
table.string('activeStorage', 130).nullable().defaultTo(null)
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
async down(knex) {
|
|
101
|
+
await knex.schema.alterTable('users', table => {
|
|
102
|
+
table.dropColumn('activeStorage')
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
migrations['2024-12-26-001 initial migration'] = {
|
|
108
|
+
async up(knex) {
|
|
109
|
+
const dbtype = await KnexMigrations.dbtype(knex)
|
|
110
|
+
|
|
111
|
+
await knex.schema.createTable('proven_txs', table => {
|
|
112
|
+
addTimeStamps(knex, table, dbtype)
|
|
113
|
+
table.increments('provenTxId').notNullable()
|
|
114
|
+
table.string('txid', 64).notNullable().unique()
|
|
115
|
+
table.integer('height').unsigned().notNullable()
|
|
116
|
+
table.integer('index').unsigned().notNullable()
|
|
117
|
+
table.binary('merklePath').notNullable()
|
|
118
|
+
table.binary('rawTx').notNullable()
|
|
119
|
+
table.string('blockHash', 64).notNullable()
|
|
120
|
+
table.string('merkleRoot', 64).notNullable()
|
|
121
|
+
})
|
|
122
|
+
await knex.schema.createTable('proven_tx_reqs', table => {
|
|
123
|
+
addTimeStamps(knex, table, dbtype)
|
|
124
|
+
table.increments('provenTxReqId')
|
|
125
|
+
table
|
|
126
|
+
.integer('provenTxId')
|
|
127
|
+
.unsigned()
|
|
128
|
+
.references('provenTxId')
|
|
129
|
+
.inTable('proven_txs')
|
|
130
|
+
table.string('status', 16).notNullable().defaultTo('unknown')
|
|
131
|
+
table.integer('attempts').unsigned().defaultTo(0).notNullable()
|
|
132
|
+
table.boolean('notified').notNullable().defaultTo(false)
|
|
133
|
+
table.string('txid', 64).notNullable().unique()
|
|
134
|
+
table.string('batch', 64).nullable()
|
|
135
|
+
table.text('history', 'longtext').notNullable().defaultTo('{}')
|
|
136
|
+
table.text('notify', 'longtext').notNullable().defaultTo('{}')
|
|
137
|
+
table.binary('rawTx').notNullable()
|
|
138
|
+
table.binary('inputBEEF')
|
|
139
|
+
table.index('status')
|
|
140
|
+
table.index('batch')
|
|
141
|
+
})
|
|
142
|
+
await knex.schema.createTable('users', table => {
|
|
143
|
+
addTimeStamps(knex, table, dbtype)
|
|
144
|
+
table.increments('userId')
|
|
145
|
+
table.string('identityKey', 130).notNullable().unique()
|
|
146
|
+
})
|
|
147
|
+
await knex.schema.createTable('certificates', table => {
|
|
148
|
+
addTimeStamps(knex, table, dbtype)
|
|
149
|
+
table.increments('certificateId')
|
|
150
|
+
table
|
|
151
|
+
.integer('userId')
|
|
152
|
+
.unsigned()
|
|
153
|
+
.references('userId')
|
|
154
|
+
.inTable('users')
|
|
155
|
+
.notNullable()
|
|
156
|
+
table.string('serialNumber', 100).notNullable()
|
|
157
|
+
table.string('type', 100).notNullable()
|
|
158
|
+
table.string('certifier', 100).notNullable()
|
|
159
|
+
table.string('subject', 100).notNullable()
|
|
160
|
+
table.string('verifier', 100).nullable()
|
|
161
|
+
table.string('revocationOutpoint', 100).notNullable()
|
|
162
|
+
table.string('signature', 255).notNullable()
|
|
163
|
+
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
164
|
+
table.unique(['userId', 'type', 'certifier', 'serialNumber'])
|
|
165
|
+
})
|
|
166
|
+
await knex.schema.createTable('certificate_fields', table => {
|
|
167
|
+
addTimeStamps(knex, table, dbtype)
|
|
168
|
+
table
|
|
169
|
+
.integer('userId')
|
|
170
|
+
.unsigned()
|
|
171
|
+
.references('userId')
|
|
172
|
+
.inTable('users')
|
|
173
|
+
.notNullable()
|
|
174
|
+
table
|
|
175
|
+
.integer('certificateId')
|
|
176
|
+
.unsigned()
|
|
177
|
+
.references('certificateId')
|
|
178
|
+
.inTable('certificates')
|
|
179
|
+
.notNullable()
|
|
180
|
+
table.string('fieldName', 100).notNullable()
|
|
181
|
+
table.string('fieldValue').notNullable()
|
|
182
|
+
table.string('masterKey', 255).defaultTo('').notNullable()
|
|
183
|
+
table.unique(['fieldName', 'certificateId'])
|
|
184
|
+
})
|
|
185
|
+
await knex.schema.createTable('output_baskets', table => {
|
|
186
|
+
addTimeStamps(knex, table, dbtype)
|
|
187
|
+
table.increments('basketId')
|
|
188
|
+
table
|
|
189
|
+
.integer('userId')
|
|
190
|
+
.unsigned()
|
|
191
|
+
.references('userId')
|
|
192
|
+
.inTable('users')
|
|
193
|
+
.notNullable()
|
|
194
|
+
table.string('name', 300).notNullable()
|
|
195
|
+
table.integer('numberOfDesiredUTXOs', 6).defaultTo(6).notNullable()
|
|
196
|
+
table
|
|
197
|
+
.integer('minimumDesiredUTXOValue', 15)
|
|
198
|
+
.defaultTo(10000)
|
|
199
|
+
.notNullable()
|
|
200
|
+
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
201
|
+
table.unique(['name', 'userId'])
|
|
202
|
+
})
|
|
203
|
+
await knex.schema.createTable('transactions', table => {
|
|
204
|
+
addTimeStamps(knex, table, dbtype)
|
|
205
|
+
table.increments('transactionId')
|
|
206
|
+
table
|
|
207
|
+
.integer('userId')
|
|
208
|
+
.unsigned()
|
|
209
|
+
.references('userId')
|
|
210
|
+
.inTable('users')
|
|
211
|
+
.notNullable()
|
|
212
|
+
table
|
|
213
|
+
.integer('provenTxId')
|
|
214
|
+
.unsigned()
|
|
215
|
+
.references('provenTxId')
|
|
216
|
+
.inTable('proven_txs')
|
|
217
|
+
table.string('status', 64).notNullable()
|
|
218
|
+
table.string('reference', 64).notNullable().unique()
|
|
219
|
+
table.boolean('isOutgoing').notNullable()
|
|
220
|
+
table.bigint('satoshis').defaultTo(0).notNullable()
|
|
221
|
+
table.integer('version').unsigned().nullable()
|
|
222
|
+
table.integer('lockTime').unsigned().nullable()
|
|
223
|
+
table.string('description', 500).notNullable()
|
|
224
|
+
table.string('txid', 64)
|
|
225
|
+
table.binary('inputBEEF')
|
|
226
|
+
table.binary('rawTx')
|
|
227
|
+
table.index('status')
|
|
228
|
+
})
|
|
229
|
+
await knex.schema.createTable('commissions', table => {
|
|
230
|
+
addTimeStamps(knex, table, dbtype)
|
|
231
|
+
table.increments('commissionId')
|
|
232
|
+
table
|
|
233
|
+
.integer('userId')
|
|
234
|
+
.unsigned()
|
|
235
|
+
.references('userId')
|
|
236
|
+
.inTable('users')
|
|
237
|
+
.notNullable()
|
|
238
|
+
table
|
|
239
|
+
.integer('transactionId')
|
|
240
|
+
.unsigned()
|
|
241
|
+
.references('transactionId')
|
|
242
|
+
.inTable('transactions')
|
|
243
|
+
.notNullable()
|
|
244
|
+
.unique()
|
|
245
|
+
table.integer('satoshis', 15).notNullable()
|
|
246
|
+
table.string('keyOffset', 130).notNullable()
|
|
247
|
+
table.boolean('isRedeemed').defaultTo(false).notNullable()
|
|
248
|
+
table.binary('lockingScript').notNullable()
|
|
249
|
+
table.index('transactionId')
|
|
250
|
+
})
|
|
251
|
+
await knex.schema.createTable('outputs', table => {
|
|
252
|
+
addTimeStamps(knex, table, dbtype)
|
|
253
|
+
table.increments('outputId')
|
|
254
|
+
table
|
|
255
|
+
.integer('userId')
|
|
256
|
+
.unsigned()
|
|
257
|
+
.references('userId')
|
|
258
|
+
.inTable('users')
|
|
259
|
+
.notNullable()
|
|
260
|
+
table
|
|
261
|
+
.integer('transactionId')
|
|
262
|
+
.unsigned()
|
|
263
|
+
.references('transactionId')
|
|
264
|
+
.inTable('transactions')
|
|
265
|
+
.notNullable()
|
|
266
|
+
table
|
|
267
|
+
.integer('basketId')
|
|
268
|
+
.unsigned()
|
|
269
|
+
.references('basketId')
|
|
270
|
+
.inTable('output_baskets')
|
|
271
|
+
table.boolean('spendable').defaultTo(false).notNullable()
|
|
272
|
+
table.boolean('change').defaultTo(false).notNullable()
|
|
273
|
+
table.integer('vout', 10).notNullable()
|
|
274
|
+
table.bigint('satoshis').notNullable()
|
|
275
|
+
table.string('providedBy', 130).notNullable()
|
|
276
|
+
table.string('purpose', 20).notNullable()
|
|
277
|
+
table.string('type', 50).notNullable()
|
|
278
|
+
table.string('outputDescription', 300) // allow extra room for encryption and imports
|
|
279
|
+
table.string('txid', 64)
|
|
280
|
+
table.string('senderIdentityKey', 130)
|
|
281
|
+
table.string('derivationPrefix', 32)
|
|
282
|
+
table.string('derivationSuffix', 32)
|
|
283
|
+
table.string('customInstructions', 2500)
|
|
284
|
+
table
|
|
285
|
+
.integer('spentBy')
|
|
286
|
+
.unsigned()
|
|
287
|
+
.references('transactionId')
|
|
288
|
+
.inTable('transactions')
|
|
289
|
+
table.integer('sequenceNumber').unsigned().nullable()
|
|
290
|
+
table.string('spendingDescription')
|
|
291
|
+
table.bigint('scriptLength').unsigned().nullable()
|
|
292
|
+
table.bigint('scriptOffset').unsigned().nullable()
|
|
293
|
+
table.binary('lockingScript')
|
|
294
|
+
table.unique(['transactionId', 'vout', 'userId'])
|
|
295
|
+
})
|
|
296
|
+
await knex.schema.createTable('output_tags', table => {
|
|
297
|
+
addTimeStamps(knex, table, dbtype)
|
|
298
|
+
table.increments('outputTagId')
|
|
299
|
+
table
|
|
300
|
+
.integer('userId')
|
|
301
|
+
.unsigned()
|
|
302
|
+
.references('userId')
|
|
303
|
+
.inTable('users')
|
|
304
|
+
.notNullable()
|
|
305
|
+
table.string('tag', 150).notNullable()
|
|
306
|
+
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
307
|
+
table.unique(['tag', 'userId'])
|
|
308
|
+
})
|
|
309
|
+
await knex.schema.createTable('output_tags_map', table => {
|
|
310
|
+
addTimeStamps(knex, table, dbtype)
|
|
311
|
+
table
|
|
312
|
+
.integer('outputTagId')
|
|
313
|
+
.unsigned()
|
|
314
|
+
.references('outputTagId')
|
|
315
|
+
.inTable('output_tags')
|
|
316
|
+
.notNullable()
|
|
317
|
+
table
|
|
318
|
+
.integer('outputId')
|
|
319
|
+
.unsigned()
|
|
320
|
+
.references('outputId')
|
|
321
|
+
.inTable('outputs')
|
|
322
|
+
.notNullable()
|
|
323
|
+
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
324
|
+
table.unique(['outputTagId', 'outputId'])
|
|
325
|
+
table.index('outputId')
|
|
326
|
+
})
|
|
327
|
+
await knex.schema.createTable('tx_labels', table => {
|
|
328
|
+
addTimeStamps(knex, table, dbtype)
|
|
329
|
+
table.increments('txLabelId')
|
|
330
|
+
table
|
|
331
|
+
.integer('userId')
|
|
332
|
+
.unsigned()
|
|
333
|
+
.references('userId')
|
|
334
|
+
.inTable('users')
|
|
335
|
+
.notNullable()
|
|
336
|
+
table.string('label', 300).notNullable()
|
|
337
|
+
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
338
|
+
table.unique(['label', 'userId'])
|
|
339
|
+
})
|
|
340
|
+
await knex.schema.createTable('tx_labels_map', table => {
|
|
341
|
+
addTimeStamps(knex, table, dbtype)
|
|
342
|
+
table
|
|
343
|
+
.integer('txLabelId')
|
|
344
|
+
.unsigned()
|
|
345
|
+
.references('txLabelId')
|
|
346
|
+
.inTable('tx_labels')
|
|
347
|
+
.notNullable()
|
|
348
|
+
table
|
|
349
|
+
.integer('transactionId')
|
|
350
|
+
.unsigned()
|
|
351
|
+
.references('transactionId')
|
|
352
|
+
.inTable('transactions')
|
|
353
|
+
.notNullable()
|
|
354
|
+
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
355
|
+
table.unique(['txLabelId', 'transactionId'])
|
|
356
|
+
table.index('transactionId')
|
|
357
|
+
})
|
|
358
|
+
await knex.schema.createTable('monitor_events', table => {
|
|
359
|
+
addTimeStamps(knex, table, dbtype)
|
|
360
|
+
table.increments('id')
|
|
361
|
+
table.string('event', 64).notNullable()
|
|
362
|
+
table.text('details', 'longtext').nullable()
|
|
363
|
+
})
|
|
364
|
+
await knex.schema.createTable('settings', table => {
|
|
365
|
+
addTimeStamps(knex, table, dbtype)
|
|
366
|
+
table.string('storageIdentityKey', 130).notNullable()
|
|
367
|
+
table.string('storageName', 128).notNullable()
|
|
368
|
+
table.string('chain', 10).notNullable()
|
|
369
|
+
table.string('dbtype', 10).notNullable()
|
|
370
|
+
table.integer('maxOutputScript', 15).notNullable()
|
|
371
|
+
})
|
|
372
|
+
await knex.schema.createTable('sync_states', table => {
|
|
373
|
+
addTimeStamps(knex, table, dbtype)
|
|
374
|
+
table.increments('syncStateId')
|
|
375
|
+
table
|
|
376
|
+
.integer('userId')
|
|
377
|
+
.unsigned()
|
|
378
|
+
.notNullable()
|
|
379
|
+
.references('userId')
|
|
380
|
+
.inTable('users')
|
|
381
|
+
table.string('storageIdentityKey', 130).notNullable().defaultTo('')
|
|
382
|
+
table.string('storageName').notNullable()
|
|
383
|
+
table.string('status').notNullable().defaultTo('unknown')
|
|
384
|
+
table.boolean('init').notNullable().defaultTo(false)
|
|
385
|
+
table.string('refNum', 100).notNullable().unique()
|
|
386
|
+
table.text('syncMap', 'longtext').notNullable()
|
|
387
|
+
table.dateTime('when')
|
|
388
|
+
table.bigint('satoshis')
|
|
389
|
+
table.text('errorLocal', 'longtext')
|
|
390
|
+
table.text('errorOther', 'longtext')
|
|
391
|
+
table.index('status')
|
|
392
|
+
table.index('refNum')
|
|
393
|
+
})
|
|
394
|
+
|
|
395
|
+
if (dbtype === 'MySQL') {
|
|
396
|
+
await knex.raw(
|
|
397
|
+
'ALTER TABLE proven_tx_reqs MODIFY COLUMN rawTx LONGBLOB'
|
|
398
|
+
)
|
|
399
|
+
await knex.raw(
|
|
400
|
+
'ALTER TABLE proven_tx_reqs MODIFY COLUMN inputBEEF LONGBLOB'
|
|
401
|
+
)
|
|
402
|
+
await knex.raw('ALTER TABLE proven_txs MODIFY COLUMN rawTx LONGBLOB')
|
|
403
|
+
await knex.raw(
|
|
404
|
+
'ALTER TABLE transactions MODIFY COLUMN rawTx LONGBLOB'
|
|
405
|
+
)
|
|
406
|
+
await knex.raw(
|
|
407
|
+
'ALTER TABLE transactions MODIFY COLUMN inputBEEF LONGBLOB'
|
|
408
|
+
)
|
|
409
|
+
await knex.raw(
|
|
410
|
+
'ALTER TABLE outputs MODIFY COLUMN lockingScript LONGBLOB'
|
|
411
|
+
)
|
|
412
|
+
} else {
|
|
413
|
+
await knex.schema.alterTable('proven_tx_reqs', table => {
|
|
414
|
+
table.binary('rawTx', 10000000).alter()
|
|
415
|
+
table.binary('beef', 10000000).alter()
|
|
416
|
+
})
|
|
417
|
+
await knex.schema.alterTable('outputs', table => {
|
|
418
|
+
table.binary('lockingScript', 10000000).alter()
|
|
419
|
+
})
|
|
420
|
+
await knex.schema.alterTable('proven_txs', table => {
|
|
421
|
+
table.binary('rawTx', 10000000).alter()
|
|
422
|
+
})
|
|
423
|
+
await knex.schema.alterTable('transactions', table => {
|
|
424
|
+
table.binary('rawTx', 10000000).alter()
|
|
425
|
+
table.binary('beef', 10000000).alter()
|
|
426
|
+
})
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
await knex('settings').insert({
|
|
430
|
+
storageIdentityKey,
|
|
431
|
+
storageName,
|
|
432
|
+
chain,
|
|
433
|
+
dbtype,
|
|
434
|
+
maxOutputScript: maxOutputScriptLength
|
|
435
|
+
})
|
|
436
|
+
},
|
|
437
|
+
async down(knex) {
|
|
438
|
+
await knex.schema.dropTable('sync_states')
|
|
439
|
+
await knex.schema.dropTable('settings')
|
|
440
|
+
await knex.schema.dropTable('monitor_events')
|
|
441
|
+
await knex.schema.dropTable('certificate_fields')
|
|
442
|
+
await knex.schema.dropTable('certificates')
|
|
443
|
+
await knex.schema.dropTable('commissions')
|
|
444
|
+
await knex.schema.dropTable('output_tags_map')
|
|
445
|
+
await knex.schema.dropTable('output_tags')
|
|
446
|
+
await knex.schema.dropTable('outputs')
|
|
447
|
+
await knex.schema.dropTable('output_baskets')
|
|
448
|
+
await knex.schema.dropTable('tx_labels_map')
|
|
449
|
+
await knex.schema.dropTable('tx_labels')
|
|
450
|
+
await knex.schema.dropTable('transactions')
|
|
451
|
+
await knex.schema.dropTable('users')
|
|
452
|
+
await knex.schema.dropTable('proven_tx_reqs')
|
|
453
|
+
await knex.schema.dropTable('proven_txs')
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return migrations
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* @param knex
|
|
461
|
+
* @returns {DBType} connected database engine variant
|
|
462
|
+
*/
|
|
463
|
+
static async dbtype(knex: Knex<any, any[]>): Promise<DBType> {
|
|
464
|
+
try {
|
|
465
|
+
const q = `SELECT
|
|
466
|
+
CASE
|
|
467
|
+
WHEN (SELECT VERSION() LIKE '%MariaDB%') = 1 THEN 'Unknown'
|
|
468
|
+
WHEN (SELECT VERSION()) IS NOT NULL THEN 'MySQL'
|
|
469
|
+
ELSE 'Unknown'
|
|
470
|
+
END AS database_type;`
|
|
471
|
+
let r = await knex.raw(q)
|
|
472
|
+
if (!r[0]['database_type']) r = r[0]
|
|
473
|
+
if (r['rows']) r = r.rows
|
|
474
|
+
const dbtype: 'SQLite' | 'MySQL' | 'Unknown' = r[0].database_type
|
|
475
|
+
if (dbtype === 'Unknown')
|
|
476
|
+
throw new sdk.WERR_NOT_IMPLEMENTED(
|
|
477
|
+
`Attempting to create database on unsuported engine.`
|
|
478
|
+
)
|
|
479
|
+
return dbtype
|
|
480
|
+
} catch (eu: unknown) {
|
|
481
|
+
const e = sdk.WalletError.fromUnknown(eu)
|
|
482
|
+
if (e.code === 'SQLITE_ERROR') return 'SQLite'
|
|
483
|
+
throw new sdk.WERR_NOT_IMPLEMENTED(
|
|
484
|
+
`Attempting to create database on unsuported engine.`
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|