@bsv/wallet-toolbox-mobile 1.7.15 → 1.7.17
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/out/src/CWIStyleWalletManager.d.ts +439 -0
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -0
- package/out/src/CWIStyleWalletManager.js +1317 -0
- package/out/src/CWIStyleWalletManager.js.map +1 -0
- package/out/src/SetupClient.d.ts +130 -0
- package/out/src/SetupClient.d.ts.map +1 -0
- package/out/src/SetupClient.js +226 -0
- package/out/src/SetupClient.js.map +1 -0
- package/out/src/SetupWallet.d.ts +103 -0
- package/out/src/SetupWallet.d.ts.map +1 -0
- package/out/src/SetupWallet.js +3 -0
- package/out/src/SetupWallet.js.map +1 -0
- package/out/src/SimpleWalletManager.d.ts +169 -0
- package/out/src/SimpleWalletManager.d.ts.map +1 -0
- package/out/src/SimpleWalletManager.js +315 -0
- package/out/src/SimpleWalletManager.js.map +1 -0
- package/out/src/Wallet.d.ts +206 -0
- package/out/src/Wallet.d.ts.map +1 -0
- package/out/src/Wallet.js +797 -0
- package/out/src/Wallet.js.map +1 -0
- package/out/src/WalletAuthenticationManager.d.ts +33 -0
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -0
- package/out/src/WalletAuthenticationManager.js +113 -0
- package/out/src/WalletAuthenticationManager.js.map +1 -0
- package/out/src/WalletLogger.d.ts +65 -0
- package/out/src/WalletLogger.d.ts.map +1 -0
- package/out/src/WalletLogger.js +167 -0
- package/out/src/WalletLogger.js.map +1 -0
- package/out/src/WalletPermissionsManager.d.ts +760 -0
- package/out/src/WalletPermissionsManager.d.ts.map +1 -0
- package/out/src/WalletPermissionsManager.js +2679 -0
- package/out/src/WalletPermissionsManager.js.map +1 -0
- package/out/src/WalletSettingsManager.d.ts +53 -0
- package/out/src/WalletSettingsManager.d.ts.map +1 -0
- package/out/src/WalletSettingsManager.js +83 -0
- package/out/src/WalletSettingsManager.js.map +1 -0
- package/out/src/index.client.d.ts +23 -0
- package/out/src/index.client.d.ts.map +1 -0
- package/out/src/index.client.js +62 -0
- package/out/src/index.client.js.map +1 -0
- package/out/src/index.mobile.d.ts +20 -0
- package/out/src/index.mobile.d.ts.map +1 -0
- package/out/src/index.mobile.js +59 -0
- package/out/src/index.mobile.js.map +1 -0
- package/out/src/monitor/Monitor.d.ts +148 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -0
- package/out/src/monitor/Monitor.js +317 -0
- package/out/src/monitor/Monitor.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 +213 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -0
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +33 -0
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCheckNoSends.js +71 -0
- package/out/src/monitor/tasks/TaskCheckNoSends.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 +28 -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/TaskMonitorCallHistory.d.ts +12 -0
- package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js +24 -0
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -0
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +50 -0
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskNewHeader.js +84 -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 +34 -0
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -0
- package/out/src/monitor/tasks/TaskReorg.d.ts +43 -0
- package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskReorg.js +82 -0
- package/out/src/monitor/tasks/TaskReorg.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 +43 -0
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +35 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskSendWaiting.js +117 -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/TaskUnFail.d.ts +41 -0
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskUnFail.js +145 -0
- package/out/src/monitor/tasks/TaskUnFail.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/CertOpsWallet.d.ts +7 -0
- package/out/src/sdk/CertOpsWallet.d.ts.map +1 -0
- package/out/src/sdk/CertOpsWallet.js +3 -0
- package/out/src/sdk/CertOpsWallet.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/WERR_errors.d.ts +136 -0
- package/out/src/sdk/WERR_errors.d.ts.map +1 -0
- package/out/src/sdk/WERR_errors.js +218 -0
- package/out/src/sdk/WERR_errors.js.map +1 -0
- package/out/src/sdk/WalletError.d.ts +63 -0
- package/out/src/sdk/WalletError.d.ts.map +1 -0
- package/out/src/sdk/WalletError.js +169 -0
- package/out/src/sdk/WalletError.js.map +1 -0
- package/out/src/sdk/WalletErrorFromJson.d.ts +12 -0
- package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -0
- package/out/src/sdk/WalletErrorFromJson.js +69 -0
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts +618 -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 +522 -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/index.d.ts +11 -0
- package/out/src/sdk/index.d.ts.map +1 -0
- package/out/src/sdk/index.js +29 -0
- package/out/src/sdk/index.js.map +1 -0
- package/out/src/sdk/types.d.ts +169 -0
- package/out/src/sdk/types.d.ts.map +1 -0
- package/out/src/sdk/types.js +90 -0
- package/out/src/sdk/types.js.map +1 -0
- package/out/src/services/ServiceCollection.d.ts +79 -0
- package/out/src/services/ServiceCollection.d.ts.map +1 -0
- package/out/src/services/ServiceCollection.js +192 -0
- package/out/src/services/ServiceCollection.js.map +1 -0
- package/out/src/services/Services.d.ts +71 -0
- package/out/src/services/Services.d.ts.map +1 -0
- package/out/src/services/Services.js +532 -0
- package/out/src/services/Services.js.map +1 -0
- package/out/src/services/chaintracker/BHServiceClient.d.ts +39 -0
- package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -0
- package/out/src/services/chaintracker/BHServiceClient.js +174 -0
- package/out/src/services/chaintracker/BHServiceClient.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 +53 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +55 -0
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js +38 -0
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.d.ts +70 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts +81 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts +54 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts +163 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts +18 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.d.ts +55 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts +338 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.d.ts +19 -0
- package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +101 -0
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js +550 -0
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +38 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +139 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts +60 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +119 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +76 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +114 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts +13 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js +20 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts +62 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +59 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts +62 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +42 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts +51 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +55 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +171 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +501 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +89 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +137 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts +23 -0
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +68 -0
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts +68 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +290 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts +92 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +465 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +37 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +260 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts +5 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js +68 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts +5 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js +68 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts +13 -0
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js +27 -0
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts +13 -0
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js +27 -0
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.client.d.ts +4 -0
- package/out/src/services/chaintracker/chaintracks/index.client.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.client.js +20 -0
- package/out/src/services/chaintracker/chaintracks/index.client.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts +30 -0
- package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.mobile.js +68 -0
- package/out/src/services/chaintracker/chaintracks/index.mobile.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +155 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +848 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts +78 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +261 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +129 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +145 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +14 -0
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +67 -0
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts +90 -0
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +140 -0
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +14 -0
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js +88 -0
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +159 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +520 -0
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts +20 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js +31 -0
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts +37 -0
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +432 -0
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -0
- package/out/src/services/chaintracker/index.client.d.ts +4 -0
- package/out/src/services/chaintracker/index.client.d.ts.map +1 -0
- package/out/src/services/chaintracker/index.client.js +20 -0
- package/out/src/services/chaintracker/index.client.js.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts +7 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.js +65 -0
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -0
- package/out/src/services/providers/ARC.d.ts +92 -0
- package/out/src/services/providers/ARC.d.ts.map +1 -0
- package/out/src/services/providers/ARC.js +270 -0
- package/out/src/services/providers/ARC.js.map +1 -0
- package/out/src/services/providers/Bitails.d.ts +50 -0
- package/out/src/services/providers/Bitails.d.ts.map +1 -0
- package/out/src/services/providers/Bitails.js +224 -0
- package/out/src/services/providers/Bitails.js.map +1 -0
- package/out/src/services/providers/SdkWhatsOnChain.d.ts +21 -0
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -0
- package/out/src/services/providers/SdkWhatsOnChain.js +67 -0
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -0
- package/out/src/services/providers/WhatsOnChain.d.ts +130 -0
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -0
- package/out/src/services/providers/WhatsOnChain.js +679 -0
- package/out/src/services/providers/WhatsOnChain.js.map +1 -0
- package/out/src/services/providers/exchangeRates.d.ts +12 -0
- package/out/src/services/providers/exchangeRates.d.ts.map +1 -0
- package/out/src/services/providers/exchangeRates.js +237 -0
- package/out/src/services/providers/exchangeRates.js.map +1 -0
- package/out/src/services/providers/getBeefForTxid.d.ts +4 -0
- package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -0
- package/out/src/services/providers/getBeefForTxid.js +286 -0
- package/out/src/services/providers/getBeefForTxid.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 +5 -0
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -0
- package/out/src/signer/methods/acquireDirectCertificate.js +45 -0
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -0
- package/out/src/signer/methods/buildSignableTransaction.d.ts +15 -0
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -0
- package/out/src/signer/methods/buildSignableTransaction.js +142 -0
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -0
- package/out/src/signer/methods/completeSignedTransaction.d.ts +10 -0
- package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -0
- package/out/src/signer/methods/completeSignedTransaction.js +106 -0
- package/out/src/signer/methods/completeSignedTransaction.js.map +1 -0
- package/out/src/signer/methods/createAction.d.ts +14 -0
- package/out/src/signer/methods/createAction.d.ts.map +1 -0
- package/out/src/signer/methods/createAction.js +117 -0
- package/out/src/signer/methods/createAction.js.map +1 -0
- package/out/src/signer/methods/internalizeAction.d.ts +32 -0
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -0
- package/out/src/signer/methods/internalizeAction.js +93 -0
- package/out/src/signer/methods/internalizeAction.js.map +1 -0
- package/out/src/signer/methods/proveCertificate.d.ts +5 -0
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -0
- package/out/src/signer/methods/proveCertificate.js +29 -0
- package/out/src/signer/methods/proveCertificate.js.map +1 -0
- package/out/src/signer/methods/signAction.d.ts +11 -0
- package/out/src/signer/methods/signAction.d.ts.map +1 -0
- package/out/src/signer/methods/signAction.js +41 -0
- package/out/src/signer/methods/signAction.js.map +1 -0
- package/out/src/storage/StorageIdb.d.ts +210 -0
- package/out/src/storage/StorageIdb.d.ts.map +1 -0
- package/out/src/storage/StorageIdb.js +2297 -0
- package/out/src/storage/StorageIdb.js.map +1 -0
- package/out/src/storage/StorageProvider.d.ts +222 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -0
- package/out/src/storage/StorageProvider.js +567 -0
- package/out/src/storage/StorageProvider.js.map +1 -0
- package/out/src/storage/StorageReader.d.ts +77 -0
- package/out/src/storage/StorageReader.d.ts.map +1 -0
- package/out/src/storage/StorageReader.js +163 -0
- package/out/src/storage/StorageReader.js.map +1 -0
- package/out/src/storage/StorageReaderWriter.d.ts +102 -0
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -0
- package/out/src/storage/StorageReaderWriter.js +338 -0
- package/out/src/storage/StorageReaderWriter.js.map +1 -0
- package/out/src/storage/StorageSyncReader.d.ts +18 -0
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -0
- package/out/src/storage/StorageSyncReader.js +71 -0
- package/out/src/storage/StorageSyncReader.js.map +1 -0
- package/out/src/storage/WalletStorageManager.d.ts +221 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -0
- package/out/src/storage/WalletStorageManager.js +819 -0
- package/out/src/storage/WalletStorageManager.js.map +1 -0
- package/out/src/storage/index.client.d.ts +8 -0
- package/out/src/storage/index.client.d.ts.map +1 -0
- package/out/src/storage/index.client.js +24 -0
- package/out/src/storage/index.client.js.map +1 -0
- package/out/src/storage/index.mobile.d.ts +7 -0
- package/out/src/storage/index.mobile.d.ts.map +1 -0
- package/out/src/storage/index.mobile.js +23 -0
- package/out/src/storage/index.mobile.js.map +1 -0
- package/out/src/storage/methods/ListActionsSpecOp.d.ts +18 -0
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -0
- package/out/src/storage/methods/ListActionsSpecOp.js +40 -0
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -0
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts +26 -0
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -0
- package/out/src/storage/methods/ListOutputsSpecOp.js +75 -0
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +41 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +324 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -0
- package/out/src/storage/methods/createAction.d.ts +13 -0
- package/out/src/storage/methods/createAction.d.ts.map +1 -0
- package/out/src/storage/methods/createAction.js +732 -0
- package/out/src/storage/methods/createAction.js.map +1 -0
- package/out/src/storage/methods/generateChange.d.ts +96 -0
- package/out/src/storage/methods/generateChange.d.ts.map +1 -0
- package/out/src/storage/methods/generateChange.js +405 -0
- package/out/src/storage/methods/generateChange.js.map +1 -0
- package/out/src/storage/methods/getBeefForTransaction.d.ts +23 -0
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -0
- package/out/src/storage/methods/getBeefForTransaction.js +109 -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 +272 -0
- package/out/src/storage/methods/getSyncChunk.js.map +1 -0
- package/out/src/storage/methods/internalizeAction.d.ts +31 -0
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -0
- package/out/src/storage/methods/internalizeAction.js +462 -0
- package/out/src/storage/methods/internalizeAction.js.map +1 -0
- package/out/src/storage/methods/listActionsIdb.d.ts +5 -0
- package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -0
- package/out/src/storage/methods/listActionsIdb.js +155 -0
- package/out/src/storage/methods/listActionsIdb.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/listOutputsIdb.d.ts +5 -0
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -0
- package/out/src/storage/methods/listOutputsIdb.js +185 -0
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -0
- package/out/src/storage/methods/offsetKey.d.ts +24 -0
- package/out/src/storage/methods/offsetKey.d.ts.map +1 -0
- package/out/src/storage/methods/offsetKey.js +67 -0
- package/out/src/storage/methods/offsetKey.js.map +1 -0
- package/out/src/storage/methods/processAction.d.ts +54 -0
- package/out/src/storage/methods/processAction.d.ts.map +1 -0
- package/out/src/storage/methods/processAction.js +267 -0
- package/out/src/storage/methods/processAction.js.map +1 -0
- package/out/src/storage/methods/purgeDataIdb.d.ts +4 -0
- package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -0
- package/out/src/storage/methods/purgeDataIdb.js +9 -0
- package/out/src/storage/methods/purgeDataIdb.js.map +1 -0
- package/out/src/storage/methods/reviewStatusIdb.d.ts +20 -0
- package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -0
- package/out/src/storage/methods/reviewStatusIdb.js +35 -0
- package/out/src/storage/methods/reviewStatusIdb.js.map +1 -0
- package/out/src/storage/methods/utils.d.ts +25 -0
- package/out/src/storage/methods/utils.d.ts.map +1 -0
- package/out/src/storage/methods/utils.js +53 -0
- package/out/src/storage/methods/utils.js.map +1 -0
- package/out/src/storage/remoting/StorageClient.d.ts +292 -0
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageClient.js +497 -0
- package/out/src/storage/remoting/StorageClient.js.map +1 -0
- package/out/src/storage/remoting/StorageMobile.d.ts +292 -0
- package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageMobile.js +477 -0
- package/out/src/storage/remoting/StorageMobile.js.map +1 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts +133 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -0
- package/out/src/storage/schema/StorageIdbSchema.js +3 -0
- package/out/src/storage/schema/StorageIdbSchema.js.map +1 -0
- package/out/src/storage/schema/entities/EntityBase.d.ts +106 -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/EntityCertificate.d.ts +44 -0
- package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityCertificate.js +162 -0
- package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -0
- package/out/src/storage/schema/entities/EntityCertificateField.d.ts +33 -0
- package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityCertificateField.js +112 -0
- package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -0
- package/out/src/storage/schema/entities/EntityCommission.d.ts +38 -0
- package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityCommission.js +127 -0
- package/out/src/storage/schema/entities/EntityCommission.js.map +1 -0
- package/out/src/storage/schema/entities/EntityOutput.d.ts +68 -0
- package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityOutput.js +264 -0
- package/out/src/storage/schema/entities/EntityOutput.js.map +1 -0
- package/out/src/storage/schema/entities/EntityOutputBasket.d.ts +36 -0
- package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityOutputBasket.js +133 -0
- package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -0
- package/out/src/storage/schema/entities/EntityOutputTag.d.ts +32 -0
- package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityOutputTag.js +104 -0
- package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -0
- package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts +29 -0
- package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityOutputTagMap.js +98 -0
- package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -0
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts +87 -0
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityProvenTx.js +278 -0
- package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -0
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +139 -0
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityProvenTxReq.js +524 -0
- package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/entities/EntitySyncState.d.ts +69 -0
- package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntitySyncState.js +334 -0
- package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -0
- package/out/src/storage/schema/entities/EntityTransaction.d.ts +71 -0
- package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityTransaction.js +255 -0
- package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -0
- package/out/src/storage/schema/entities/EntityTxLabel.d.ts +32 -0
- package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityTxLabel.js +104 -0
- package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -0
- package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts +29 -0
- package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityTxLabelMap.js +98 -0
- package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -0
- package/out/src/storage/schema/entities/EntityUser.d.ts +30 -0
- package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityUser.js +99 -0
- package/out/src/storage/schema/entities/EntityUser.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 +63 -0
- package/out/src/storage/schema/entities/MergeEntity.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/TableCertificate.d.ts +20 -0
- package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableCertificate.js +3 -0
- package/out/src/storage/schema/tables/TableCertificate.js.map +1 -0
- package/out/src/storage/schema/tables/TableCertificateField.d.ts +12 -0
- package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableCertificateField.js +3 -0
- package/out/src/storage/schema/tables/TableCertificateField.js.map +1 -0
- package/out/src/storage/schema/tables/TableCommission.d.ts +13 -0
- package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableCommission.js +3 -0
- package/out/src/storage/schema/tables/TableCommission.js.map +1 -0
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +9 -0
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableMonitorEvent.js +3 -0
- package/out/src/storage/schema/tables/TableMonitorEvent.js.map +1 -0
- package/out/src/storage/schema/tables/TableOutput.d.ts +36 -0
- package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableOutput.js +31 -0
- package/out/src/storage/schema/tables/TableOutput.js.map +1 -0
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts +12 -0
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableOutputBasket.js +3 -0
- package/out/src/storage/schema/tables/TableOutputBasket.js.map +1 -0
- package/out/src/storage/schema/tables/TableOutputTag.d.ts +10 -0
- package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableOutputTag.js +3 -0
- package/out/src/storage/schema/tables/TableOutputTag.js.map +1 -0
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +9 -0
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableOutputTagMap.js +3 -0
- package/out/src/storage/schema/tables/TableOutputTagMap.js.map +1 -0
- package/out/src/storage/schema/tables/TableProvenTx.d.ts +14 -0
- package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableProvenTx.js +3 -0
- package/out/src/storage/schema/tables/TableProvenTx.js.map +1 -0
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +64 -0
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableProvenTxReq.js +3 -0
- package/out/src/storage/schema/tables/TableProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/tables/TableSettings.d.ts +17 -0
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableSettings.js +3 -0
- package/out/src/storage/schema/tables/TableSettings.js.map +1 -0
- package/out/src/storage/schema/tables/TableSyncState.d.ts +18 -0
- package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableSyncState.js +3 -0
- package/out/src/storage/schema/tables/TableSyncState.js.map +1 -0
- package/out/src/storage/schema/tables/TableTransaction.d.ts +37 -0
- package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTransaction.js +21 -0
- package/out/src/storage/schema/tables/TableTransaction.js.map +1 -0
- package/out/src/storage/schema/tables/TableTxLabel.d.ts +10 -0
- package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTxLabel.js +3 -0
- package/out/src/storage/schema/tables/TableTxLabel.js.map +1 -0
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +9 -0
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTxLabelMap.js +3 -0
- package/out/src/storage/schema/tables/TableTxLabelMap.js.map +1 -0
- package/out/src/storage/schema/tables/TableUser.d.ts +16 -0
- package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableUser.js +3 -0
- package/out/src/storage/schema/tables/TableUser.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/utility/ReaderUint8Array.d.ts +28 -0
- package/out/src/utility/ReaderUint8Array.d.ts.map +1 -0
- package/out/src/utility/ReaderUint8Array.js +166 -0
- package/out/src/utility/ReaderUint8Array.js.map +1 -0
- package/out/src/utility/ScriptTemplateBRC29.d.ts +25 -0
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -0
- package/out/src/utility/ScriptTemplateBRC29.js +48 -0
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -0
- package/out/src/utility/aggregateResults.d.ts +8 -0
- package/out/src/utility/aggregateResults.d.ts.map +1 -0
- package/out/src/utility/aggregateResults.js +59 -0
- package/out/src/utility/aggregateResults.js.map +1 -0
- package/out/src/utility/identityUtils.d.ts +31 -0
- package/out/src/utility/identityUtils.d.ts.map +1 -0
- package/out/src/utility/identityUtils.js +116 -0
- package/out/src/utility/identityUtils.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.d.ts +138 -0
- package/out/src/utility/utilityHelpers.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.js +294 -0
- package/out/src/utility/utilityHelpers.js.map +1 -0
- package/out/src/utility/utilityHelpers.noBuffer.d.ts +26 -0
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.noBuffer.js +64 -0
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -0
- package/out/src/wab-client/WABClient.d.ts +49 -0
- package/out/src/wab-client/WABClient.d.ts.map +1 -0
- package/out/src/wab-client/WABClient.js +80 -0
- package/out/src/wab-client/WABClient.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +34 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts +7 -0
- package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts.map +1 -0
- package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js +36 -0
- package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +28 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +69 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -0
- package/out/tsconfig.mobile.tsbuildinfo +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageIdb = void 0;
|
|
4
|
+
const idb_1 = require("idb");
|
|
5
|
+
const utilityHelpers_1 = require("../utility/utilityHelpers");
|
|
6
|
+
const StorageProvider_1 = require("./StorageProvider");
|
|
7
|
+
const listActionsIdb_1 = require("./methods/listActionsIdb");
|
|
8
|
+
const listOutputsIdb_1 = require("./methods/listOutputsIdb");
|
|
9
|
+
const reviewStatusIdb_1 = require("./methods/reviewStatusIdb");
|
|
10
|
+
const purgeDataIdb_1 = require("./methods/purgeDataIdb");
|
|
11
|
+
const WERR_errors_1 = require("../sdk/WERR_errors");
|
|
12
|
+
/**
|
|
13
|
+
* This class implements the `StorageProvider` interface using IndexedDB,
|
|
14
|
+
* via the promises wrapper package `idb`.
|
|
15
|
+
*/
|
|
16
|
+
class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
this.allStores = [
|
|
20
|
+
'certificates',
|
|
21
|
+
'certificate_fields',
|
|
22
|
+
'commissions',
|
|
23
|
+
'monitor_events',
|
|
24
|
+
'outputs',
|
|
25
|
+
'output_baskets',
|
|
26
|
+
'output_tags',
|
|
27
|
+
'output_tags_map',
|
|
28
|
+
'proven_txs',
|
|
29
|
+
'proven_tx_reqs',
|
|
30
|
+
'sync_states',
|
|
31
|
+
'transactions',
|
|
32
|
+
'tx_labels',
|
|
33
|
+
'tx_labels_map',
|
|
34
|
+
'users'
|
|
35
|
+
];
|
|
36
|
+
this.dbName = `wallet-toolbox-${this.chain}net`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* This method must be called at least once before any other method accesses the database,
|
|
40
|
+
* and each time the schema may have updated.
|
|
41
|
+
*
|
|
42
|
+
* If the database has already been created in this context, `storageName` and `storageIdentityKey`
|
|
43
|
+
* are ignored.
|
|
44
|
+
*
|
|
45
|
+
* @param storageName
|
|
46
|
+
* @param storageIdentityKey
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
async migrate(storageName, storageIdentityKey) {
|
|
50
|
+
const db = await this.verifyDB(storageName, storageIdentityKey);
|
|
51
|
+
return db.version.toString();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Following initial database initialization, this method verfies that db is ready for use.
|
|
55
|
+
*
|
|
56
|
+
* @throws `WERR_INVALID_OPERATION` if the database has not been initialized by a call to `migrate`.
|
|
57
|
+
*
|
|
58
|
+
* @param storageName
|
|
59
|
+
* @param storageIdentityKey
|
|
60
|
+
*
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
async verifyDB(storageName, storageIdentityKey) {
|
|
64
|
+
if (this.db)
|
|
65
|
+
return this.db;
|
|
66
|
+
this.db = await this.initDB(storageName, storageIdentityKey);
|
|
67
|
+
this._settings = (await this.db.getAll('settings'))[0];
|
|
68
|
+
this.whenLastAccess = new Date();
|
|
69
|
+
return this.db;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert the standard optional `TrxToken` parameter into either a direct knex database instance,
|
|
73
|
+
* or a Knex.Transaction as appropriate.
|
|
74
|
+
*/
|
|
75
|
+
toDbTrx(stores, mode, trx) {
|
|
76
|
+
if (trx) {
|
|
77
|
+
const t = trx;
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (!this.db)
|
|
82
|
+
throw new Error('not initialized');
|
|
83
|
+
const db = this.db;
|
|
84
|
+
const trx = db.transaction(stores || this.allStores, mode || 'readwrite');
|
|
85
|
+
this.whenLastAccess = new Date();
|
|
86
|
+
return trx;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Called by `makeAvailable` to return storage `TableSettings`.
|
|
91
|
+
* Since this is the first async method that must be called by all clients,
|
|
92
|
+
* it is where async initialization occurs.
|
|
93
|
+
*
|
|
94
|
+
* After initialization, cached settings are returned.
|
|
95
|
+
*
|
|
96
|
+
* @param trx
|
|
97
|
+
*/
|
|
98
|
+
async readSettings(trx) {
|
|
99
|
+
await this.verifyDB();
|
|
100
|
+
return this._settings;
|
|
101
|
+
}
|
|
102
|
+
async initDB(storageName, storageIdentityKey) {
|
|
103
|
+
const chain = this.chain;
|
|
104
|
+
const maxOutputScript = 1024;
|
|
105
|
+
const db = await (0, idb_1.openDB)(this.dbName, 1, {
|
|
106
|
+
upgrade(db, oldVersion, newVersion, transaction) {
|
|
107
|
+
if (!db.objectStoreNames.contains('proven_txs')) {
|
|
108
|
+
// proven_txs object store
|
|
109
|
+
const provenTxsStore = db.createObjectStore('proven_txs', {
|
|
110
|
+
keyPath: 'provenTxId',
|
|
111
|
+
autoIncrement: true
|
|
112
|
+
});
|
|
113
|
+
provenTxsStore.createIndex('txid', 'txid', { unique: true });
|
|
114
|
+
}
|
|
115
|
+
if (!db.objectStoreNames.contains('proven_tx_reqs')) {
|
|
116
|
+
// proven_tx_reqs object store
|
|
117
|
+
const provenTxReqsStore = db.createObjectStore('proven_tx_reqs', {
|
|
118
|
+
keyPath: 'provenTxReqId',
|
|
119
|
+
autoIncrement: true
|
|
120
|
+
});
|
|
121
|
+
provenTxReqsStore.createIndex('provenTxId', 'provenTxId');
|
|
122
|
+
provenTxReqsStore.createIndex('txid', 'txid', { unique: true });
|
|
123
|
+
provenTxReqsStore.createIndex('status', 'status');
|
|
124
|
+
provenTxReqsStore.createIndex('batch', 'batch');
|
|
125
|
+
}
|
|
126
|
+
if (!db.objectStoreNames.contains('users')) {
|
|
127
|
+
const users = db.createObjectStore('users', {
|
|
128
|
+
keyPath: 'userId',
|
|
129
|
+
autoIncrement: true
|
|
130
|
+
});
|
|
131
|
+
users.createIndex('identityKey', 'identityKey', { unique: true });
|
|
132
|
+
}
|
|
133
|
+
if (!db.objectStoreNames.contains('certificates')) {
|
|
134
|
+
// certificates object store
|
|
135
|
+
const certificatesStore = db.createObjectStore('certificates', {
|
|
136
|
+
keyPath: 'certificateId',
|
|
137
|
+
autoIncrement: true
|
|
138
|
+
});
|
|
139
|
+
certificatesStore.createIndex('userId', 'userId');
|
|
140
|
+
certificatesStore.createIndex('userId_type_certifier_serialNumber', ['userId', 'type', 'certifier', 'serialNumber'], { unique: true });
|
|
141
|
+
}
|
|
142
|
+
if (!db.objectStoreNames.contains('certificate_fields')) {
|
|
143
|
+
// certificate_fields object store
|
|
144
|
+
const certificateFieldsStore = db.createObjectStore('certificate_fields', {
|
|
145
|
+
keyPath: ['certificateId', 'fieldName'] // Composite key
|
|
146
|
+
});
|
|
147
|
+
certificateFieldsStore.createIndex('userId', 'userId');
|
|
148
|
+
certificateFieldsStore.createIndex('certificateId', 'certificateId');
|
|
149
|
+
}
|
|
150
|
+
if (!db.objectStoreNames.contains('output_baskets')) {
|
|
151
|
+
// output_baskets object store
|
|
152
|
+
const outputBasketsStore = db.createObjectStore('output_baskets', {
|
|
153
|
+
keyPath: 'basketId',
|
|
154
|
+
autoIncrement: true
|
|
155
|
+
});
|
|
156
|
+
outputBasketsStore.createIndex('userId', 'userId');
|
|
157
|
+
outputBasketsStore.createIndex('name_userId', ['name', 'userId'], { unique: true });
|
|
158
|
+
}
|
|
159
|
+
if (!db.objectStoreNames.contains('transactions')) {
|
|
160
|
+
// transactions object store
|
|
161
|
+
const transactionsStore = db.createObjectStore('transactions', {
|
|
162
|
+
keyPath: 'transactionId',
|
|
163
|
+
autoIncrement: true
|
|
164
|
+
});
|
|
165
|
+
transactionsStore.createIndex('userId', 'userId');
|
|
166
|
+
(transactionsStore.createIndex('status', 'status'),
|
|
167
|
+
transactionsStore.createIndex('status_userId', ['status', 'userId']));
|
|
168
|
+
transactionsStore.createIndex('provenTxId', 'provenTxId');
|
|
169
|
+
transactionsStore.createIndex('reference', 'reference', { unique: true });
|
|
170
|
+
}
|
|
171
|
+
if (!db.objectStoreNames.contains('commissions')) {
|
|
172
|
+
// commissions object store
|
|
173
|
+
const commissionsStore = db.createObjectStore('commissions', {
|
|
174
|
+
keyPath: 'commissionId',
|
|
175
|
+
autoIncrement: true
|
|
176
|
+
});
|
|
177
|
+
commissionsStore.createIndex('userId', 'userId');
|
|
178
|
+
commissionsStore.createIndex('transactionId', 'transactionId', { unique: true });
|
|
179
|
+
}
|
|
180
|
+
if (!db.objectStoreNames.contains('outputs')) {
|
|
181
|
+
// outputs object store
|
|
182
|
+
const outputsStore = db.createObjectStore('outputs', {
|
|
183
|
+
keyPath: 'outputId',
|
|
184
|
+
autoIncrement: true
|
|
185
|
+
});
|
|
186
|
+
outputsStore.createIndex('userId', 'userId');
|
|
187
|
+
outputsStore.createIndex('transactionId', 'transactionId');
|
|
188
|
+
outputsStore.createIndex('basketId', 'basketId');
|
|
189
|
+
outputsStore.createIndex('spentBy', 'spentBy');
|
|
190
|
+
outputsStore.createIndex('transactionId_vout_userId', ['transactionId', 'vout', 'userId'], { unique: true });
|
|
191
|
+
}
|
|
192
|
+
if (!db.objectStoreNames.contains('output_tags')) {
|
|
193
|
+
// output_tags object store
|
|
194
|
+
const outputTagsStore = db.createObjectStore('output_tags', {
|
|
195
|
+
keyPath: 'outputTagId',
|
|
196
|
+
autoIncrement: true
|
|
197
|
+
});
|
|
198
|
+
outputTagsStore.createIndex('userId', 'userId');
|
|
199
|
+
outputTagsStore.createIndex('tag_userId', ['tag', 'userId'], { unique: true });
|
|
200
|
+
}
|
|
201
|
+
if (!db.objectStoreNames.contains('output_tags_map')) {
|
|
202
|
+
// output_tags_map object store
|
|
203
|
+
const outputTagsMapStore = db.createObjectStore('output_tags_map', {
|
|
204
|
+
keyPath: ['outputTagId', 'outputId']
|
|
205
|
+
});
|
|
206
|
+
outputTagsMapStore.createIndex('outputTagId', 'outputTagId');
|
|
207
|
+
outputTagsMapStore.createIndex('outputId', 'outputId');
|
|
208
|
+
}
|
|
209
|
+
if (!db.objectStoreNames.contains('tx_labels')) {
|
|
210
|
+
// tx_labels object store
|
|
211
|
+
const txLabelsStore = db.createObjectStore('tx_labels', {
|
|
212
|
+
keyPath: 'txLabelId',
|
|
213
|
+
autoIncrement: true
|
|
214
|
+
});
|
|
215
|
+
txLabelsStore.createIndex('userId', 'userId');
|
|
216
|
+
txLabelsStore.createIndex('label_userId', ['label', 'userId'], { unique: true });
|
|
217
|
+
}
|
|
218
|
+
if (!db.objectStoreNames.contains('tx_labels_map')) {
|
|
219
|
+
// tx_labels_map object store
|
|
220
|
+
const txLabelsMapStore = db.createObjectStore('tx_labels_map', {
|
|
221
|
+
keyPath: ['txLabelId', 'transactionId']
|
|
222
|
+
});
|
|
223
|
+
txLabelsMapStore.createIndex('txLabelId', 'txLabelId');
|
|
224
|
+
txLabelsMapStore.createIndex('transactionId', 'transactionId');
|
|
225
|
+
}
|
|
226
|
+
if (!db.objectStoreNames.contains('monitor_events')) {
|
|
227
|
+
// monitor_events object store
|
|
228
|
+
const monitorEventsStore = db.createObjectStore('monitor_events', {
|
|
229
|
+
keyPath: 'id',
|
|
230
|
+
autoIncrement: true
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (!db.objectStoreNames.contains('sync_states')) {
|
|
234
|
+
// sync_states object store
|
|
235
|
+
const syncStatesStore = db.createObjectStore('sync_states', {
|
|
236
|
+
keyPath: 'syncStateId',
|
|
237
|
+
autoIncrement: true
|
|
238
|
+
});
|
|
239
|
+
syncStatesStore.createIndex('userId', 'userId');
|
|
240
|
+
syncStatesStore.createIndex('refNum', 'refNum', { unique: true });
|
|
241
|
+
syncStatesStore.createIndex('status', 'status');
|
|
242
|
+
}
|
|
243
|
+
if (!db.objectStoreNames.contains('settings')) {
|
|
244
|
+
if (!storageName || !storageIdentityKey) {
|
|
245
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION('migrate must be called before first access');
|
|
246
|
+
}
|
|
247
|
+
const settings = db.createObjectStore('settings', {
|
|
248
|
+
keyPath: 'storageIdentityKey'
|
|
249
|
+
});
|
|
250
|
+
const s = {
|
|
251
|
+
created_at: new Date(),
|
|
252
|
+
updated_at: new Date(),
|
|
253
|
+
storageIdentityKey,
|
|
254
|
+
storageName,
|
|
255
|
+
chain,
|
|
256
|
+
dbtype: 'IndexedDB',
|
|
257
|
+
maxOutputScript
|
|
258
|
+
};
|
|
259
|
+
settings.put(s);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
return db;
|
|
264
|
+
}
|
|
265
|
+
//
|
|
266
|
+
// StorageProvider abstract methods
|
|
267
|
+
//
|
|
268
|
+
async reviewStatus(args) {
|
|
269
|
+
return await (0, reviewStatusIdb_1.reviewStatusIdb)(this, args);
|
|
270
|
+
}
|
|
271
|
+
async purgeData(params, trx) {
|
|
272
|
+
return await (0, purgeDataIdb_1.purgeDataIdb)(this, params, trx);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Proceeds in three stages:
|
|
276
|
+
* 1. Find an output that exactly funds the transaction (if exactSatoshis is not undefined).
|
|
277
|
+
* 2. Find an output that overfunds by the least amount (targetSatoshis).
|
|
278
|
+
* 3. Find an output that comes as close to funding as possible (targetSatoshis).
|
|
279
|
+
* 4. Return undefined if no output is found.
|
|
280
|
+
*
|
|
281
|
+
* Outputs must belong to userId and basketId and have spendable true.
|
|
282
|
+
* Their corresponding transaction must have status of 'completed', 'unproven', or 'sending' (if excludeSending is false).
|
|
283
|
+
*
|
|
284
|
+
* @param userId
|
|
285
|
+
* @param basketId
|
|
286
|
+
* @param targetSatoshis
|
|
287
|
+
* @param exactSatoshis
|
|
288
|
+
* @param excludeSending
|
|
289
|
+
* @param transactionId
|
|
290
|
+
* @returns next funding output to add to transaction or undefined if there are none.
|
|
291
|
+
*/
|
|
292
|
+
async allocateChangeInput(userId, basketId, targetSatoshis, exactSatoshis, excludeSending, transactionId) {
|
|
293
|
+
const dbTrx = this.toDbTrx(['outputs', 'transactions'], 'readwrite');
|
|
294
|
+
try {
|
|
295
|
+
const txStatus = ['completed', 'unproven'];
|
|
296
|
+
if (!excludeSending)
|
|
297
|
+
txStatus.push('sending');
|
|
298
|
+
const args = {
|
|
299
|
+
partial: { userId, basketId, spendable: true },
|
|
300
|
+
txStatus,
|
|
301
|
+
trx: dbTrx
|
|
302
|
+
};
|
|
303
|
+
const outputs = await this.findOutputs(args);
|
|
304
|
+
let output;
|
|
305
|
+
let scores = [];
|
|
306
|
+
for (const o of outputs) {
|
|
307
|
+
if (exactSatoshis && o.satoshis === exactSatoshis) {
|
|
308
|
+
output = o;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
const score = o.satoshis - targetSatoshis;
|
|
312
|
+
scores.push({ output: o, score });
|
|
313
|
+
}
|
|
314
|
+
if (!output) {
|
|
315
|
+
// sort scores increasing by score property
|
|
316
|
+
scores = scores.sort((a, b) => a.score - b.score);
|
|
317
|
+
// find the first score that is greater than or equal to 0
|
|
318
|
+
const o = scores.find(s => s.score >= 0);
|
|
319
|
+
if (o) {
|
|
320
|
+
// stage 2 satisfied (minimally funded)
|
|
321
|
+
output = o.output;
|
|
322
|
+
}
|
|
323
|
+
else if (scores.length > 0) {
|
|
324
|
+
// stage 3 satisfied (minimally under-funded)
|
|
325
|
+
output = scores.slice(-1)[0].output;
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
// no available funding outputs
|
|
329
|
+
output = undefined;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (output) {
|
|
333
|
+
// mark output as spent by transactionId
|
|
334
|
+
await this.updateOutput(output.outputId, { spendable: false, spentBy: transactionId }, dbTrx);
|
|
335
|
+
}
|
|
336
|
+
return output;
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
await dbTrx.done;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async getProvenOrRawTx(txid, trx) {
|
|
343
|
+
const r = {
|
|
344
|
+
proven: undefined,
|
|
345
|
+
rawTx: undefined,
|
|
346
|
+
inputBEEF: undefined
|
|
347
|
+
};
|
|
348
|
+
r.proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid: txid }, trx }));
|
|
349
|
+
if (!r.proven) {
|
|
350
|
+
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid: txid }, trx }));
|
|
351
|
+
if (req && ['unsent', 'unmined', 'unconfirmed', 'sending', 'nosend', 'completed'].includes(req.status)) {
|
|
352
|
+
r.rawTx = req.rawTx;
|
|
353
|
+
r.inputBEEF = req.inputBEEF;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return r;
|
|
357
|
+
}
|
|
358
|
+
async getRawTxOfKnownValidTransaction(txid, offset, length, trx) {
|
|
359
|
+
if (!txid)
|
|
360
|
+
return undefined;
|
|
361
|
+
if (!this.isAvailable())
|
|
362
|
+
await this.makeAvailable();
|
|
363
|
+
let rawTx = undefined;
|
|
364
|
+
const r = await this.getProvenOrRawTx(txid, trx);
|
|
365
|
+
if (r.proven)
|
|
366
|
+
rawTx = r.proven.rawTx;
|
|
367
|
+
else
|
|
368
|
+
rawTx = r.rawTx;
|
|
369
|
+
if (rawTx && offset !== undefined && length !== undefined && Number.isInteger(offset) && Number.isInteger(length)) {
|
|
370
|
+
rawTx = rawTx.slice(offset, offset + length);
|
|
371
|
+
}
|
|
372
|
+
return rawTx;
|
|
373
|
+
}
|
|
374
|
+
async getLabelsForTransactionId(transactionId, trx) {
|
|
375
|
+
const maps = await this.findTxLabelMaps({ partial: { transactionId, isDeleted: false }, trx });
|
|
376
|
+
const labelIds = maps.map(m => m.txLabelId);
|
|
377
|
+
const labels = [];
|
|
378
|
+
for (const txLabelId of labelIds) {
|
|
379
|
+
const label = (0, utilityHelpers_1.verifyOne)(await this.findTxLabels({ partial: { txLabelId, isDeleted: false }, trx }));
|
|
380
|
+
labels.push(label);
|
|
381
|
+
}
|
|
382
|
+
return labels;
|
|
383
|
+
}
|
|
384
|
+
async getTagsForOutputId(outputId, trx) {
|
|
385
|
+
const maps = await this.findOutputTagMaps({ partial: { outputId, isDeleted: false }, trx });
|
|
386
|
+
const tagIds = maps.map(m => m.outputTagId);
|
|
387
|
+
const tags = [];
|
|
388
|
+
for (const outputTagId of tagIds) {
|
|
389
|
+
const tag = (0, utilityHelpers_1.verifyOne)(await this.findOutputTags({ partial: { outputTagId, isDeleted: false }, trx }));
|
|
390
|
+
tags.push(tag);
|
|
391
|
+
}
|
|
392
|
+
return tags;
|
|
393
|
+
}
|
|
394
|
+
async listActions(auth, vargs) {
|
|
395
|
+
if (!auth.userId)
|
|
396
|
+
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
397
|
+
return await (0, listActionsIdb_1.listActionsIdb)(this, auth, vargs);
|
|
398
|
+
}
|
|
399
|
+
async listOutputs(auth, vargs) {
|
|
400
|
+
if (!auth.userId)
|
|
401
|
+
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
402
|
+
return await (0, listOutputsIdb_1.listOutputsIdb)(this, auth, vargs);
|
|
403
|
+
}
|
|
404
|
+
async countChangeInputs(userId, basketId, excludeSending) {
|
|
405
|
+
const txStatus = ['completed', 'unproven'];
|
|
406
|
+
if (!excludeSending)
|
|
407
|
+
txStatus.push('sending');
|
|
408
|
+
const args = { partial: { userId, basketId }, txStatus };
|
|
409
|
+
let count = 0;
|
|
410
|
+
await this.filterOutputs(args, r => {
|
|
411
|
+
count++;
|
|
412
|
+
});
|
|
413
|
+
return count;
|
|
414
|
+
}
|
|
415
|
+
async findCertificatesAuth(auth, args) {
|
|
416
|
+
if (!auth.userId || (args.partial.userId && args.partial.userId !== auth.userId))
|
|
417
|
+
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
418
|
+
args.partial.userId = auth.userId;
|
|
419
|
+
return await this.findCertificates(args);
|
|
420
|
+
}
|
|
421
|
+
async findOutputBasketsAuth(auth, args) {
|
|
422
|
+
if (!auth.userId || (args.partial.userId && args.partial.userId !== auth.userId))
|
|
423
|
+
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
424
|
+
args.partial.userId = auth.userId;
|
|
425
|
+
return await this.findOutputBaskets(args);
|
|
426
|
+
}
|
|
427
|
+
async findOutputsAuth(auth, args) {
|
|
428
|
+
if (!auth.userId || (args.partial.userId && args.partial.userId !== auth.userId))
|
|
429
|
+
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
430
|
+
args.partial.userId = auth.userId;
|
|
431
|
+
return await this.findOutputs(args);
|
|
432
|
+
}
|
|
433
|
+
async insertCertificateAuth(auth, certificate) {
|
|
434
|
+
if (!auth.userId || (certificate.userId && certificate.userId !== auth.userId))
|
|
435
|
+
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
436
|
+
certificate.userId = auth.userId;
|
|
437
|
+
return await this.insertCertificate(certificate);
|
|
438
|
+
}
|
|
439
|
+
//
|
|
440
|
+
// StorageReaderWriter abstract methods
|
|
441
|
+
//
|
|
442
|
+
async dropAllData() {
|
|
443
|
+
await (0, idb_1.deleteDB)(this.dbName);
|
|
444
|
+
}
|
|
445
|
+
async filterOutputTagMaps(args, filtered, userId) {
|
|
446
|
+
var _a, _b, _c, _d;
|
|
447
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
448
|
+
let skipped = 0;
|
|
449
|
+
let count = 0;
|
|
450
|
+
const dbTrx = this.toDbTrx(['output_tags_map'], 'readonly', args.trx);
|
|
451
|
+
let cursor;
|
|
452
|
+
if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.outputTagId) !== undefined) {
|
|
453
|
+
cursor = await dbTrx.objectStore('output_tags_map').index('outputTagId').openCursor(args.partial.outputTagId);
|
|
454
|
+
}
|
|
455
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.outputId) !== undefined) {
|
|
456
|
+
cursor = await dbTrx.objectStore('output_tags_map').index('outputId').openCursor(args.partial.outputId);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
cursor = await dbTrx.objectStore('output_tags_map').openCursor();
|
|
460
|
+
}
|
|
461
|
+
let firstTime = true;
|
|
462
|
+
while (cursor) {
|
|
463
|
+
if (!firstTime)
|
|
464
|
+
cursor = await cursor.continue();
|
|
465
|
+
if (!cursor)
|
|
466
|
+
break;
|
|
467
|
+
firstTime = false;
|
|
468
|
+
const r = cursor.value;
|
|
469
|
+
if (args.since && args.since > r.updated_at)
|
|
470
|
+
continue;
|
|
471
|
+
if (args.tagIds && !args.tagIds.includes(r.outputTagId))
|
|
472
|
+
continue;
|
|
473
|
+
if (args.partial) {
|
|
474
|
+
if (args.partial.outputTagId && r.outputTagId !== args.partial.outputTagId)
|
|
475
|
+
continue;
|
|
476
|
+
if (args.partial.outputId && r.outputId !== args.partial.outputId)
|
|
477
|
+
continue;
|
|
478
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
479
|
+
continue;
|
|
480
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
481
|
+
continue;
|
|
482
|
+
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (userId !== undefined && r.txid) {
|
|
486
|
+
const count = await this.countOutputTags({ partial: { userId, outputTagId: r.outputTagId }, trx: args.trx });
|
|
487
|
+
if (count === 0)
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (skipped < offset) {
|
|
491
|
+
skipped++;
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
filtered(r);
|
|
495
|
+
count++;
|
|
496
|
+
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
if (!args.trx)
|
|
500
|
+
await dbTrx.done;
|
|
501
|
+
}
|
|
502
|
+
async findOutputTagMaps(args) {
|
|
503
|
+
const results = [];
|
|
504
|
+
await this.filterOutputTagMaps(args, r => {
|
|
505
|
+
results.push(this.validateEntity(r));
|
|
506
|
+
});
|
|
507
|
+
return results;
|
|
508
|
+
}
|
|
509
|
+
async filterProvenTxReqs(args, filtered, userId) {
|
|
510
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
511
|
+
if (args.partial.rawTx)
|
|
512
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. ProvenTxReqs may not be found by rawTx value.`);
|
|
513
|
+
if (args.partial.inputBEEF)
|
|
514
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', `undefined. ProvenTxReqs may not be found by inputBEEF value.`);
|
|
515
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
516
|
+
let skipped = 0;
|
|
517
|
+
let count = 0;
|
|
518
|
+
const dbTrx = this.toDbTrx(['proven_tx_reqs'], 'readonly', args.trx);
|
|
519
|
+
let cursor;
|
|
520
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.provenTxReqId) {
|
|
521
|
+
cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor(args.partial.provenTxReqId);
|
|
522
|
+
}
|
|
523
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.provenTxId) !== undefined) {
|
|
524
|
+
cursor = await dbTrx.objectStore('proven_tx_reqs').index('provenTxId').openCursor(args.partial.provenTxId);
|
|
525
|
+
}
|
|
526
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.txid) !== undefined) {
|
|
527
|
+
cursor = await dbTrx.objectStore('proven_tx_reqs').index('txid').openCursor(args.partial.txid);
|
|
528
|
+
}
|
|
529
|
+
else if (((_e = args.partial) === null || _e === void 0 ? void 0 : _e.status) !== undefined) {
|
|
530
|
+
cursor = await dbTrx.objectStore('proven_tx_reqs').index('status').openCursor(args.partial.status);
|
|
531
|
+
}
|
|
532
|
+
else if (((_f = args.partial) === null || _f === void 0 ? void 0 : _f.batch) !== undefined) {
|
|
533
|
+
cursor = await dbTrx.objectStore('proven_tx_reqs').index('batch').openCursor(args.partial.batch);
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor();
|
|
537
|
+
}
|
|
538
|
+
let firstTime = true;
|
|
539
|
+
while (cursor) {
|
|
540
|
+
if (!firstTime)
|
|
541
|
+
cursor = await cursor.continue();
|
|
542
|
+
if (!cursor)
|
|
543
|
+
break;
|
|
544
|
+
firstTime = false;
|
|
545
|
+
const r = cursor.value;
|
|
546
|
+
if (args.since && args.since > r.updated_at)
|
|
547
|
+
continue;
|
|
548
|
+
if (args.partial) {
|
|
549
|
+
if (args.partial.provenTxReqId && r.provenTxReqId !== args.partial.provenTxReqId)
|
|
550
|
+
continue;
|
|
551
|
+
if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId)
|
|
552
|
+
continue;
|
|
553
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
554
|
+
continue;
|
|
555
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
556
|
+
continue;
|
|
557
|
+
if (args.partial.status && r.status !== args.partial.status)
|
|
558
|
+
continue;
|
|
559
|
+
if (args.partial.attempts !== undefined && r.attempts !== args.partial.attempts)
|
|
560
|
+
continue;
|
|
561
|
+
if (args.partial.notified !== undefined && r.notified !== args.partial.notified)
|
|
562
|
+
continue;
|
|
563
|
+
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
564
|
+
continue;
|
|
565
|
+
if (args.partial.batch && r.batch !== args.partial.batch)
|
|
566
|
+
continue;
|
|
567
|
+
if (args.partial.history && r.history !== args.partial.history)
|
|
568
|
+
continue;
|
|
569
|
+
if (args.partial.notify && r.notify !== args.partial.notify)
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (userId !== undefined && r.txid) {
|
|
573
|
+
const count = await this.countTransactions({ partial: { userId, txid: r.txid }, trx: args.trx });
|
|
574
|
+
if (count === 0)
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
if (skipped < offset) {
|
|
578
|
+
skipped++;
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
filtered(r);
|
|
582
|
+
count++;
|
|
583
|
+
if (((_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit) && count >= args.paged.limit)
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
if (!args.trx)
|
|
587
|
+
await dbTrx.done;
|
|
588
|
+
}
|
|
589
|
+
async findProvenTxReqs(args) {
|
|
590
|
+
const results = [];
|
|
591
|
+
await this.filterProvenTxReqs(args, r => {
|
|
592
|
+
results.push(this.validateEntity(r));
|
|
593
|
+
});
|
|
594
|
+
return results;
|
|
595
|
+
}
|
|
596
|
+
async filterProvenTxs(args, filtered, userId) {
|
|
597
|
+
var _a, _b, _c, _d;
|
|
598
|
+
if (args.partial.rawTx)
|
|
599
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. ProvenTxs may not be found by rawTx value.`);
|
|
600
|
+
if (args.partial.merklePath)
|
|
601
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.merklePath', `undefined. ProvenTxs may not be found by merklePath value.`);
|
|
602
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
603
|
+
let skipped = 0;
|
|
604
|
+
let count = 0;
|
|
605
|
+
const dbTrx = this.toDbTrx(['proven_txs'], 'readonly', args.trx);
|
|
606
|
+
let cursor;
|
|
607
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.provenTxId) {
|
|
608
|
+
cursor = await dbTrx.objectStore('proven_txs').openCursor(args.partial.provenTxId);
|
|
609
|
+
}
|
|
610
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.txid) !== undefined) {
|
|
611
|
+
cursor = await dbTrx.objectStore('proven_txs').index('txid').openCursor(args.partial.txid);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
cursor = await dbTrx.objectStore('proven_txs').openCursor();
|
|
615
|
+
}
|
|
616
|
+
let firstTime = true;
|
|
617
|
+
while (cursor) {
|
|
618
|
+
if (!firstTime)
|
|
619
|
+
cursor = await cursor.continue();
|
|
620
|
+
if (!cursor)
|
|
621
|
+
break;
|
|
622
|
+
firstTime = false;
|
|
623
|
+
const r = cursor.value;
|
|
624
|
+
if (args.since && args.since > r.updated_at)
|
|
625
|
+
continue;
|
|
626
|
+
if (args.partial) {
|
|
627
|
+
if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId)
|
|
628
|
+
continue;
|
|
629
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
630
|
+
continue;
|
|
631
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
632
|
+
continue;
|
|
633
|
+
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
634
|
+
continue;
|
|
635
|
+
if (args.partial.height !== undefined && r.height !== args.partial.height)
|
|
636
|
+
continue;
|
|
637
|
+
if (args.partial.index !== undefined && r.index !== args.partial.index)
|
|
638
|
+
continue;
|
|
639
|
+
if (args.partial.blockHash && r.blockHash !== args.partial.blockHash)
|
|
640
|
+
continue;
|
|
641
|
+
if (args.partial.merkleRoot && r.merkleRoot !== args.partial.merkleRoot)
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (userId !== undefined) {
|
|
645
|
+
const count = await this.countTransactions({ partial: { userId, provenTxId: r.provenTxId }, trx: args.trx });
|
|
646
|
+
if (count === 0)
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
if (skipped < offset) {
|
|
650
|
+
skipped++;
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
filtered(r);
|
|
654
|
+
count++;
|
|
655
|
+
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
if (!args.trx)
|
|
659
|
+
await dbTrx.done;
|
|
660
|
+
}
|
|
661
|
+
async findProvenTxs(args) {
|
|
662
|
+
const results = [];
|
|
663
|
+
await this.filterProvenTxs(args, r => {
|
|
664
|
+
results.push(this.validateEntity(r));
|
|
665
|
+
});
|
|
666
|
+
return results;
|
|
667
|
+
}
|
|
668
|
+
async filterTxLabelMaps(args, filtered, userId) {
|
|
669
|
+
var _a, _b, _c, _d;
|
|
670
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
671
|
+
let skipped = 0;
|
|
672
|
+
let count = 0;
|
|
673
|
+
const dbTrx = this.toDbTrx(['tx_labels_map'], 'readonly', args.trx);
|
|
674
|
+
let cursor;
|
|
675
|
+
if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.transactionId) !== undefined) {
|
|
676
|
+
cursor = await dbTrx.objectStore('tx_labels_map').index('transactionId').openCursor(args.partial.transactionId);
|
|
677
|
+
}
|
|
678
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.txLabelId) !== undefined) {
|
|
679
|
+
cursor = await dbTrx.objectStore('tx_labels_map').index('txLabelId').openCursor(args.partial.txLabelId);
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
cursor = await dbTrx.objectStore('tx_labels_map').openCursor();
|
|
683
|
+
}
|
|
684
|
+
let firstTime = true;
|
|
685
|
+
while (cursor) {
|
|
686
|
+
if (!firstTime)
|
|
687
|
+
cursor = await cursor.continue();
|
|
688
|
+
if (!cursor)
|
|
689
|
+
break;
|
|
690
|
+
firstTime = false;
|
|
691
|
+
const r = cursor.value;
|
|
692
|
+
if (args.since && args.since > r.updated_at)
|
|
693
|
+
continue;
|
|
694
|
+
if (args.partial) {
|
|
695
|
+
if (args.partial.txLabelId && r.txLabelId !== args.partial.txLabelId)
|
|
696
|
+
continue;
|
|
697
|
+
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
698
|
+
continue;
|
|
699
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
700
|
+
continue;
|
|
701
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
702
|
+
continue;
|
|
703
|
+
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (userId !== undefined) {
|
|
707
|
+
const count = await this.countTxLabels({ partial: { userId, txLabelId: r.txLabelId }, trx: args.trx });
|
|
708
|
+
if (count === 0)
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
if (skipped < offset) {
|
|
712
|
+
skipped++;
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
filtered(r);
|
|
716
|
+
count++;
|
|
717
|
+
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
if (!args.trx)
|
|
721
|
+
await dbTrx.done;
|
|
722
|
+
}
|
|
723
|
+
async findTxLabelMaps(args) {
|
|
724
|
+
const results = [];
|
|
725
|
+
await this.filterTxLabelMaps(args, r => {
|
|
726
|
+
results.push(this.validateEntity(r));
|
|
727
|
+
});
|
|
728
|
+
return results;
|
|
729
|
+
}
|
|
730
|
+
async countOutputTagMaps(args) {
|
|
731
|
+
let count = 0;
|
|
732
|
+
await this.filterOutputTagMaps(args, () => {
|
|
733
|
+
count++;
|
|
734
|
+
});
|
|
735
|
+
return count;
|
|
736
|
+
}
|
|
737
|
+
async countProvenTxReqs(args) {
|
|
738
|
+
let count = 0;
|
|
739
|
+
await this.filterProvenTxReqs(args, () => {
|
|
740
|
+
count++;
|
|
741
|
+
});
|
|
742
|
+
return count;
|
|
743
|
+
}
|
|
744
|
+
async countProvenTxs(args) {
|
|
745
|
+
let count = 0;
|
|
746
|
+
await this.filterProvenTxs(args, () => {
|
|
747
|
+
count++;
|
|
748
|
+
});
|
|
749
|
+
return count;
|
|
750
|
+
}
|
|
751
|
+
async countTxLabelMaps(args) {
|
|
752
|
+
let count = 0;
|
|
753
|
+
await this.filterTxLabelMaps(args, () => {
|
|
754
|
+
count++;
|
|
755
|
+
});
|
|
756
|
+
return count;
|
|
757
|
+
}
|
|
758
|
+
async insertCertificate(certificate, trx) {
|
|
759
|
+
const e = await this.validateEntityForInsert(certificate, trx, undefined, ['isDeleted']);
|
|
760
|
+
const fields = e.fields;
|
|
761
|
+
if (e.fields)
|
|
762
|
+
delete e.fields;
|
|
763
|
+
if (e.certificateId === 0)
|
|
764
|
+
delete e.certificateId;
|
|
765
|
+
const dbTrx = this.toDbTrx(['certificates', 'certificate_fields'], 'readwrite', trx);
|
|
766
|
+
const store = dbTrx.objectStore('certificates');
|
|
767
|
+
try {
|
|
768
|
+
const id = Number(await store.add(e));
|
|
769
|
+
certificate.certificateId = id;
|
|
770
|
+
if (fields) {
|
|
771
|
+
for (const field of fields) {
|
|
772
|
+
field.certificateId = certificate.certificateId;
|
|
773
|
+
field.userId = certificate.userId;
|
|
774
|
+
await this.insertCertificateField(field, dbTrx);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
finally {
|
|
779
|
+
if (!trx)
|
|
780
|
+
await dbTrx.done;
|
|
781
|
+
}
|
|
782
|
+
return certificate.certificateId;
|
|
783
|
+
}
|
|
784
|
+
async insertCertificateField(certificateField, trx) {
|
|
785
|
+
const e = await this.validateEntityForInsert(certificateField, trx);
|
|
786
|
+
const dbTrx = this.toDbTrx(['certificate_fields'], 'readwrite', trx);
|
|
787
|
+
const store = dbTrx.objectStore('certificate_fields');
|
|
788
|
+
try {
|
|
789
|
+
await store.add(e);
|
|
790
|
+
}
|
|
791
|
+
finally {
|
|
792
|
+
if (!trx)
|
|
793
|
+
await dbTrx.done;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
async insertCommission(commission, trx) {
|
|
797
|
+
const e = await this.validateEntityForInsert(commission, trx);
|
|
798
|
+
if (e.commissionId === 0)
|
|
799
|
+
delete e.commissionId;
|
|
800
|
+
const dbTrx = this.toDbTrx(['commissions'], 'readwrite', trx);
|
|
801
|
+
const store = dbTrx.objectStore('commissions');
|
|
802
|
+
try {
|
|
803
|
+
const id = Number(await store.add(e));
|
|
804
|
+
commission.commissionId = id;
|
|
805
|
+
}
|
|
806
|
+
finally {
|
|
807
|
+
if (!trx)
|
|
808
|
+
await dbTrx.done;
|
|
809
|
+
}
|
|
810
|
+
return commission.commissionId;
|
|
811
|
+
}
|
|
812
|
+
async insertMonitorEvent(event, trx) {
|
|
813
|
+
const e = await this.validateEntityForInsert(event, trx);
|
|
814
|
+
if (e.id === 0)
|
|
815
|
+
delete e.id;
|
|
816
|
+
const dbTrx = this.toDbTrx(['monitor_events'], 'readwrite', trx);
|
|
817
|
+
const store = dbTrx.objectStore('monitor_events');
|
|
818
|
+
try {
|
|
819
|
+
const id = Number(await store.add(e));
|
|
820
|
+
event.id = id;
|
|
821
|
+
}
|
|
822
|
+
finally {
|
|
823
|
+
if (!trx)
|
|
824
|
+
await dbTrx.done;
|
|
825
|
+
}
|
|
826
|
+
return event.id;
|
|
827
|
+
}
|
|
828
|
+
async insertOutput(output, trx) {
|
|
829
|
+
const e = await this.validateEntityForInsert(output, trx);
|
|
830
|
+
if (e.outputId === 0)
|
|
831
|
+
delete e.outputId;
|
|
832
|
+
const dbTrx = this.toDbTrx(['outputs'], 'readwrite', trx);
|
|
833
|
+
const store = dbTrx.objectStore('outputs');
|
|
834
|
+
try {
|
|
835
|
+
const id = Number(await store.add(e));
|
|
836
|
+
output.outputId = id;
|
|
837
|
+
}
|
|
838
|
+
finally {
|
|
839
|
+
if (!trx)
|
|
840
|
+
await dbTrx.done;
|
|
841
|
+
}
|
|
842
|
+
return output.outputId;
|
|
843
|
+
}
|
|
844
|
+
async insertOutputBasket(basket, trx) {
|
|
845
|
+
const e = await this.validateEntityForInsert(basket, trx, undefined, ['isDeleted']);
|
|
846
|
+
if (e.basketId === 0)
|
|
847
|
+
delete e.basketId;
|
|
848
|
+
const dbTrx = this.toDbTrx(['output_baskets'], 'readwrite', trx);
|
|
849
|
+
const store = dbTrx.objectStore('output_baskets');
|
|
850
|
+
try {
|
|
851
|
+
const id = Number(await store.add(e));
|
|
852
|
+
basket.basketId = id;
|
|
853
|
+
}
|
|
854
|
+
finally {
|
|
855
|
+
if (!trx)
|
|
856
|
+
await dbTrx.done;
|
|
857
|
+
}
|
|
858
|
+
return basket.basketId;
|
|
859
|
+
}
|
|
860
|
+
async insertOutputTag(tag, trx) {
|
|
861
|
+
const e = await this.validateEntityForInsert(tag, trx, undefined, ['isDeleted']);
|
|
862
|
+
if (e.outputTagId === 0)
|
|
863
|
+
delete e.outputTagId;
|
|
864
|
+
const dbTrx = this.toDbTrx(['output_tags'], 'readwrite', trx);
|
|
865
|
+
const store = dbTrx.objectStore('output_tags');
|
|
866
|
+
try {
|
|
867
|
+
const id = Number(await store.add(e));
|
|
868
|
+
tag.outputTagId = id;
|
|
869
|
+
}
|
|
870
|
+
finally {
|
|
871
|
+
if (!trx)
|
|
872
|
+
await dbTrx.done;
|
|
873
|
+
}
|
|
874
|
+
return tag.outputTagId;
|
|
875
|
+
}
|
|
876
|
+
async insertOutputTagMap(tagMap, trx) {
|
|
877
|
+
const e = await this.validateEntityForInsert(tagMap, trx, undefined, ['isDeleted']);
|
|
878
|
+
const dbTrx = this.toDbTrx(['output_tags_map'], 'readwrite', trx);
|
|
879
|
+
const store = dbTrx.objectStore('output_tags_map');
|
|
880
|
+
try {
|
|
881
|
+
await store.add(e);
|
|
882
|
+
}
|
|
883
|
+
finally {
|
|
884
|
+
if (!trx)
|
|
885
|
+
await dbTrx.done;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
async insertProvenTx(tx, trx) {
|
|
889
|
+
const e = await this.validateEntityForInsert(tx, trx);
|
|
890
|
+
if (e.provenTxId === 0)
|
|
891
|
+
delete e.provenTxId;
|
|
892
|
+
const dbTrx = this.toDbTrx(['proven_txs'], 'readwrite', trx);
|
|
893
|
+
const store = dbTrx.objectStore('proven_txs');
|
|
894
|
+
try {
|
|
895
|
+
const id = Number(await store.add(e));
|
|
896
|
+
tx.provenTxId = id;
|
|
897
|
+
}
|
|
898
|
+
finally {
|
|
899
|
+
if (!trx)
|
|
900
|
+
await dbTrx.done;
|
|
901
|
+
}
|
|
902
|
+
return tx.provenTxId;
|
|
903
|
+
}
|
|
904
|
+
async insertProvenTxReq(tx, trx) {
|
|
905
|
+
const e = await this.validateEntityForInsert(tx, trx);
|
|
906
|
+
if (e.provenTxReqId === 0)
|
|
907
|
+
delete e.provenTxReqId;
|
|
908
|
+
const dbTrx = this.toDbTrx(['proven_tx_reqs'], 'readwrite', trx);
|
|
909
|
+
const store = dbTrx.objectStore('proven_tx_reqs');
|
|
910
|
+
try {
|
|
911
|
+
const id = Number(await store.add(e));
|
|
912
|
+
tx.provenTxReqId = id;
|
|
913
|
+
}
|
|
914
|
+
finally {
|
|
915
|
+
if (!trx)
|
|
916
|
+
await dbTrx.done;
|
|
917
|
+
}
|
|
918
|
+
return tx.provenTxReqId;
|
|
919
|
+
}
|
|
920
|
+
async insertSyncState(syncState, trx) {
|
|
921
|
+
const e = await this.validateEntityForInsert(syncState, trx, ['when'], ['init']);
|
|
922
|
+
if (e.syncStateId === 0)
|
|
923
|
+
delete e.syncStateId;
|
|
924
|
+
const dbTrx = this.toDbTrx(['sync_states'], 'readwrite', trx);
|
|
925
|
+
const store = dbTrx.objectStore('sync_states');
|
|
926
|
+
try {
|
|
927
|
+
const id = Number(await store.add(e));
|
|
928
|
+
syncState.syncStateId = id;
|
|
929
|
+
}
|
|
930
|
+
finally {
|
|
931
|
+
if (!trx)
|
|
932
|
+
await dbTrx.done;
|
|
933
|
+
}
|
|
934
|
+
return syncState.syncStateId;
|
|
935
|
+
}
|
|
936
|
+
async insertTransaction(tx, trx) {
|
|
937
|
+
const e = await this.validateEntityForInsert(tx, trx);
|
|
938
|
+
if (e.transactionId === 0)
|
|
939
|
+
delete e.transactionId;
|
|
940
|
+
const dbTrx = this.toDbTrx(['transactions'], 'readwrite', trx);
|
|
941
|
+
const store = dbTrx.objectStore('transactions');
|
|
942
|
+
try {
|
|
943
|
+
const id = Number(await store.add(e));
|
|
944
|
+
tx.transactionId = id;
|
|
945
|
+
}
|
|
946
|
+
finally {
|
|
947
|
+
if (!trx)
|
|
948
|
+
await dbTrx.done;
|
|
949
|
+
}
|
|
950
|
+
return tx.transactionId;
|
|
951
|
+
}
|
|
952
|
+
async insertTxLabel(label, trx) {
|
|
953
|
+
const e = await this.validateEntityForInsert(label, trx, undefined, ['isDeleted']);
|
|
954
|
+
if (e.txLabelId === 0)
|
|
955
|
+
delete e.txLabelId;
|
|
956
|
+
const dbTrx = this.toDbTrx(['tx_labels'], 'readwrite', trx);
|
|
957
|
+
const store = dbTrx.objectStore('tx_labels');
|
|
958
|
+
try {
|
|
959
|
+
const id = Number(await store.add(e));
|
|
960
|
+
label.txLabelId = id;
|
|
961
|
+
}
|
|
962
|
+
finally {
|
|
963
|
+
if (!trx)
|
|
964
|
+
await dbTrx.done;
|
|
965
|
+
}
|
|
966
|
+
return label.txLabelId;
|
|
967
|
+
}
|
|
968
|
+
async insertTxLabelMap(labelMap, trx) {
|
|
969
|
+
const e = await this.validateEntityForInsert(labelMap, trx, undefined, ['isDeleted']);
|
|
970
|
+
const dbTrx = this.toDbTrx(['tx_labels_map'], 'readwrite', trx);
|
|
971
|
+
const store = dbTrx.objectStore('tx_labels_map');
|
|
972
|
+
try {
|
|
973
|
+
await store.add(e);
|
|
974
|
+
}
|
|
975
|
+
finally {
|
|
976
|
+
if (!trx)
|
|
977
|
+
await dbTrx.done;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
async insertUser(user, trx) {
|
|
981
|
+
const e = await this.validateEntityForInsert(user, trx);
|
|
982
|
+
if (e.userId === 0)
|
|
983
|
+
delete e.userId;
|
|
984
|
+
const dbTrx = this.toDbTrx(['users'], 'readwrite', trx);
|
|
985
|
+
const store = dbTrx.objectStore('users');
|
|
986
|
+
try {
|
|
987
|
+
const id = Number(await store.add(e));
|
|
988
|
+
user.userId = id;
|
|
989
|
+
}
|
|
990
|
+
finally {
|
|
991
|
+
if (!trx)
|
|
992
|
+
await dbTrx.done;
|
|
993
|
+
}
|
|
994
|
+
return user.userId;
|
|
995
|
+
}
|
|
996
|
+
async updateIdb(id, update, keyProp, storeName, trx) {
|
|
997
|
+
if (update[keyProp] !== undefined && (Array.isArray(id) || update[keyProp] !== id)) {
|
|
998
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProp}`, `undefined`);
|
|
999
|
+
}
|
|
1000
|
+
const u = this.validatePartialForUpdate(update);
|
|
1001
|
+
const dbTrx = this.toDbTrx([storeName], 'readwrite', trx);
|
|
1002
|
+
const store = dbTrx.objectStore(storeName);
|
|
1003
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
1004
|
+
try {
|
|
1005
|
+
for (const i of ids) {
|
|
1006
|
+
const e = await store.get(i);
|
|
1007
|
+
if (!e)
|
|
1008
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('id', `an existing record to update ${keyProp} ${i} not found`);
|
|
1009
|
+
const v = {
|
|
1010
|
+
...e,
|
|
1011
|
+
...u
|
|
1012
|
+
};
|
|
1013
|
+
const uid = await store.put(v);
|
|
1014
|
+
if (uid !== i)
|
|
1015
|
+
throw new WERR_errors_1.WERR_INTERNAL(`updated id ${uid} does not match original ${id}`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
finally {
|
|
1019
|
+
if (!trx)
|
|
1020
|
+
await dbTrx.done;
|
|
1021
|
+
}
|
|
1022
|
+
return 1;
|
|
1023
|
+
}
|
|
1024
|
+
async updateIdbKey(key, update, keyProps, storeName, trx) {
|
|
1025
|
+
if (key.length !== keyProps.length)
|
|
1026
|
+
throw new WERR_errors_1.WERR_INTERNAL(`key.length ${key.length} !== keyProps.length ${keyProps.length}`);
|
|
1027
|
+
for (let i = 0; i < key.length; i++) {
|
|
1028
|
+
if (update[keyProps[i]] !== undefined && update[keyProps[i]] !== key[i]) {
|
|
1029
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProps[i]}`, `undefined`);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
const u = this.validatePartialForUpdate(update);
|
|
1033
|
+
const dbTrx = this.toDbTrx([storeName], 'readwrite', trx);
|
|
1034
|
+
const store = dbTrx.objectStore(storeName);
|
|
1035
|
+
try {
|
|
1036
|
+
const e = await store.get(key);
|
|
1037
|
+
if (!e)
|
|
1038
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('key', `an existing record to update ${keyProps.join(',')} ${key.join(',')} not found`);
|
|
1039
|
+
const v = {
|
|
1040
|
+
...e,
|
|
1041
|
+
...u
|
|
1042
|
+
};
|
|
1043
|
+
const uid = await store.put(v);
|
|
1044
|
+
for (let i = 0; i < key.length; i++) {
|
|
1045
|
+
if (uid[i] !== key[i])
|
|
1046
|
+
throw new WERR_errors_1.WERR_INTERNAL(`updated key ${uid[i]} does not match original ${key[i]}`);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
finally {
|
|
1050
|
+
if (!trx)
|
|
1051
|
+
await dbTrx.done;
|
|
1052
|
+
}
|
|
1053
|
+
return 1;
|
|
1054
|
+
}
|
|
1055
|
+
async updateCertificate(id, update, trx) {
|
|
1056
|
+
return this.updateIdb(id, update, 'certificateId', 'certificates', trx);
|
|
1057
|
+
}
|
|
1058
|
+
async updateCertificateField(certificateId, fieldName, update, trx) {
|
|
1059
|
+
return this.updateIdbKey([certificateId, fieldName], update, ['certificateId', 'fieldName'], 'certificate_fields', trx);
|
|
1060
|
+
}
|
|
1061
|
+
async updateCommission(id, update, trx) {
|
|
1062
|
+
return this.updateIdb(id, update, 'commissionId', 'commissions', trx);
|
|
1063
|
+
}
|
|
1064
|
+
async updateMonitorEvent(id, update, trx) {
|
|
1065
|
+
return this.updateIdb(id, update, 'id', 'monitor_events', trx);
|
|
1066
|
+
}
|
|
1067
|
+
async updateOutput(id, update, trx) {
|
|
1068
|
+
return this.updateIdb(id, update, 'outputId', 'outputs', trx);
|
|
1069
|
+
}
|
|
1070
|
+
async updateOutputBasket(id, update, trx) {
|
|
1071
|
+
return this.updateIdb(id, update, 'basketId', 'output_baskets', trx);
|
|
1072
|
+
}
|
|
1073
|
+
async updateOutputTag(id, update, trx) {
|
|
1074
|
+
return this.updateIdb(id, update, 'outputTagId', 'output_tags', trx);
|
|
1075
|
+
}
|
|
1076
|
+
async updateProvenTx(id, update, trx) {
|
|
1077
|
+
return this.updateIdb(id, update, 'provenTxId', 'proven_txs', trx);
|
|
1078
|
+
}
|
|
1079
|
+
async updateProvenTxReq(id, update, trx) {
|
|
1080
|
+
return this.updateIdb(id, update, 'provenTxReqId', 'proven_tx_reqs', trx);
|
|
1081
|
+
}
|
|
1082
|
+
async updateSyncState(id, update, trx) {
|
|
1083
|
+
return this.updateIdb(id, update, 'syncStateId', 'sync_states', trx);
|
|
1084
|
+
}
|
|
1085
|
+
async updateTransaction(id, update, trx) {
|
|
1086
|
+
return this.updateIdb(id, update, 'transactionId', 'transactions', trx);
|
|
1087
|
+
}
|
|
1088
|
+
async updateTxLabel(id, update, trx) {
|
|
1089
|
+
return this.updateIdb(id, update, 'txLabelId', 'tx_labels', trx);
|
|
1090
|
+
}
|
|
1091
|
+
async updateUser(id, update, trx) {
|
|
1092
|
+
return this.updateIdb(id, update, 'userId', 'users', trx);
|
|
1093
|
+
}
|
|
1094
|
+
async updateOutputTagMap(outputId, tagId, update, trx) {
|
|
1095
|
+
return this.updateIdbKey([tagId, outputId], update, ['outputTagId', 'outputId'], 'output_tags_map', trx);
|
|
1096
|
+
}
|
|
1097
|
+
async updateTxLabelMap(transactionId, txLabelId, update, trx) {
|
|
1098
|
+
return this.updateIdbKey([txLabelId, transactionId], update, ['txLabelId', 'transactionId'], 'tx_labels_map', trx);
|
|
1099
|
+
}
|
|
1100
|
+
//
|
|
1101
|
+
// StorageReader abstract methods
|
|
1102
|
+
//
|
|
1103
|
+
async destroy() {
|
|
1104
|
+
if (this.db) {
|
|
1105
|
+
this.db.close();
|
|
1106
|
+
}
|
|
1107
|
+
this.db = undefined;
|
|
1108
|
+
this._settings = undefined;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* @param scope
|
|
1112
|
+
* @param trx
|
|
1113
|
+
* @returns
|
|
1114
|
+
*/
|
|
1115
|
+
async transaction(scope, trx) {
|
|
1116
|
+
if (trx)
|
|
1117
|
+
return await scope(trx);
|
|
1118
|
+
const stores = this.allStores;
|
|
1119
|
+
const db = await this.verifyDB();
|
|
1120
|
+
const tx = db.transaction(stores, 'readwrite');
|
|
1121
|
+
try {
|
|
1122
|
+
const r = await scope(tx);
|
|
1123
|
+
await tx.done;
|
|
1124
|
+
return r;
|
|
1125
|
+
}
|
|
1126
|
+
catch (err) {
|
|
1127
|
+
tx.abort();
|
|
1128
|
+
await tx.done;
|
|
1129
|
+
throw err;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
async filterCertificateFields(args, filtered) {
|
|
1133
|
+
var _a, _b, _c, _d;
|
|
1134
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1135
|
+
let skipped = 0;
|
|
1136
|
+
let count = 0;
|
|
1137
|
+
const dbTrx = this.toDbTrx(['certificate_fields'], 'readonly', args.trx);
|
|
1138
|
+
let cursor;
|
|
1139
|
+
if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.certificateId) !== undefined) {
|
|
1140
|
+
cursor = await dbTrx
|
|
1141
|
+
.objectStore('certificate_fields')
|
|
1142
|
+
.index('certificateId')
|
|
1143
|
+
.openCursor(args.partial.certificateId);
|
|
1144
|
+
}
|
|
1145
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1146
|
+
cursor = await dbTrx.objectStore('certificate_fields').index('userId').openCursor(args.partial.userId);
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
cursor = await dbTrx.objectStore('certificate_fields').openCursor();
|
|
1150
|
+
}
|
|
1151
|
+
let firstTime = true;
|
|
1152
|
+
while (cursor) {
|
|
1153
|
+
if (!firstTime)
|
|
1154
|
+
cursor = await cursor.continue();
|
|
1155
|
+
if (!cursor)
|
|
1156
|
+
break;
|
|
1157
|
+
firstTime = false;
|
|
1158
|
+
const r = cursor.value;
|
|
1159
|
+
if (args.since && args.since > r.updated_at)
|
|
1160
|
+
continue;
|
|
1161
|
+
if (args.partial) {
|
|
1162
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1163
|
+
continue;
|
|
1164
|
+
if (args.partial.certificateId && r.certificateId !== args.partial.certificateId)
|
|
1165
|
+
continue;
|
|
1166
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1167
|
+
continue;
|
|
1168
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1169
|
+
continue;
|
|
1170
|
+
if (args.partial.fieldName && r.fieldName !== args.partial.fieldName)
|
|
1171
|
+
continue;
|
|
1172
|
+
if (args.partial.fieldValue && r.fieldValue !== args.partial.fieldValue)
|
|
1173
|
+
continue;
|
|
1174
|
+
if (args.partial.masterKey && r.masterKey !== args.partial.masterKey)
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
if (skipped < offset) {
|
|
1178
|
+
skipped++;
|
|
1179
|
+
continue;
|
|
1180
|
+
}
|
|
1181
|
+
filtered(r);
|
|
1182
|
+
count++;
|
|
1183
|
+
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
if (!args.trx)
|
|
1187
|
+
await dbTrx.done;
|
|
1188
|
+
}
|
|
1189
|
+
async findCertificateFields(args) {
|
|
1190
|
+
const result = [];
|
|
1191
|
+
await this.filterCertificateFields(args, r => {
|
|
1192
|
+
result.push(this.validateEntity(r));
|
|
1193
|
+
});
|
|
1194
|
+
return result;
|
|
1195
|
+
}
|
|
1196
|
+
async filterCertificates(args, filtered) {
|
|
1197
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1198
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1199
|
+
let skipped = 0;
|
|
1200
|
+
let count = 0;
|
|
1201
|
+
const dbTrx = this.toDbTrx(['certificates'], 'readonly', args.trx);
|
|
1202
|
+
let cursor;
|
|
1203
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.certificateId) {
|
|
1204
|
+
cursor = await dbTrx.objectStore('certificates').openCursor(args.partial.certificateId);
|
|
1205
|
+
}
|
|
1206
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1207
|
+
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.type) && ((_e = args.partial) === null || _e === void 0 ? void 0 : _e.certifier) && ((_f = args.partial) === null || _f === void 0 ? void 0 : _f.serialNumber)) {
|
|
1208
|
+
cursor = await dbTrx
|
|
1209
|
+
.objectStore('certificates')
|
|
1210
|
+
.index('userId_type_certifier_serialNumber')
|
|
1211
|
+
.openCursor([args.partial.userId, args.partial.type, args.partial.certifier, args.partial.serialNumber]);
|
|
1212
|
+
}
|
|
1213
|
+
else {
|
|
1214
|
+
cursor = await dbTrx.objectStore('certificates').index('userId').openCursor(args.partial.userId);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
cursor = await dbTrx.objectStore('certificates').openCursor();
|
|
1219
|
+
}
|
|
1220
|
+
let firstTime = true;
|
|
1221
|
+
while (cursor) {
|
|
1222
|
+
if (!firstTime)
|
|
1223
|
+
cursor = await cursor.continue();
|
|
1224
|
+
if (!cursor)
|
|
1225
|
+
break;
|
|
1226
|
+
firstTime = false;
|
|
1227
|
+
const r = cursor.value;
|
|
1228
|
+
if (args.since && args.since > r.updated_at)
|
|
1229
|
+
continue;
|
|
1230
|
+
if (args.certifiers && !args.certifiers.includes(r.certifier))
|
|
1231
|
+
continue;
|
|
1232
|
+
if (args.types && !args.types.includes(r.type))
|
|
1233
|
+
continue;
|
|
1234
|
+
if (args.partial) {
|
|
1235
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1236
|
+
continue;
|
|
1237
|
+
if (args.partial.certificateId && r.certificateId !== args.partial.certificateId)
|
|
1238
|
+
continue;
|
|
1239
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1240
|
+
continue;
|
|
1241
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1242
|
+
continue;
|
|
1243
|
+
if (args.partial.type && r.type !== args.partial.type)
|
|
1244
|
+
continue;
|
|
1245
|
+
if (args.partial.serialNumber && r.serialNumber !== args.partial.serialNumber)
|
|
1246
|
+
continue;
|
|
1247
|
+
if (args.partial.certifier && r.certifier !== args.partial.certifier)
|
|
1248
|
+
continue;
|
|
1249
|
+
if (args.partial.subject && r.subject !== args.partial.subject)
|
|
1250
|
+
continue;
|
|
1251
|
+
if (args.partial.verifier && r.verifier !== args.partial.verifier)
|
|
1252
|
+
continue;
|
|
1253
|
+
if (args.partial.revocationOutpoint && r.revocationOutpoint !== args.partial.revocationOutpoint)
|
|
1254
|
+
continue;
|
|
1255
|
+
if (args.partial.signature && r.signature !== args.partial.signature)
|
|
1256
|
+
continue;
|
|
1257
|
+
if (args.partial.isDeleted && r.isDeleted !== args.partial.isDeleted)
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
if (skipped < offset) {
|
|
1261
|
+
skipped++;
|
|
1262
|
+
continue;
|
|
1263
|
+
}
|
|
1264
|
+
filtered(r);
|
|
1265
|
+
count++;
|
|
1266
|
+
if (((_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit) && count >= args.paged.limit)
|
|
1267
|
+
break;
|
|
1268
|
+
}
|
|
1269
|
+
if (!args.trx)
|
|
1270
|
+
await dbTrx.done;
|
|
1271
|
+
}
|
|
1272
|
+
async findCertificates(args) {
|
|
1273
|
+
const result = [];
|
|
1274
|
+
await this.filterCertificates(args, r => {
|
|
1275
|
+
result.push(this.validateEntity(r));
|
|
1276
|
+
});
|
|
1277
|
+
if (args.includeFields) {
|
|
1278
|
+
for (const c of result) {
|
|
1279
|
+
const fields = await this.findCertificateFields({ partial: { certificateId: c.certificateId }, trx: args.trx });
|
|
1280
|
+
c.fields = fields;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
return result;
|
|
1284
|
+
}
|
|
1285
|
+
async filterCommissions(args, filtered) {
|
|
1286
|
+
var _a, _b, _c, _d, _e;
|
|
1287
|
+
if (args.partial.lockingScript)
|
|
1288
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('partial.lockingScript', `undefined. Commissions may not be found by lockingScript value.`);
|
|
1289
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1290
|
+
let skipped = 0;
|
|
1291
|
+
let count = 0;
|
|
1292
|
+
const dbTrx = this.toDbTrx(['commissions'], 'readonly', args.trx);
|
|
1293
|
+
let cursor;
|
|
1294
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.commissionId) {
|
|
1295
|
+
cursor = await dbTrx.objectStore('commissions').openCursor(args.partial.commissionId);
|
|
1296
|
+
}
|
|
1297
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1298
|
+
cursor = await dbTrx.objectStore('commissions').index('userId').openCursor(args.partial.userId);
|
|
1299
|
+
}
|
|
1300
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.transactionId) !== undefined) {
|
|
1301
|
+
cursor = await dbTrx.objectStore('commissions').index('transactionId').openCursor(args.partial.transactionId);
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
cursor = await dbTrx.objectStore('commissions').openCursor();
|
|
1305
|
+
}
|
|
1306
|
+
let firstTime = true;
|
|
1307
|
+
while (cursor) {
|
|
1308
|
+
if (!firstTime)
|
|
1309
|
+
cursor = await cursor.continue();
|
|
1310
|
+
if (!cursor)
|
|
1311
|
+
break;
|
|
1312
|
+
firstTime = false;
|
|
1313
|
+
const r = cursor.value;
|
|
1314
|
+
if (args.since && args.since > r.updated_at)
|
|
1315
|
+
continue;
|
|
1316
|
+
if (args.partial) {
|
|
1317
|
+
if (args.partial.commissionId && r.commissionId !== args.partial.commissionId)
|
|
1318
|
+
continue;
|
|
1319
|
+
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
1320
|
+
continue;
|
|
1321
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1322
|
+
continue;
|
|
1323
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1324
|
+
continue;
|
|
1325
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1326
|
+
continue;
|
|
1327
|
+
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1328
|
+
continue;
|
|
1329
|
+
if (args.partial.keyOffset && r.keyOffset !== args.partial.keyOffset)
|
|
1330
|
+
continue;
|
|
1331
|
+
if (args.partial.isRedeemed !== undefined && r.isRedeemed !== args.partial.isRedeemed)
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
if (skipped < offset) {
|
|
1335
|
+
skipped++;
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1338
|
+
filtered(r);
|
|
1339
|
+
count++;
|
|
1340
|
+
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1341
|
+
break;
|
|
1342
|
+
}
|
|
1343
|
+
if (!args.trx)
|
|
1344
|
+
await dbTrx.done;
|
|
1345
|
+
}
|
|
1346
|
+
async findCommissions(args) {
|
|
1347
|
+
const result = [];
|
|
1348
|
+
await this.filterCommissions(args, r => {
|
|
1349
|
+
result.push(this.validateEntity(r));
|
|
1350
|
+
});
|
|
1351
|
+
return result;
|
|
1352
|
+
}
|
|
1353
|
+
async filterMonitorEvents(args, filtered) {
|
|
1354
|
+
var _a, _b, _c;
|
|
1355
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1356
|
+
let skipped = 0;
|
|
1357
|
+
let count = 0;
|
|
1358
|
+
const dbTrx = this.toDbTrx(['monitor_events'], 'readonly', args.trx);
|
|
1359
|
+
let cursor;
|
|
1360
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.id) {
|
|
1361
|
+
cursor = await dbTrx.objectStore('monitor_events').openCursor(args.partial.id);
|
|
1362
|
+
}
|
|
1363
|
+
else {
|
|
1364
|
+
cursor = await dbTrx.objectStore('monitor_events').openCursor();
|
|
1365
|
+
}
|
|
1366
|
+
let firstTime = true;
|
|
1367
|
+
while (cursor) {
|
|
1368
|
+
if (!firstTime)
|
|
1369
|
+
cursor = await cursor.continue();
|
|
1370
|
+
if (!cursor)
|
|
1371
|
+
break;
|
|
1372
|
+
firstTime = false;
|
|
1373
|
+
const r = cursor.value;
|
|
1374
|
+
if (args.since && args.since > r.updated_at)
|
|
1375
|
+
continue;
|
|
1376
|
+
if (args.partial) {
|
|
1377
|
+
if (args.partial.id && r.id !== args.partial.id)
|
|
1378
|
+
continue;
|
|
1379
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1380
|
+
continue;
|
|
1381
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1382
|
+
continue;
|
|
1383
|
+
if (args.partial.event && r.event !== args.partial.event)
|
|
1384
|
+
continue;
|
|
1385
|
+
if (args.partial.details && r.details !== args.partial.details)
|
|
1386
|
+
continue;
|
|
1387
|
+
}
|
|
1388
|
+
if (skipped < offset) {
|
|
1389
|
+
skipped++;
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1392
|
+
filtered(r);
|
|
1393
|
+
count++;
|
|
1394
|
+
if (((_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit) && count >= args.paged.limit)
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
if (!args.trx)
|
|
1398
|
+
await dbTrx.done;
|
|
1399
|
+
}
|
|
1400
|
+
async findMonitorEvents(args) {
|
|
1401
|
+
const result = [];
|
|
1402
|
+
await this.filterMonitorEvents(args, r => {
|
|
1403
|
+
result.push(this.validateEntity(r));
|
|
1404
|
+
});
|
|
1405
|
+
return result;
|
|
1406
|
+
}
|
|
1407
|
+
async filterOutputBaskets(args, filtered) {
|
|
1408
|
+
var _a, _b, _c, _d, _e;
|
|
1409
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1410
|
+
let skipped = 0;
|
|
1411
|
+
let count = 0;
|
|
1412
|
+
const dbTrx = this.toDbTrx(['output_baskets'], 'readonly', args.trx);
|
|
1413
|
+
let cursor;
|
|
1414
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.basketId) {
|
|
1415
|
+
cursor = await dbTrx.objectStore('output_baskets').openCursor(args.partial.basketId);
|
|
1416
|
+
}
|
|
1417
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1418
|
+
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.name) !== undefined) {
|
|
1419
|
+
cursor = await dbTrx
|
|
1420
|
+
.objectStore('output_baskets')
|
|
1421
|
+
.index('name_userId')
|
|
1422
|
+
.openCursor([args.partial.name, args.partial.userId]);
|
|
1423
|
+
}
|
|
1424
|
+
else {
|
|
1425
|
+
cursor = await dbTrx.objectStore('output_baskets').index('userId').openCursor(args.partial.userId);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
cursor = await dbTrx.objectStore('output_baskets').openCursor();
|
|
1430
|
+
}
|
|
1431
|
+
let firstTime = true;
|
|
1432
|
+
while (cursor) {
|
|
1433
|
+
if (!firstTime)
|
|
1434
|
+
cursor = await cursor.continue();
|
|
1435
|
+
if (!cursor)
|
|
1436
|
+
break;
|
|
1437
|
+
firstTime = false;
|
|
1438
|
+
const r = cursor.value;
|
|
1439
|
+
if (args.since && args.since > r.updated_at)
|
|
1440
|
+
continue;
|
|
1441
|
+
if (args.partial) {
|
|
1442
|
+
if (args.partial.basketId && r.basketId !== args.partial.basketId)
|
|
1443
|
+
continue;
|
|
1444
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1445
|
+
continue;
|
|
1446
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1447
|
+
continue;
|
|
1448
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1449
|
+
continue;
|
|
1450
|
+
if (args.partial.name && r.name !== args.partial.name)
|
|
1451
|
+
continue;
|
|
1452
|
+
if (args.partial.numberOfDesiredUTXOs !== undefined &&
|
|
1453
|
+
r.numberOfDesiredUTXOs !== args.partial.numberOfDesiredUTXOs)
|
|
1454
|
+
continue;
|
|
1455
|
+
if (args.partial.minimumDesiredUTXOValue !== undefined &&
|
|
1456
|
+
r.numberOfDesiredSatoshis !== args.partial.minimumDesiredUTXOValue)
|
|
1457
|
+
continue;
|
|
1458
|
+
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1459
|
+
continue;
|
|
1460
|
+
}
|
|
1461
|
+
if (skipped < offset) {
|
|
1462
|
+
skipped++;
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
filtered(r);
|
|
1466
|
+
count++;
|
|
1467
|
+
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
if (!args.trx)
|
|
1471
|
+
await dbTrx.done;
|
|
1472
|
+
}
|
|
1473
|
+
async findOutputBaskets(args) {
|
|
1474
|
+
const result = [];
|
|
1475
|
+
await this.filterOutputBaskets(args, r => {
|
|
1476
|
+
result.push(this.validateEntity(r));
|
|
1477
|
+
});
|
|
1478
|
+
return result;
|
|
1479
|
+
}
|
|
1480
|
+
async filterOutputs(args, filtered, tagIds, isQueryModeAll) {
|
|
1481
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1482
|
+
// args.txStatus
|
|
1483
|
+
// args.noScript
|
|
1484
|
+
if (args.partial.lockingScript)
|
|
1485
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.lockingScript', `undefined. Outputs may not be found by lockingScript value.`);
|
|
1486
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1487
|
+
let skipped = 0;
|
|
1488
|
+
let count = 0;
|
|
1489
|
+
const stores = ['outputs'];
|
|
1490
|
+
if (tagIds && tagIds.length > 0) {
|
|
1491
|
+
stores.push('output_tags_map');
|
|
1492
|
+
}
|
|
1493
|
+
if (args.txStatus) {
|
|
1494
|
+
stores.push('transactions');
|
|
1495
|
+
}
|
|
1496
|
+
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1497
|
+
let cursor;
|
|
1498
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.outputId) {
|
|
1499
|
+
cursor = await dbTrx.objectStore('outputs').openCursor(args.partial.outputId);
|
|
1500
|
+
}
|
|
1501
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1502
|
+
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.transactionId) && ((_e = args.partial) === null || _e === void 0 ? void 0 : _e.vout) !== undefined) {
|
|
1503
|
+
cursor = await dbTrx
|
|
1504
|
+
.objectStore('outputs')
|
|
1505
|
+
.index('transactionId_vout_userId')
|
|
1506
|
+
.openCursor([args.partial.transactionId, args.partial.vout, args.partial.userId]);
|
|
1507
|
+
}
|
|
1508
|
+
else {
|
|
1509
|
+
cursor = await dbTrx.objectStore('outputs').index('userId').openCursor(args.partial.userId);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
else if (((_f = args.partial) === null || _f === void 0 ? void 0 : _f.transactionId) !== undefined) {
|
|
1513
|
+
cursor = await dbTrx.objectStore('outputs').index('transactionId').openCursor(args.partial.transactionId);
|
|
1514
|
+
}
|
|
1515
|
+
else if (((_g = args.partial) === null || _g === void 0 ? void 0 : _g.basketId) !== undefined) {
|
|
1516
|
+
cursor = await dbTrx.objectStore('outputs').index('basketId').openCursor(args.partial.basketId);
|
|
1517
|
+
}
|
|
1518
|
+
else if (((_h = args.partial) === null || _h === void 0 ? void 0 : _h.spentBy) !== undefined) {
|
|
1519
|
+
cursor = await dbTrx.objectStore('outputs').index('spentBy').openCursor(args.partial.spentBy);
|
|
1520
|
+
}
|
|
1521
|
+
else {
|
|
1522
|
+
cursor = await dbTrx.objectStore('outputs').openCursor();
|
|
1523
|
+
}
|
|
1524
|
+
let firstTime = true;
|
|
1525
|
+
while (cursor) {
|
|
1526
|
+
if (!firstTime)
|
|
1527
|
+
cursor = await cursor.continue();
|
|
1528
|
+
if (!cursor)
|
|
1529
|
+
break;
|
|
1530
|
+
firstTime = false;
|
|
1531
|
+
const r = cursor.value;
|
|
1532
|
+
if (args.since && args.since > r.updated_at)
|
|
1533
|
+
continue;
|
|
1534
|
+
if (args.partial) {
|
|
1535
|
+
if (args.partial.outputId && r.outputId !== args.partial.outputId)
|
|
1536
|
+
continue;
|
|
1537
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1538
|
+
continue;
|
|
1539
|
+
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
1540
|
+
continue;
|
|
1541
|
+
if (args.partial.basketId && r.basketId !== args.partial.basketId)
|
|
1542
|
+
continue;
|
|
1543
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1544
|
+
continue;
|
|
1545
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1546
|
+
continue;
|
|
1547
|
+
if (args.partial.spendable !== undefined && r.spendable !== args.partial.spendable)
|
|
1548
|
+
continue;
|
|
1549
|
+
if (args.partial.change !== undefined && r.change !== args.partial.change)
|
|
1550
|
+
continue;
|
|
1551
|
+
if (args.partial.outputDescription && r.outputDescription !== args.partial.outputDescription)
|
|
1552
|
+
continue;
|
|
1553
|
+
if (args.partial.vout !== undefined && r.vout !== args.partial.vout)
|
|
1554
|
+
continue;
|
|
1555
|
+
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1556
|
+
continue;
|
|
1557
|
+
if (args.partial.providedBy && r.providedBy !== args.partial.providedBy)
|
|
1558
|
+
continue;
|
|
1559
|
+
if (args.partial.purpose && r.purpose !== args.partial.purpose)
|
|
1560
|
+
continue;
|
|
1561
|
+
if (args.partial.type && r.type !== args.partial.type)
|
|
1562
|
+
continue;
|
|
1563
|
+
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
1564
|
+
continue;
|
|
1565
|
+
if (args.partial.senderIdentityKey && r.senderIdentityKey !== args.partial.senderIdentityKey)
|
|
1566
|
+
continue;
|
|
1567
|
+
if (args.partial.derivationPrefix && r.derivationPrefix !== args.partial.derivationPrefix)
|
|
1568
|
+
continue;
|
|
1569
|
+
if (args.partial.derivationSuffix && r.derivationSuffix !== args.partial.derivationSuffix)
|
|
1570
|
+
continue;
|
|
1571
|
+
if (args.partial.customInstructions && r.customInstructions !== args.partial.customInstructions)
|
|
1572
|
+
continue;
|
|
1573
|
+
if (args.partial.spentBy && r.spentBy !== args.partial.spentBy)
|
|
1574
|
+
continue;
|
|
1575
|
+
if (args.partial.sequenceNumber !== undefined && r.sequenceNumber !== args.partial.sequenceNumber)
|
|
1576
|
+
continue;
|
|
1577
|
+
if (args.partial.scriptLength !== undefined && r.scriptLength !== args.partial.scriptLength)
|
|
1578
|
+
continue;
|
|
1579
|
+
if (args.partial.scriptOffset !== undefined && r.scriptOffset !== args.partial.scriptOffset)
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
if (args.txStatus !== undefined) {
|
|
1583
|
+
const count = await this.countTransactions({
|
|
1584
|
+
partial: { transactionId: r.transactionId },
|
|
1585
|
+
status: args.txStatus,
|
|
1586
|
+
trx: dbTrx
|
|
1587
|
+
});
|
|
1588
|
+
if (count === 0)
|
|
1589
|
+
continue;
|
|
1590
|
+
}
|
|
1591
|
+
if (tagIds && tagIds.length > 0) {
|
|
1592
|
+
let ids = [...tagIds];
|
|
1593
|
+
await this.filterOutputTagMaps({ partial: { outputId: r.outputId }, trx: dbTrx }, tm => {
|
|
1594
|
+
if (ids.length > 0) {
|
|
1595
|
+
const i = ids.indexOf(tm.outputTagId);
|
|
1596
|
+
if (i >= 0) {
|
|
1597
|
+
if (isQueryModeAll) {
|
|
1598
|
+
ids.splice(i, 1);
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1601
|
+
ids = [];
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
if (ids.length > 0)
|
|
1607
|
+
continue;
|
|
1608
|
+
}
|
|
1609
|
+
if (skipped < offset) {
|
|
1610
|
+
skipped++;
|
|
1611
|
+
continue;
|
|
1612
|
+
}
|
|
1613
|
+
if (args.noScript === true) {
|
|
1614
|
+
r.script = undefined;
|
|
1615
|
+
}
|
|
1616
|
+
filtered(r);
|
|
1617
|
+
count++;
|
|
1618
|
+
if (((_j = args.paged) === null || _j === void 0 ? void 0 : _j.limit) && count >= args.paged.limit)
|
|
1619
|
+
break;
|
|
1620
|
+
}
|
|
1621
|
+
if (!args.trx)
|
|
1622
|
+
await dbTrx.done;
|
|
1623
|
+
}
|
|
1624
|
+
async findOutputs(args, tagIds, isQueryModeAll) {
|
|
1625
|
+
const results = [];
|
|
1626
|
+
await this.filterOutputs(args, r => {
|
|
1627
|
+
results.push(this.validateEntity(r));
|
|
1628
|
+
}, tagIds, isQueryModeAll);
|
|
1629
|
+
for (const o of results) {
|
|
1630
|
+
if (!args.noScript) {
|
|
1631
|
+
await this.validateOutputScript(o);
|
|
1632
|
+
}
|
|
1633
|
+
else {
|
|
1634
|
+
o.lockingScript = undefined;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
return results;
|
|
1638
|
+
}
|
|
1639
|
+
async filterOutputTags(args, filtered) {
|
|
1640
|
+
var _a, _b, _c, _d, _e;
|
|
1641
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1642
|
+
let skipped = 0;
|
|
1643
|
+
let count = 0;
|
|
1644
|
+
const dbTrx = this.toDbTrx(['output_tags'], 'readonly', args.trx);
|
|
1645
|
+
let cursor;
|
|
1646
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.outputTagId) {
|
|
1647
|
+
cursor = await dbTrx.objectStore('output_tags').openCursor(args.partial.outputTagId);
|
|
1648
|
+
}
|
|
1649
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1650
|
+
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.tag) !== undefined) {
|
|
1651
|
+
cursor = await dbTrx
|
|
1652
|
+
.objectStore('output_tags')
|
|
1653
|
+
.index('tag_userId')
|
|
1654
|
+
.openCursor([args.partial.tag, args.partial.userId]);
|
|
1655
|
+
}
|
|
1656
|
+
else {
|
|
1657
|
+
cursor = await dbTrx.objectStore('output_tags').index('userId').openCursor(args.partial.userId);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
else {
|
|
1661
|
+
cursor = await dbTrx.objectStore('output_tags').openCursor();
|
|
1662
|
+
}
|
|
1663
|
+
let firstTime = true;
|
|
1664
|
+
while (cursor) {
|
|
1665
|
+
if (!firstTime)
|
|
1666
|
+
cursor = await cursor.continue();
|
|
1667
|
+
if (!cursor)
|
|
1668
|
+
break;
|
|
1669
|
+
firstTime = false;
|
|
1670
|
+
const r = cursor.value;
|
|
1671
|
+
if (args.since && args.since > r.updated_at)
|
|
1672
|
+
continue;
|
|
1673
|
+
if (args.partial) {
|
|
1674
|
+
if (args.partial.outputTagId && r.outputTagId !== args.partial.outputTagId)
|
|
1675
|
+
continue;
|
|
1676
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1677
|
+
continue;
|
|
1678
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1679
|
+
continue;
|
|
1680
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1681
|
+
continue;
|
|
1682
|
+
if (args.partial.tag && r.tag !== args.partial.tag)
|
|
1683
|
+
continue;
|
|
1684
|
+
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1687
|
+
if (skipped < offset) {
|
|
1688
|
+
skipped++;
|
|
1689
|
+
continue;
|
|
1690
|
+
}
|
|
1691
|
+
filtered(r);
|
|
1692
|
+
count++;
|
|
1693
|
+
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1694
|
+
break;
|
|
1695
|
+
}
|
|
1696
|
+
if (!args.trx)
|
|
1697
|
+
await dbTrx.done;
|
|
1698
|
+
}
|
|
1699
|
+
async findOutputTags(args) {
|
|
1700
|
+
const result = [];
|
|
1701
|
+
await this.filterOutputTags(args, r => {
|
|
1702
|
+
result.push(this.validateEntity(r));
|
|
1703
|
+
});
|
|
1704
|
+
return result;
|
|
1705
|
+
}
|
|
1706
|
+
async filterSyncStates(args, filtered) {
|
|
1707
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1708
|
+
if (args.partial.syncMap)
|
|
1709
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.syncMap', `undefined. SyncStates may not be found by syncMap value.`);
|
|
1710
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1711
|
+
let skipped = 0;
|
|
1712
|
+
let count = 0;
|
|
1713
|
+
const dbTrx = this.toDbTrx(['sync_states'], 'readonly', args.trx);
|
|
1714
|
+
let cursor;
|
|
1715
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.syncStateId) {
|
|
1716
|
+
cursor = await dbTrx.objectStore('sync_states').openCursor(args.partial.syncStateId);
|
|
1717
|
+
}
|
|
1718
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1719
|
+
cursor = await dbTrx.objectStore('sync_states').index('userId').openCursor(args.partial.userId);
|
|
1720
|
+
}
|
|
1721
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.refNum) !== undefined) {
|
|
1722
|
+
cursor = await dbTrx.objectStore('sync_states').index('refNum').openCursor(args.partial.refNum);
|
|
1723
|
+
}
|
|
1724
|
+
else if (((_e = args.partial) === null || _e === void 0 ? void 0 : _e.status) !== undefined) {
|
|
1725
|
+
cursor = await dbTrx.objectStore('sync_states').index('status').openCursor(args.partial.status);
|
|
1726
|
+
}
|
|
1727
|
+
else {
|
|
1728
|
+
cursor = await dbTrx.objectStore('sync_states').openCursor();
|
|
1729
|
+
}
|
|
1730
|
+
let firstTime = true;
|
|
1731
|
+
while (cursor) {
|
|
1732
|
+
if (!firstTime)
|
|
1733
|
+
cursor = await cursor.continue();
|
|
1734
|
+
if (!cursor)
|
|
1735
|
+
break;
|
|
1736
|
+
firstTime = false;
|
|
1737
|
+
const r = cursor.value;
|
|
1738
|
+
if (args.since && args.since > r.updated_at)
|
|
1739
|
+
continue;
|
|
1740
|
+
if (args.partial) {
|
|
1741
|
+
if (args.partial.syncStateId && r.syncStateId !== args.partial.syncStateId)
|
|
1742
|
+
continue;
|
|
1743
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1744
|
+
continue;
|
|
1745
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1746
|
+
continue;
|
|
1747
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1748
|
+
continue;
|
|
1749
|
+
if (args.partial.storageIdentityKey && r.storageIdentityKey !== args.partial.storageIdentityKey)
|
|
1750
|
+
continue;
|
|
1751
|
+
if (args.partial.storageName && r.storageName !== args.partial.storageName)
|
|
1752
|
+
continue;
|
|
1753
|
+
if (args.partial.status && r.status !== args.partial.status)
|
|
1754
|
+
continue;
|
|
1755
|
+
if (args.partial.init !== undefined && r.init !== args.partial.init)
|
|
1756
|
+
continue;
|
|
1757
|
+
if (args.partial.refNum !== undefined && r.refNum !== args.partial.refNum)
|
|
1758
|
+
continue;
|
|
1759
|
+
if (args.partial.when && ((_f = r.when) === null || _f === void 0 ? void 0 : _f.getTime()) !== args.partial.when.getTime())
|
|
1760
|
+
continue;
|
|
1761
|
+
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1762
|
+
continue;
|
|
1763
|
+
if (args.partial.errorLocal && r.errorLocale !== args.partial.errorLocal)
|
|
1764
|
+
continue;
|
|
1765
|
+
if (args.partial.errorOther && r.errorOther !== args.partial.errorOther)
|
|
1766
|
+
continue;
|
|
1767
|
+
}
|
|
1768
|
+
if (skipped < offset) {
|
|
1769
|
+
skipped++;
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
filtered(r);
|
|
1773
|
+
count++;
|
|
1774
|
+
if (((_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit) && count >= args.paged.limit)
|
|
1775
|
+
break;
|
|
1776
|
+
}
|
|
1777
|
+
if (!args.trx)
|
|
1778
|
+
await dbTrx.done;
|
|
1779
|
+
}
|
|
1780
|
+
async findSyncStates(args) {
|
|
1781
|
+
const result = [];
|
|
1782
|
+
await this.filterSyncStates(args, r => {
|
|
1783
|
+
result.push(this.validateEntity(r));
|
|
1784
|
+
});
|
|
1785
|
+
return result;
|
|
1786
|
+
}
|
|
1787
|
+
async filterTransactions(args, filtered, labelIds, isQueryModeAll) {
|
|
1788
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1789
|
+
if (args.partial.rawTx)
|
|
1790
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. Transactions may not be found by rawTx value.`);
|
|
1791
|
+
if (args.partial.inputBEEF)
|
|
1792
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', `undefined. Transactions may not be found by inputBEEF value.`);
|
|
1793
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1794
|
+
let skipped = 0;
|
|
1795
|
+
let count = 0;
|
|
1796
|
+
const stores = ['transactions'];
|
|
1797
|
+
if (labelIds && labelIds.length > 0) {
|
|
1798
|
+
stores.push('tx_labels_map');
|
|
1799
|
+
}
|
|
1800
|
+
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1801
|
+
let cursor;
|
|
1802
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.transactionId) {
|
|
1803
|
+
cursor = await dbTrx.objectStore('transactions').openCursor(args.partial.transactionId);
|
|
1804
|
+
}
|
|
1805
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1806
|
+
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.status) !== undefined) {
|
|
1807
|
+
cursor = await dbTrx
|
|
1808
|
+
.objectStore('transactions')
|
|
1809
|
+
.index('status_userId')
|
|
1810
|
+
.openCursor([args.partial.status, args.partial.userId]);
|
|
1811
|
+
}
|
|
1812
|
+
else {
|
|
1813
|
+
cursor = await dbTrx.objectStore('transactions').index('userId').openCursor(args.partial.userId);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
else if (((_e = args.partial) === null || _e === void 0 ? void 0 : _e.status) !== undefined) {
|
|
1817
|
+
cursor = await dbTrx.objectStore('transactions').index('status').openCursor(args.partial.status);
|
|
1818
|
+
}
|
|
1819
|
+
else if (((_f = args.partial) === null || _f === void 0 ? void 0 : _f.provenTxId) !== undefined) {
|
|
1820
|
+
cursor = await dbTrx.objectStore('transactions').index('provenTxId').openCursor(args.partial.provenTxId);
|
|
1821
|
+
}
|
|
1822
|
+
else if (((_g = args.partial) === null || _g === void 0 ? void 0 : _g.reference) !== undefined) {
|
|
1823
|
+
cursor = await dbTrx.objectStore('transactions').index('reference').openCursor(args.partial.reference);
|
|
1824
|
+
}
|
|
1825
|
+
else {
|
|
1826
|
+
cursor = await dbTrx.objectStore('transactions').openCursor();
|
|
1827
|
+
}
|
|
1828
|
+
let firstTime = true;
|
|
1829
|
+
while (cursor) {
|
|
1830
|
+
if (!firstTime)
|
|
1831
|
+
cursor = await cursor.continue();
|
|
1832
|
+
if (!cursor)
|
|
1833
|
+
break;
|
|
1834
|
+
firstTime = false;
|
|
1835
|
+
const r = cursor.value;
|
|
1836
|
+
if (args.since && args.since > r.updated_at)
|
|
1837
|
+
continue;
|
|
1838
|
+
if (args.status && !args.status.includes(r.status))
|
|
1839
|
+
continue;
|
|
1840
|
+
if (args.partial) {
|
|
1841
|
+
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
1842
|
+
continue;
|
|
1843
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1844
|
+
continue;
|
|
1845
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1846
|
+
continue;
|
|
1847
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1848
|
+
continue;
|
|
1849
|
+
if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId)
|
|
1850
|
+
continue;
|
|
1851
|
+
if (args.partial.status && r.status !== args.partial.status)
|
|
1852
|
+
continue;
|
|
1853
|
+
if (args.partial.reference && r.reference !== args.partial.reference)
|
|
1854
|
+
continue;
|
|
1855
|
+
if (args.partial.isOutgoing !== undefined && r.isOutgoing !== args.partial.isOutgoing)
|
|
1856
|
+
continue;
|
|
1857
|
+
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1858
|
+
continue;
|
|
1859
|
+
if (args.partial.description && r.description !== args.partial.description)
|
|
1860
|
+
continue;
|
|
1861
|
+
if (args.partial.version !== undefined && r.version !== args.partial.version)
|
|
1862
|
+
continue;
|
|
1863
|
+
if (args.partial.lockTime !== undefined && r.lockTime !== args.partial.lockTime)
|
|
1864
|
+
continue;
|
|
1865
|
+
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
1866
|
+
continue;
|
|
1867
|
+
}
|
|
1868
|
+
if (labelIds && labelIds.length > 0) {
|
|
1869
|
+
let ids = [...labelIds];
|
|
1870
|
+
await this.filterTxLabelMaps({ partial: { transactionId: r.transactionId }, trx: dbTrx }, lm => {
|
|
1871
|
+
if (ids.length > 0) {
|
|
1872
|
+
const i = ids.indexOf(lm.txLabelId);
|
|
1873
|
+
if (i >= 0) {
|
|
1874
|
+
if (isQueryModeAll) {
|
|
1875
|
+
ids.splice(i, 1);
|
|
1876
|
+
}
|
|
1877
|
+
else {
|
|
1878
|
+
ids = [];
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
if (ids.length > 0)
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
if (skipped < offset) {
|
|
1887
|
+
skipped++;
|
|
1888
|
+
continue;
|
|
1889
|
+
}
|
|
1890
|
+
filtered(r);
|
|
1891
|
+
count++;
|
|
1892
|
+
if (((_h = args.paged) === null || _h === void 0 ? void 0 : _h.limit) && count >= args.paged.limit)
|
|
1893
|
+
break;
|
|
1894
|
+
}
|
|
1895
|
+
if (!args.trx)
|
|
1896
|
+
await dbTrx.done;
|
|
1897
|
+
}
|
|
1898
|
+
async findTransactions(args, labelIds, isQueryModeAll) {
|
|
1899
|
+
const results = [];
|
|
1900
|
+
await this.filterTransactions(args, r => {
|
|
1901
|
+
results.push(this.validateEntity(r));
|
|
1902
|
+
}, labelIds, isQueryModeAll);
|
|
1903
|
+
for (const t of results) {
|
|
1904
|
+
if (!args.noRawTx) {
|
|
1905
|
+
await this.validateRawTransaction(t, args.trx);
|
|
1906
|
+
}
|
|
1907
|
+
else {
|
|
1908
|
+
t.rawTx = undefined;
|
|
1909
|
+
t.inputBEEF = undefined;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return results;
|
|
1913
|
+
}
|
|
1914
|
+
async filterTxLabels(args, filtered) {
|
|
1915
|
+
var _a, _b, _c, _d, _e;
|
|
1916
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1917
|
+
let skipped = 0;
|
|
1918
|
+
let count = 0;
|
|
1919
|
+
const dbTrx = this.toDbTrx(['tx_labels'], 'readonly', args.trx);
|
|
1920
|
+
let cursor;
|
|
1921
|
+
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.txLabelId) {
|
|
1922
|
+
cursor = await dbTrx.objectStore('tx_labels').openCursor(args.partial.txLabelId);
|
|
1923
|
+
}
|
|
1924
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1925
|
+
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.label) !== undefined) {
|
|
1926
|
+
cursor = await dbTrx
|
|
1927
|
+
.objectStore('tx_labels')
|
|
1928
|
+
.index('label_userId')
|
|
1929
|
+
.openCursor([args.partial.label, args.partial.userId]);
|
|
1930
|
+
}
|
|
1931
|
+
else {
|
|
1932
|
+
cursor = await dbTrx.objectStore('tx_labels').index('userId').openCursor(args.partial.userId);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
else {
|
|
1936
|
+
cursor = await dbTrx.objectStore('tx_labels').openCursor();
|
|
1937
|
+
}
|
|
1938
|
+
let firstTime = true;
|
|
1939
|
+
while (cursor) {
|
|
1940
|
+
if (!firstTime)
|
|
1941
|
+
cursor = await cursor.continue();
|
|
1942
|
+
if (!cursor)
|
|
1943
|
+
break;
|
|
1944
|
+
firstTime = false;
|
|
1945
|
+
const r = cursor.value;
|
|
1946
|
+
if (args.since && args.since > r.updated_at)
|
|
1947
|
+
continue;
|
|
1948
|
+
if (args.partial) {
|
|
1949
|
+
if (args.partial.txLabelId && r.txLabelId !== args.partial.txLabelId)
|
|
1950
|
+
continue;
|
|
1951
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1952
|
+
continue;
|
|
1953
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1954
|
+
continue;
|
|
1955
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1956
|
+
continue;
|
|
1957
|
+
if (args.partial.label && r.label !== args.partial.label)
|
|
1958
|
+
continue;
|
|
1959
|
+
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
if (skipped < offset) {
|
|
1963
|
+
skipped++;
|
|
1964
|
+
continue;
|
|
1965
|
+
}
|
|
1966
|
+
filtered(r);
|
|
1967
|
+
count++;
|
|
1968
|
+
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1969
|
+
break;
|
|
1970
|
+
}
|
|
1971
|
+
if (!args.trx)
|
|
1972
|
+
await dbTrx.done;
|
|
1973
|
+
}
|
|
1974
|
+
async findTxLabels(args) {
|
|
1975
|
+
const result = [];
|
|
1976
|
+
await this.filterTxLabels(args, r => {
|
|
1977
|
+
result.push(this.validateEntity(r));
|
|
1978
|
+
});
|
|
1979
|
+
return result;
|
|
1980
|
+
}
|
|
1981
|
+
async filterUsers(args, filtered) {
|
|
1982
|
+
var _a, _b;
|
|
1983
|
+
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1984
|
+
let skipped = 0;
|
|
1985
|
+
let count = 0;
|
|
1986
|
+
const dbTrx = this.toDbTrx(['users'], 'readonly', args.trx);
|
|
1987
|
+
let cursor = await dbTrx.objectStore('users').openCursor();
|
|
1988
|
+
let firstTime = true;
|
|
1989
|
+
while (cursor) {
|
|
1990
|
+
if (!firstTime)
|
|
1991
|
+
cursor = await cursor.continue();
|
|
1992
|
+
if (!cursor)
|
|
1993
|
+
break;
|
|
1994
|
+
firstTime = false;
|
|
1995
|
+
const r = cursor.value;
|
|
1996
|
+
if (args.since && args.since > r.updated_at)
|
|
1997
|
+
continue;
|
|
1998
|
+
if (args.partial) {
|
|
1999
|
+
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
2000
|
+
continue;
|
|
2001
|
+
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
2002
|
+
continue;
|
|
2003
|
+
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
2004
|
+
continue;
|
|
2005
|
+
if (args.partial.identityKey && r.identityKey !== args.partial.identityKey)
|
|
2006
|
+
continue;
|
|
2007
|
+
if (args.partial.activeStorage && r.activeStorage !== args.partial.activeStorage)
|
|
2008
|
+
continue;
|
|
2009
|
+
}
|
|
2010
|
+
if (skipped < offset) {
|
|
2011
|
+
skipped++;
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
filtered(r);
|
|
2015
|
+
count++;
|
|
2016
|
+
if (((_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit) && count >= args.paged.limit)
|
|
2017
|
+
break;
|
|
2018
|
+
}
|
|
2019
|
+
if (!args.trx)
|
|
2020
|
+
await dbTrx.done;
|
|
2021
|
+
}
|
|
2022
|
+
async findUsers(args) {
|
|
2023
|
+
const result = [];
|
|
2024
|
+
await this.filterUsers(args, r => {
|
|
2025
|
+
result.push(this.validateEntity(r));
|
|
2026
|
+
});
|
|
2027
|
+
return result;
|
|
2028
|
+
}
|
|
2029
|
+
async countCertificateFields(args) {
|
|
2030
|
+
let count = 0;
|
|
2031
|
+
await this.filterCertificateFields(args, () => {
|
|
2032
|
+
count++;
|
|
2033
|
+
});
|
|
2034
|
+
return count;
|
|
2035
|
+
}
|
|
2036
|
+
async countCertificates(args) {
|
|
2037
|
+
let count = 0;
|
|
2038
|
+
await this.filterCertificates(args, () => {
|
|
2039
|
+
count++;
|
|
2040
|
+
});
|
|
2041
|
+
return count;
|
|
2042
|
+
}
|
|
2043
|
+
async countCommissions(args) {
|
|
2044
|
+
let count = 0;
|
|
2045
|
+
await this.filterCommissions(args, () => {
|
|
2046
|
+
count++;
|
|
2047
|
+
});
|
|
2048
|
+
return count;
|
|
2049
|
+
}
|
|
2050
|
+
async countMonitorEvents(args) {
|
|
2051
|
+
let count = 0;
|
|
2052
|
+
await this.filterMonitorEvents(args, () => {
|
|
2053
|
+
count++;
|
|
2054
|
+
});
|
|
2055
|
+
return count;
|
|
2056
|
+
}
|
|
2057
|
+
async countOutputBaskets(args) {
|
|
2058
|
+
let count = 0;
|
|
2059
|
+
await this.filterOutputBaskets(args, () => {
|
|
2060
|
+
count++;
|
|
2061
|
+
});
|
|
2062
|
+
return count;
|
|
2063
|
+
}
|
|
2064
|
+
async countOutputs(args, tagIds, isQueryModeAll) {
|
|
2065
|
+
let count = 0;
|
|
2066
|
+
await this.filterOutputs({ ...args, noScript: true }, () => {
|
|
2067
|
+
count++;
|
|
2068
|
+
}, tagIds, isQueryModeAll);
|
|
2069
|
+
return count;
|
|
2070
|
+
}
|
|
2071
|
+
async countOutputTags(args) {
|
|
2072
|
+
let count = 0;
|
|
2073
|
+
await this.filterOutputTags(args, () => {
|
|
2074
|
+
count++;
|
|
2075
|
+
});
|
|
2076
|
+
return count;
|
|
2077
|
+
}
|
|
2078
|
+
async countSyncStates(args) {
|
|
2079
|
+
let count = 0;
|
|
2080
|
+
await this.filterSyncStates(args, () => {
|
|
2081
|
+
count++;
|
|
2082
|
+
});
|
|
2083
|
+
return count;
|
|
2084
|
+
}
|
|
2085
|
+
async countTransactions(args, labelIds, isQueryModeAll) {
|
|
2086
|
+
let count = 0;
|
|
2087
|
+
await this.filterTransactions({ ...args, noRawTx: true }, () => {
|
|
2088
|
+
count++;
|
|
2089
|
+
}, labelIds, isQueryModeAll);
|
|
2090
|
+
return count;
|
|
2091
|
+
}
|
|
2092
|
+
async countTxLabels(args) {
|
|
2093
|
+
let count = 0;
|
|
2094
|
+
await this.filterTxLabels(args, () => {
|
|
2095
|
+
count++;
|
|
2096
|
+
});
|
|
2097
|
+
return count;
|
|
2098
|
+
}
|
|
2099
|
+
async countUsers(args) {
|
|
2100
|
+
let count = 0;
|
|
2101
|
+
await this.filterUsers(args, () => {
|
|
2102
|
+
count++;
|
|
2103
|
+
});
|
|
2104
|
+
return count;
|
|
2105
|
+
}
|
|
2106
|
+
async getProvenTxsForUser(args) {
|
|
2107
|
+
const results = [];
|
|
2108
|
+
const fargs = {
|
|
2109
|
+
partial: {},
|
|
2110
|
+
since: args.since,
|
|
2111
|
+
paged: args.paged,
|
|
2112
|
+
trx: args.trx
|
|
2113
|
+
};
|
|
2114
|
+
await this.filterProvenTxs(fargs, r => {
|
|
2115
|
+
results.push(this.validateEntity(r));
|
|
2116
|
+
}, args.userId);
|
|
2117
|
+
return results;
|
|
2118
|
+
}
|
|
2119
|
+
async getProvenTxReqsForUser(args) {
|
|
2120
|
+
const results = [];
|
|
2121
|
+
const fargs = {
|
|
2122
|
+
partial: {},
|
|
2123
|
+
since: args.since,
|
|
2124
|
+
paged: args.paged,
|
|
2125
|
+
trx: args.trx
|
|
2126
|
+
};
|
|
2127
|
+
await this.filterProvenTxReqs(fargs, r => {
|
|
2128
|
+
results.push(this.validateEntity(r));
|
|
2129
|
+
}, args.userId);
|
|
2130
|
+
return results;
|
|
2131
|
+
}
|
|
2132
|
+
async getTxLabelMapsForUser(args) {
|
|
2133
|
+
const results = [];
|
|
2134
|
+
const fargs = {
|
|
2135
|
+
partial: {},
|
|
2136
|
+
since: args.since,
|
|
2137
|
+
paged: args.paged,
|
|
2138
|
+
trx: args.trx
|
|
2139
|
+
};
|
|
2140
|
+
await this.filterTxLabelMaps(fargs, r => {
|
|
2141
|
+
results.push(this.validateEntity(r));
|
|
2142
|
+
}, args.userId);
|
|
2143
|
+
return results;
|
|
2144
|
+
}
|
|
2145
|
+
async getOutputTagMapsForUser(args) {
|
|
2146
|
+
const results = [];
|
|
2147
|
+
const fargs = {
|
|
2148
|
+
partial: {},
|
|
2149
|
+
since: args.since,
|
|
2150
|
+
paged: args.paged,
|
|
2151
|
+
trx: args.trx
|
|
2152
|
+
};
|
|
2153
|
+
await this.filterOutputTagMaps(fargs, r => {
|
|
2154
|
+
results.push(this.validateEntity(r));
|
|
2155
|
+
}, args.userId);
|
|
2156
|
+
return results;
|
|
2157
|
+
}
|
|
2158
|
+
async verifyReadyForDatabaseAccess(trx) {
|
|
2159
|
+
if (!this._settings) {
|
|
2160
|
+
this._settings = await this.readSettings();
|
|
2161
|
+
}
|
|
2162
|
+
return this._settings.dbtype;
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
* Helper to force uniform behavior across database engines.
|
|
2166
|
+
* Use to process all individual records with time stamps or number[] retreived from database.
|
|
2167
|
+
*/
|
|
2168
|
+
validateEntity(entity, dateFields, booleanFields) {
|
|
2169
|
+
entity.created_at = this.validateDate(entity.created_at);
|
|
2170
|
+
entity.updated_at = this.validateDate(entity.updated_at);
|
|
2171
|
+
if (dateFields) {
|
|
2172
|
+
for (const df of dateFields) {
|
|
2173
|
+
if (entity[df])
|
|
2174
|
+
entity[df] = this.validateDate(entity[df]);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (booleanFields) {
|
|
2178
|
+
for (const df of booleanFields) {
|
|
2179
|
+
if (entity[df] !== undefined)
|
|
2180
|
+
entity[df] = !!entity[df];
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
for (const key of Object.keys(entity)) {
|
|
2184
|
+
const val = entity[key];
|
|
2185
|
+
if (val === null) {
|
|
2186
|
+
entity[key] = undefined;
|
|
2187
|
+
}
|
|
2188
|
+
else if (val instanceof Uint8Array) {
|
|
2189
|
+
entity[key] = Array.from(val);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
return entity;
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Helper to force uniform behavior across database engines.
|
|
2196
|
+
* Use to process all arrays of records with time stamps retreived from database.
|
|
2197
|
+
* @returns input `entities` array with contained values validated.
|
|
2198
|
+
*/
|
|
2199
|
+
validateEntities(entities, dateFields, booleanFields) {
|
|
2200
|
+
for (let i = 0; i < entities.length; i++) {
|
|
2201
|
+
entities[i] = this.validateEntity(entities[i], dateFields, booleanFields);
|
|
2202
|
+
}
|
|
2203
|
+
return entities;
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Helper to force uniform behavior across database engines.
|
|
2207
|
+
* Use to process the update template for entities being updated.
|
|
2208
|
+
*/
|
|
2209
|
+
validatePartialForUpdate(update, dateFields, booleanFields) {
|
|
2210
|
+
if (!this.dbtype)
|
|
2211
|
+
throw new WERR_errors_1.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first');
|
|
2212
|
+
const v = { ...update };
|
|
2213
|
+
if (v.created_at)
|
|
2214
|
+
v.created_at = this.validateEntityDate(v.created_at);
|
|
2215
|
+
if (v.updated_at)
|
|
2216
|
+
v.updated_at = this.validateEntityDate(v.updated_at);
|
|
2217
|
+
if (!v.created_at)
|
|
2218
|
+
delete v.created_at;
|
|
2219
|
+
if (!v.updated_at)
|
|
2220
|
+
v.updated_at = this.validateEntityDate(new Date());
|
|
2221
|
+
if (dateFields) {
|
|
2222
|
+
for (const df of dateFields) {
|
|
2223
|
+
if (v[df])
|
|
2224
|
+
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
if (booleanFields) {
|
|
2228
|
+
for (const df of booleanFields) {
|
|
2229
|
+
if (update[df] !== undefined)
|
|
2230
|
+
update[df] = !!update[df] ? 1 : 0;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
for (const key of Object.keys(v)) {
|
|
2234
|
+
const val = v[key];
|
|
2235
|
+
if (Array.isArray(val) && (val.length === 0 || Number.isInteger(val[0]))) {
|
|
2236
|
+
v[key] = Uint8Array.from(val);
|
|
2237
|
+
}
|
|
2238
|
+
else if (val === null) {
|
|
2239
|
+
v[key] = undefined;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
this.isDirty = true;
|
|
2243
|
+
return v;
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Helper to force uniform behavior across database engines.
|
|
2247
|
+
* Use to process new entities being inserted into the database.
|
|
2248
|
+
*/
|
|
2249
|
+
async validateEntityForInsert(entity, trx, dateFields, booleanFields) {
|
|
2250
|
+
await this.verifyReadyForDatabaseAccess(trx);
|
|
2251
|
+
const v = { ...entity };
|
|
2252
|
+
v.created_at = this.validateOptionalEntityDate(v.created_at, true);
|
|
2253
|
+
v.updated_at = this.validateOptionalEntityDate(v.updated_at, true);
|
|
2254
|
+
if (!v.created_at)
|
|
2255
|
+
delete v.created_at;
|
|
2256
|
+
if (!v.updated_at)
|
|
2257
|
+
delete v.updated_at;
|
|
2258
|
+
if (dateFields) {
|
|
2259
|
+
for (const df of dateFields) {
|
|
2260
|
+
if (v[df])
|
|
2261
|
+
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
if (booleanFields) {
|
|
2265
|
+
for (const df of booleanFields) {
|
|
2266
|
+
if (entity[df] !== undefined)
|
|
2267
|
+
entity[df] = !!entity[df] ? 1 : 0;
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
for (const key of Object.keys(v)) {
|
|
2271
|
+
const val = v[key];
|
|
2272
|
+
if (Array.isArray(val) && (val.length === 0 || Number.isInteger(val[0]))) {
|
|
2273
|
+
v[key] = Uint8Array.from(val);
|
|
2274
|
+
}
|
|
2275
|
+
else if (val === null) {
|
|
2276
|
+
v[key] = undefined;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
this.isDirty = true;
|
|
2280
|
+
return v;
|
|
2281
|
+
}
|
|
2282
|
+
async validateRawTransaction(t, trx) {
|
|
2283
|
+
// if there is no txid or there is a rawTransaction return what we have.
|
|
2284
|
+
if (t.rawTx || !t.txid)
|
|
2285
|
+
return;
|
|
2286
|
+
// rawTransaction is missing, see if we moved it ...
|
|
2287
|
+
const rawTx = await this.getRawTxOfKnownValidTransaction(t.txid, undefined, undefined, trx);
|
|
2288
|
+
if (!rawTx)
|
|
2289
|
+
return;
|
|
2290
|
+
t.rawTx = rawTx;
|
|
2291
|
+
}
|
|
2292
|
+
async adminStats(adminIdentityKey) {
|
|
2293
|
+
throw new Error('Method intentionally not implemented for personal storage.');
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
exports.StorageIdb = StorageIdb;
|
|
2297
|
+
//# sourceMappingURL=StorageIdb.js.map
|