@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,1035 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageKnex = void 0;
|
|
4
|
+
const index_all_1 = require("../index.all");
|
|
5
|
+
const index_all_2 = require("./index.all");
|
|
6
|
+
const StorageProvider_1 = require("./StorageProvider");
|
|
7
|
+
const purgeData_1 = require("./methods/purgeData");
|
|
8
|
+
const listActions_1 = require("./methods/listActions");
|
|
9
|
+
const listOutputs_1 = require("./methods/listOutputs");
|
|
10
|
+
const reviewStatus_1 = require("./methods/reviewStatus");
|
|
11
|
+
class StorageKnex extends StorageProvider_1.StorageProvider {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
this._verifiedReadyForDatabaseAccess = false;
|
|
15
|
+
if (!options.knex)
|
|
16
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('options.knex', `valid`);
|
|
17
|
+
this.knex = options.knex;
|
|
18
|
+
}
|
|
19
|
+
async readSettings() {
|
|
20
|
+
return this.validateEntity((0, index_all_1.verifyOne)(await this.toDb(undefined)('settings')));
|
|
21
|
+
}
|
|
22
|
+
async getProvenOrRawTx(txid, trx) {
|
|
23
|
+
const k = this.toDb(trx);
|
|
24
|
+
const r = {
|
|
25
|
+
proven: undefined,
|
|
26
|
+
rawTx: undefined,
|
|
27
|
+
inputBEEF: undefined
|
|
28
|
+
};
|
|
29
|
+
r.proven = (0, index_all_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid: txid } }));
|
|
30
|
+
if (!r.proven) {
|
|
31
|
+
const reqRawTx = (0, index_all_1.verifyOneOrNone)(await k('proven_tx_reqs')
|
|
32
|
+
.where('txid', txid)
|
|
33
|
+
.whereIn('status', [
|
|
34
|
+
'unsent',
|
|
35
|
+
'unmined',
|
|
36
|
+
'unconfirmed',
|
|
37
|
+
'sending',
|
|
38
|
+
'nosend',
|
|
39
|
+
'completed'
|
|
40
|
+
])
|
|
41
|
+
.select('rawTx', 'inputBEEF'));
|
|
42
|
+
if (reqRawTx) {
|
|
43
|
+
r.rawTx = Array.from(reqRawTx.rawTx);
|
|
44
|
+
r.inputBEEF = Array.from(reqRawTx.inputBEEF);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return r;
|
|
48
|
+
}
|
|
49
|
+
dbTypeSubstring(source, fromOffset, forLength) {
|
|
50
|
+
if (this.dbtype === 'MySQL')
|
|
51
|
+
return `substring(${source} from ${fromOffset} for ${forLength})`;
|
|
52
|
+
return `substr(${source}, ${fromOffset}, ${forLength})`;
|
|
53
|
+
}
|
|
54
|
+
async getRawTxOfKnownValidTransaction(txid, offset, length, trx) {
|
|
55
|
+
if (!txid)
|
|
56
|
+
return undefined;
|
|
57
|
+
let rawTx = undefined;
|
|
58
|
+
if (Number.isInteger(offset) && Number.isInteger(length)) {
|
|
59
|
+
let rs = await this.toDb(trx).raw(`select ${this.dbTypeSubstring('rawTx', offset + 1, length)} as rawTx from proven_txs where txid = '${txid}'`);
|
|
60
|
+
if (this.dbtype === 'MySQL')
|
|
61
|
+
rs = rs[0];
|
|
62
|
+
const r = (0, index_all_1.verifyOneOrNone)(rs);
|
|
63
|
+
if (r && r.rawTx) {
|
|
64
|
+
rawTx = Array.from(r.rawTx);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
let rs = await this.toDb(trx).raw(`select ${this.dbTypeSubstring('rawTx', offset + 1, length)} as rawTx from proven_tx_reqs where txid = '${txid}' and status in ('unsent', 'nosend', 'sending', 'unmined', 'completed')`);
|
|
68
|
+
if (this.dbtype === 'MySQL')
|
|
69
|
+
rs = rs[0];
|
|
70
|
+
const r = (0, index_all_1.verifyOneOrNone)(rs);
|
|
71
|
+
if (r && r.rawTx) {
|
|
72
|
+
rawTx = Array.from(r.rawTx);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const r = await this.getProvenOrRawTx(txid, trx);
|
|
78
|
+
if (r.proven)
|
|
79
|
+
rawTx = r.proven.rawTx;
|
|
80
|
+
else
|
|
81
|
+
rawTx = r.rawTx;
|
|
82
|
+
}
|
|
83
|
+
return rawTx;
|
|
84
|
+
}
|
|
85
|
+
getProvenTxsForUserQuery(args) {
|
|
86
|
+
const k = this.toDb(args.trx);
|
|
87
|
+
let q = k('proven_txs').where(function () {
|
|
88
|
+
this.whereExists(k
|
|
89
|
+
.select('*')
|
|
90
|
+
.from('transactions')
|
|
91
|
+
.whereRaw(`proven_txs.provenTxId = transactions.provenTxId and transactions.userId = ${args.userId}`));
|
|
92
|
+
});
|
|
93
|
+
if (args.paged) {
|
|
94
|
+
q = q.limit(args.paged.limit);
|
|
95
|
+
q = q.offset(args.paged.offset || 0);
|
|
96
|
+
}
|
|
97
|
+
if (args.since)
|
|
98
|
+
q = q.where('updated_at', '>=', args.since);
|
|
99
|
+
return q;
|
|
100
|
+
}
|
|
101
|
+
async getProvenTxsForUser(args) {
|
|
102
|
+
const q = this.getProvenTxsForUserQuery(args);
|
|
103
|
+
const rs = await q;
|
|
104
|
+
return this.validateEntities(rs);
|
|
105
|
+
}
|
|
106
|
+
getProvenTxReqsForUserQuery(args) {
|
|
107
|
+
const k = this.toDb(args.trx);
|
|
108
|
+
let q = k('proven_tx_reqs').where(function () {
|
|
109
|
+
this.whereExists(k
|
|
110
|
+
.select('*')
|
|
111
|
+
.from('transactions')
|
|
112
|
+
.whereRaw(`proven_tx_reqs.txid = transactions.txid and transactions.userId = ${args.userId}`));
|
|
113
|
+
});
|
|
114
|
+
if (args.paged) {
|
|
115
|
+
q = q.limit(args.paged.limit);
|
|
116
|
+
q = q.offset(args.paged.offset || 0);
|
|
117
|
+
}
|
|
118
|
+
if (args.since)
|
|
119
|
+
q = q.where('updated_at', '>=', args.since);
|
|
120
|
+
return q;
|
|
121
|
+
}
|
|
122
|
+
async getProvenTxReqsForUser(args) {
|
|
123
|
+
const q = this.getProvenTxReqsForUserQuery(args);
|
|
124
|
+
const rs = await q;
|
|
125
|
+
return this.validateEntities(rs, undefined, ['notified']);
|
|
126
|
+
}
|
|
127
|
+
getTxLabelMapsForUserQuery(args) {
|
|
128
|
+
const k = this.toDb(args.trx);
|
|
129
|
+
let q = k('tx_labels_map').whereExists(k
|
|
130
|
+
.select('*')
|
|
131
|
+
.from('tx_labels')
|
|
132
|
+
.whereRaw(`tx_labels.txLabelId = tx_labels_map.txLabelId and tx_labels.userId = ${args.userId}`));
|
|
133
|
+
if (args.since)
|
|
134
|
+
q = q.where('updated_at', '>=', this.validateDateForWhere(args.since));
|
|
135
|
+
if (args.paged) {
|
|
136
|
+
q = q.limit(args.paged.limit);
|
|
137
|
+
q = q.offset(args.paged.offset || 0);
|
|
138
|
+
}
|
|
139
|
+
return q;
|
|
140
|
+
}
|
|
141
|
+
async getTxLabelMapsForUser(args) {
|
|
142
|
+
const q = this.getTxLabelMapsForUserQuery(args);
|
|
143
|
+
const rs = await q;
|
|
144
|
+
return this.validateEntities(rs, undefined, ['isDeleted']);
|
|
145
|
+
}
|
|
146
|
+
getOutputTagMapsForUserQuery(args) {
|
|
147
|
+
const k = this.toDb(args.trx);
|
|
148
|
+
let q = k('output_tags_map').whereExists(k
|
|
149
|
+
.select('*')
|
|
150
|
+
.from('output_tags')
|
|
151
|
+
.whereRaw(`output_tags.outputTagId = output_tags_map.outputTagId and output_tags.userId = ${args.userId}`));
|
|
152
|
+
if (args.since)
|
|
153
|
+
q = q.where('updated_at', '>=', this.validateDateForWhere(args.since));
|
|
154
|
+
if (args.paged) {
|
|
155
|
+
q = q.limit(args.paged.limit);
|
|
156
|
+
q = q.offset(args.paged.offset || 0);
|
|
157
|
+
}
|
|
158
|
+
return q;
|
|
159
|
+
}
|
|
160
|
+
async getOutputTagMapsForUser(args) {
|
|
161
|
+
const q = this.getOutputTagMapsForUserQuery(args);
|
|
162
|
+
const rs = await q;
|
|
163
|
+
return this.validateEntities(rs, undefined, ['isDeleted']);
|
|
164
|
+
}
|
|
165
|
+
async listActions(auth, vargs) {
|
|
166
|
+
if (!auth.userId)
|
|
167
|
+
throw new index_all_1.sdk.WERR_UNAUTHORIZED();
|
|
168
|
+
return await (0, listActions_1.listActions)(this, auth, vargs);
|
|
169
|
+
}
|
|
170
|
+
async listOutputs(auth, vargs) {
|
|
171
|
+
if (!auth.userId)
|
|
172
|
+
throw new index_all_1.sdk.WERR_UNAUTHORIZED();
|
|
173
|
+
return await (0, listOutputs_1.listOutputs)(this, auth, vargs);
|
|
174
|
+
}
|
|
175
|
+
async insertProvenTx(tx, trx) {
|
|
176
|
+
const e = await this.validateEntityForInsert(tx, trx);
|
|
177
|
+
if (e.provenTxId === 0)
|
|
178
|
+
delete e.provenTxId;
|
|
179
|
+
const [id] = await this.toDb(trx)('proven_txs').insert(e);
|
|
180
|
+
tx.provenTxId = id;
|
|
181
|
+
return tx.provenTxId;
|
|
182
|
+
}
|
|
183
|
+
async insertProvenTxReq(tx, trx) {
|
|
184
|
+
const e = await this.validateEntityForInsert(tx, trx);
|
|
185
|
+
if (e.provenTxReqId === 0)
|
|
186
|
+
delete e.provenTxReqId;
|
|
187
|
+
const [id] = await this.toDb(trx)('proven_tx_reqs').insert(e);
|
|
188
|
+
tx.provenTxReqId = id;
|
|
189
|
+
return tx.provenTxReqId;
|
|
190
|
+
}
|
|
191
|
+
async insertUser(user, trx) {
|
|
192
|
+
const e = await this.validateEntityForInsert(user, trx);
|
|
193
|
+
if (e.userId === 0)
|
|
194
|
+
delete e.userId;
|
|
195
|
+
const [id] = await this.toDb(trx)('users').insert(e);
|
|
196
|
+
user.userId = id;
|
|
197
|
+
return user.userId;
|
|
198
|
+
}
|
|
199
|
+
async insertCertificateAuth(auth, certificate) {
|
|
200
|
+
if (!auth.userId ||
|
|
201
|
+
(certificate.userId && certificate.userId !== auth.userId))
|
|
202
|
+
throw new index_all_1.sdk.WERR_UNAUTHORIZED();
|
|
203
|
+
certificate.userId = auth.userId;
|
|
204
|
+
return await this.insertCertificate(certificate);
|
|
205
|
+
}
|
|
206
|
+
async insertCertificate(certificate, trx) {
|
|
207
|
+
const e = await this.validateEntityForInsert(certificate, trx, undefined, [
|
|
208
|
+
'isDeleted'
|
|
209
|
+
]);
|
|
210
|
+
const fields = e.fields;
|
|
211
|
+
if (e.fields)
|
|
212
|
+
delete e.fields;
|
|
213
|
+
if (e.certificateId === 0)
|
|
214
|
+
delete e.certificateId;
|
|
215
|
+
const [id] = await this.toDb(trx)('certificates').insert(e);
|
|
216
|
+
certificate.certificateId = id;
|
|
217
|
+
if (fields) {
|
|
218
|
+
for (const field of fields) {
|
|
219
|
+
field.certificateId = id;
|
|
220
|
+
field.userId = certificate.userId;
|
|
221
|
+
await this.insertCertificateField(field, trx);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return certificate.certificateId;
|
|
225
|
+
}
|
|
226
|
+
async insertCertificateField(certificateField, trx) {
|
|
227
|
+
const e = await this.validateEntityForInsert(certificateField, trx);
|
|
228
|
+
await this.toDb(trx)('certificate_fields').insert(e);
|
|
229
|
+
}
|
|
230
|
+
async insertOutputBasket(basket, trx) {
|
|
231
|
+
const e = await this.validateEntityForInsert(basket, trx, undefined, [
|
|
232
|
+
'isDeleted'
|
|
233
|
+
]);
|
|
234
|
+
if (e.basketId === 0)
|
|
235
|
+
delete e.basketId;
|
|
236
|
+
const [id] = await this.toDb(trx)('output_baskets').insert(e);
|
|
237
|
+
basket.basketId = id;
|
|
238
|
+
return basket.basketId;
|
|
239
|
+
}
|
|
240
|
+
async insertTransaction(tx, trx) {
|
|
241
|
+
const e = await this.validateEntityForInsert(tx, trx);
|
|
242
|
+
if (e.transactionId === 0)
|
|
243
|
+
delete e.transactionId;
|
|
244
|
+
const [id] = await this.toDb(trx)('transactions').insert(e);
|
|
245
|
+
tx.transactionId = id;
|
|
246
|
+
return tx.transactionId;
|
|
247
|
+
}
|
|
248
|
+
async insertCommission(commission, trx) {
|
|
249
|
+
const e = await this.validateEntityForInsert(commission, trx);
|
|
250
|
+
if (e.commissionId === 0)
|
|
251
|
+
delete e.commissionId;
|
|
252
|
+
const [id] = await this.toDb(trx)('commissions').insert(e);
|
|
253
|
+
commission.commissionId = id;
|
|
254
|
+
return commission.commissionId;
|
|
255
|
+
}
|
|
256
|
+
async insertOutput(output, trx) {
|
|
257
|
+
const e = await this.validateEntityForInsert(output, trx);
|
|
258
|
+
if (e.outputId === 0)
|
|
259
|
+
delete e.outputId;
|
|
260
|
+
const [id] = await this.toDb(trx)('outputs').insert(e);
|
|
261
|
+
output.outputId = id;
|
|
262
|
+
return output.outputId;
|
|
263
|
+
}
|
|
264
|
+
async insertOutputTag(tag, trx) {
|
|
265
|
+
const e = await this.validateEntityForInsert(tag, trx, undefined, [
|
|
266
|
+
'isDeleted'
|
|
267
|
+
]);
|
|
268
|
+
if (e.outputTagId === 0)
|
|
269
|
+
delete e.outputTagId;
|
|
270
|
+
const [id] = await this.toDb(trx)('output_tags').insert(e);
|
|
271
|
+
tag.outputTagId = id;
|
|
272
|
+
return tag.outputTagId;
|
|
273
|
+
}
|
|
274
|
+
async insertOutputTagMap(tagMap, trx) {
|
|
275
|
+
const e = await this.validateEntityForInsert(tagMap, trx, undefined, [
|
|
276
|
+
'isDeleted'
|
|
277
|
+
]);
|
|
278
|
+
const [id] = await this.toDb(trx)('output_tags_map').insert(e);
|
|
279
|
+
}
|
|
280
|
+
async insertTxLabel(label, trx) {
|
|
281
|
+
const e = await this.validateEntityForInsert(label, trx, undefined, [
|
|
282
|
+
'isDeleted'
|
|
283
|
+
]);
|
|
284
|
+
if (e.txLabelId === 0)
|
|
285
|
+
delete e.txLabelId;
|
|
286
|
+
const [id] = await this.toDb(trx)('tx_labels').insert(e);
|
|
287
|
+
label.txLabelId = id;
|
|
288
|
+
return label.txLabelId;
|
|
289
|
+
}
|
|
290
|
+
async insertTxLabelMap(labelMap, trx) {
|
|
291
|
+
const e = await this.validateEntityForInsert(labelMap, trx, undefined, [
|
|
292
|
+
'isDeleted'
|
|
293
|
+
]);
|
|
294
|
+
const [id] = await this.toDb(trx)('tx_labels_map').insert(e);
|
|
295
|
+
}
|
|
296
|
+
async insertMonitorEvent(event, trx) {
|
|
297
|
+
const e = await this.validateEntityForInsert(event, trx);
|
|
298
|
+
if (e.id === 0)
|
|
299
|
+
delete e.id;
|
|
300
|
+
const [id] = await this.toDb(trx)('monitor_events').insert(e);
|
|
301
|
+
event.id = id;
|
|
302
|
+
return event.id;
|
|
303
|
+
}
|
|
304
|
+
async insertSyncState(syncState, trx) {
|
|
305
|
+
const e = await this.validateEntityForInsert(syncState, trx, ['when'], ['init']);
|
|
306
|
+
if (e.syncStateId === 0)
|
|
307
|
+
delete e.syncStateId;
|
|
308
|
+
const [id] = await this.toDb(trx)('sync_states').insert(e);
|
|
309
|
+
syncState.syncStateId = id;
|
|
310
|
+
return syncState.syncStateId;
|
|
311
|
+
}
|
|
312
|
+
async updateCertificateField(certificateId, fieldName, update, trx) {
|
|
313
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
314
|
+
return await this.toDb(trx)('certificate_fields')
|
|
315
|
+
.where({ certificateId, fieldName })
|
|
316
|
+
.update(this.validatePartialForUpdate(update));
|
|
317
|
+
}
|
|
318
|
+
async updateCertificate(id, update, trx) {
|
|
319
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
320
|
+
return await this.toDb(trx)('certificates')
|
|
321
|
+
.where({ certificateId: id })
|
|
322
|
+
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']));
|
|
323
|
+
}
|
|
324
|
+
async updateCommission(id, update, trx) {
|
|
325
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
326
|
+
return await this.toDb(trx)('commissions')
|
|
327
|
+
.where({ commissionId: id })
|
|
328
|
+
.update(this.validatePartialForUpdate(update));
|
|
329
|
+
}
|
|
330
|
+
async updateOutputBasket(id, update, trx) {
|
|
331
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
332
|
+
return await this.toDb(trx)('output_baskets')
|
|
333
|
+
.where({ basketId: id })
|
|
334
|
+
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']));
|
|
335
|
+
}
|
|
336
|
+
async updateOutput(id, update, trx) {
|
|
337
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
338
|
+
return await this.toDb(trx)('outputs')
|
|
339
|
+
.where({ outputId: id })
|
|
340
|
+
.update(this.validatePartialForUpdate(update));
|
|
341
|
+
}
|
|
342
|
+
async updateOutputTagMap(outputId, tagId, update, trx) {
|
|
343
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
344
|
+
return await this.toDb(trx)('output_tags_map')
|
|
345
|
+
.where({ outputId, outputTagId: tagId })
|
|
346
|
+
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']));
|
|
347
|
+
}
|
|
348
|
+
async updateOutputTag(id, update, trx) {
|
|
349
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
350
|
+
return await this.toDb(trx)('output_tags')
|
|
351
|
+
.where({ outputTagId: id })
|
|
352
|
+
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']));
|
|
353
|
+
}
|
|
354
|
+
async updateProvenTxReq(id, update, trx) {
|
|
355
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
356
|
+
let r;
|
|
357
|
+
if (Array.isArray(id)) {
|
|
358
|
+
r = await this.toDb(trx)('proven_tx_reqs')
|
|
359
|
+
.whereIn('provenTxReqId', id)
|
|
360
|
+
.update(this.validatePartialForUpdate(update));
|
|
361
|
+
}
|
|
362
|
+
else if (Number.isInteger(id)) {
|
|
363
|
+
r = await this.toDb(trx)('proven_tx_reqs')
|
|
364
|
+
.where({ provenTxReqId: id })
|
|
365
|
+
.update(this.validatePartialForUpdate(update));
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('id', 'transactionId or array of transactionId');
|
|
369
|
+
}
|
|
370
|
+
return r;
|
|
371
|
+
}
|
|
372
|
+
async updateProvenTx(id, update, trx) {
|
|
373
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
374
|
+
return await this.toDb(trx)('proven_txs')
|
|
375
|
+
.where({ provenTxId: id })
|
|
376
|
+
.update(this.validatePartialForUpdate(update));
|
|
377
|
+
}
|
|
378
|
+
async updateSyncState(id, update, trx) {
|
|
379
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
380
|
+
return await this.toDb(trx)('sync_states')
|
|
381
|
+
.where({ syncStateId: id })
|
|
382
|
+
.update(this.validatePartialForUpdate(update, ['when'], ['init']));
|
|
383
|
+
}
|
|
384
|
+
async updateTransaction(id, update, trx) {
|
|
385
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
386
|
+
let r;
|
|
387
|
+
if (Array.isArray(id)) {
|
|
388
|
+
r = await this.toDb(trx)('transactions')
|
|
389
|
+
.whereIn('transactionId', id)
|
|
390
|
+
.update(await this.validatePartialForUpdate(update));
|
|
391
|
+
}
|
|
392
|
+
else if (Number.isInteger(id)) {
|
|
393
|
+
r = await this.toDb(trx)('transactions')
|
|
394
|
+
.where({ transactionId: id })
|
|
395
|
+
.update(await this.validatePartialForUpdate(update));
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('id', 'transactionId or array of transactionId');
|
|
399
|
+
}
|
|
400
|
+
return r;
|
|
401
|
+
}
|
|
402
|
+
async updateTxLabelMap(transactionId, txLabelId, update, trx) {
|
|
403
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
404
|
+
return await this.toDb(trx)('tx_labels_map')
|
|
405
|
+
.where({ transactionId, txLabelId })
|
|
406
|
+
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']));
|
|
407
|
+
}
|
|
408
|
+
async updateTxLabel(id, update, trx) {
|
|
409
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
410
|
+
return await this.toDb(trx)('tx_labels')
|
|
411
|
+
.where({ txLabelId: id })
|
|
412
|
+
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']));
|
|
413
|
+
}
|
|
414
|
+
async updateUser(id, update, trx) {
|
|
415
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
416
|
+
return await this.toDb(trx)('users')
|
|
417
|
+
.where({ userId: id })
|
|
418
|
+
.update(this.validatePartialForUpdate(update));
|
|
419
|
+
}
|
|
420
|
+
async updateMonitorEvent(id, update, trx) {
|
|
421
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
422
|
+
return await this.toDb(trx)('monitor_events')
|
|
423
|
+
.where({ id })
|
|
424
|
+
.update(this.validatePartialForUpdate(update));
|
|
425
|
+
}
|
|
426
|
+
setupQuery(table, args) {
|
|
427
|
+
let q = this.toDb(args.trx)(table);
|
|
428
|
+
if (args.partial && Object.keys(args.partial).length > 0)
|
|
429
|
+
q.where(args.partial);
|
|
430
|
+
if (args.since)
|
|
431
|
+
q.where('updated_at', '>=', this.validateDateForWhere(args.since));
|
|
432
|
+
if (args.paged) {
|
|
433
|
+
q.limit(args.paged.limit);
|
|
434
|
+
q.offset(args.paged.offset || 0);
|
|
435
|
+
}
|
|
436
|
+
return q;
|
|
437
|
+
}
|
|
438
|
+
findCertificateFieldsQuery(args) {
|
|
439
|
+
return this.setupQuery('certificate_fields', args);
|
|
440
|
+
}
|
|
441
|
+
findCertificatesQuery(args) {
|
|
442
|
+
const q = this.setupQuery('certificates', args);
|
|
443
|
+
if (args.certifiers && args.certifiers.length > 0)
|
|
444
|
+
q.whereIn('certifier', args.certifiers);
|
|
445
|
+
if (args.types && args.types.length > 0)
|
|
446
|
+
q.whereIn('type', args.types);
|
|
447
|
+
return q;
|
|
448
|
+
}
|
|
449
|
+
findCommissionsQuery(args) {
|
|
450
|
+
if (args.partial.lockingScript)
|
|
451
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('partial.lockingScript', `undefined. Commissions may not be found by lockingScript value.`);
|
|
452
|
+
return this.setupQuery('commissions', args);
|
|
453
|
+
}
|
|
454
|
+
findOutputBasketsQuery(args) {
|
|
455
|
+
return this.setupQuery('output_baskets', args);
|
|
456
|
+
}
|
|
457
|
+
findOutputsQuery(args, count) {
|
|
458
|
+
if (args.partial.lockingScript)
|
|
459
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.lockingScript', `undefined. Outputs may not be found by lockingScript value.`);
|
|
460
|
+
const q = this.setupQuery('outputs', args);
|
|
461
|
+
if (args.txStatus && args.txStatus.length > 0) {
|
|
462
|
+
q.whereRaw(`(select status from transactions where transactions.transactionId = outputs.transactionId) in (${args.txStatus.map(s => `'${s}'`).join(',')})`);
|
|
463
|
+
}
|
|
464
|
+
if (args.noScript && !count) {
|
|
465
|
+
const columns = index_all_2.table.outputColumnsWithoutLockingScript.map(c => `outputs.${c}`);
|
|
466
|
+
q.select(columns);
|
|
467
|
+
}
|
|
468
|
+
return q;
|
|
469
|
+
}
|
|
470
|
+
findOutputTagMapsQuery(args) {
|
|
471
|
+
const q = this.setupQuery('output_tags_map', args);
|
|
472
|
+
if (args.tagIds && args.tagIds.length > 0)
|
|
473
|
+
q.whereIn('outputTagId', args.tagIds);
|
|
474
|
+
return q;
|
|
475
|
+
}
|
|
476
|
+
findOutputTagsQuery(args) {
|
|
477
|
+
return this.setupQuery('output_tags', args);
|
|
478
|
+
}
|
|
479
|
+
findProvenTxReqsQuery(args) {
|
|
480
|
+
if (args.partial.rawTx)
|
|
481
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. ProvenTxReqs may not be found by rawTx value.`);
|
|
482
|
+
if (args.partial.inputBEEF)
|
|
483
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.inputBEEF', `undefined. ProvenTxReqs may not be found by inputBEEF value.`);
|
|
484
|
+
const q = this.setupQuery('proven_tx_reqs', args);
|
|
485
|
+
if (args.status && args.status.length > 0)
|
|
486
|
+
q.whereIn('status', args.status);
|
|
487
|
+
if (args.txids && args.txids.length > 0)
|
|
488
|
+
q.whereIn('txid', args.txids);
|
|
489
|
+
return q;
|
|
490
|
+
}
|
|
491
|
+
findProvenTxsQuery(args) {
|
|
492
|
+
if (args.partial.rawTx)
|
|
493
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. ProvenTxs may not be found by rawTx value.`);
|
|
494
|
+
if (args.partial.merklePath)
|
|
495
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.merklePath', `undefined. ProvenTxs may not be found by merklePath value.`);
|
|
496
|
+
return this.setupQuery('proven_txs', args);
|
|
497
|
+
}
|
|
498
|
+
findSyncStatesQuery(args) {
|
|
499
|
+
return this.setupQuery('sync_states', args);
|
|
500
|
+
}
|
|
501
|
+
findTransactionsQuery(args, count) {
|
|
502
|
+
if (args.partial.rawTx)
|
|
503
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. Transactions may not be found by rawTx value.`);
|
|
504
|
+
if (args.partial.inputBEEF)
|
|
505
|
+
throw new index_all_1.sdk.WERR_INVALID_PARAMETER('args.partial.inputBEEF', `undefined. Transactions may not be found by inputBEEF value.`);
|
|
506
|
+
const q = this.setupQuery('transactions', args);
|
|
507
|
+
if (args.status && args.status.length > 0)
|
|
508
|
+
q.whereIn('status', args.status);
|
|
509
|
+
if (args.noRawTx && !count) {
|
|
510
|
+
const columns = index_all_2.table.transactionColumnsWithoutRawTx.map(c => `transactions.${c}`);
|
|
511
|
+
q.select(columns);
|
|
512
|
+
}
|
|
513
|
+
return q;
|
|
514
|
+
}
|
|
515
|
+
findTxLabelMapsQuery(args) {
|
|
516
|
+
const q = this.setupQuery('tx_labels_map', args);
|
|
517
|
+
if (args.labelIds && args.labelIds.length > 0)
|
|
518
|
+
q.whereIn('txLabelId', args.labelIds);
|
|
519
|
+
return q;
|
|
520
|
+
}
|
|
521
|
+
findTxLabelsQuery(args) {
|
|
522
|
+
return this.setupQuery('tx_labels', args);
|
|
523
|
+
}
|
|
524
|
+
findUsersQuery(args) {
|
|
525
|
+
return this.setupQuery('users', args);
|
|
526
|
+
}
|
|
527
|
+
findMonitorEventsQuery(args) {
|
|
528
|
+
return this.setupQuery('monitor_events', args);
|
|
529
|
+
}
|
|
530
|
+
async findCertificatesAuth(auth, args) {
|
|
531
|
+
if (!auth.userId ||
|
|
532
|
+
(args.partial.userId && args.partial.userId !== auth.userId))
|
|
533
|
+
throw new index_all_1.sdk.WERR_UNAUTHORIZED();
|
|
534
|
+
args.partial.userId = auth.userId;
|
|
535
|
+
return await this.findCertificates(args);
|
|
536
|
+
}
|
|
537
|
+
async findOutputBasketsAuth(auth, args) {
|
|
538
|
+
if (!auth.userId ||
|
|
539
|
+
(args.partial.userId && args.partial.userId !== auth.userId))
|
|
540
|
+
throw new index_all_1.sdk.WERR_UNAUTHORIZED();
|
|
541
|
+
args.partial.userId = auth.userId;
|
|
542
|
+
return await this.findOutputBaskets(args);
|
|
543
|
+
}
|
|
544
|
+
async findOutputsAuth(auth, args) {
|
|
545
|
+
if (!auth.userId ||
|
|
546
|
+
(args.partial.userId && args.partial.userId !== auth.userId))
|
|
547
|
+
throw new index_all_1.sdk.WERR_UNAUTHORIZED();
|
|
548
|
+
args.partial.userId = auth.userId;
|
|
549
|
+
return await this.findOutputs(args);
|
|
550
|
+
}
|
|
551
|
+
async findCertificateFields(args) {
|
|
552
|
+
return this.validateEntities(await this.findCertificateFieldsQuery(args));
|
|
553
|
+
}
|
|
554
|
+
async findCertificates(args) {
|
|
555
|
+
const q = this.findCertificatesQuery(args);
|
|
556
|
+
const r = await q;
|
|
557
|
+
return this.validateEntities(r, undefined, ['isDeleted']);
|
|
558
|
+
}
|
|
559
|
+
async findCommissions(args) {
|
|
560
|
+
const q = this.findCommissionsQuery(args);
|
|
561
|
+
const r = await q;
|
|
562
|
+
return this.validateEntities(r, undefined, ['isRedeemed']);
|
|
563
|
+
}
|
|
564
|
+
async findOutputBaskets(args) {
|
|
565
|
+
const q = this.findOutputBasketsQuery(args);
|
|
566
|
+
const r = await q;
|
|
567
|
+
return this.validateEntities(r, undefined, ['isDeleted']);
|
|
568
|
+
}
|
|
569
|
+
async findOutputs(args) {
|
|
570
|
+
const q = this.findOutputsQuery(args);
|
|
571
|
+
const r = await q;
|
|
572
|
+
if (!args.noScript) {
|
|
573
|
+
for (const o of r) {
|
|
574
|
+
await this.validateOutputScript(o, args.trx);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return this.validateEntities(r, undefined, ['spendable', 'change']);
|
|
578
|
+
}
|
|
579
|
+
async findOutputTagMaps(args) {
|
|
580
|
+
const q = this.findOutputTagMapsQuery(args);
|
|
581
|
+
const r = await q;
|
|
582
|
+
return this.validateEntities(r, undefined, ['isDeleted']);
|
|
583
|
+
}
|
|
584
|
+
async findOutputTags(args) {
|
|
585
|
+
const q = this.findOutputTagsQuery(args);
|
|
586
|
+
const r = await q;
|
|
587
|
+
return this.validateEntities(r, undefined, ['isDeleted']);
|
|
588
|
+
}
|
|
589
|
+
async findProvenTxReqs(args) {
|
|
590
|
+
const q = this.findProvenTxReqsQuery(args);
|
|
591
|
+
const r = await q;
|
|
592
|
+
return this.validateEntities(r, undefined, ['notified']);
|
|
593
|
+
}
|
|
594
|
+
async findProvenTxs(args) {
|
|
595
|
+
const q = this.findProvenTxsQuery(args);
|
|
596
|
+
const r = await q;
|
|
597
|
+
return this.validateEntities(r);
|
|
598
|
+
}
|
|
599
|
+
async findSyncStates(args) {
|
|
600
|
+
const q = this.findSyncStatesQuery(args);
|
|
601
|
+
const r = await q;
|
|
602
|
+
return this.validateEntities(r, ['when'], ['init']);
|
|
603
|
+
}
|
|
604
|
+
async findTransactions(args) {
|
|
605
|
+
const q = this.findTransactionsQuery(args);
|
|
606
|
+
const r = await q;
|
|
607
|
+
if (!args.noRawTx) {
|
|
608
|
+
for (const t of r) {
|
|
609
|
+
await this.validateRawTransaction(t, args.trx);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return this.validateEntities(r, undefined, ['isOutgoing']);
|
|
613
|
+
}
|
|
614
|
+
async findTxLabelMaps(args) {
|
|
615
|
+
const q = this.findTxLabelMapsQuery(args);
|
|
616
|
+
const r = await q;
|
|
617
|
+
return this.validateEntities(r, undefined, ['isDeleted']);
|
|
618
|
+
}
|
|
619
|
+
async findTxLabels(args) {
|
|
620
|
+
const q = this.findTxLabelsQuery(args);
|
|
621
|
+
const r = await q;
|
|
622
|
+
return this.validateEntities(r, undefined, ['isDeleted']);
|
|
623
|
+
}
|
|
624
|
+
async findUsers(args) {
|
|
625
|
+
const q = this.findUsersQuery(args);
|
|
626
|
+
const r = await q;
|
|
627
|
+
return this.validateEntities(r);
|
|
628
|
+
}
|
|
629
|
+
async findMonitorEvents(args) {
|
|
630
|
+
const q = this.findMonitorEventsQuery(args);
|
|
631
|
+
const r = await q;
|
|
632
|
+
return this.validateEntities(r, ['when'], undefined);
|
|
633
|
+
}
|
|
634
|
+
async getCount(q) {
|
|
635
|
+
q.count();
|
|
636
|
+
const r = await q;
|
|
637
|
+
return r[0]['count(*)'];
|
|
638
|
+
}
|
|
639
|
+
async countCertificateFields(args) {
|
|
640
|
+
return await this.getCount(this.findCertificateFieldsQuery(args));
|
|
641
|
+
}
|
|
642
|
+
async countCertificates(args) {
|
|
643
|
+
return await this.getCount(this.findCertificatesQuery(args));
|
|
644
|
+
}
|
|
645
|
+
async countCommissions(args) {
|
|
646
|
+
return await this.getCount(this.findCommissionsQuery(args));
|
|
647
|
+
}
|
|
648
|
+
async countOutputBaskets(args) {
|
|
649
|
+
return await this.getCount(this.findOutputBasketsQuery(args));
|
|
650
|
+
}
|
|
651
|
+
async countOutputs(args) {
|
|
652
|
+
return await this.getCount(this.findOutputsQuery(args, true));
|
|
653
|
+
}
|
|
654
|
+
async countOutputTagMaps(args) {
|
|
655
|
+
return await this.getCount(this.findOutputTagMapsQuery(args));
|
|
656
|
+
}
|
|
657
|
+
async countOutputTags(args) {
|
|
658
|
+
return await this.getCount(this.findOutputTagsQuery(args));
|
|
659
|
+
}
|
|
660
|
+
async countProvenTxReqs(args) {
|
|
661
|
+
return await this.getCount(this.findProvenTxReqsQuery(args));
|
|
662
|
+
}
|
|
663
|
+
async countProvenTxs(args) {
|
|
664
|
+
return await this.getCount(this.findProvenTxsQuery(args));
|
|
665
|
+
}
|
|
666
|
+
async countSyncStates(args) {
|
|
667
|
+
return await this.getCount(this.findSyncStatesQuery(args));
|
|
668
|
+
}
|
|
669
|
+
async countTransactions(args) {
|
|
670
|
+
return await this.getCount(this.findTransactionsQuery(args, true));
|
|
671
|
+
}
|
|
672
|
+
async countTxLabelMaps(args) {
|
|
673
|
+
return await this.getCount(this.findTxLabelMapsQuery(args));
|
|
674
|
+
}
|
|
675
|
+
async countTxLabels(args) {
|
|
676
|
+
return await this.getCount(this.findTxLabelsQuery(args));
|
|
677
|
+
}
|
|
678
|
+
async countUsers(args) {
|
|
679
|
+
return await this.getCount(this.findUsersQuery(args));
|
|
680
|
+
}
|
|
681
|
+
async countMonitorEvents(args) {
|
|
682
|
+
return await this.getCount(this.findMonitorEventsQuery(args));
|
|
683
|
+
}
|
|
684
|
+
async destroy() {
|
|
685
|
+
var _a;
|
|
686
|
+
await ((_a = this.knex) === null || _a === void 0 ? void 0 : _a.destroy());
|
|
687
|
+
}
|
|
688
|
+
async migrate(storageName, storageIdentityKey) {
|
|
689
|
+
const config = {
|
|
690
|
+
migrationSource: new index_all_2.KnexMigrations(this.chain, storageName, storageIdentityKey, 1024)
|
|
691
|
+
};
|
|
692
|
+
await this.knex.migrate.latest(config);
|
|
693
|
+
const version = await this.knex.migrate.currentVersion(config);
|
|
694
|
+
return version;
|
|
695
|
+
}
|
|
696
|
+
async dropAllData() {
|
|
697
|
+
// Only using migrations to migrate down, don't need valid properties for settings table.
|
|
698
|
+
const config = {
|
|
699
|
+
migrationSource: new index_all_2.KnexMigrations('test', '', '', 1024)
|
|
700
|
+
};
|
|
701
|
+
const count = Object.keys(config.migrationSource.migrations).length;
|
|
702
|
+
for (let i = 0; i < count; i++) {
|
|
703
|
+
try {
|
|
704
|
+
const r = await this.knex.migrate.down(config);
|
|
705
|
+
expect(r).toBeTruthy();
|
|
706
|
+
}
|
|
707
|
+
catch (eu) {
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
async transaction(scope, trx) {
|
|
713
|
+
if (trx)
|
|
714
|
+
return await scope(trx);
|
|
715
|
+
return await this.knex.transaction(async (knextrx) => {
|
|
716
|
+
const trx = knextrx;
|
|
717
|
+
return await scope(trx);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Convert the standard optional `TrxToken` parameter into either a direct knex database instance,
|
|
722
|
+
* or a Knex.Transaction as appropriate.
|
|
723
|
+
*/
|
|
724
|
+
toDb(trx) {
|
|
725
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
726
|
+
const db = !trx ? this.knex : trx;
|
|
727
|
+
this.whenLastAccess = new Date();
|
|
728
|
+
return db;
|
|
729
|
+
}
|
|
730
|
+
async validateRawTransaction(t, trx) {
|
|
731
|
+
// if there is no txid or there is a rawTransaction return what we have.
|
|
732
|
+
if (t.rawTx || !t.txid)
|
|
733
|
+
return;
|
|
734
|
+
// rawTransaction is missing, see if we moved it ...
|
|
735
|
+
const rawTx = await this.getRawTxOfKnownValidTransaction(t.txid, undefined, undefined, trx);
|
|
736
|
+
if (!rawTx)
|
|
737
|
+
return;
|
|
738
|
+
t.rawTx = rawTx;
|
|
739
|
+
}
|
|
740
|
+
async validateOutputScript(o, trx) {
|
|
741
|
+
// without offset and length values return what we have (make no changes)
|
|
742
|
+
if (!o.scriptLength || !o.scriptOffset || !o.txid)
|
|
743
|
+
return;
|
|
744
|
+
// if there is an outputScript and its length is the expected length return what we have.
|
|
745
|
+
if (o.lockingScript && o.lockingScript.length === o.scriptLength)
|
|
746
|
+
return;
|
|
747
|
+
// outputScript is missing or has incorrect length...
|
|
748
|
+
const script = await this.getRawTxOfKnownValidTransaction(o.txid, o.scriptOffset, o.scriptLength, trx);
|
|
749
|
+
if (!script)
|
|
750
|
+
return;
|
|
751
|
+
o.lockingScript = script;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Make sure database is ready for access:
|
|
755
|
+
*
|
|
756
|
+
* - dateScheme is known
|
|
757
|
+
* - foreign key constraints are enabled
|
|
758
|
+
*
|
|
759
|
+
* @param trx
|
|
760
|
+
*/
|
|
761
|
+
async verifyReadyForDatabaseAccess(trx) {
|
|
762
|
+
if (!this._settings) {
|
|
763
|
+
this._settings = await this.readSettings();
|
|
764
|
+
}
|
|
765
|
+
if (!this._verifiedReadyForDatabaseAccess) {
|
|
766
|
+
// Make sure foreign key constraint checking is turned on in SQLite.
|
|
767
|
+
if (this._settings.dbtype === 'SQLite') {
|
|
768
|
+
await this.toDb(trx).raw('PRAGMA foreign_keys = ON;');
|
|
769
|
+
}
|
|
770
|
+
this._verifiedReadyForDatabaseAccess = true;
|
|
771
|
+
}
|
|
772
|
+
return this._settings.dbtype;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Helper to force uniform behavior across database engines.
|
|
776
|
+
* Use to process the update template for entities being updated.
|
|
777
|
+
*/
|
|
778
|
+
validatePartialForUpdate(update, dateFields, booleanFields) {
|
|
779
|
+
if (!this.dbtype)
|
|
780
|
+
throw new index_all_1.sdk.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first');
|
|
781
|
+
const v = update;
|
|
782
|
+
if (v.created_at)
|
|
783
|
+
v.created_at = this.validateEntityDate(v.created_at);
|
|
784
|
+
if (v.updated_at)
|
|
785
|
+
v.updated_at = this.validateEntityDate(v.updated_at);
|
|
786
|
+
if (!v.created_at)
|
|
787
|
+
delete v.created_at;
|
|
788
|
+
if (!v.updated_at)
|
|
789
|
+
v.updated_at = this.validateEntityDate(new Date());
|
|
790
|
+
if (dateFields) {
|
|
791
|
+
for (const df of dateFields) {
|
|
792
|
+
if (v[df])
|
|
793
|
+
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
if (booleanFields) {
|
|
797
|
+
for (const df of booleanFields) {
|
|
798
|
+
if (update[df] !== undefined)
|
|
799
|
+
update[df] = !!update[df] ? 1 : 0;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
for (const key of Object.keys(v)) {
|
|
803
|
+
const val = v[key];
|
|
804
|
+
if (Array.isArray(val) &&
|
|
805
|
+
(val.length === 0 || typeof val[0] === 'number')) {
|
|
806
|
+
v[key] = Buffer.from(val);
|
|
807
|
+
}
|
|
808
|
+
else if (val === undefined) {
|
|
809
|
+
v[key] = null;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
this.isDirty = true;
|
|
813
|
+
return v;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Helper to force uniform behavior across database engines.
|
|
817
|
+
* Use to process new entities being inserted into the database.
|
|
818
|
+
*/
|
|
819
|
+
async validateEntityForInsert(entity, trx, dateFields, booleanFields) {
|
|
820
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
821
|
+
const v = { ...entity };
|
|
822
|
+
v.created_at = this.validateOptionalEntityDate(v.created_at, true);
|
|
823
|
+
v.updated_at = this.validateOptionalEntityDate(v.updated_at, true);
|
|
824
|
+
if (!v.created_at)
|
|
825
|
+
delete v.created_at;
|
|
826
|
+
if (!v.updated_at)
|
|
827
|
+
delete v.updated_at;
|
|
828
|
+
if (dateFields) {
|
|
829
|
+
for (const df of dateFields) {
|
|
830
|
+
if (v[df])
|
|
831
|
+
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (booleanFields) {
|
|
835
|
+
for (const df of booleanFields) {
|
|
836
|
+
if (entity[df] !== undefined)
|
|
837
|
+
entity[df] = !!entity[df] ? 1 : 0;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
for (const key of Object.keys(v)) {
|
|
841
|
+
const val = v[key];
|
|
842
|
+
if (Array.isArray(val) &&
|
|
843
|
+
(val.length === 0 || typeof val[0] === 'number')) {
|
|
844
|
+
v[key] = Buffer.from(val);
|
|
845
|
+
}
|
|
846
|
+
else if (val === undefined) {
|
|
847
|
+
v[key] = null;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
this.isDirty = true;
|
|
851
|
+
return v;
|
|
852
|
+
}
|
|
853
|
+
async getLabelsForTransactionId(transactionId, trx) {
|
|
854
|
+
if (transactionId === undefined)
|
|
855
|
+
return [];
|
|
856
|
+
const labels = await this.toDb(trx)('tx_labels')
|
|
857
|
+
.join('tx_labels_map', 'tx_labels_map.txLabelId', 'tx_labels.txLabelId')
|
|
858
|
+
.where('tx_labels_map.transactionId', transactionId)
|
|
859
|
+
.whereNot('tx_labels_map.isDeleted', true)
|
|
860
|
+
.whereNot('tx_labels.isDeleted', true);
|
|
861
|
+
return this.validateEntities(labels, undefined, ['isDeleted']);
|
|
862
|
+
}
|
|
863
|
+
async extendOutput(o, includeBasket = false, includeTags = false, trx) {
|
|
864
|
+
const ox = o;
|
|
865
|
+
if (includeBasket && ox.basketId)
|
|
866
|
+
ox.basket = await this.findOutputBasketById(o.basketId, trx);
|
|
867
|
+
if (includeTags) {
|
|
868
|
+
ox.tags = await this.getTagsForOutputId(o.outputId);
|
|
869
|
+
}
|
|
870
|
+
return o;
|
|
871
|
+
}
|
|
872
|
+
async getTagsForOutputId(outputId, trx) {
|
|
873
|
+
const tags = await this.toDb(trx)('output_tags')
|
|
874
|
+
.join('output_tags_map', 'output_tags_map.outputTagId', 'output_tags.outputTagId')
|
|
875
|
+
.where('output_tags_map.outputId', outputId)
|
|
876
|
+
.whereNot('output_tags_map.isDeleted', true)
|
|
877
|
+
.whereNot('output_tags.isDeleted', true);
|
|
878
|
+
return this.validateEntities(tags, undefined, ['isDeleted']);
|
|
879
|
+
}
|
|
880
|
+
async purgeData(params, trx) {
|
|
881
|
+
return await (0, purgeData_1.purgeData)(this, params, trx);
|
|
882
|
+
}
|
|
883
|
+
async reviewStatus(args) {
|
|
884
|
+
return await (0, reviewStatus_1.reviewStatus)(this, args);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Finds closest matching available change output to use as input for new transaction.
|
|
888
|
+
*
|
|
889
|
+
* Transactionally allocate the output such that
|
|
890
|
+
*/
|
|
891
|
+
async countChangeInputs(userId, basketId, excludeSending) {
|
|
892
|
+
const status = ['completed', 'unproven'];
|
|
893
|
+
if (!excludeSending)
|
|
894
|
+
status.push('sending');
|
|
895
|
+
const statusText = status.map(s => `'${s}'`).join(',');
|
|
896
|
+
const txStatusCondition = `(SELECT status FROM transactions WHERE outputs.transactionId = transactions.transactionId) in (${statusText})`;
|
|
897
|
+
let q = this.knex('outputs')
|
|
898
|
+
.where({ userId, spendable: true, basketId })
|
|
899
|
+
.whereRaw(txStatusCondition);
|
|
900
|
+
const count = await this.getCount(q);
|
|
901
|
+
return count;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Finds closest matching available change output to use as input for new transaction.
|
|
905
|
+
*
|
|
906
|
+
* Transactionally allocate the output such that
|
|
907
|
+
*/
|
|
908
|
+
async allocateChangeInput(userId, basketId, targetSatoshis, exactSatoshis, excludeSending, transactionId) {
|
|
909
|
+
const status = ['completed', 'unproven'];
|
|
910
|
+
if (!excludeSending)
|
|
911
|
+
status.push('sending');
|
|
912
|
+
const statusText = status.map(s => `'${s}'`).join(',');
|
|
913
|
+
const r = await this.knex.transaction(async (trx) => {
|
|
914
|
+
const txStatusCondition = `AND (SELECT status FROM transactions WHERE outputs.transactionId = transactions.transactionId) in (${statusText})`;
|
|
915
|
+
let outputId;
|
|
916
|
+
const setOutputId = async (rawQuery) => {
|
|
917
|
+
let oidr = await trx.raw(rawQuery);
|
|
918
|
+
outputId = undefined;
|
|
919
|
+
if (!oidr['outputId'] && oidr.length > 0)
|
|
920
|
+
oidr = oidr[0];
|
|
921
|
+
if (!oidr['outputId'] && oidr.length > 0)
|
|
922
|
+
oidr = oidr[0];
|
|
923
|
+
if (oidr['outputId'])
|
|
924
|
+
outputId = Number(oidr['outputId']);
|
|
925
|
+
};
|
|
926
|
+
if (exactSatoshis !== undefined) {
|
|
927
|
+
// Find outputId of output that with exactSatoshis
|
|
928
|
+
await setOutputId(`
|
|
929
|
+
SELECT outputId
|
|
930
|
+
FROM outputs
|
|
931
|
+
WHERE userId = ${userId}
|
|
932
|
+
AND spendable = 1
|
|
933
|
+
AND basketId = ${basketId}
|
|
934
|
+
${txStatusCondition}
|
|
935
|
+
AND satoshis = ${exactSatoshis}
|
|
936
|
+
LIMIT 1;
|
|
937
|
+
`);
|
|
938
|
+
}
|
|
939
|
+
if (outputId === undefined) {
|
|
940
|
+
// Find outputId of output that would at least fund targetSatoshis
|
|
941
|
+
await setOutputId(`
|
|
942
|
+
SELECT outputId
|
|
943
|
+
FROM outputs
|
|
944
|
+
WHERE userId = ${userId}
|
|
945
|
+
AND spendable = 1
|
|
946
|
+
AND basketId = ${basketId}
|
|
947
|
+
${txStatusCondition}
|
|
948
|
+
AND satoshis - ${targetSatoshis} = (
|
|
949
|
+
SELECT MIN(satoshis - ${targetSatoshis})
|
|
950
|
+
FROM outputs
|
|
951
|
+
WHERE userId = ${userId}
|
|
952
|
+
AND spendable = 1
|
|
953
|
+
AND basketId = ${basketId}
|
|
954
|
+
${txStatusCondition}
|
|
955
|
+
AND satoshis - ${targetSatoshis} >= 0
|
|
956
|
+
)
|
|
957
|
+
LIMIT 1;
|
|
958
|
+
`);
|
|
959
|
+
}
|
|
960
|
+
if (outputId === undefined) {
|
|
961
|
+
// Find outputId of output that would add the most fund targetSatoshis
|
|
962
|
+
await setOutputId(`
|
|
963
|
+
SELECT outputId
|
|
964
|
+
FROM outputs
|
|
965
|
+
WHERE userId = ${userId}
|
|
966
|
+
AND spendable = 1
|
|
967
|
+
AND basketId = ${basketId}
|
|
968
|
+
${txStatusCondition}
|
|
969
|
+
AND satoshis - ${targetSatoshis} = (
|
|
970
|
+
SELECT MAX(satoshis - ${targetSatoshis})
|
|
971
|
+
FROM outputs
|
|
972
|
+
WHERE userId = ${userId}
|
|
973
|
+
AND spendable = 1
|
|
974
|
+
AND basketId = ${basketId}
|
|
975
|
+
${txStatusCondition}
|
|
976
|
+
AND satoshis - ${targetSatoshis} < 0
|
|
977
|
+
)
|
|
978
|
+
LIMIT 1;
|
|
979
|
+
`);
|
|
980
|
+
}
|
|
981
|
+
if (outputId === undefined)
|
|
982
|
+
return undefined;
|
|
983
|
+
await this.updateOutput(outputId, {
|
|
984
|
+
spendable: false,
|
|
985
|
+
spentBy: transactionId
|
|
986
|
+
}, trx);
|
|
987
|
+
const r = (0, index_all_1.verifyTruthy)(await this.findOutputById(outputId, trx));
|
|
988
|
+
return r;
|
|
989
|
+
});
|
|
990
|
+
return r;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Helper to force uniform behavior across database engines.
|
|
994
|
+
* Use to process all individual records with time stamps retreived from database.
|
|
995
|
+
*/
|
|
996
|
+
validateEntity(entity, dateFields, booleanFields) {
|
|
997
|
+
entity.created_at = this.validateDate(entity.created_at);
|
|
998
|
+
entity.updated_at = this.validateDate(entity.updated_at);
|
|
999
|
+
if (dateFields) {
|
|
1000
|
+
for (const df of dateFields) {
|
|
1001
|
+
if (entity[df])
|
|
1002
|
+
entity[df] = this.validateDate(entity[df]);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (booleanFields) {
|
|
1006
|
+
for (const df of booleanFields) {
|
|
1007
|
+
if (entity[df] !== undefined)
|
|
1008
|
+
entity[df] = !!entity[df];
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
for (const key of Object.keys(entity)) {
|
|
1012
|
+
const val = entity[key];
|
|
1013
|
+
if (val === null) {
|
|
1014
|
+
entity[key] = undefined;
|
|
1015
|
+
}
|
|
1016
|
+
else if (Buffer.isBuffer(val)) {
|
|
1017
|
+
entity[key] = Array.from(val);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
return entity;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Helper to force uniform behavior across database engines.
|
|
1024
|
+
* Use to process all arrays of records with time stamps retreived from database.
|
|
1025
|
+
* @returns input `entities` array with contained values validated.
|
|
1026
|
+
*/
|
|
1027
|
+
validateEntities(entities, dateFields, booleanFields) {
|
|
1028
|
+
for (let i = 0; i < entities.length; i++) {
|
|
1029
|
+
entities[i] = this.validateEntity(entities[i], dateFields, booleanFields);
|
|
1030
|
+
}
|
|
1031
|
+
return entities;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
exports.StorageKnex = StorageKnex;
|
|
1035
|
+
//# sourceMappingURL=StorageKnex.js.map
|