@bsv/wallet-toolbox 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.template +22 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
- package/.github/ISSUE_TEMPLATE/discussion.md +24 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/push.yaml +66 -0
- package/.prettierrc +10 -0
- package/CONTRIBUTING.md +89 -0
- package/LICENSE.txt +28 -0
- package/README.md +124 -0
- package/dev.sqlite3 +0 -0
- package/docs/README.md +15 -0
- package/docs/client.md +6812 -0
- package/docs/monitor.md +648 -0
- package/docs/services.md +496 -0
- package/docs/storage.md +1884 -0
- package/docs/wallet.md +6812 -0
- package/jest.config.ts +29 -0
- package/knexfile.js +9 -0
- package/license.md +1 -0
- package/out/src/Wallet.d.ts +83 -0
- package/out/src/Wallet.d.ts.map +1 -0
- package/out/src/Wallet.js +415 -0
- package/out/src/Wallet.js.map +1 -0
- package/out/src/index.all.d.ts +9 -0
- package/out/src/index.all.d.ts.map +1 -0
- package/out/src/index.all.js +48 -0
- package/out/src/index.all.js.map +1 -0
- package/out/src/index.client.d.ts +8 -0
- package/out/src/index.client.d.ts.map +1 -0
- package/out/src/index.client.js +47 -0
- package/out/src/index.client.js.map +1 -0
- package/out/src/index.d.ts +3 -0
- package/out/src/index.d.ts.map +1 -0
- package/out/src/index.js +42 -0
- package/out/src/index.js.map +1 -0
- package/out/src/monitor/Monitor.d.ts +89 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -0
- package/out/src/monitor/Monitor.js +253 -0
- package/out/src/monitor/Monitor.js.map +1 -0
- package/out/src/monitor/MonitorDaemon.d.ts +30 -0
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -0
- package/out/src/monitor/MonitorDaemon.js +135 -0
- package/out/src/monitor/MonitorDaemon.js.map +1 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.d.ts +2 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.d.ts.map +1 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.js +50 -0
- package/out/src/monitor/__test/MonitorDaemon.man.test.js.map +1 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +53 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.js +197 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -0
- package/out/src/monitor/tasks/TaskClock.d.ts +14 -0
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskClock.js +27 -0
- package/out/src/monitor/tasks/TaskClock.js.map +1 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +20 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.js +52 -0
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -0
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +15 -0
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskNewHeader.js +45 -0
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -0
- package/out/src/monitor/tasks/TaskPurge.d.ts +45 -0
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskPurge.js +35 -0
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -0
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts +26 -0
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskReviewStatus.js +44 -0
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +32 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskSendWaiting.js +99 -0
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts +12 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.js +22 -0
- package/out/src/monitor/tasks/TaskSyncWhenIdle.js.map +1 -0
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts +40 -0
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -0
- package/out/src/monitor/tasks/WalletMonitorTask.js +37 -0
- package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -0
- package/out/src/sdk/CertOps.d.ts +66 -0
- package/out/src/sdk/CertOps.d.ts.map +1 -0
- package/out/src/sdk/CertOps.js +198 -0
- package/out/src/sdk/CertOps.js.map +1 -0
- package/out/src/sdk/PrivilegedKeyManager.d.ts +125 -0
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -0
- package/out/src/sdk/PrivilegedKeyManager.js +293 -0
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -0
- package/out/src/sdk/StorageSyncReader.d.ts +121 -0
- package/out/src/sdk/StorageSyncReader.d.ts.map +1 -0
- package/out/src/sdk/StorageSyncReader.js +3 -0
- package/out/src/sdk/StorageSyncReader.js.map +1 -0
- package/out/src/sdk/StorageSyncReaderWriter.d.ts +89 -0
- package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +1 -0
- package/out/src/sdk/StorageSyncReaderWriter.js +3 -0
- package/out/src/sdk/StorageSyncReaderWriter.js.map +1 -0
- package/out/src/sdk/WERR_errors.d.ts +90 -0
- package/out/src/sdk/WERR_errors.d.ts.map +1 -0
- package/out/src/sdk/WERR_errors.js +128 -0
- package/out/src/sdk/WERR_errors.js.map +1 -0
- package/out/src/sdk/WalletError.d.ts +45 -0
- package/out/src/sdk/WalletError.d.ts.map +1 -0
- package/out/src/sdk/WalletError.js +122 -0
- package/out/src/sdk/WalletError.js.map +1 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts +325 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -0
- package/out/src/sdk/WalletServices.interfaces.js +3 -0
- package/out/src/sdk/WalletServices.interfaces.js.map +1 -0
- package/out/src/sdk/WalletSigner.interfaces.d.ts +10 -0
- package/out/src/sdk/WalletSigner.interfaces.d.ts.map +1 -0
- package/out/src/sdk/WalletSigner.interfaces.js +3 -0
- package/out/src/sdk/WalletSigner.interfaces.js.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts +299 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.js +3 -0
- package/out/src/sdk/WalletStorage.interfaces.js.map +1 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.d.ts +2 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.d.ts.map +1 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.js +125 -0
- package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.d.ts +2 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.d.ts.map +1 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js +660 -0
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -0
- package/out/src/sdk/index.d.ts +12 -0
- package/out/src/sdk/index.d.ts.map +1 -0
- package/out/src/sdk/index.js +28 -0
- package/out/src/sdk/index.js.map +1 -0
- package/out/src/sdk/types.d.ts +74 -0
- package/out/src/sdk/types.d.ts.map +1 -0
- package/out/src/sdk/types.js +20 -0
- package/out/src/sdk/types.js.map +1 -0
- package/out/src/sdk/validationHelpers.d.ts +288 -0
- package/out/src/sdk/validationHelpers.d.ts.map +1 -0
- package/out/src/sdk/validationHelpers.js +630 -0
- package/out/src/sdk/validationHelpers.js.map +1 -0
- package/out/src/services/ServiceCollection.d.ts +25 -0
- package/out/src/services/ServiceCollection.d.ts.map +1 -0
- package/out/src/services/ServiceCollection.js +43 -0
- package/out/src/services/ServiceCollection.js.map +1 -0
- package/out/src/services/Services.d.ts +60 -0
- package/out/src/services/Services.d.ts.map +1 -0
- package/out/src/services/Services.js +342 -0
- package/out/src/services/Services.js.map +1 -0
- package/out/src/services/__tests/getMerklePath.test.d.ts +2 -0
- package/out/src/services/__tests/getMerklePath.test.d.ts.map +1 -0
- package/out/src/services/__tests/getMerklePath.test.js +16 -0
- package/out/src/services/__tests/getMerklePath.test.js.map +1 -0
- package/out/src/services/__tests/getRawTx.test.d.ts +2 -0
- package/out/src/services/__tests/getRawTx.test.d.ts.map +1 -0
- package/out/src/services/__tests/getRawTx.test.js +13 -0
- package/out/src/services/__tests/getRawTx.test.js.map +1 -0
- package/out/src/services/__tests/postBeef.test.d.ts +2 -0
- package/out/src/services/__tests/postBeef.test.d.ts.map +1 -0
- package/out/src/services/__tests/postBeef.test.js +18 -0
- package/out/src/services/__tests/postBeef.test.js.map +1 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.d.ts +2 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.d.ts.map +1 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.js +479 -0
- package/out/src/services/__tests/postBeefToArcTaal.test.js.map +1 -0
- package/out/src/services/__tests/postTxs.test.d.ts +2 -0
- package/out/src/services/__tests/postTxs.test.d.ts.map +1 -0
- package/out/src/services/__tests/postTxs.test.js +19 -0
- package/out/src/services/__tests/postTxs.test.js.map +1 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +15 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.js +51 -0
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.d.ts +2 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.d.ts.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js +19 -0
- package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.d.ts +2 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.d.ts.map +1 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js +29 -0
- package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts +98 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js +38 -0
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +36 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +130 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/index.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/index.js +19 -0
- package/out/src/services/chaintracker/chaintracks/index.js.map +1 -0
- package/out/src/services/chaintracker/index.d.ts +3 -0
- package/out/src/services/chaintracker/index.d.ts.map +1 -0
- package/out/src/services/chaintracker/index.js +19 -0
- package/out/src/services/chaintracker/index.js.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts +3 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.js +34 -0
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -0
- package/out/src/services/index.d.ts +2 -0
- package/out/src/services/index.d.ts.map +1 -0
- package/out/src/services/index.js +18 -0
- package/out/src/services/index.js.map +1 -0
- package/out/src/services/providers/arcServices.d.ts +62 -0
- package/out/src/services/providers/arcServices.d.ts.map +1 -0
- package/out/src/services/providers/arcServices.js +368 -0
- package/out/src/services/providers/arcServices.js.map +1 -0
- package/out/src/services/providers/echangeRates.d.ts +12 -0
- package/out/src/services/providers/echangeRates.d.ts.map +1 -0
- package/out/src/services/providers/echangeRates.js +237 -0
- package/out/src/services/providers/echangeRates.js.map +1 -0
- package/out/src/services/providers/whatsonchain.d.ts +17 -0
- package/out/src/services/providers/whatsonchain.d.ts.map +1 -0
- package/out/src/services/providers/whatsonchain.js +130 -0
- package/out/src/services/providers/whatsonchain.js.map +1 -0
- package/out/src/signer/WalletSigner.d.ts +11 -0
- package/out/src/signer/WalletSigner.d.ts.map +1 -0
- package/out/src/signer/WalletSigner.js +13 -0
- package/out/src/signer/WalletSigner.js.map +1 -0
- package/out/src/signer/methods/acquireDirectCertificate.d.ts +4 -0
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -0
- package/out/src/signer/methods/acquireDirectCertificate.js +47 -0
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -0
- package/out/src/signer/methods/createAction.d.ts +7 -0
- package/out/src/signer/methods/createAction.d.ts.map +1 -0
- package/out/src/signer/methods/createAction.js +250 -0
- package/out/src/signer/methods/createAction.js.map +1 -0
- package/out/src/signer/methods/internalizeAction.d.ts +31 -0
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -0
- package/out/src/signer/methods/internalizeAction.js +95 -0
- package/out/src/signer/methods/internalizeAction.js.map +1 -0
- package/out/src/signer/methods/proveCertificate.d.ts +4 -0
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -0
- package/out/src/signer/methods/proveCertificate.js +45 -0
- package/out/src/signer/methods/proveCertificate.js.map +1 -0
- package/out/src/signer/methods/signAction.d.ts +6 -0
- package/out/src/signer/methods/signAction.d.ts.map +1 -0
- package/out/src/signer/methods/signAction.js +79 -0
- package/out/src/signer/methods/signAction.js.map +1 -0
- package/out/src/storage/StorageKnex.d.ts +176 -0
- package/out/src/storage/StorageKnex.d.ts.map +1 -0
- package/out/src/storage/StorageKnex.js +1035 -0
- package/out/src/storage/StorageKnex.js.map +1 -0
- package/out/src/storage/StorageProvider.d.ts +140 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -0
- package/out/src/storage/StorageProvider.js +539 -0
- package/out/src/storage/StorageProvider.js.map +1 -0
- package/out/src/storage/StorageReader.d.ts +76 -0
- package/out/src/storage/StorageReader.d.ts.map +1 -0
- package/out/src/storage/StorageReader.js +124 -0
- package/out/src/storage/StorageReader.js.map +1 -0
- package/out/src/storage/StorageReaderWriter.d.ts +87 -0
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -0
- package/out/src/storage/StorageReaderWriter.js +337 -0
- package/out/src/storage/StorageReaderWriter.js.map +1 -0
- package/out/src/storage/StorageSyncReader.d.ts +33 -0
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -0
- package/out/src/storage/StorageSyncReader.js +142 -0
- package/out/src/storage/StorageSyncReader.js.map +1 -0
- package/out/src/storage/WalletStorageManager.d.ts +103 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -0
- package/out/src/storage/WalletStorageManager.js +408 -0
- package/out/src/storage/WalletStorageManager.js.map +1 -0
- package/out/src/storage/__test/WalletStorageManager.test.d.ts +2 -0
- package/out/src/storage/__test/WalletStorageManager.test.d.ts.map +1 -0
- package/out/src/storage/__test/WalletStorageManager.test.js +260 -0
- package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -0
- package/out/src/storage/index.all.d.ts +11 -0
- package/out/src/storage/index.all.d.ts.map +1 -0
- package/out/src/storage/index.all.js +50 -0
- package/out/src/storage/index.all.js.map +1 -0
- package/out/src/storage/index.client.d.ts +7 -0
- package/out/src/storage/index.client.d.ts.map +1 -0
- package/out/src/storage/index.client.js +46 -0
- package/out/src/storage/index.client.js.map +1 -0
- package/out/src/storage/index.db.d.ts +1 -0
- package/out/src/storage/index.db.d.ts.map +1 -0
- package/out/src/storage/index.db.js +2 -0
- package/out/src/storage/index.db.js.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.d.ts +2 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.d.ts.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +948 -0
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts +2 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +35 -0
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +27 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +148 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -0
- package/out/src/storage/methods/createAction.d.ts +23 -0
- package/out/src/storage/methods/createAction.d.ts.map +1 -0
- package/out/src/storage/methods/createAction.js +663 -0
- package/out/src/storage/methods/createAction.js.map +1 -0
- package/out/src/storage/methods/generateChange.d.ts +108 -0
- package/out/src/storage/methods/generateChange.d.ts.map +1 -0
- package/out/src/storage/methods/generateChange.js +422 -0
- package/out/src/storage/methods/generateChange.js.map +1 -0
- package/out/src/storage/methods/getBeefForTransaction.d.ts +22 -0
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -0
- package/out/src/storage/methods/getBeefForTransaction.js +94 -0
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -0
- package/out/src/storage/methods/getSyncChunk.d.ts +10 -0
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -0
- package/out/src/storage/methods/getSyncChunk.js +271 -0
- package/out/src/storage/methods/getSyncChunk.js.map +1 -0
- package/out/src/storage/methods/internalizeAction.d.ts +38 -0
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -0
- package/out/src/storage/methods/internalizeAction.js +378 -0
- package/out/src/storage/methods/internalizeAction.js.map +1 -0
- package/out/src/storage/methods/listActions.d.ts +5 -0
- package/out/src/storage/methods/listActions.d.ts.map +1 -0
- package/out/src/storage/methods/listActions.js +174 -0
- package/out/src/storage/methods/listActions.js.map +1 -0
- package/out/src/storage/methods/listCertificates.d.ts +5 -0
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -0
- package/out/src/storage/methods/listCertificates.js +68 -0
- package/out/src/storage/methods/listCertificates.js.map +1 -0
- package/out/src/storage/methods/listOutputs.d.ts +5 -0
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -0
- package/out/src/storage/methods/listOutputs.js +189 -0
- package/out/src/storage/methods/listOutputs.js.map +1 -0
- package/out/src/storage/methods/processAction.d.ts +35 -0
- package/out/src/storage/methods/processAction.d.ts.map +1 -0
- package/out/src/storage/methods/processAction.js +271 -0
- package/out/src/storage/methods/processAction.js.map +1 -0
- package/out/src/storage/methods/purgeData.d.ts +4 -0
- package/out/src/storage/methods/purgeData.d.ts.map +1 -0
- package/out/src/storage/methods/purgeData.js +229 -0
- package/out/src/storage/methods/purgeData.js.map +1 -0
- package/out/src/storage/methods/reviewStatus.d.ts +9 -0
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -0
- package/out/src/storage/methods/reviewStatus.js +75 -0
- package/out/src/storage/methods/reviewStatus.js.map +1 -0
- package/out/src/storage/remoting/StorageClient.d.ts +56 -0
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageClient.js +181 -0
- package/out/src/storage/remoting/StorageClient.js.map +1 -0
- package/out/src/storage/remoting/StorageServer.d.ts +26 -0
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageServer.js +144 -0
- package/out/src/storage/remoting/StorageServer.js.map +1 -0
- package/out/src/storage/schema/KnexMigrations.d.ts +39 -0
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -0
- package/out/src/storage/schema/KnexMigrations.js +442 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -0
- package/out/src/storage/schema/entities/Certificate.d.ts +43 -0
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Certificate.js +162 -0
- package/out/src/storage/schema/entities/Certificate.js.map +1 -0
- package/out/src/storage/schema/entities/CertificateField.d.ts +32 -0
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/entities/CertificateField.js +114 -0
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -0
- package/out/src/storage/schema/entities/Commission.d.ts +37 -0
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Commission.js +130 -0
- package/out/src/storage/schema/entities/Commission.js.map +1 -0
- package/out/src/storage/schema/entities/EntityBase.d.ts +105 -0
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -0
- package/out/src/storage/schema/entities/EntityBase.js +100 -0
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -0
- package/out/src/storage/schema/entities/MergeEntity.d.ts +34 -0
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -0
- package/out/src/storage/schema/entities/MergeEntity.js +57 -0
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -0
- package/out/src/storage/schema/entities/Output.d.ts +67 -0
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Output.js +281 -0
- package/out/src/storage/schema/entities/Output.js.map +1 -0
- package/out/src/storage/schema/entities/OutputBasket.d.ts +35 -0
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/entities/OutputBasket.js +133 -0
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -0
- package/out/src/storage/schema/entities/OutputTag.d.ts +31 -0
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/entities/OutputTag.js +104 -0
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -0
- package/out/src/storage/schema/entities/OutputTagMap.d.ts +28 -0
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/entities/OutputTagMap.js +101 -0
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -0
- package/out/src/storage/schema/entities/ProvenTx.d.ts +84 -0
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/entities/ProvenTx.js +283 -0
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -0
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts +130 -0
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/entities/ProvenTxReq.js +521 -0
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/entities/SyncState.d.ts +66 -0
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -0
- package/out/src/storage/schema/entities/SyncState.js +284 -0
- package/out/src/storage/schema/entities/SyncState.js.map +1 -0
- package/out/src/storage/schema/entities/Transaction.d.ts +67 -0
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -0
- package/out/src/storage/schema/entities/Transaction.js +264 -0
- package/out/src/storage/schema/entities/Transaction.js.map +1 -0
- package/out/src/storage/schema/entities/TxLabel.d.ts +31 -0
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/entities/TxLabel.js +104 -0
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -0
- package/out/src/storage/schema/entities/TxLabelMap.d.ts +28 -0
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/entities/TxLabelMap.js +103 -0
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -0
- package/out/src/storage/schema/entities/User.d.ts +29 -0
- package/out/src/storage/schema/entities/User.d.ts.map +1 -0
- package/out/src/storage/schema/entities/User.js +100 -0
- package/out/src/storage/schema/entities/User.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +588 -0
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +449 -0
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +602 -0
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +515 -0
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +478 -0
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +440 -0
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js +626 -0
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +585 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +628 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +307 -0
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +823 -0
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +442 -0
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +313 -0
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js +81 -0
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.d.ts +2 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.d.ts.map +1 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.js +418 -0
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -0
- package/out/src/storage/schema/entities/index.d.ts +17 -0
- package/out/src/storage/schema/entities/index.d.ts.map +1 -0
- package/out/src/storage/schema/entities/index.js +33 -0
- package/out/src/storage/schema/entities/index.js.map +1 -0
- package/out/src/storage/schema/tables/Certificate.d.ts +20 -0
- package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Certificate.js +3 -0
- package/out/src/storage/schema/tables/Certificate.js.map +1 -0
- package/out/src/storage/schema/tables/CertificateField.d.ts +12 -0
- package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/tables/CertificateField.js +3 -0
- package/out/src/storage/schema/tables/CertificateField.js.map +1 -0
- package/out/src/storage/schema/tables/Commission.d.ts +13 -0
- package/out/src/storage/schema/tables/Commission.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Commission.js +3 -0
- package/out/src/storage/schema/tables/Commission.js.map +1 -0
- package/out/src/storage/schema/tables/MonitorEvent.d.ts +9 -0
- package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -0
- package/out/src/storage/schema/tables/MonitorEvent.js +3 -0
- package/out/src/storage/schema/tables/MonitorEvent.js.map +1 -0
- package/out/src/storage/schema/tables/Output.d.ts +36 -0
- package/out/src/storage/schema/tables/Output.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Output.js +31 -0
- package/out/src/storage/schema/tables/Output.js.map +1 -0
- package/out/src/storage/schema/tables/OutputBasket.d.ts +12 -0
- package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/tables/OutputBasket.js +3 -0
- package/out/src/storage/schema/tables/OutputBasket.js.map +1 -0
- package/out/src/storage/schema/tables/OutputTag.d.ts +10 -0
- package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/tables/OutputTag.js +3 -0
- package/out/src/storage/schema/tables/OutputTag.js.map +1 -0
- package/out/src/storage/schema/tables/OutputTagMap.d.ts +9 -0
- package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/OutputTagMap.js +3 -0
- package/out/src/storage/schema/tables/OutputTagMap.js.map +1 -0
- package/out/src/storage/schema/tables/ProvenTx.d.ts +14 -0
- package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/tables/ProvenTx.js +3 -0
- package/out/src/storage/schema/tables/ProvenTx.js.map +1 -0
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts +64 -0
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/tables/ProvenTxReq.js +3 -0
- package/out/src/storage/schema/tables/ProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/tables/Settings.d.ts +17 -0
- package/out/src/storage/schema/tables/Settings.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Settings.js +3 -0
- package/out/src/storage/schema/tables/Settings.js.map +1 -0
- package/out/src/storage/schema/tables/SyncState.d.ts +18 -0
- package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -0
- package/out/src/storage/schema/tables/SyncState.js +3 -0
- package/out/src/storage/schema/tables/SyncState.js.map +1 -0
- package/out/src/storage/schema/tables/Transaction.d.ts +37 -0
- package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -0
- package/out/src/storage/schema/tables/Transaction.js +21 -0
- package/out/src/storage/schema/tables/Transaction.js.map +1 -0
- package/out/src/storage/schema/tables/TxLabel.d.ts +10 -0
- package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TxLabel.js +3 -0
- package/out/src/storage/schema/tables/TxLabel.js.map +1 -0
- package/out/src/storage/schema/tables/TxLabelMap.d.ts +9 -0
- package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TxLabelMap.js +3 -0
- package/out/src/storage/schema/tables/TxLabelMap.js.map +1 -0
- package/out/src/storage/schema/tables/User.d.ts +16 -0
- package/out/src/storage/schema/tables/User.d.ts.map +1 -0
- package/out/src/storage/schema/tables/User.js +3 -0
- package/out/src/storage/schema/tables/User.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +17 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -0
- package/out/src/storage/schema/tables/index.js +33 -0
- package/out/src/storage/schema/tables/index.js.map +1 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +71 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.js +612 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -0
- package/out/src/storage/sync/index.d.ts +2 -0
- package/out/src/storage/sync/index.d.ts.map +1 -0
- package/out/src/storage/sync/index.js +18 -0
- package/out/src/storage/sync/index.js.map +1 -0
- package/out/src/utility/ScriptTemplateSABPPP.d.ts +25 -0
- package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +1 -0
- package/out/src/utility/ScriptTemplateSABPPP.js +46 -0
- package/out/src/utility/ScriptTemplateSABPPP.js.map +1 -0
- package/out/src/utility/index.all.d.ts +7 -0
- package/out/src/utility/index.all.d.ts.map +1 -0
- package/out/src/utility/index.all.js +23 -0
- package/out/src/utility/index.all.js.map +1 -0
- package/out/src/utility/index.client.d.ts +7 -0
- package/out/src/utility/index.client.d.ts.map +1 -0
- package/out/src/utility/index.client.js +23 -0
- package/out/src/utility/index.client.js.map +1 -0
- package/out/src/utility/parseTxScriptOffsets.d.ts +14 -0
- package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -0
- package/out/src/utility/parseTxScriptOffsets.js +26 -0
- package/out/src/utility/parseTxScriptOffsets.js.map +1 -0
- package/out/src/utility/stampLog.d.ts +18 -0
- package/out/src/utility/stampLog.d.ts.map +1 -0
- package/out/src/utility/stampLog.js +72 -0
- package/out/src/utility/stampLog.js.map +1 -0
- package/out/src/utility/tscProofToMerklePath.d.ts +8 -0
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -0
- package/out/src/utility/tscProofToMerklePath.js +41 -0
- package/out/src/utility/tscProofToMerklePath.js.map +1 -0
- package/out/src/utility/utilityHelpers.buffer.d.ts +18 -0
- package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.buffer.js +45 -0
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -0
- package/out/src/utility/utilityHelpers.d.ts +129 -0
- package/out/src/utility/utilityHelpers.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.js +268 -0
- package/out/src/utility/utilityHelpers.js.map +1 -0
- package/out/src/utility/utilityHelpers.noBuffer.d.ts +9 -0
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -0
- package/out/src/utility/utilityHelpers.noBuffer.js +23 -0
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.d.ts +2 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.d.ts.map +1 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.js +45 -0
- package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -0
- package/out/test/Wallet/action/internalizeAction.a.test.d.ts +2 -0
- package/out/test/Wallet/action/internalizeAction.a.test.d.ts.map +1 -0
- package/out/test/Wallet/action/internalizeAction.a.test.js +243 -0
- package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.d.ts +2 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.d.ts.map +1 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.js +213 -0
- package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -0
- package/out/test/Wallet/certificate/listCertificates.test.d.ts +2 -0
- package/out/test/Wallet/certificate/listCertificates.test.d.ts.map +1 -0
- package/out/test/Wallet/certificate/listCertificates.test.js +305 -0
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.d.ts +2 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.js +68 -0
- package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -0
- package/out/test/Wallet/get/getHeight.test.d.ts +2 -0
- package/out/test/Wallet/get/getHeight.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getHeight.test.js +45 -0
- package/out/test/Wallet/get/getHeight.test.js.map +1 -0
- package/out/test/Wallet/get/getKnownTxids.test.d.ts +2 -0
- package/out/test/Wallet/get/getKnownTxids.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getKnownTxids.test.js +73 -0
- package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -0
- package/out/test/Wallet/get/getNetwork.test.d.ts +2 -0
- package/out/test/Wallet/get/getNetwork.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getNetwork.test.js +26 -0
- package/out/test/Wallet/get/getNetwork.test.js.map +1 -0
- package/out/test/Wallet/get/getVersion.test.d.ts +2 -0
- package/out/test/Wallet/get/getVersion.test.d.ts.map +1 -0
- package/out/test/Wallet/get/getVersion.test.js +25 -0
- package/out/test/Wallet/get/getVersion.test.js.map +1 -0
- package/out/test/Wallet/live/walletLive.man.test.d.ts +26 -0
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -0
- package/out/test/Wallet/live/walletLive.man.test.js +389 -0
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.d.ts +2 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.d.ts.map +1 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js +153 -0
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -0
- package/out/test/checkDB.d.ts +4 -0
- package/out/test/checkDB.d.ts.map +1 -0
- package/out/test/checkDB.js +55 -0
- package/out/test/checkDB.js.map +1 -0
- package/out/test/examples/README.man.test.d.ts +2 -0
- package/out/test/examples/README.man.test.d.ts.map +1 -0
- package/out/test/examples/README.man.test.js +46 -0
- package/out/test/examples/README.man.test.js.map +1 -0
- package/out/test/monitor/Monitor.test.d.ts +2 -0
- package/out/test/monitor/Monitor.test.d.ts.map +1 -0
- package/out/test/monitor/Monitor.test.js +446 -0
- package/out/test/monitor/Monitor.test.js.map +1 -0
- package/out/test/services/Services.test.d.ts +2 -0
- package/out/test/services/Services.test.d.ts.map +1 -0
- package/out/test/services/Services.test.js +128 -0
- package/out/test/services/Services.test.js.map +1 -0
- package/out/test/storage/KnexMigrations.test.d.ts +2 -0
- package/out/test/storage/KnexMigrations.test.d.ts.map +1 -0
- package/out/test/storage/KnexMigrations.test.js +81 -0
- package/out/test/storage/KnexMigrations.test.js.map +1 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.d.ts +2 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.d.ts.map +1 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +88 -0
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -0
- package/out/test/storage/count.test.d.ts +2 -0
- package/out/test/storage/count.test.d.ts.map +1 -0
- package/out/test/storage/count.test.js +141 -0
- package/out/test/storage/count.test.js.map +1 -0
- package/out/test/storage/find.test.d.ts +2 -0
- package/out/test/storage/find.test.d.ts.map +1 -0
- package/out/test/storage/find.test.js +148 -0
- package/out/test/storage/find.test.js.map +1 -0
- package/out/test/storage/findLegacy.test.d.ts +2 -0
- package/out/test/storage/findLegacy.test.d.ts.map +1 -0
- package/out/test/storage/findLegacy.test.js +52 -0
- package/out/test/storage/findLegacy.test.js.map +1 -0
- package/out/test/storage/insert.test.d.ts +2 -0
- package/out/test/storage/insert.test.d.ts.map +1 -0
- package/out/test/storage/insert.test.js +256 -0
- package/out/test/storage/insert.test.js.map +1 -0
- package/out/test/storage/update.test.d.ts +2 -0
- package/out/test/storage/update.test.d.ts.map +1 -0
- package/out/test/storage/update.test.js +926 -0
- package/out/test/storage/update.test.js.map +1 -0
- package/out/test/storage/update2.test.d.ts +2 -0
- package/out/test/storage/update2.test.d.ts.map +1 -0
- package/out/test/storage/update2.test.js +766 -0
- package/out/test/storage/update2.test.js.map +1 -0
- package/out/test/utils/TestUtilsWalletStorage.d.ts +399 -0
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -0
- package/out/test/utils/TestUtilsWalletStorage.js +1337 -0
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -0
- package/out/test/wallet/action/abortAction.test.d.ts +2 -0
- package/out/test/wallet/action/abortAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/abortAction.test.js +44 -0
- package/out/test/wallet/action/abortAction.test.js.map +1 -0
- package/out/test/wallet/action/createAction.test.d.ts +2 -0
- package/out/test/wallet/action/createAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/createAction.test.js +230 -0
- package/out/test/wallet/action/createAction.test.js.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts +2 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js +273 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.d.ts +2 -0
- package/out/test/wallet/action/internalizeAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.js +603 -0
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts +2 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.js +31 -0
- package/out/test/wallet/action/relinquishOutput.test.js.map +1 -0
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts +2 -0
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts.map +1 -0
- package/out/test/wallet/construct/Wallet.constructor.test.js +49 -0
- package/out/test/wallet/construct/Wallet.constructor.test.js.map +1 -0
- package/out/test/wallet/list/listActions.test.d.ts +2 -0
- package/out/test/wallet/list/listActions.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions.test.js +265 -0
- package/out/test/wallet/list/listActions.test.js.map +1 -0
- package/out/test/wallet/list/listActions2.test.d.ts +2 -0
- package/out/test/wallet/list/listActions2.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions2.test.js +423 -0
- package/out/test/wallet/list/listActions2.test.js.map +1 -0
- package/out/test/wallet/list/listCertificates.test.d.ts +2 -0
- package/out/test/wallet/list/listCertificates.test.d.ts.map +1 -0
- package/out/test/wallet/list/listCertificates.test.js +115 -0
- package/out/test/wallet/list/listCertificates.test.js.map +1 -0
- package/out/test/wallet/list/listOutputs.test.d.ts +2 -0
- package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -0
- package/out/test/wallet/list/listOutputs.test.js +521 -0
- package/out/test/wallet/list/listOutputs.test.js.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts +2 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.js +142 -0
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -0
- package/package.json +63 -0
- package/src/Wallet.ts +771 -0
- package/src/index.all.ts +8 -0
- package/src/index.client.ts +7 -0
- package/src/index.ts +2 -0
- package/src/monitor/Monitor.ts +317 -0
- package/src/monitor/MonitorDaemon.ts +197 -0
- package/src/monitor/README.md +3 -0
- package/src/monitor/__test/MonitorDaemon.man.test.ts +17 -0
- package/src/monitor/tasks/TaskCheckForProofs.ts +235 -0
- package/src/monitor/tasks/TaskClock.ts +35 -0
- package/src/monitor/tasks/TaskFailAbandoned.ts +56 -0
- package/src/monitor/tasks/TaskNewHeader.ts +48 -0
- package/src/monitor/tasks/TaskPurge.ts +69 -0
- package/src/monitor/tasks/TaskReviewStatus.ts +51 -0
- package/src/monitor/tasks/TaskSendWaiting.ts +107 -0
- package/src/monitor/tasks/TaskSyncWhenIdle.ts +26 -0
- package/src/monitor/tasks/WalletMonitorTask.ts +47 -0
- package/src/sdk/CertOps.ts +346 -0
- package/src/sdk/PrivilegedKeyManager.ts +402 -0
- package/src/sdk/README.md +13 -0
- package/src/sdk/StorageSyncReader.ts +155 -0
- package/src/sdk/StorageSyncReaderWriter.ts +263 -0
- package/src/sdk/WERR_errors.ts +152 -0
- package/src/sdk/WalletError.ts +136 -0
- package/src/sdk/WalletServices.interfaces.ts +399 -0
- package/src/sdk/WalletSigner.interfaces.ts +38 -0
- package/src/sdk/WalletStorage.interfaces.ts +416 -0
- package/src/sdk/__test/CertificateLifeCycle.test.ts +194 -0
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +775 -0
- package/src/sdk/index.ts +11 -0
- package/src/sdk/types.ts +115 -0
- package/src/sdk/validationHelpers.ts +1248 -0
- package/src/services/README.md +11 -0
- package/src/services/ServiceCollection.ts +50 -0
- package/src/services/Services.ts +461 -0
- package/src/services/__tests/getMerklePath.test.ts +16 -0
- package/src/services/__tests/getRawTx.test.ts +15 -0
- package/src/services/__tests/postBeef.test.ts +19 -0
- package/src/services/__tests/postBeefToArcTaal.test.ts +487 -0
- package/src/services/__tests/postTxs.test.ts +20 -0
- package/src/services/chaintracker/ChaintracksChainTracker.ts +78 -0
- package/src/services/chaintracker/__tests/ChaintracksChainTracker.test.ts +25 -0
- package/src/services/chaintracker/__tests/ChaintracksServiceClient.test.ts +32 -0
- package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +123 -0
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +160 -0
- package/src/services/chaintracker/chaintracks/index.ts +2 -0
- package/src/services/chaintracker/index.ts +2 -0
- package/src/services/createDefaultWalletServicesOptions.ts +38 -0
- package/src/services/index.ts +1 -0
- package/src/services/providers/arcServices.ts +570 -0
- package/src/services/providers/echangeRates.ts +276 -0
- package/src/services/providers/whatsonchain.ts +170 -0
- package/src/signer/README.md +5 -0
- package/src/signer/WalletSigner.ts +21 -0
- package/src/signer/methods/acquireDirectCertificate.ts +53 -0
- package/src/signer/methods/createAction.ts +364 -0
- package/src/signer/methods/internalizeAction.ts +142 -0
- package/src/signer/methods/proveCertificate.ts +51 -0
- package/src/signer/methods/signAction.ts +121 -0
- package/src/storage/README.md +14 -0
- package/src/storage/StorageKnex.ts +1449 -0
- package/src/storage/StorageProvider.ts +853 -0
- package/src/storage/StorageReader.ts +222 -0
- package/src/storage/StorageReaderWriter.ts +623 -0
- package/src/storage/StorageSyncReader.ts +143 -0
- package/src/storage/WalletStorageManager.ts +532 -0
- package/src/storage/__test/WalletStorageManager.test.ts +292 -0
- package/src/storage/index.all.ts +10 -0
- package/src/storage/index.client.ts +6 -0
- package/src/storage/index.db.ts +0 -0
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +1143 -0
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +31 -0
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +185 -0
- package/src/storage/methods/createAction.ts +997 -0
- package/src/storage/methods/generateChange.ts +629 -0
- package/src/storage/methods/getBeefForTransaction.ts +143 -0
- package/src/storage/methods/getSyncChunk.ts +330 -0
- package/src/storage/methods/internalizeAction.ts +538 -0
- package/src/storage/methods/listActions.ts +203 -0
- package/src/storage/methods/listCertificates.ts +81 -0
- package/src/storage/methods/listOutputs.ts +219 -0
- package/src/storage/methods/processAction.ts +477 -0
- package/src/storage/methods/purgeData.ts +276 -0
- package/src/storage/methods/reviewStatus.ts +95 -0
- package/src/storage/remoting/StorageClient.ts +306 -0
- package/src/storage/remoting/StorageServer.ts +179 -0
- package/src/storage/schema/KnexMigrations.ts +488 -0
- package/src/storage/schema/entities/Certificate.ts +199 -0
- package/src/storage/schema/entities/CertificateField.ts +157 -0
- package/src/storage/schema/entities/Commission.ts +169 -0
- package/src/storage/schema/entities/EntityBase.ts +214 -0
- package/src/storage/schema/entities/MergeEntity.ts +79 -0
- package/src/storage/schema/entities/Output.ts +323 -0
- package/src/storage/schema/entities/OutputBasket.ts +165 -0
- package/src/storage/schema/entities/OutputTag.ts +138 -0
- package/src/storage/schema/entities/OutputTagMap.ts +146 -0
- package/src/storage/schema/entities/ProvenTx.ts +349 -0
- package/src/storage/schema/entities/ProvenTxReq.ts +646 -0
- package/src/storage/schema/entities/SyncState.ts +429 -0
- package/src/storage/schema/entities/Transaction.ts +334 -0
- package/src/storage/schema/entities/TxLabel.ts +135 -0
- package/src/storage/schema/entities/TxLabelMap.ts +148 -0
- package/src/storage/schema/entities/User.ts +138 -0
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +663 -0
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +527 -0
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +658 -0
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +567 -0
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +530 -0
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +504 -0
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +689 -0
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +669 -0
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +700 -0
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +376 -0
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +920 -0
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +512 -0
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +350 -0
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +97 -0
- package/src/storage/schema/entities/__tests/usersTests.test.ts +485 -0
- package/src/storage/schema/entities/index.ts +16 -0
- package/src/storage/schema/tables/Certificate.ts +21 -0
- package/src/storage/schema/tables/CertificateField.ts +12 -0
- package/src/storage/schema/tables/Commission.ts +13 -0
- package/src/storage/schema/tables/MonitorEvent.ts +9 -0
- package/src/storage/schema/tables/Output.ts +64 -0
- package/src/storage/schema/tables/OutputBasket.ts +12 -0
- package/src/storage/schema/tables/OutputTag.ts +10 -0
- package/src/storage/schema/tables/OutputTagMap.ts +9 -0
- package/src/storage/schema/tables/ProvenTx.ts +14 -0
- package/src/storage/schema/tables/ProvenTxReq.ts +65 -0
- package/src/storage/schema/tables/Settings.ts +17 -0
- package/src/storage/schema/tables/SyncState.ts +18 -0
- package/src/storage/schema/tables/Transaction.ts +54 -0
- package/src/storage/schema/tables/TxLabel.ts +10 -0
- package/src/storage/schema/tables/TxLabelMap.ts +9 -0
- package/src/storage/schema/tables/User.ts +16 -0
- package/src/storage/schema/tables/index.ts +16 -0
- package/src/storage/sync/StorageMySQLDojoReader.ts +771 -0
- package/src/storage/sync/index.ts +1 -0
- package/src/utility/README.md +3 -0
- package/src/utility/ScriptTemplateSABPPP.ts +79 -0
- package/src/utility/index.all.ts +7 -0
- package/src/utility/index.client.ts +7 -0
- package/src/utility/parseTxScriptOffsets.ts +29 -0
- package/src/utility/stampLog.ts +73 -0
- package/src/utility/tscProofToMerklePath.ts +51 -0
- package/src/utility/utilityHelpers.buffer.ts +43 -0
- package/src/utility/utilityHelpers.noBuffer.ts +18 -0
- package/src/utility/utilityHelpers.ts +283 -0
- package/test/Wallet/StorageClient/storageClient.man.test.ts +55 -0
- package/test/Wallet/action/internalizeAction.a.test.ts +301 -0
- package/test/Wallet/certificate/acquireCertificate.test.ts +253 -0
- package/test/Wallet/certificate/listCertificates.test.ts +352 -0
- package/test/Wallet/get/getHeaderForHeight.test.ts +79 -0
- package/test/Wallet/get/getHeight.test.ts +52 -0
- package/test/Wallet/get/getKnownTxids.test.ts +90 -0
- package/test/Wallet/get/getNetwork.test.ts +28 -0
- package/test/Wallet/get/getVersion.test.ts +28 -0
- package/test/Wallet/live/walletLive.man.test.ts +510 -0
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +155 -0
- package/test/checkDB.ts +63 -0
- package/test/checkdb +0 -0
- package/test/examples/README.man.test.ts +53 -0
- package/test/monitor/Monitor.test.ts +536 -0
- package/test/services/Services.test.ts +149 -0
- package/test/storage/KnexMigrations.test.ts +100 -0
- package/test/storage/StorageMySQLDojoReader.man.test.ts +71 -0
- package/test/storage/count.test.ts +193 -0
- package/test/storage/find.test.ts +216 -0
- package/test/storage/findLegacy.test.ts +70 -0
- package/test/storage/insert.test.ts +294 -0
- package/test/storage/update.test.ts +1146 -0
- package/test/storage/update2.test.ts +1017 -0
- package/test/utils/TestUtilsWalletStorage.ts +1923 -0
- package/test/utils/removeFailedFromDatabase.sql +17 -0
- package/test/wallet/action/abortAction.test.ts +55 -0
- package/test/wallet/action/createAction.test.ts +266 -0
- package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +297 -0
- package/test/wallet/action/internalizeAction.test.ts +729 -0
- package/test/wallet/action/relinquishOutput.test.ts +43 -0
- package/test/wallet/construct/Wallet.constructor.test.ts +57 -0
- package/test/wallet/list/listActions.test.ts +282 -0
- package/test/wallet/list/listActions2.test.ts +570 -0
- package/test/wallet/list/listCertificates.test.ts +129 -0
- package/test/wallet/list/listOutputs.test.ts +573 -0
- package/test/wallet/sync/Wallet.sync.test.ts +226 -0
- package/ts2md.json +32 -0
- package/tsconfig.all.json +29 -0
- package/tsconfig.client.json +22 -0
- package/tsconfig.json +14 -0
- package/unlock-migrations.sh +41 -0
|
@@ -0,0 +1,1248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbortActionArgs,
|
|
3
|
+
AcquireCertificateArgs,
|
|
4
|
+
AcquisitionProtocol,
|
|
5
|
+
AtomicBEEF,
|
|
6
|
+
Base64String,
|
|
7
|
+
BasketInsertion,
|
|
8
|
+
BasketStringUnder300Bytes,
|
|
9
|
+
Beef,
|
|
10
|
+
BEEF,
|
|
11
|
+
BooleanDefaultFalse,
|
|
12
|
+
BooleanDefaultTrue,
|
|
13
|
+
CertificateFieldNameUnder50Bytes,
|
|
14
|
+
CreateActionArgs,
|
|
15
|
+
CreateActionInput,
|
|
16
|
+
CreateActionOptions,
|
|
17
|
+
CreateActionOutput,
|
|
18
|
+
DescriptionString5to50Bytes,
|
|
19
|
+
DiscoverByAttributesArgs,
|
|
20
|
+
DiscoverByIdentityKeyArgs,
|
|
21
|
+
HexString,
|
|
22
|
+
InternalizeActionArgs,
|
|
23
|
+
InternalizeOutput,
|
|
24
|
+
KeyringRevealer,
|
|
25
|
+
LabelStringUnder300Bytes,
|
|
26
|
+
ListActionsArgs,
|
|
27
|
+
ListCertificatesArgs,
|
|
28
|
+
ListOutputsArgs,
|
|
29
|
+
OutpointString,
|
|
30
|
+
OutputTagStringUnder300Bytes,
|
|
31
|
+
PositiveInteger,
|
|
32
|
+
PositiveIntegerDefault10Max10000,
|
|
33
|
+
PositiveIntegerOrZero,
|
|
34
|
+
ProveCertificateArgs,
|
|
35
|
+
PubKeyHex,
|
|
36
|
+
RelinquishCertificateArgs,
|
|
37
|
+
RelinquishOutputArgs,
|
|
38
|
+
SatoshiValue,
|
|
39
|
+
SignActionArgs,
|
|
40
|
+
SignActionOptions,
|
|
41
|
+
SignActionSpend,
|
|
42
|
+
TrustSelf,
|
|
43
|
+
TXIDHexString,
|
|
44
|
+
Utils,
|
|
45
|
+
WalletPayment
|
|
46
|
+
} from '@bsv/sdk'
|
|
47
|
+
import { sdk } from '../index.client'
|
|
48
|
+
import { OutPoint } from './types'
|
|
49
|
+
|
|
50
|
+
export function parseWalletOutpoint(outpoint: string): {
|
|
51
|
+
txid: string
|
|
52
|
+
vout: number
|
|
53
|
+
} {
|
|
54
|
+
const [txid, vout] = outpoint.split('.')
|
|
55
|
+
return { txid, vout: Number(vout) }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function defaultTrue(v?: boolean) {
|
|
59
|
+
return v === undefined ? true : v
|
|
60
|
+
}
|
|
61
|
+
function defaultFalse(v?: boolean) {
|
|
62
|
+
return v === undefined ? false : v
|
|
63
|
+
}
|
|
64
|
+
function defaultZero(v?: number) {
|
|
65
|
+
return v === undefined ? 0 : v
|
|
66
|
+
}
|
|
67
|
+
function default0xffffffff(v?: number) {
|
|
68
|
+
return v === undefined ? 0xffffffff : v
|
|
69
|
+
}
|
|
70
|
+
function defaultOne(v?: number) {
|
|
71
|
+
return v === undefined ? 1 : v
|
|
72
|
+
}
|
|
73
|
+
function defaultEmpty<T>(v?: T[]) {
|
|
74
|
+
return v === undefined ? [] : v
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function validateOptionalStringLength(
|
|
78
|
+
s: string | undefined,
|
|
79
|
+
name: string,
|
|
80
|
+
min?: number,
|
|
81
|
+
max?: number
|
|
82
|
+
): string | undefined {
|
|
83
|
+
if (s === undefined) return undefined
|
|
84
|
+
return validateStringLength(s, name, min, max)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function validateSatoshis(
|
|
88
|
+
v: number | undefined,
|
|
89
|
+
name: string,
|
|
90
|
+
min?: number
|
|
91
|
+
): number {
|
|
92
|
+
if (v === undefined || !Number.isInteger(v) || v < 0 || v > 21e14)
|
|
93
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, 'a valid number of satoshis')
|
|
94
|
+
if (min !== undefined && v < min)
|
|
95
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} satoshis.`)
|
|
96
|
+
return v
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function validateOptionalInteger(
|
|
100
|
+
v: number | undefined,
|
|
101
|
+
name: string,
|
|
102
|
+
min?: number,
|
|
103
|
+
max?: number
|
|
104
|
+
): number | undefined {
|
|
105
|
+
if (v === undefined) return undefined
|
|
106
|
+
return validateInteger(v, name, undefined, min, max)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function validateInteger(
|
|
110
|
+
v: number | undefined,
|
|
111
|
+
name: string,
|
|
112
|
+
defaultValue?: number,
|
|
113
|
+
min?: number,
|
|
114
|
+
max?: number
|
|
115
|
+
): number {
|
|
116
|
+
if (v === undefined) {
|
|
117
|
+
if (defaultValue !== undefined) return defaultValue
|
|
118
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, 'a valid integer')
|
|
119
|
+
}
|
|
120
|
+
if (!Number.isInteger(v))
|
|
121
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, 'an integer')
|
|
122
|
+
v = Number(v)
|
|
123
|
+
if (min !== undefined && v < min)
|
|
124
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
125
|
+
if (max !== undefined && v > max)
|
|
126
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
127
|
+
return v
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function validatePositiveIntegerOrZero(v: number, name: string): number {
|
|
131
|
+
return validateInteger(v, name, 0, 0)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function validateStringLength(
|
|
135
|
+
s: string,
|
|
136
|
+
name: string,
|
|
137
|
+
min?: number,
|
|
138
|
+
max?: number
|
|
139
|
+
): string {
|
|
140
|
+
const bytes = Utils.toArray(s, 'utf8').length
|
|
141
|
+
if (min !== undefined && bytes < min)
|
|
142
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
143
|
+
if (max !== undefined && bytes > max)
|
|
144
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
145
|
+
return s
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function validateOptionalBasket(s?: string): string | undefined {
|
|
149
|
+
if (s === undefined) return undefined
|
|
150
|
+
return validateBasket(s)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function validateBasket(s: string): string {
|
|
154
|
+
return validateIdentifier(s, 'basket', 1, 300)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function validateLabel(s: string): string {
|
|
158
|
+
return validateIdentifier(s, 'label', 1, 300)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function validateTag(s: string): string {
|
|
162
|
+
return validateIdentifier(s, 'tag', 1, 300)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function validateIdentifier(
|
|
166
|
+
s: string,
|
|
167
|
+
name: string,
|
|
168
|
+
min?: number,
|
|
169
|
+
max?: number
|
|
170
|
+
): string {
|
|
171
|
+
s = s.trim().toLowerCase()
|
|
172
|
+
const bytes = Utils.toArray(s, 'utf8').length
|
|
173
|
+
if (min !== undefined && bytes < min)
|
|
174
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
175
|
+
if (max !== undefined && bytes > max)
|
|
176
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
177
|
+
return s
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function validateOptionalBase64String(
|
|
181
|
+
s: string | undefined,
|
|
182
|
+
name: string,
|
|
183
|
+
min?: number,
|
|
184
|
+
max?: number
|
|
185
|
+
): string | undefined {
|
|
186
|
+
if (s === undefined) return undefined
|
|
187
|
+
return validateBase64String(s, name, min, max)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function validateBase64String(
|
|
191
|
+
s: string,
|
|
192
|
+
name: string,
|
|
193
|
+
min?: number,
|
|
194
|
+
max?: number
|
|
195
|
+
): string {
|
|
196
|
+
// Remove any whitespace and check if the string length is valid for Base64
|
|
197
|
+
s = s.trim()
|
|
198
|
+
const base64Regex =
|
|
199
|
+
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/
|
|
200
|
+
const paddingCount = (s.match(/=+$/) || [])[0]?.length || 0
|
|
201
|
+
|
|
202
|
+
if (
|
|
203
|
+
paddingCount > 2 ||
|
|
204
|
+
(s.length % 4 !== 0 && paddingCount !== 0) ||
|
|
205
|
+
!base64Regex.test(s)
|
|
206
|
+
) {
|
|
207
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `balid base64 string`)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const bytes = Utils.toArray(s, 'base64').length
|
|
211
|
+
if (min !== undefined && bytes < min)
|
|
212
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
213
|
+
if (max !== undefined && bytes > max)
|
|
214
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
215
|
+
|
|
216
|
+
return s
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function validateOptionalHexString(
|
|
220
|
+
s: string | undefined,
|
|
221
|
+
name: string,
|
|
222
|
+
min?: number,
|
|
223
|
+
max?: number
|
|
224
|
+
): string | undefined {
|
|
225
|
+
if (s === undefined) return undefined
|
|
226
|
+
return validateHexString(s, name, min, max)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param s
|
|
231
|
+
* @param name
|
|
232
|
+
* @param min if valid, string length minimum (not bytes)
|
|
233
|
+
* @param max if valid, string length maximum (not bytes)
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
function validateHexString(
|
|
237
|
+
s: string,
|
|
238
|
+
name: string,
|
|
239
|
+
min?: number,
|
|
240
|
+
max?: number
|
|
241
|
+
): string {
|
|
242
|
+
s = s.trim().toLowerCase()
|
|
243
|
+
if (s.length % 2 === 1)
|
|
244
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `even length, not ${s.length}.`)
|
|
245
|
+
const hexRegex = /^[0-9A-Fa-f]+$/
|
|
246
|
+
if (!hexRegex.test(s))
|
|
247
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `hexadecimal string.`)
|
|
248
|
+
if (min !== undefined && s.length < min)
|
|
249
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
250
|
+
if (max !== undefined && s.length > max)
|
|
251
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
252
|
+
return s
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function isHexString(s: string): boolean {
|
|
256
|
+
s = s.trim()
|
|
257
|
+
if (s.length % 2 === 1) return false
|
|
258
|
+
const hexRegex = /^[0-9A-Fa-f]+$/
|
|
259
|
+
if (!hexRegex.test(s)) return false
|
|
260
|
+
return true
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface ValidWalletSignerArgs {}
|
|
264
|
+
|
|
265
|
+
export interface ValidCreateActionInput {
|
|
266
|
+
outpoint: OutPoint
|
|
267
|
+
inputDescription: DescriptionString5to50Bytes
|
|
268
|
+
sequenceNumber: PositiveIntegerOrZero
|
|
269
|
+
unlockingScript?: HexString
|
|
270
|
+
unlockingScriptLength: PositiveInteger
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function validateCreateActionInput(
|
|
274
|
+
i: CreateActionInput
|
|
275
|
+
): ValidCreateActionInput {
|
|
276
|
+
if (i.unlockingScript === undefined && i.unlockingScriptLength === undefined)
|
|
277
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
278
|
+
'unlockingScript, unlockingScriptLength',
|
|
279
|
+
`at least one valid value.`
|
|
280
|
+
)
|
|
281
|
+
const unlockingScript = validateOptionalHexString(
|
|
282
|
+
i.unlockingScript,
|
|
283
|
+
'unlockingScript'
|
|
284
|
+
)
|
|
285
|
+
const unlockingScriptLength =
|
|
286
|
+
i.unlockingScriptLength || unlockingScript!.length / 2
|
|
287
|
+
if (unlockingScript && unlockingScriptLength !== unlockingScript.length / 2)
|
|
288
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
289
|
+
'unlockingScriptLength',
|
|
290
|
+
`length unlockingScript if both valid.`
|
|
291
|
+
)
|
|
292
|
+
const vi: ValidCreateActionInput = {
|
|
293
|
+
outpoint: parseWalletOutpoint(i.outpoint),
|
|
294
|
+
inputDescription: validateStringLength(
|
|
295
|
+
i.inputDescription,
|
|
296
|
+
'inputDescription',
|
|
297
|
+
5,
|
|
298
|
+
50
|
|
299
|
+
),
|
|
300
|
+
unlockingScript,
|
|
301
|
+
unlockingScriptLength,
|
|
302
|
+
sequenceNumber: default0xffffffff(i.sequenceNumber)
|
|
303
|
+
}
|
|
304
|
+
return vi
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface ValidCreateActionOutput {
|
|
308
|
+
lockingScript: HexString
|
|
309
|
+
satoshis: SatoshiValue
|
|
310
|
+
outputDescription: DescriptionString5to50Bytes
|
|
311
|
+
basket?: BasketStringUnder300Bytes
|
|
312
|
+
customInstructions?: string
|
|
313
|
+
tags: BasketStringUnder300Bytes[]
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function validateCreateActionOutput(
|
|
317
|
+
o: CreateActionOutput
|
|
318
|
+
): ValidCreateActionOutput {
|
|
319
|
+
const vo: ValidCreateActionOutput = {
|
|
320
|
+
lockingScript: validateHexString(o.lockingScript, 'lockingScript'),
|
|
321
|
+
satoshis: validateSatoshis(o.satoshis, 'satoshis'),
|
|
322
|
+
outputDescription: validateStringLength(
|
|
323
|
+
o.outputDescription,
|
|
324
|
+
'outputDescription',
|
|
325
|
+
5,
|
|
326
|
+
50
|
|
327
|
+
),
|
|
328
|
+
basket: validateOptionalBasket(o.basket),
|
|
329
|
+
customInstructions: o.customInstructions,
|
|
330
|
+
tags: defaultEmpty(o.tags).map(t => validateTag(t))
|
|
331
|
+
}
|
|
332
|
+
return vo
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Set all default true/false booleans to true or false if undefined.
|
|
337
|
+
* Set all possibly undefined numbers to their default values.
|
|
338
|
+
* Set all possibly undefined arrays to empty arrays.
|
|
339
|
+
* Convert string outpoints to `{ txid: string, vout: number }`
|
|
340
|
+
*/
|
|
341
|
+
export function validateCreateActionOptions(
|
|
342
|
+
options?: CreateActionOptions
|
|
343
|
+
): ValidCreateActionOptions {
|
|
344
|
+
const o = options || {}
|
|
345
|
+
const vo: ValidCreateActionOptions = {
|
|
346
|
+
signAndProcess: defaultTrue(o.signAndProcess),
|
|
347
|
+
acceptDelayedBroadcast: defaultTrue(o.acceptDelayedBroadcast),
|
|
348
|
+
knownTxids: defaultEmpty(o.knownTxids),
|
|
349
|
+
returnTXIDOnly: defaultFalse(o.returnTXIDOnly),
|
|
350
|
+
noSend: defaultFalse(o.noSend),
|
|
351
|
+
noSendChange: defaultEmpty(o.noSendChange).map(nsc =>
|
|
352
|
+
parseWalletOutpoint(nsc)
|
|
353
|
+
),
|
|
354
|
+
sendWith: defaultEmpty(o.sendWith),
|
|
355
|
+
randomizeOutputs: defaultTrue(o.randomizeOutputs)
|
|
356
|
+
}
|
|
357
|
+
return vo
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface ValidProcessActionOptions {
|
|
361
|
+
acceptDelayedBroadcast: BooleanDefaultTrue
|
|
362
|
+
returnTXIDOnly: BooleanDefaultFalse
|
|
363
|
+
noSend: BooleanDefaultFalse
|
|
364
|
+
sendWith: TXIDHexString[]
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface ValidCreateActionOptions extends ValidProcessActionOptions {
|
|
368
|
+
signAndProcess: boolean
|
|
369
|
+
trustSelf?: TrustSelf
|
|
370
|
+
knownTxids: TXIDHexString[]
|
|
371
|
+
noSendChange: OutPoint[]
|
|
372
|
+
randomizeOutputs: boolean
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface ValidSignActionOptions extends ValidProcessActionOptions {
|
|
376
|
+
acceptDelayedBroadcast: boolean
|
|
377
|
+
returnTXIDOnly: boolean
|
|
378
|
+
noSend: boolean
|
|
379
|
+
sendWith: TXIDHexString[]
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export interface ValidProcessActionArgs extends ValidWalletSignerArgs {
|
|
383
|
+
options: sdk.ValidProcessActionOptions
|
|
384
|
+
// true if a batch of transactions is included for processing.
|
|
385
|
+
isSendWith: boolean
|
|
386
|
+
// true if there is a new transaction (not no inputs and no outputs)
|
|
387
|
+
isNewTx: boolean
|
|
388
|
+
// true if any new transaction should NOT be sent to the network
|
|
389
|
+
isNoSend: boolean
|
|
390
|
+
// true if options.acceptDelayedBroadcast is true
|
|
391
|
+
isDelayed: boolean
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export interface ValidCreateActionArgs extends ValidProcessActionArgs {
|
|
395
|
+
description: DescriptionString5to50Bytes
|
|
396
|
+
inputBEEF?: BEEF
|
|
397
|
+
inputs: sdk.ValidCreateActionInput[]
|
|
398
|
+
outputs: sdk.ValidCreateActionOutput[]
|
|
399
|
+
lockTime: number
|
|
400
|
+
version: number
|
|
401
|
+
labels: string[]
|
|
402
|
+
|
|
403
|
+
options: ValidCreateActionOptions
|
|
404
|
+
// true if transaction creation completion will require a `signAction` call.
|
|
405
|
+
isSignAction: boolean
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface ValidSignActionArgs extends ValidProcessActionArgs {
|
|
409
|
+
spends: Record<PositiveIntegerOrZero, SignActionSpend>
|
|
410
|
+
reference: Base64String
|
|
411
|
+
|
|
412
|
+
options: sdk.ValidSignActionOptions
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export function validateCreateActionArgs(
|
|
416
|
+
args: CreateActionArgs
|
|
417
|
+
): ValidCreateActionArgs {
|
|
418
|
+
const vargs: ValidCreateActionArgs = {
|
|
419
|
+
description: validateStringLength(args.description, 'description', 5, 50),
|
|
420
|
+
inputBEEF: args.inputBEEF,
|
|
421
|
+
inputs: defaultEmpty(args.inputs).map(i => validateCreateActionInput(i)),
|
|
422
|
+
outputs: defaultEmpty(args.outputs).map(o => validateCreateActionOutput(o)),
|
|
423
|
+
lockTime: defaultZero(args.lockTime),
|
|
424
|
+
version: defaultOne(args.version),
|
|
425
|
+
labels: defaultEmpty(args.labels?.map(l => validateLabel(l))),
|
|
426
|
+
options: validateCreateActionOptions(args.options),
|
|
427
|
+
isSendWith: false,
|
|
428
|
+
isDelayed: false,
|
|
429
|
+
isNoSend: false,
|
|
430
|
+
isNewTx: false,
|
|
431
|
+
isSignAction: false
|
|
432
|
+
}
|
|
433
|
+
vargs.isSendWith = vargs.options.sendWith.length > 0
|
|
434
|
+
vargs.isNewTx = vargs.inputs.length > 0 || vargs.outputs.length > 0
|
|
435
|
+
vargs.isSignAction =
|
|
436
|
+
vargs.isNewTx &&
|
|
437
|
+
(vargs.options.signAndProcess === false ||
|
|
438
|
+
vargs.inputs.some(i => i.unlockingScript === undefined))
|
|
439
|
+
vargs.isDelayed = vargs.options.acceptDelayedBroadcast
|
|
440
|
+
vargs.isNoSend = vargs.options.noSend
|
|
441
|
+
|
|
442
|
+
if (!vargs.isSendWith && !vargs.isNewTx)
|
|
443
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
444
|
+
'args',
|
|
445
|
+
'either at least one input or output, or a sendWith.'
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
return vargs
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Set all default true/false booleans to true or false if undefined.
|
|
453
|
+
* Set all possibly undefined numbers to their default values.
|
|
454
|
+
* Set all possibly undefined arrays to empty arrays.
|
|
455
|
+
* Convert string outpoints to `{ txid: string, vout: number }`
|
|
456
|
+
*/
|
|
457
|
+
export function validateSignActionOptions(
|
|
458
|
+
options?: SignActionOptions
|
|
459
|
+
): ValidSignActionOptions {
|
|
460
|
+
const o = options || {}
|
|
461
|
+
const vo: ValidSignActionOptions = {
|
|
462
|
+
acceptDelayedBroadcast: defaultTrue(o.acceptDelayedBroadcast),
|
|
463
|
+
returnTXIDOnly: defaultFalse(o.returnTXIDOnly),
|
|
464
|
+
noSend: defaultFalse(o.noSend),
|
|
465
|
+
sendWith: defaultEmpty(o.sendWith)
|
|
466
|
+
}
|
|
467
|
+
return vo
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export function validateSignActionArgs(
|
|
471
|
+
args: SignActionArgs
|
|
472
|
+
): ValidSignActionArgs {
|
|
473
|
+
const vargs: ValidSignActionArgs = {
|
|
474
|
+
spends: args.spends,
|
|
475
|
+
reference: args.reference,
|
|
476
|
+
options: validateSignActionOptions(args.options),
|
|
477
|
+
isSendWith: false,
|
|
478
|
+
isDelayed: false,
|
|
479
|
+
isNoSend: false,
|
|
480
|
+
isNewTx: true
|
|
481
|
+
}
|
|
482
|
+
vargs.isSendWith = vargs.options.sendWith.length > 0
|
|
483
|
+
vargs.isDelayed = vargs.options.acceptDelayedBroadcast
|
|
484
|
+
vargs.isNoSend = vargs.options.noSend
|
|
485
|
+
|
|
486
|
+
return vargs
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export interface ValidAbortActionArgs extends ValidWalletSignerArgs {
|
|
490
|
+
reference: Base64String
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export function validateAbortActionArgs(
|
|
494
|
+
args: AbortActionArgs
|
|
495
|
+
): ValidAbortActionArgs {
|
|
496
|
+
const vargs: ValidAbortActionArgs = {
|
|
497
|
+
reference: validateBase64String(args.reference, 'reference')
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return vargs
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export interface ValidWalletPayment {
|
|
504
|
+
derivationPrefix: Base64String
|
|
505
|
+
derivationSuffix: Base64String
|
|
506
|
+
senderIdentityKey: PubKeyHex
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export function validateWalletPayment(
|
|
510
|
+
args?: WalletPayment
|
|
511
|
+
): ValidWalletPayment | undefined {
|
|
512
|
+
if (args === undefined) return undefined
|
|
513
|
+
const v: ValidWalletPayment = {
|
|
514
|
+
derivationPrefix: validateBase64String(
|
|
515
|
+
args.derivationPrefix,
|
|
516
|
+
'derivationPrefix'
|
|
517
|
+
),
|
|
518
|
+
derivationSuffix: validateBase64String(
|
|
519
|
+
args.derivationSuffix,
|
|
520
|
+
'derivationSuffix'
|
|
521
|
+
),
|
|
522
|
+
senderIdentityKey: validateHexString(
|
|
523
|
+
args.senderIdentityKey,
|
|
524
|
+
'senderIdentityKey'
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
return v
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export interface ValidBasketInsertion {
|
|
531
|
+
basket: BasketStringUnder300Bytes
|
|
532
|
+
customInstructions?: string
|
|
533
|
+
tags: BasketStringUnder300Bytes[]
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export function validateBasketInsertion(
|
|
537
|
+
args?: BasketInsertion
|
|
538
|
+
): ValidBasketInsertion | undefined {
|
|
539
|
+
if (args === undefined) return undefined
|
|
540
|
+
const v: ValidBasketInsertion = {
|
|
541
|
+
basket: validateBasket(args.basket),
|
|
542
|
+
customInstructions: validateOptionalStringLength(
|
|
543
|
+
args.customInstructions,
|
|
544
|
+
'customInstructions',
|
|
545
|
+
0,
|
|
546
|
+
1000
|
|
547
|
+
), // TODO: real max??
|
|
548
|
+
tags: defaultEmpty(args.tags).map(t => validateTag(t))
|
|
549
|
+
}
|
|
550
|
+
return v
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export interface ValidInternalizeOutput {
|
|
554
|
+
outputIndex: PositiveIntegerOrZero
|
|
555
|
+
protocol: 'wallet payment' | 'basket insertion'
|
|
556
|
+
paymentRemittance?: ValidWalletPayment
|
|
557
|
+
insertionRemittance?: ValidBasketInsertion
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export function validateInternalizeOutput(
|
|
561
|
+
args: InternalizeOutput
|
|
562
|
+
): ValidInternalizeOutput {
|
|
563
|
+
if (
|
|
564
|
+
args.protocol !== 'basket insertion' &&
|
|
565
|
+
args.protocol !== 'wallet payment'
|
|
566
|
+
)
|
|
567
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
568
|
+
'protocol',
|
|
569
|
+
`'basket insertion' or 'wallet payment'`
|
|
570
|
+
)
|
|
571
|
+
const v: ValidInternalizeOutput = {
|
|
572
|
+
outputIndex: validatePositiveIntegerOrZero(args.outputIndex, 'outputIndex'),
|
|
573
|
+
protocol: args.protocol,
|
|
574
|
+
paymentRemittance: validateWalletPayment(args.paymentRemittance),
|
|
575
|
+
insertionRemittance: validateBasketInsertion(args.insertionRemittance)
|
|
576
|
+
}
|
|
577
|
+
return v
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export interface ValidInternalizeActionArgs extends ValidWalletSignerArgs {
|
|
581
|
+
tx: AtomicBEEF
|
|
582
|
+
outputs: InternalizeOutput[]
|
|
583
|
+
description: DescriptionString5to50Bytes
|
|
584
|
+
labels: LabelStringUnder300Bytes[]
|
|
585
|
+
seekPermission: BooleanDefaultTrue
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export function validateOriginator(s?: string): string | undefined {
|
|
589
|
+
if (s === undefined) return undefined
|
|
590
|
+
s = s.trim().toLowerCase()
|
|
591
|
+
validateStringLength(s, 'originator', 1, 250)
|
|
592
|
+
const sps = s.split('.')
|
|
593
|
+
for (const sp of sps) {
|
|
594
|
+
validateStringLength(sp, 'originator part', 1, 63)
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
export function validateInternalizeActionArgs(
|
|
599
|
+
args: InternalizeActionArgs
|
|
600
|
+
): ValidInternalizeActionArgs {
|
|
601
|
+
const vargs: ValidInternalizeActionArgs = {
|
|
602
|
+
tx: args.tx,
|
|
603
|
+
outputs: args.outputs.map(o => validateInternalizeOutput(o)),
|
|
604
|
+
description: validateStringLength(args.description, 'description', 5, 50),
|
|
605
|
+
labels: (args.labels || []).map(t => validateLabel(t)),
|
|
606
|
+
seekPermission: defaultTrue(args.seekPermission)
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
try {
|
|
610
|
+
const beef = Beef.fromBinary(vargs.tx)
|
|
611
|
+
if (beef.txs.length < 1)
|
|
612
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
613
|
+
'tx',
|
|
614
|
+
`at least one transaction to internalize an output from`
|
|
615
|
+
)
|
|
616
|
+
} catch {
|
|
617
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
618
|
+
'tx',
|
|
619
|
+
`valid with at least one transaction to internalize an output from`
|
|
620
|
+
)
|
|
621
|
+
}
|
|
622
|
+
if (vargs.outputs.length < 1)
|
|
623
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
624
|
+
'outputs',
|
|
625
|
+
`at least one output to internalize from the transaction`
|
|
626
|
+
)
|
|
627
|
+
|
|
628
|
+
return vargs
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
export function validateOptionalOutpointString(
|
|
632
|
+
outpoint: string | undefined,
|
|
633
|
+
name: string
|
|
634
|
+
): string | undefined {
|
|
635
|
+
if (outpoint === undefined) return undefined
|
|
636
|
+
return validateOutpointString(outpoint, name)
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export function validateOutpointString(outpoint: string, name: string): string {
|
|
640
|
+
const s = outpoint.split('.')
|
|
641
|
+
if (s.length !== 2 || !Number.isInteger(Number(s[1])))
|
|
642
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
643
|
+
name,
|
|
644
|
+
`txid as hex string and numeric output index joined with '.'`
|
|
645
|
+
)
|
|
646
|
+
const txid = validateHexString(s[0], `${name} txid`, undefined, 64)
|
|
647
|
+
const vout = validatePositiveIntegerOrZero(Number(s[1]), `${name} vout`)
|
|
648
|
+
return `${txid}.${vout}`
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export interface ValidRelinquishOutputArgs extends ValidWalletSignerArgs {
|
|
652
|
+
basket: BasketStringUnder300Bytes
|
|
653
|
+
output: OutpointString
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
export function validateRelinquishOutputArgs(
|
|
657
|
+
args: RelinquishOutputArgs
|
|
658
|
+
): ValidRelinquishOutputArgs {
|
|
659
|
+
const vargs: ValidRelinquishOutputArgs = {
|
|
660
|
+
basket: validateBasket(args.basket),
|
|
661
|
+
output: validateOutpointString(args.output, 'output')
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
return vargs
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export interface ValidRelinquishCertificateArgs extends ValidWalletSignerArgs {
|
|
668
|
+
type: Base64String
|
|
669
|
+
serialNumber: Base64String
|
|
670
|
+
certifier: PubKeyHex
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export function validateRelinquishCertificateArgs(
|
|
674
|
+
args: RelinquishCertificateArgs
|
|
675
|
+
): ValidRelinquishCertificateArgs {
|
|
676
|
+
const vargs: ValidRelinquishCertificateArgs = {
|
|
677
|
+
type: validateBase64String(args.type, 'type'),
|
|
678
|
+
serialNumber: validateBase64String(args.serialNumber, 'serialNumber'),
|
|
679
|
+
certifier: validateHexString(args.certifier, 'certifier')
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return vargs
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export interface ValidListCertificatesArgs extends ValidWalletSignerArgs {
|
|
686
|
+
partial?: {
|
|
687
|
+
type?: Base64String
|
|
688
|
+
serialNumber?: Base64String
|
|
689
|
+
certifier?: PubKeyHex
|
|
690
|
+
subject?: PubKeyHex
|
|
691
|
+
revocationOutpoint?: OutpointString
|
|
692
|
+
signature?: HexString
|
|
693
|
+
}
|
|
694
|
+
certifiers: PubKeyHex[]
|
|
695
|
+
types: Base64String[]
|
|
696
|
+
limit: PositiveIntegerDefault10Max10000
|
|
697
|
+
offset: PositiveIntegerOrZero
|
|
698
|
+
privileged: BooleanDefaultFalse
|
|
699
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export function validateListCertificatesArgs(
|
|
703
|
+
args: ListCertificatesArgs
|
|
704
|
+
): ValidListCertificatesArgs {
|
|
705
|
+
const vargs: ValidListCertificatesArgs = {
|
|
706
|
+
certifiers: defaultEmpty(
|
|
707
|
+
args.certifiers.map(c => validateHexString(c.trim(), 'certifiers'))
|
|
708
|
+
),
|
|
709
|
+
types: defaultEmpty(
|
|
710
|
+
args.types.map(t => validateBase64String(t.trim(), 'types'))
|
|
711
|
+
),
|
|
712
|
+
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
713
|
+
offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
|
|
714
|
+
privileged: defaultFalse(args.privileged),
|
|
715
|
+
privilegedReason: validateOptionalStringLength(
|
|
716
|
+
args.privilegedReason,
|
|
717
|
+
'privilegedReason',
|
|
718
|
+
5,
|
|
719
|
+
50
|
|
720
|
+
),
|
|
721
|
+
partial: undefined
|
|
722
|
+
}
|
|
723
|
+
return vargs
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export interface ValidAcquireCertificateArgs extends ValidWalletSignerArgs {
|
|
727
|
+
acquisitionProtocol: AcquisitionProtocol
|
|
728
|
+
|
|
729
|
+
type: Base64String
|
|
730
|
+
serialNumber?: Base64String
|
|
731
|
+
certifier: PubKeyHex
|
|
732
|
+
revocationOutpoint?: OutpointString
|
|
733
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
734
|
+
signature?: HexString
|
|
735
|
+
|
|
736
|
+
certifierUrl?: string
|
|
737
|
+
|
|
738
|
+
keyringRevealer?: KeyringRevealer
|
|
739
|
+
keyringForSubject?: Record<CertificateFieldNameUnder50Bytes, Base64String>
|
|
740
|
+
|
|
741
|
+
privileged: boolean
|
|
742
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function validateCertificateFields(
|
|
746
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
747
|
+
): Record<CertificateFieldNameUnder50Bytes, string> {
|
|
748
|
+
for (const fieldName of Object.keys(fields)) {
|
|
749
|
+
validateStringLength(fieldName, 'field name', 1, 50)
|
|
750
|
+
}
|
|
751
|
+
return fields
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function validateKeyringRevealer(
|
|
755
|
+
kr: KeyringRevealer,
|
|
756
|
+
name: string
|
|
757
|
+
): KeyringRevealer {
|
|
758
|
+
if (kr === 'certifier') return kr
|
|
759
|
+
return validateHexString(kr, name)
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function validateOptionalKeyringRevealer(
|
|
763
|
+
kr: KeyringRevealer | undefined,
|
|
764
|
+
name: string
|
|
765
|
+
): KeyringRevealer | undefined {
|
|
766
|
+
if (kr === undefined) return undefined
|
|
767
|
+
return validateKeyringRevealer(kr, name)
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function validateKeyringForSubject(
|
|
771
|
+
kr: Record<CertificateFieldNameUnder50Bytes, Base64String>,
|
|
772
|
+
name: string
|
|
773
|
+
): Record<CertificateFieldNameUnder50Bytes, Base64String> {
|
|
774
|
+
for (const fn of Object.keys(kr)) {
|
|
775
|
+
validateStringLength(fn, `${name} field name`, 1, 50)
|
|
776
|
+
validateBase64String(kr[fn], `${name} field value`)
|
|
777
|
+
}
|
|
778
|
+
return kr
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function validateOptionalKeyringForSubject(
|
|
782
|
+
kr: Record<CertificateFieldNameUnder50Bytes, Base64String> | undefined,
|
|
783
|
+
name: string
|
|
784
|
+
): Record<CertificateFieldNameUnder50Bytes, Base64String> | undefined {
|
|
785
|
+
if (kr === undefined) return undefined
|
|
786
|
+
return validateKeyringForSubject(kr, name)
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
*
|
|
791
|
+
* @param args
|
|
792
|
+
* @param subject Must be valid for "direct" `acquisitionProtocol`. public key of the certificate subject.
|
|
793
|
+
* @returns
|
|
794
|
+
*/
|
|
795
|
+
export async function validateAcquireCertificateArgs(
|
|
796
|
+
args: AcquireCertificateArgs
|
|
797
|
+
): Promise<ValidAcquireCertificateArgs> {
|
|
798
|
+
const vargs: ValidAcquireCertificateArgs = {
|
|
799
|
+
acquisitionProtocol: args.acquisitionProtocol,
|
|
800
|
+
type: validateBase64String(args.type, 'type'),
|
|
801
|
+
serialNumber: validateOptionalBase64String(
|
|
802
|
+
args.serialNumber,
|
|
803
|
+
'serialNumber'
|
|
804
|
+
),
|
|
805
|
+
certifier: validateHexString(args.certifier, 'certifier'),
|
|
806
|
+
revocationOutpoint: validateOptionalOutpointString(
|
|
807
|
+
args.revocationOutpoint,
|
|
808
|
+
'revocationOutpoint'
|
|
809
|
+
),
|
|
810
|
+
fields: validateCertificateFields(args.fields),
|
|
811
|
+
signature: validateOptionalHexString(args.signature, 'signature'),
|
|
812
|
+
certifierUrl: args.certifierUrl,
|
|
813
|
+
keyringRevealer: validateOptionalKeyringRevealer(
|
|
814
|
+
args.keyringRevealer,
|
|
815
|
+
'keyringRevealer'
|
|
816
|
+
),
|
|
817
|
+
keyringForSubject: validateOptionalKeyringForSubject(
|
|
818
|
+
args.keyringForSubject,
|
|
819
|
+
'keyringForSubject'
|
|
820
|
+
),
|
|
821
|
+
privileged: defaultFalse(args.privileged),
|
|
822
|
+
privilegedReason: validateOptionalStringLength(
|
|
823
|
+
args.privilegedReason,
|
|
824
|
+
'privilegedReason',
|
|
825
|
+
5,
|
|
826
|
+
50
|
|
827
|
+
)
|
|
828
|
+
}
|
|
829
|
+
if (vargs.privileged && !vargs.privilegedReason)
|
|
830
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
831
|
+
'privilegedReason',
|
|
832
|
+
`valid when 'privileged' is true `
|
|
833
|
+
)
|
|
834
|
+
if (vargs.acquisitionProtocol === 'direct') {
|
|
835
|
+
if (!vargs.serialNumber)
|
|
836
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
837
|
+
'serialNumber',
|
|
838
|
+
'valid when acquisitionProtocol is "direct"'
|
|
839
|
+
)
|
|
840
|
+
if (!vargs.signature)
|
|
841
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
842
|
+
'signature',
|
|
843
|
+
'valid when acquisitionProtocol is "direct"'
|
|
844
|
+
)
|
|
845
|
+
if (!vargs.revocationOutpoint)
|
|
846
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
847
|
+
'revocationOutpoint',
|
|
848
|
+
'valid when acquisitionProtocol is "direct"'
|
|
849
|
+
)
|
|
850
|
+
}
|
|
851
|
+
return vargs
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
export interface ValidAcquireDirectCertificateArgs
|
|
855
|
+
extends ValidWalletSignerArgs {
|
|
856
|
+
type: Base64String
|
|
857
|
+
serialNumber: Base64String
|
|
858
|
+
certifier: PubKeyHex
|
|
859
|
+
revocationOutpoint: OutpointString
|
|
860
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
861
|
+
signature: HexString
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* validated to an empty string, must be provided by wallet and must
|
|
865
|
+
* match expectations of keyringForSubject
|
|
866
|
+
*/
|
|
867
|
+
subject: PubKeyHex
|
|
868
|
+
|
|
869
|
+
keyringRevealer: KeyringRevealer
|
|
870
|
+
keyringForSubject: Record<CertificateFieldNameUnder50Bytes, Base64String>
|
|
871
|
+
|
|
872
|
+
privileged: boolean
|
|
873
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
export interface ValidAcquireIssuanceCertificateArgs
|
|
877
|
+
extends ValidWalletSignerArgs {
|
|
878
|
+
type: Base64String
|
|
879
|
+
certifier: PubKeyHex
|
|
880
|
+
certifierUrl: string
|
|
881
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* validated to an empty string, must be provided by wallet and must
|
|
885
|
+
* match expectations of keyringForSubject
|
|
886
|
+
*/
|
|
887
|
+
subject: PubKeyHex
|
|
888
|
+
|
|
889
|
+
privileged: boolean
|
|
890
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
export function validateAcquireIssuanceCertificateArgs(
|
|
894
|
+
args: AcquireCertificateArgs
|
|
895
|
+
): ValidAcquireIssuanceCertificateArgs {
|
|
896
|
+
if (args.acquisitionProtocol !== 'issuance')
|
|
897
|
+
throw new sdk.WERR_INTERNAL(
|
|
898
|
+
'Only acquire certificate via issuance requests allowed here.'
|
|
899
|
+
)
|
|
900
|
+
if (args.serialNumber)
|
|
901
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
902
|
+
'serialNumber',
|
|
903
|
+
'valid when acquisitionProtocol is "direct"'
|
|
904
|
+
)
|
|
905
|
+
if (args.signature)
|
|
906
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
907
|
+
'signature',
|
|
908
|
+
'valid when acquisitionProtocol is "direct"'
|
|
909
|
+
)
|
|
910
|
+
if (args.revocationOutpoint)
|
|
911
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
912
|
+
'revocationOutpoint',
|
|
913
|
+
'valid when acquisitionProtocol is "direct"'
|
|
914
|
+
)
|
|
915
|
+
if (args.keyringRevealer)
|
|
916
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
917
|
+
'keyringRevealer',
|
|
918
|
+
'valid when acquisitionProtocol is "direct"'
|
|
919
|
+
)
|
|
920
|
+
if (args.keyringForSubject)
|
|
921
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
922
|
+
'keyringForSubject',
|
|
923
|
+
'valid when acquisitionProtocol is "direct"'
|
|
924
|
+
)
|
|
925
|
+
if (!args.certifierUrl)
|
|
926
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
927
|
+
'certifierUrl',
|
|
928
|
+
'valid when acquisitionProtocol is "issuance"'
|
|
929
|
+
)
|
|
930
|
+
if (args.privileged && !args.privilegedReason)
|
|
931
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
932
|
+
'privilegedReason',
|
|
933
|
+
`valid when 'privileged' is true `
|
|
934
|
+
)
|
|
935
|
+
|
|
936
|
+
const vargs: ValidAcquireIssuanceCertificateArgs = {
|
|
937
|
+
type: validateBase64String(args.type, 'type'),
|
|
938
|
+
certifier: validateHexString(args.certifier, 'certifier'),
|
|
939
|
+
certifierUrl: args.certifierUrl,
|
|
940
|
+
fields: validateCertificateFields(args.fields),
|
|
941
|
+
privileged: defaultFalse(args.privileged),
|
|
942
|
+
privilegedReason: validateOptionalStringLength(
|
|
943
|
+
args.privilegedReason,
|
|
944
|
+
'privilegedReason',
|
|
945
|
+
5,
|
|
946
|
+
50
|
|
947
|
+
),
|
|
948
|
+
subject: ''
|
|
949
|
+
}
|
|
950
|
+
return vargs
|
|
951
|
+
}
|
|
952
|
+
export function validateAcquireDirectCertificateArgs(
|
|
953
|
+
args: AcquireCertificateArgs
|
|
954
|
+
): ValidAcquireDirectCertificateArgs {
|
|
955
|
+
if (args.acquisitionProtocol !== 'direct')
|
|
956
|
+
throw new sdk.WERR_INTERNAL(
|
|
957
|
+
'Only acquire direct certificate requests allowed here.'
|
|
958
|
+
)
|
|
959
|
+
if (!args.serialNumber)
|
|
960
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
961
|
+
'serialNumber',
|
|
962
|
+
'valid when acquisitionProtocol is "direct"'
|
|
963
|
+
)
|
|
964
|
+
if (!args.signature)
|
|
965
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
966
|
+
'signature',
|
|
967
|
+
'valid when acquisitionProtocol is "direct"'
|
|
968
|
+
)
|
|
969
|
+
if (!args.revocationOutpoint)
|
|
970
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
971
|
+
'revocationOutpoint',
|
|
972
|
+
'valid when acquisitionProtocol is "direct"'
|
|
973
|
+
)
|
|
974
|
+
if (!args.keyringRevealer)
|
|
975
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
976
|
+
'keyringRevealer',
|
|
977
|
+
'valid when acquisitionProtocol is "direct"'
|
|
978
|
+
)
|
|
979
|
+
if (!args.keyringForSubject)
|
|
980
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
981
|
+
'keyringForSubject',
|
|
982
|
+
'valid when acquisitionProtocol is "direct"'
|
|
983
|
+
)
|
|
984
|
+
if (args.privileged && !args.privilegedReason)
|
|
985
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
986
|
+
'privilegedReason',
|
|
987
|
+
`valid when 'privileged' is true `
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
const vargs: ValidAcquireDirectCertificateArgs = {
|
|
991
|
+
type: validateBase64String(args.type, 'type'),
|
|
992
|
+
serialNumber: validateBase64String(args.serialNumber, 'serialNumber'),
|
|
993
|
+
certifier: validateHexString(args.certifier, 'certifier'),
|
|
994
|
+
revocationOutpoint: validateOutpointString(
|
|
995
|
+
args.revocationOutpoint,
|
|
996
|
+
'revocationOutpoint'
|
|
997
|
+
),
|
|
998
|
+
fields: validateCertificateFields(args.fields),
|
|
999
|
+
signature: validateHexString(args.signature, 'signature'),
|
|
1000
|
+
keyringRevealer: validateKeyringRevealer(
|
|
1001
|
+
args.keyringRevealer,
|
|
1002
|
+
'keyringRevealer'
|
|
1003
|
+
),
|
|
1004
|
+
keyringForSubject: validateKeyringForSubject(
|
|
1005
|
+
args.keyringForSubject,
|
|
1006
|
+
'keyringForSubject'
|
|
1007
|
+
),
|
|
1008
|
+
privileged: defaultFalse(args.privileged),
|
|
1009
|
+
privilegedReason: validateOptionalStringLength(
|
|
1010
|
+
args.privilegedReason,
|
|
1011
|
+
'privilegedReason',
|
|
1012
|
+
5,
|
|
1013
|
+
50
|
|
1014
|
+
),
|
|
1015
|
+
subject: ''
|
|
1016
|
+
}
|
|
1017
|
+
return vargs
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
export interface ValidProveCertificateArgs extends ValidWalletSignerArgs {
|
|
1021
|
+
type?: Base64String
|
|
1022
|
+
serialNumber?: Base64String
|
|
1023
|
+
certifier?: PubKeyHex
|
|
1024
|
+
subject?: PubKeyHex
|
|
1025
|
+
revocationOutpoint?: OutpointString
|
|
1026
|
+
signature?: HexString
|
|
1027
|
+
|
|
1028
|
+
fieldsToReveal: CertificateFieldNameUnder50Bytes[]
|
|
1029
|
+
verifier: PubKeyHex
|
|
1030
|
+
privileged: boolean
|
|
1031
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
export function validateProveCertificateArgs(
|
|
1035
|
+
args: ProveCertificateArgs
|
|
1036
|
+
): ValidProveCertificateArgs {
|
|
1037
|
+
if (args.privileged && !args.privilegedReason)
|
|
1038
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1039
|
+
'privilegedReason',
|
|
1040
|
+
`valid when 'privileged' is true `
|
|
1041
|
+
)
|
|
1042
|
+
|
|
1043
|
+
const vargs: ValidProveCertificateArgs = {
|
|
1044
|
+
type: validateOptionalBase64String(
|
|
1045
|
+
args.certificate.type,
|
|
1046
|
+
'certificate.type'
|
|
1047
|
+
),
|
|
1048
|
+
serialNumber: validateOptionalBase64String(
|
|
1049
|
+
args.certificate.serialNumber,
|
|
1050
|
+
'certificate.serialNumber'
|
|
1051
|
+
),
|
|
1052
|
+
certifier: validateOptionalHexString(
|
|
1053
|
+
args.certificate.certifier,
|
|
1054
|
+
'certificate.certifier'
|
|
1055
|
+
),
|
|
1056
|
+
subject: validateOptionalHexString(
|
|
1057
|
+
args.certificate.subject,
|
|
1058
|
+
'certificate.subject'
|
|
1059
|
+
),
|
|
1060
|
+
revocationOutpoint: validateOptionalOutpointString(
|
|
1061
|
+
args.certificate.revocationOutpoint,
|
|
1062
|
+
'certificate.revocationOutpoint'
|
|
1063
|
+
),
|
|
1064
|
+
signature: validateOptionalHexString(
|
|
1065
|
+
args.certificate.signature,
|
|
1066
|
+
'certificate.signature'
|
|
1067
|
+
),
|
|
1068
|
+
fieldsToReveal: defaultEmpty(args.fieldsToReveal).map(fieldName =>
|
|
1069
|
+
validateStringLength(fieldName, `fieldsToReveal ${fieldName}`, 1, 50)
|
|
1070
|
+
),
|
|
1071
|
+
verifier: validateHexString(args.verifier, 'verifier'),
|
|
1072
|
+
privileged: defaultFalse(args.privileged),
|
|
1073
|
+
privilegedReason: validateOptionalStringLength(
|
|
1074
|
+
args.privilegedReason,
|
|
1075
|
+
'privilegedReason',
|
|
1076
|
+
5,
|
|
1077
|
+
50
|
|
1078
|
+
)
|
|
1079
|
+
}
|
|
1080
|
+
return vargs
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
export interface ValidDiscoverByIdentityKeyArgs extends ValidWalletSignerArgs {
|
|
1084
|
+
identityKey: PubKeyHex
|
|
1085
|
+
limit: PositiveIntegerDefault10Max10000
|
|
1086
|
+
offset: PositiveIntegerOrZero
|
|
1087
|
+
seekPermission: boolean
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
export function validateDiscoverByIdentityKeyArgs(
|
|
1091
|
+
args: DiscoverByIdentityKeyArgs
|
|
1092
|
+
): ValidDiscoverByIdentityKeyArgs {
|
|
1093
|
+
const vargs: ValidDiscoverByIdentityKeyArgs = {
|
|
1094
|
+
identityKey: validateHexString(args.identityKey, 'identityKey', 66, 66),
|
|
1095
|
+
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
1096
|
+
offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
|
|
1097
|
+
seekPermission: defaultFalse(args.seekPermission)
|
|
1098
|
+
}
|
|
1099
|
+
return vargs
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
export interface ValidDiscoverByAttributesArgs extends ValidWalletSignerArgs {
|
|
1103
|
+
attributes: Record<CertificateFieldNameUnder50Bytes, string>
|
|
1104
|
+
limit: PositiveIntegerDefault10Max10000
|
|
1105
|
+
offset: PositiveIntegerOrZero
|
|
1106
|
+
seekPermission: boolean
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
function validateAttributes(
|
|
1110
|
+
attributes: Record<CertificateFieldNameUnder50Bytes, string>
|
|
1111
|
+
): Record<CertificateFieldNameUnder50Bytes, string> {
|
|
1112
|
+
for (const fieldName of Object.keys(attributes)) {
|
|
1113
|
+
validateStringLength(fieldName, `field name ${fieldName}`, 1, 50)
|
|
1114
|
+
}
|
|
1115
|
+
return attributes
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
export function validateDiscoverByAttributesArgs(
|
|
1119
|
+
args: DiscoverByAttributesArgs
|
|
1120
|
+
): ValidDiscoverByAttributesArgs {
|
|
1121
|
+
const vargs: ValidDiscoverByAttributesArgs = {
|
|
1122
|
+
attributes: validateAttributes(args.attributes),
|
|
1123
|
+
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
1124
|
+
offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
|
|
1125
|
+
seekPermission: defaultFalse(args.seekPermission)
|
|
1126
|
+
}
|
|
1127
|
+
return vargs
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
export interface ValidListOutputsArgs extends ValidWalletSignerArgs {
|
|
1131
|
+
basket: BasketStringUnder300Bytes
|
|
1132
|
+
tags: OutputTagStringUnder300Bytes[]
|
|
1133
|
+
tagQueryMode: 'all' | 'any'
|
|
1134
|
+
includeLockingScripts: boolean
|
|
1135
|
+
includeTransactions: boolean
|
|
1136
|
+
includeCustomInstructions: BooleanDefaultFalse
|
|
1137
|
+
includeTags: BooleanDefaultFalse
|
|
1138
|
+
includeLabels: BooleanDefaultFalse
|
|
1139
|
+
limit: PositiveIntegerDefault10Max10000
|
|
1140
|
+
offset: PositiveIntegerOrZero
|
|
1141
|
+
seekPermission: BooleanDefaultTrue
|
|
1142
|
+
knownTxids: string[]
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* @param {BasketStringUnder300Bytes} args.basket - Required. The associated basket name whose outputs should be listed.
|
|
1147
|
+
* @param {OutputTagStringUnder300Bytes[]} [args.tags] - Optional. Filter outputs based on these tags.
|
|
1148
|
+
* @param {'all' | 'any'} [args.tagQueryMode] - Optional. Filter mode, defining whether all or any of the tags must match. By default, any tag can match.
|
|
1149
|
+
* @param {'locking scripts' | 'entire transactions'} [args.include] - Optional. Whether to include locking scripts (with each output) or entire transactions (as aggregated BEEF, at the top level) in the result. By default, unless specified, neither are returned.
|
|
1150
|
+
* @param {BooleanDefaultFalse} [args.includeEntireTransactions] - Optional. Whether to include the entire transaction(s) in the result.
|
|
1151
|
+
* @param {BooleanDefaultFalse} [args.includeCustomInstructions] - Optional. Whether custom instructions should be returned in the result.
|
|
1152
|
+
* @param {BooleanDefaultFalse} [args.includeTags] - Optional. Whether the tags associated with the output should be returned.
|
|
1153
|
+
* @param {BooleanDefaultFalse} [args.includeLabels] - Optional. Whether the labels associated with the transaction containing the output should be returned.
|
|
1154
|
+
* @param {PositiveIntegerDefault10Max10000} [args.limit] - Optional limit on the number of outputs to return.
|
|
1155
|
+
* @param {PositiveIntegerOrZero} [args.offset] - Optional. Number of outputs to skip before starting to return results.
|
|
1156
|
+
* @param {BooleanDefaultTrue} [args.seekPermission] — Optional. Whether to seek permission from the user for this operation if required. Default true, will return an error rather than proceed if set to false.
|
|
1157
|
+
*/
|
|
1158
|
+
export function validateListOutputsArgs(
|
|
1159
|
+
args: ListOutputsArgs
|
|
1160
|
+
): ValidListOutputsArgs {
|
|
1161
|
+
let tagQueryMode: 'any' | 'all'
|
|
1162
|
+
if (args.tagQueryMode === undefined || args.tagQueryMode === 'any')
|
|
1163
|
+
tagQueryMode = 'any'
|
|
1164
|
+
else if (args.tagQueryMode === 'all') tagQueryMode = 'all'
|
|
1165
|
+
else
|
|
1166
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1167
|
+
'tagQueryMode',
|
|
1168
|
+
`undefined, 'any', or 'all'`
|
|
1169
|
+
)
|
|
1170
|
+
|
|
1171
|
+
const vargs: ValidListOutputsArgs = {
|
|
1172
|
+
basket: validateStringLength(args.basket, 'basket', 1, 300),
|
|
1173
|
+
tags: (args.tags || []).map(t => validateStringLength(t, 'tag', 1, 300)),
|
|
1174
|
+
tagQueryMode,
|
|
1175
|
+
includeLockingScripts: args.include === 'locking scripts',
|
|
1176
|
+
includeTransactions: args.include === 'entire transactions',
|
|
1177
|
+
includeCustomInstructions: defaultFalse(args.includeCustomInstructions),
|
|
1178
|
+
includeTags: defaultFalse(args.includeTags),
|
|
1179
|
+
includeLabels: defaultFalse(args.includeLabels),
|
|
1180
|
+
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
1181
|
+
offset: validateInteger(args.offset, 'offset', 0, 0, undefined),
|
|
1182
|
+
seekPermission: defaultTrue(args.seekPermission),
|
|
1183
|
+
knownTxids: []
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
return vargs
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
export interface ValidListActionsArgs extends ValidWalletSignerArgs {
|
|
1190
|
+
labels: LabelStringUnder300Bytes[]
|
|
1191
|
+
labelQueryMode: 'any' | 'all'
|
|
1192
|
+
includeLabels: BooleanDefaultFalse
|
|
1193
|
+
includeInputs: BooleanDefaultFalse
|
|
1194
|
+
includeInputSourceLockingScripts: BooleanDefaultFalse
|
|
1195
|
+
includeInputUnlockingScripts: BooleanDefaultFalse
|
|
1196
|
+
includeOutputs: BooleanDefaultFalse
|
|
1197
|
+
includeOutputLockingScripts: BooleanDefaultFalse
|
|
1198
|
+
limit: PositiveIntegerDefault10Max10000
|
|
1199
|
+
offset: PositiveIntegerOrZero
|
|
1200
|
+
seekPermission: BooleanDefaultTrue
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* @param {LabelStringUnder300Bytes[]} args.labels - An array of labels used to filter actions.
|
|
1205
|
+
* @param {'any' | 'all'} [args.labelQueryMode] - Optional. Specifies how to match labels (default is any which matches any of the labels).
|
|
1206
|
+
* @param {BooleanDefaultFalse} [args.includeLabels] - Optional. Whether to include transaction labels in the result set.
|
|
1207
|
+
* @param {BooleanDefaultFalse} [args.includeInputs] - Optional. Whether to include input details in the result set.
|
|
1208
|
+
* @param {BooleanDefaultFalse} [args.includeInputSourceLockingScripts] - Optional. Whether to include input source locking scripts in the result set.
|
|
1209
|
+
* @param {BooleanDefaultFalse} [args.includeInputUnlockingScripts] - Optional. Whether to include input unlocking scripts in the result set.
|
|
1210
|
+
* @param {BooleanDefaultFalse} [args.includeOutputs] - Optional. Whether to include output details in the result set.
|
|
1211
|
+
* @param {BooleanDefaultFalse} [args.includeOutputLockingScripts] - Optional. Whether to include output locking scripts in the result set.
|
|
1212
|
+
* @param {PositiveIntegerDefault10Max10000} [args.limit] - Optional. The maximum number of transactions to retrieve.
|
|
1213
|
+
* @param {PositiveIntegerOrZero} [args.offset] - Optional. Number of transactions to skip before starting to return the results.
|
|
1214
|
+
* @param {BooleanDefaultTrue} [args.seekPermission] — Optional. Whether to seek permission from the user for this operation if required. Default true, will return an error rather than proceed if set to false.
|
|
1215
|
+
*/
|
|
1216
|
+
export function validateListActionsArgs(
|
|
1217
|
+
args: ListActionsArgs
|
|
1218
|
+
): ValidListActionsArgs {
|
|
1219
|
+
let labelQueryMode: 'any' | 'all'
|
|
1220
|
+
if (args.labelQueryMode === undefined || args.labelQueryMode === 'any')
|
|
1221
|
+
labelQueryMode = 'any'
|
|
1222
|
+
else if (args.labelQueryMode === 'all') labelQueryMode = 'all'
|
|
1223
|
+
else
|
|
1224
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1225
|
+
'labelQueryMode',
|
|
1226
|
+
`undefined, 'any', or 'all'`
|
|
1227
|
+
)
|
|
1228
|
+
|
|
1229
|
+
const vargs: ValidListActionsArgs = {
|
|
1230
|
+
labels: (args.labels || []).map(t => validateLabel(t)),
|
|
1231
|
+
labelQueryMode,
|
|
1232
|
+
includeLabels: defaultFalse(args.includeLabels),
|
|
1233
|
+
includeInputs: defaultFalse(args.includeInputs),
|
|
1234
|
+
includeInputSourceLockingScripts: defaultFalse(
|
|
1235
|
+
args.includeInputSourceLockingScripts
|
|
1236
|
+
),
|
|
1237
|
+
includeInputUnlockingScripts: defaultFalse(
|
|
1238
|
+
args.includeInputUnlockingScripts
|
|
1239
|
+
),
|
|
1240
|
+
includeOutputs: defaultFalse(args.includeOutputs),
|
|
1241
|
+
includeOutputLockingScripts: defaultFalse(args.includeOutputLockingScripts),
|
|
1242
|
+
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
1243
|
+
offset: validateInteger(args.offset, 'offset', 0, 0, undefined),
|
|
1244
|
+
seekPermission: defaultTrue(args.seekPermission)
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
return vargs
|
|
1248
|
+
}
|