@bsv/wallet-toolbox 1.1.59 → 1.1.61
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/.prettierrc +1 -1
- package/docs/client.md +39 -5
- package/docs/services.md +1 -0
- package/docs/setup.md +9 -26
- package/docs/storage.md +35 -0
- package/docs/wallet.md +39 -5
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +6 -16
- package/out/src/Setup.js.map +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +4 -11
- package/out/src/Wallet.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +1 -3
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -10
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskClock.js +1 -1
- package/out/src/monitor/tasks/TaskClock.js.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +1 -2
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js +1 -2
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js +1 -2
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/sdk/CertOps.d.ts.map +1 -1
- package/out/src/sdk/CertOps.js +4 -12
- package/out/src/sdk/CertOps.js.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +1 -4
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +2 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/__test/CertificateLifeCycle.test.js +1 -3
- package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -1
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js +13 -26
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -1
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +2 -10
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/sdk/validationHelpers.d.ts.map +1 -1
- package/out/src/sdk/validationHelpers.js +5 -12
- package/out/src/sdk/validationHelpers.js.map +1 -1
- package/out/src/services/Services.d.ts +1 -0
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +29 -38
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/__tests/bitrails.test.js.map +1 -1
- package/out/src/services/__tests/getMerklePath.test.js.map +1 -1
- package/out/src/services/__tests/getRawTx.test.js.map +1 -1
- package/out/src/services/__tests/verifyBeef.test.js +2 -1
- package/out/src/services/__tests/verifyBeef.test.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +1 -3
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +1 -2
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +62 -134
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +6 -21
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/__tests/WhatsOnChain.test.js +1 -2
- package/out/src/services/providers/__tests/WhatsOnChain.test.js.map +1 -1
- package/out/src/services/providers/echangeRates.d.ts.map +1 -1
- package/out/src/services/providers/echangeRates.js.map +1 -1
- package/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/out/src/signer/WalletSigner.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js +1 -3
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +3 -11
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +3 -10
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +2 -7
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +15 -44
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +9 -34
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +5 -10
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/__test/WalletStorageManager.test.js +2 -8
- package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +10 -30
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +17 -28
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +6 -20
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +4 -9
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +7 -18
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +1 -3
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +2 -9
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActions.d.ts.map +1 -1
- package/out/src/storage/methods/listActions.js +3 -15
- package/out/src/storage/methods/listActions.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputs.js +4 -11
- package/out/src/storage/methods/listOutputs.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +4 -10
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +8 -32
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +1 -3
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +15 -41
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +2 -5
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +24 -130
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Certificate.js +1 -1
- package/out/src/storage/schema/entities/Certificate.js.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.js +2 -5
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Commission.js +2 -5
- package/out/src/storage/schema/entities/Commission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +14 -9
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Output.js +8 -25
- package/out/src/storage/schema/entities/Output.js.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.js +1 -1
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.js +3 -7
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.js +10 -20
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.js +8 -18
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/SyncState.d.ts +1 -0
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/SyncState.js +41 -6
- package/out/src/storage/schema/entities/SyncState.js.map +1 -1
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Transaction.js +4 -13
- package/out/src/storage/schema/entities/Transaction.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.js +1 -1
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.js +3 -9
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/User.d.ts.map +1 -1
- package/out/src/storage/schema/entities/User.js +3 -5
- package/out/src/storage/schema/entities/User.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -2
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +2 -2
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +1 -3
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +1 -2
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +1 -3
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -1
- package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -1
- package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -1
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
- package/out/test/Wallet/get/getHeaderForHeight.test.js +2 -6
- package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -1
- package/out/test/Wallet/get/getNetwork.test.js.map +1 -1
- package/out/test/Wallet/get/getVersion.test.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +3 -9
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +15 -22
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/specOps/specOps.man.test.js +1 -4
- package/out/test/Wallet/specOps/specOps.man.test.js.map +1 -1
- package/out/test/Wallet/support/janitor.man.test.js.map +1 -1
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -1
- package/out/test/Wallet/sync/setActive.test.js +73 -50
- package/out/test/Wallet/sync/setActive.test.js.map +1 -1
- package/out/test/checkDB.d.ts.map +1 -1
- package/out/test/checkDB.js.map +1 -1
- package/out/test/examples/backup.man.test.d.ts.map +1 -1
- package/out/test/examples/backup.man.test.js.map +1 -1
- package/out/test/examples/pushdrop.test.d.ts.map +1 -1
- package/out/test/examples/pushdrop.test.js +5 -4
- package/out/test/examples/pushdrop.test.js.map +1 -1
- package/out/test/monitor/Monitor.test.js.map +1 -1
- package/out/test/services/Services.test.js.map +1 -1
- package/out/test/storage/KnexMigrations.test.js.map +1 -1
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -3
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
- package/out/test/storage/count.test.js.map +1 -1
- package/out/test/storage/find.test.js +5 -10
- package/out/test/storage/find.test.js.map +1 -1
- package/out/test/storage/findLegacy.test.js.map +1 -1
- package/out/test/storage/insert.test.js.map +1 -1
- package/out/test/storage/update.test.js +7 -19
- package/out/test/storage/update.test.js.map +1 -1
- package/out/test/storage/update2.test.js +22 -24
- package/out/test/storage/update2.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +3 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +52 -76
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/abortAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/abortAction.test.js.map +1 -0
- package/out/test/wallet/action/createAction.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/createAction.test.js +1 -2
- package/out/test/wallet/action/createAction.test.js.map +1 -0
- package/out/test/{Wallet → wallet}/action/createAction2.test.d.ts.map +1 -1
- package/out/test/{Wallet → wallet}/action/createAction2.test.js +6 -16
- package/out/test/wallet/action/createAction2.test.js.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/test/wallet/action/internalizeAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/relinquishOutput.test.js.map +1 -1
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.js.map +1 -1
- package/out/test/wallet/list/listActions.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions.test.js.map +1 -0
- package/out/test/wallet/list/listActions2.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions2.test.js.map +1 -0
- package/out/test/wallet/list/listCertificates.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/list/listCertificates.test.js +2 -6
- package/out/test/wallet/list/listCertificates.test.js.map +1 -0
- package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/list/listOutputs.test.js +2 -10
- package/out/test/wallet/list/listOutputs.test.js.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/sync/Wallet.sync.test.js +4 -6
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Setup.ts +15 -52
- package/src/Wallet.ts +58 -161
- package/src/monitor/Monitor.ts +7 -22
- package/src/monitor/MonitorDaemon.ts +6 -23
- package/src/monitor/tasks/TaskCheckForProofs.ts +4 -23
- package/src/monitor/tasks/TaskClock.ts +1 -3
- package/src/monitor/tasks/TaskFailAbandoned.ts +1 -3
- package/src/monitor/tasks/TaskNewHeader.ts +1 -4
- package/src/monitor/tasks/TaskPurge.ts +1 -2
- package/src/monitor/tasks/TaskReviewStatus.ts +1 -3
- package/src/monitor/tasks/TaskSendWaiting.ts +3 -10
- package/src/sdk/CertOps.ts +31 -103
- package/src/sdk/PrivilegedKeyManager.ts +18 -48
- package/src/sdk/WERR_errors.ts +6 -25
- package/src/sdk/WalletError.ts +5 -21
- package/src/sdk/WalletServices.interfaces.ts +11 -33
- package/src/sdk/WalletStorage.interfaces.ts +25 -91
- package/src/sdk/__test/CertificateLifeCycle.test.ts +9 -27
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +29 -66
- package/src/sdk/types.ts +6 -26
- package/src/sdk/validationHelpers.ts +111 -402
- package/src/services/Services.ts +51 -114
- package/src/services/__tests/bitrails.test.ts +4 -15
- package/src/services/__tests/getMerklePath.test.ts +1 -2
- package/src/services/__tests/getRawTx.test.ts +1 -3
- package/src/services/__tests/verifyBeef.test.ts +2 -1
- package/src/services/chaintracker/ChaintracksChainTracker.ts +3 -13
- package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +4 -12
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +9 -27
- package/src/services/createDefaultWalletServicesOptions.ts +2 -5
- package/src/services/providers/ARC.ts +5 -24
- package/src/services/providers/Bitails.ts +61 -159
- package/src/services/providers/SdkWhatsOnChain.ts +4 -17
- package/src/services/providers/WhatsOnChain.ts +31 -100
- package/src/services/providers/__tests/WhatsOnChain.test.ts +5 -15
- package/src/services/providers/echangeRates.ts +7 -22
- package/src/signer/WalletSigner.ts +1 -5
- package/src/signer/methods/acquireDirectCertificate.ts +1 -4
- package/src/signer/methods/buildSignableTransaction.ts +5 -20
- package/src/signer/methods/createAction.ts +15 -54
- package/src/signer/methods/internalizeAction.ts +10 -39
- package/src/signer/methods/proveCertificate.ts +2 -5
- package/src/signer/methods/signAction.ts +9 -39
- package/src/storage/StorageKnex.ts +166 -499
- package/src/storage/StorageProvider.ts +75 -291
- package/src/storage/StorageReader.ts +20 -65
- package/src/storage/StorageReaderWriter.ts +67 -264
- package/src/storage/StorageSyncReader.ts +2 -5
- package/src/storage/WalletStorageManager.ts +33 -108
- package/src/storage/__test/WalletStorageManager.test.ts +6 -23
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +53 -171
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +17 -28
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +9 -37
- package/src/storage/methods/createAction.ts +45 -181
- package/src/storage/methods/generateChange.ts +33 -114
- package/src/storage/methods/getBeefForTransaction.ts +7 -37
- package/src/storage/methods/getSyncChunk.ts +18 -69
- package/src/storage/methods/internalizeAction.ts +18 -70
- package/src/storage/methods/listActions.ts +6 -23
- package/src/storage/methods/listCertificates.ts +5 -14
- package/src/storage/methods/listOutputs.ts +14 -68
- package/src/storage/methods/processAction.ts +29 -104
- package/src/storage/methods/purgeData.ts +11 -45
- package/src/storage/methods/reviewStatus.ts +3 -9
- package/src/storage/remoting/StorageClient.ts +43 -146
- package/src/storage/remoting/StorageServer.ts +21 -59
- package/src/storage/schema/KnexMigrations.ts +34 -165
- package/src/storage/schema/entities/Certificate.ts +3 -14
- package/src/storage/schema/entities/CertificateField.ts +6 -28
- package/src/storage/schema/entities/Commission.ts +6 -23
- package/src/storage/schema/entities/EntityBase.ts +1 -6
- package/src/storage/schema/entities/MergeEntity.ts +14 -21
- package/src/storage/schema/entities/Output.ts +10 -39
- package/src/storage/schema/entities/OutputBasket.ts +4 -16
- package/src/storage/schema/entities/OutputTag.ts +4 -17
- package/src/storage/schema/entities/OutputTagMap.ts +7 -30
- package/src/storage/schema/entities/ProvenTx.ts +16 -57
- package/src/storage/schema/entities/ProvenTxReq.ts +29 -93
- package/src/storage/schema/entities/SyncState.ts +64 -116
- package/src/storage/schema/entities/Transaction.ts +10 -35
- package/src/storage/schema/entities/TxLabel.ts +4 -17
- package/src/storage/schema/entities/TxLabelMap.ts +6 -28
- package/src/storage/schema/entities/User.ts +8 -31
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +23 -54
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +26 -59
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +2 -11
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +1 -4
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +3 -14
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +4 -16
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +5 -18
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +5 -26
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +12 -48
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +4 -22
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +3 -10
- package/src/storage/schema/entities/__tests/usersTests.test.ts +4 -7
- package/src/storage/schema/tables/TableSettings.ts +1 -3
- package/src/storage/sync/StorageMySQLDojoReader.ts +47 -148
- package/src/utility/ScriptTemplateBRC29.ts +2 -11
- package/src/utility/stampLog.ts +2 -6
- package/src/utility/tscProofToMerklePath.ts +1 -4
- package/src/utility/utilityHelpers.buffer.ts +3 -12
- package/src/utility/utilityHelpers.ts +14 -49
- package/test/Wallet/StorageClient/storageClient.man.test.ts +2 -8
- package/test/Wallet/action/internalizeAction.a.test.ts +8 -23
- package/test/Wallet/certificate/acquireCertificate.test.ts +10 -24
- package/test/Wallet/certificate/listCertificates.test.ts +8 -18
- package/test/Wallet/get/getHeaderForHeight.test.ts +4 -15
- package/test/Wallet/get/getHeight.test.ts +2 -6
- package/test/Wallet/get/getKnownTxids.test.ts +1 -5
- package/test/Wallet/get/getNetwork.test.ts +1 -2
- package/test/Wallet/get/getVersion.test.ts +1 -2
- package/test/Wallet/live/walletLive.man.test.ts +14 -41
- package/test/Wallet/local/localWallet.man.test.ts +26 -99
- package/test/Wallet/specOps/specOps.man.test.ts +4 -13
- package/test/Wallet/support/janitor.man.test.ts +2 -7
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +11 -34
- package/test/Wallet/sync/setActive.test.ts +75 -61
- package/test/checkDB.ts +2 -8
- package/test/examples/backup.man.test.ts +2 -9
- package/test/examples/pushdrop.test.ts +7 -20
- package/test/monitor/Monitor.test.ts +33 -87
- package/test/services/Services.test.ts +8 -19
- package/test/storage/KnexMigrations.test.ts +3 -18
- package/test/storage/StorageMySQLDojoReader.man.test.ts +4 -15
- package/test/storage/count.test.ts +7 -24
- package/test/storage/find.test.ts +7 -29
- package/test/storage/findLegacy.test.ts +2 -5
- package/test/storage/insert.test.ts +3 -19
- package/test/storage/update.test.ts +47 -179
- package/test/storage/update2.test.ts +54 -176
- package/test/utils/TestUtilsWalletStorage.ts +139 -372
- package/test/{Wallet → wallet}/action/abortAction.test.ts +4 -12
- package/test/{Wallet → wallet}/action/createAction.test.ts +4 -14
- package/test/{Wallet → wallet}/action/createAction2.test.ts +74 -208
- package/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.ts +8 -11
- package/test/{Wallet → wallet}/action/internalizeAction.test.ts +20 -72
- package/test/{Wallet → wallet}/action/relinquishOutput.test.ts +3 -9
- package/test/{Wallet → wallet}/list/listActions.test.ts +2 -9
- package/test/{Wallet → wallet}/list/listActions2.test.ts +8 -34
- package/test/{Wallet → wallet}/list/listCertificates.test.ts +5 -16
- package/test/{Wallet → wallet}/list/listOutputs.test.ts +15 -54
- package/test/{Wallet → wallet}/sync/Wallet.sync.test.ts +18 -49
- package/out/src/sdk/StorageSyncReader.d.ts +0 -121
- package/out/src/sdk/StorageSyncReader.d.ts.map +0 -1
- package/out/src/sdk/StorageSyncReader.js +0 -3
- package/out/src/sdk/StorageSyncReader.js.map +0 -1
- package/out/src/sdk/StorageSyncReaderWriter.d.ts +0 -89
- package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +0 -1
- package/out/src/sdk/StorageSyncReaderWriter.js +0 -3
- package/out/src/sdk/StorageSyncReaderWriter.js.map +0 -1
- package/out/test/Wallet/action/abortAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/abortAction.test.js.map +0 -1
- package/out/test/Wallet/action/createAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/createAction.test.js.map +0 -1
- package/out/test/Wallet/action/createAction2.test.js.map +0 -1
- package/out/test/Wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +0 -1
- package/out/test/Wallet/action/internalizeAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/internalizeAction.test.js.map +0 -1
- package/out/test/Wallet/action/relinquishOutput.test.d.ts.map +0 -1
- package/out/test/Wallet/construct/Wallet.constructor.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions.test.js.map +0 -1
- package/out/test/Wallet/list/listActions2.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions2.test.js.map +0 -1
- package/out/test/Wallet/list/listCertificates.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listCertificates.test.js.map +0 -1
- package/out/test/Wallet/list/listOutputs.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listOutputs.test.js.map +0 -1
- package/out/test/Wallet/sync/Wallet.sync.test.d.ts.map +0 -1
- package/out/test/Wallet/sync/Wallet.sync.test.js.map +0 -1
- /package/out/test/{Wallet → wallet}/action/abortAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/abortAction.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/createAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createAction2.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/internalizeAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/internalizeAction.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/relinquishOutput.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/relinquishOutput.test.js +0 -0
- /package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions2.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions2.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listCertificates.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listOutputs.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/sync/Wallet.sync.test.d.ts +0 -0
- /package/test/{Wallet → wallet}/construct/Wallet.constructor.test.ts +0 -0
|
@@ -84,15 +84,10 @@ function validateOptionalStringLength(
|
|
|
84
84
|
return validateStringLength(s, name, min, max)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export function validateSatoshis(
|
|
88
|
-
v: number | undefined,
|
|
89
|
-
name: string,
|
|
90
|
-
min?: number
|
|
91
|
-
): number {
|
|
87
|
+
export function validateSatoshis(v: number | undefined, name: string, min?: number): number {
|
|
92
88
|
if (v === undefined || !Number.isInteger(v) || v < 0 || v > 21e14)
|
|
93
89
|
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.`)
|
|
90
|
+
if (min !== undefined && v < min) throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} satoshis.`)
|
|
96
91
|
return v
|
|
97
92
|
}
|
|
98
93
|
|
|
@@ -117,13 +112,10 @@ export function validateInteger(
|
|
|
117
112
|
if (defaultValue !== undefined) return defaultValue
|
|
118
113
|
throw new sdk.WERR_INVALID_PARAMETER(name, 'a valid integer')
|
|
119
114
|
}
|
|
120
|
-
if (!Number.isInteger(v))
|
|
121
|
-
throw new sdk.WERR_INVALID_PARAMETER(name, 'an integer')
|
|
115
|
+
if (!Number.isInteger(v)) throw new sdk.WERR_INVALID_PARAMETER(name, 'an integer')
|
|
122
116
|
v = Number(v)
|
|
123
|
-
if (min !== undefined && v < min)
|
|
124
|
-
|
|
125
|
-
if (max !== undefined && v > max)
|
|
126
|
-
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
117
|
+
if (min !== undefined && v < min) throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
118
|
+
if (max !== undefined && v > max) throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
127
119
|
return v
|
|
128
120
|
}
|
|
129
121
|
|
|
@@ -131,17 +123,10 @@ export function validatePositiveIntegerOrZero(v: number, name: string): number {
|
|
|
131
123
|
return validateInteger(v, name, 0, 0)
|
|
132
124
|
}
|
|
133
125
|
|
|
134
|
-
export function validateStringLength(
|
|
135
|
-
s: string,
|
|
136
|
-
name: string,
|
|
137
|
-
min?: number,
|
|
138
|
-
max?: number
|
|
139
|
-
): string {
|
|
126
|
+
export function validateStringLength(s: string, name: string, min?: number, max?: number): string {
|
|
140
127
|
const bytes = Utils.toArray(s, 'utf8').length
|
|
141
|
-
if (min !== undefined && bytes < min)
|
|
142
|
-
|
|
143
|
-
if (max !== undefined && bytes > max)
|
|
144
|
-
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
128
|
+
if (min !== undefined && bytes < min) throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
129
|
+
if (max !== undefined && bytes > max) throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
145
130
|
return s
|
|
146
131
|
}
|
|
147
132
|
|
|
@@ -162,18 +147,11 @@ function validateTag(s: string): string {
|
|
|
162
147
|
return validateIdentifier(s, 'tag', 1, 300)
|
|
163
148
|
}
|
|
164
149
|
|
|
165
|
-
function validateIdentifier(
|
|
166
|
-
s: string,
|
|
167
|
-
name: string,
|
|
168
|
-
min?: number,
|
|
169
|
-
max?: number
|
|
170
|
-
): string {
|
|
150
|
+
function validateIdentifier(s: string, name: string, min?: number, max?: number): string {
|
|
171
151
|
s = s.trim().toLowerCase()
|
|
172
152
|
const bytes = Utils.toArray(s, 'utf8').length
|
|
173
|
-
if (min !== undefined && bytes < min)
|
|
174
|
-
|
|
175
|
-
if (max !== undefined && bytes > max)
|
|
176
|
-
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
153
|
+
if (min !== undefined && bytes < min) throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
154
|
+
if (max !== undefined && bytes > max) throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
177
155
|
return s
|
|
178
156
|
}
|
|
179
157
|
|
|
@@ -187,31 +165,19 @@ function validateOptionalBase64String(
|
|
|
187
165
|
return validateBase64String(s, name, min, max)
|
|
188
166
|
}
|
|
189
167
|
|
|
190
|
-
function validateBase64String(
|
|
191
|
-
s: string,
|
|
192
|
-
name: string,
|
|
193
|
-
min?: number,
|
|
194
|
-
max?: number
|
|
195
|
-
): string {
|
|
168
|
+
function validateBase64String(s: string, name: string, min?: number, max?: number): string {
|
|
196
169
|
// Remove any whitespace and check if the string length is valid for Base64
|
|
197
170
|
s = s.trim()
|
|
198
|
-
const base64Regex =
|
|
199
|
-
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/
|
|
171
|
+
const base64Regex = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/
|
|
200
172
|
const paddingCount = (s.match(/=+$/) || [])[0]?.length || 0
|
|
201
173
|
|
|
202
|
-
if (
|
|
203
|
-
paddingCount > 2 ||
|
|
204
|
-
(s.length % 4 !== 0 && paddingCount !== 0) ||
|
|
205
|
-
!base64Regex.test(s)
|
|
206
|
-
) {
|
|
174
|
+
if (paddingCount > 2 || (s.length % 4 !== 0 && paddingCount !== 0) || !base64Regex.test(s)) {
|
|
207
175
|
throw new sdk.WERR_INVALID_PARAMETER(name, `balid base64 string`)
|
|
208
176
|
}
|
|
209
177
|
|
|
210
178
|
const bytes = Utils.toArray(s, 'base64').length
|
|
211
|
-
if (min !== undefined && bytes < min)
|
|
212
|
-
|
|
213
|
-
if (max !== undefined && bytes > max)
|
|
214
|
-
throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
179
|
+
if (min !== undefined && bytes < min) throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
180
|
+
if (max !== undefined && bytes > max) throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
215
181
|
|
|
216
182
|
return s
|
|
217
183
|
}
|
|
@@ -233,22 +199,13 @@ function validateOptionalHexString(
|
|
|
233
199
|
* @param max if valid, string length maximum (not bytes)
|
|
234
200
|
* @returns
|
|
235
201
|
*/
|
|
236
|
-
function validateHexString(
|
|
237
|
-
s: string,
|
|
238
|
-
name: string,
|
|
239
|
-
min?: number,
|
|
240
|
-
max?: number
|
|
241
|
-
): string {
|
|
202
|
+
function validateHexString(s: string, name: string, min?: number, max?: number): string {
|
|
242
203
|
s = s.trim().toLowerCase()
|
|
243
|
-
if (s.length % 2 === 1)
|
|
244
|
-
throw new sdk.WERR_INVALID_PARAMETER(name, `even length, not ${s.length}.`)
|
|
204
|
+
if (s.length % 2 === 1) throw new sdk.WERR_INVALID_PARAMETER(name, `even length, not ${s.length}.`)
|
|
245
205
|
const hexRegex = /^[0-9A-Fa-f]+$/
|
|
246
|
-
if (!hexRegex.test(s))
|
|
247
|
-
|
|
248
|
-
if (
|
|
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.`)
|
|
206
|
+
if (!hexRegex.test(s)) throw new sdk.WERR_INVALID_PARAMETER(name, `hexadecimal string.`)
|
|
207
|
+
if (min !== undefined && s.length < min) throw new sdk.WERR_INVALID_PARAMETER(name, `at least ${min} length.`)
|
|
208
|
+
if (max !== undefined && s.length > max) throw new sdk.WERR_INVALID_PARAMETER(name, `no more than ${max} length.`)
|
|
252
209
|
return s
|
|
253
210
|
}
|
|
254
211
|
|
|
@@ -276,33 +233,16 @@ export interface ValidCreateActionInput {
|
|
|
276
233
|
unlockingScriptLength: PositiveInteger
|
|
277
234
|
}
|
|
278
235
|
|
|
279
|
-
export function validateCreateActionInput(
|
|
280
|
-
i: CreateActionInput
|
|
281
|
-
): ValidCreateActionInput {
|
|
236
|
+
export function validateCreateActionInput(i: CreateActionInput): ValidCreateActionInput {
|
|
282
237
|
if (i.unlockingScript === undefined && i.unlockingScriptLength === undefined)
|
|
283
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
)
|
|
287
|
-
const unlockingScript = validateOptionalHexString(
|
|
288
|
-
i.unlockingScript,
|
|
289
|
-
'unlockingScript'
|
|
290
|
-
)
|
|
291
|
-
const unlockingScriptLength =
|
|
292
|
-
i.unlockingScriptLength || unlockingScript!.length / 2
|
|
238
|
+
throw new sdk.WERR_INVALID_PARAMETER('unlockingScript, unlockingScriptLength', `at least one valid value.`)
|
|
239
|
+
const unlockingScript = validateOptionalHexString(i.unlockingScript, 'unlockingScript')
|
|
240
|
+
const unlockingScriptLength = i.unlockingScriptLength || unlockingScript!.length / 2
|
|
293
241
|
if (unlockingScript && unlockingScriptLength !== unlockingScript.length / 2)
|
|
294
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
295
|
-
'unlockingScriptLength',
|
|
296
|
-
`length unlockingScript if both valid.`
|
|
297
|
-
)
|
|
242
|
+
throw new sdk.WERR_INVALID_PARAMETER('unlockingScriptLength', `length unlockingScript if both valid.`)
|
|
298
243
|
const vi: ValidCreateActionInput = {
|
|
299
244
|
outpoint: parseWalletOutpoint(i.outpoint),
|
|
300
|
-
inputDescription: validateStringLength(
|
|
301
|
-
i.inputDescription,
|
|
302
|
-
'inputDescription',
|
|
303
|
-
5,
|
|
304
|
-
2000
|
|
305
|
-
),
|
|
245
|
+
inputDescription: validateStringLength(i.inputDescription, 'inputDescription', 5, 2000),
|
|
306
246
|
unlockingScript,
|
|
307
247
|
unlockingScriptLength,
|
|
308
248
|
sequenceNumber: default0xffffffff(i.sequenceNumber)
|
|
@@ -319,18 +259,11 @@ export interface ValidCreateActionOutput {
|
|
|
319
259
|
tags: BasketStringUnder300Bytes[]
|
|
320
260
|
}
|
|
321
261
|
|
|
322
|
-
export function validateCreateActionOutput(
|
|
323
|
-
o: CreateActionOutput
|
|
324
|
-
): ValidCreateActionOutput {
|
|
262
|
+
export function validateCreateActionOutput(o: CreateActionOutput): ValidCreateActionOutput {
|
|
325
263
|
const vo: ValidCreateActionOutput = {
|
|
326
264
|
lockingScript: validateHexString(o.lockingScript, 'lockingScript'),
|
|
327
265
|
satoshis: validateSatoshis(o.satoshis, 'satoshis'),
|
|
328
|
-
outputDescription: validateStringLength(
|
|
329
|
-
o.outputDescription,
|
|
330
|
-
'outputDescription',
|
|
331
|
-
5,
|
|
332
|
-
2000
|
|
333
|
-
),
|
|
266
|
+
outputDescription: validateStringLength(o.outputDescription, 'outputDescription', 5, 2000),
|
|
334
267
|
basket: validateOptionalBasket(o.basket),
|
|
335
268
|
customInstructions: o.customInstructions,
|
|
336
269
|
tags: defaultEmpty(o.tags).map(t => validateTag(t))
|
|
@@ -344,9 +277,7 @@ export function validateCreateActionOutput(
|
|
|
344
277
|
* Set all possibly undefined arrays to empty arrays.
|
|
345
278
|
* Convert string outpoints to `{ txid: string, vout: number }`
|
|
346
279
|
*/
|
|
347
|
-
export function validateCreateActionOptions(
|
|
348
|
-
options?: CreateActionOptions
|
|
349
|
-
): ValidCreateActionOptions {
|
|
280
|
+
export function validateCreateActionOptions(options?: CreateActionOptions): ValidCreateActionOptions {
|
|
350
281
|
const o = options || {}
|
|
351
282
|
const vo: ValidCreateActionOptions = {
|
|
352
283
|
signAndProcess: defaultTrue(o.signAndProcess),
|
|
@@ -354,9 +285,7 @@ export function validateCreateActionOptions(
|
|
|
354
285
|
knownTxids: defaultEmpty(o.knownTxids),
|
|
355
286
|
returnTXIDOnly: defaultFalse(o.returnTXIDOnly),
|
|
356
287
|
noSend: defaultFalse(o.noSend),
|
|
357
|
-
noSendChange: defaultEmpty(o.noSendChange).map(nsc =>
|
|
358
|
-
parseWalletOutpoint(nsc)
|
|
359
|
-
),
|
|
288
|
+
noSendChange: defaultEmpty(o.noSendChange).map(nsc => parseWalletOutpoint(nsc)),
|
|
360
289
|
sendWith: defaultEmpty(o.sendWith),
|
|
361
290
|
randomizeOutputs: defaultTrue(o.randomizeOutputs)
|
|
362
291
|
}
|
|
@@ -427,9 +356,7 @@ export interface ValidSignActionArgs extends ValidProcessActionArgs {
|
|
|
427
356
|
options: sdk.ValidSignActionOptions
|
|
428
357
|
}
|
|
429
358
|
|
|
430
|
-
export function validateCreateActionArgs(
|
|
431
|
-
args: CreateActionArgs
|
|
432
|
-
): ValidCreateActionArgs {
|
|
359
|
+
export function validateCreateActionArgs(args: CreateActionArgs): ValidCreateActionArgs {
|
|
433
360
|
const vargs: ValidCreateActionArgs = {
|
|
434
361
|
description: validateStringLength(args.description, 'description', 5, 2000),
|
|
435
362
|
inputBEEF: args.inputBEEF,
|
|
@@ -449,14 +376,10 @@ export function validateCreateActionArgs(
|
|
|
449
376
|
includeAllSourceTransactions: false
|
|
450
377
|
}
|
|
451
378
|
vargs.isSendWith = vargs.options.sendWith.length > 0
|
|
452
|
-
vargs.isRemixChange =
|
|
453
|
-
|
|
454
|
-
vargs.isNewTx =
|
|
455
|
-
vargs.isRemixChange || vargs.inputs.length > 0 || vargs.outputs.length > 0
|
|
379
|
+
vargs.isRemixChange = !vargs.isSendWith && vargs.inputs.length === 0 && vargs.outputs.length === 0
|
|
380
|
+
vargs.isNewTx = vargs.isRemixChange || vargs.inputs.length > 0 || vargs.outputs.length > 0
|
|
456
381
|
vargs.isSignAction =
|
|
457
|
-
vargs.isNewTx &&
|
|
458
|
-
(vargs.options.signAndProcess === false ||
|
|
459
|
-
vargs.inputs.some(i => i.unlockingScript === undefined))
|
|
382
|
+
vargs.isNewTx && (vargs.options.signAndProcess === false || vargs.inputs.some(i => i.unlockingScript === undefined))
|
|
460
383
|
vargs.isDelayed = vargs.options.acceptDelayedBroadcast
|
|
461
384
|
vargs.isNoSend = vargs.options.noSend
|
|
462
385
|
|
|
@@ -469,9 +392,7 @@ export function validateCreateActionArgs(
|
|
|
469
392
|
* Set all possibly undefined arrays to empty arrays.
|
|
470
393
|
* Convert string outpoints to `{ txid: string, vout: number }`
|
|
471
394
|
*/
|
|
472
|
-
export function validateSignActionOptions(
|
|
473
|
-
options?: SignActionOptions
|
|
474
|
-
): ValidSignActionOptions {
|
|
395
|
+
export function validateSignActionOptions(options?: SignActionOptions): ValidSignActionOptions {
|
|
475
396
|
const o = options || {}
|
|
476
397
|
const vo: ValidSignActionOptions = {
|
|
477
398
|
acceptDelayedBroadcast: defaultTrue(o.acceptDelayedBroadcast),
|
|
@@ -482,9 +403,7 @@ export function validateSignActionOptions(
|
|
|
482
403
|
return vo
|
|
483
404
|
}
|
|
484
405
|
|
|
485
|
-
export function validateSignActionArgs(
|
|
486
|
-
args: SignActionArgs
|
|
487
|
-
): ValidSignActionArgs {
|
|
406
|
+
export function validateSignActionArgs(args: SignActionArgs): ValidSignActionArgs {
|
|
488
407
|
const vargs: ValidSignActionArgs = {
|
|
489
408
|
spends: args.spends,
|
|
490
409
|
reference: args.reference,
|
|
@@ -506,9 +425,7 @@ export interface ValidAbortActionArgs extends ValidWalletSignerArgs {
|
|
|
506
425
|
reference: Base64String
|
|
507
426
|
}
|
|
508
427
|
|
|
509
|
-
export function validateAbortActionArgs(
|
|
510
|
-
args: AbortActionArgs
|
|
511
|
-
): ValidAbortActionArgs {
|
|
428
|
+
export function validateAbortActionArgs(args: AbortActionArgs): ValidAbortActionArgs {
|
|
512
429
|
const vargs: ValidAbortActionArgs = {
|
|
513
430
|
reference: validateBase64String(args.reference, 'reference')
|
|
514
431
|
}
|
|
@@ -522,23 +439,12 @@ export interface ValidWalletPayment {
|
|
|
522
439
|
senderIdentityKey: PubKeyHex
|
|
523
440
|
}
|
|
524
441
|
|
|
525
|
-
export function validateWalletPayment(
|
|
526
|
-
args?: WalletPayment
|
|
527
|
-
): ValidWalletPayment | undefined {
|
|
442
|
+
export function validateWalletPayment(args?: WalletPayment): ValidWalletPayment | undefined {
|
|
528
443
|
if (args === undefined) return undefined
|
|
529
444
|
const v: ValidWalletPayment = {
|
|
530
|
-
derivationPrefix: validateBase64String(
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
),
|
|
534
|
-
derivationSuffix: validateBase64String(
|
|
535
|
-
args.derivationSuffix,
|
|
536
|
-
'derivationSuffix'
|
|
537
|
-
),
|
|
538
|
-
senderIdentityKey: validateHexString(
|
|
539
|
-
args.senderIdentityKey,
|
|
540
|
-
'senderIdentityKey'
|
|
541
|
-
)
|
|
445
|
+
derivationPrefix: validateBase64String(args.derivationPrefix, 'derivationPrefix'),
|
|
446
|
+
derivationSuffix: validateBase64String(args.derivationSuffix, 'derivationSuffix'),
|
|
447
|
+
senderIdentityKey: validateHexString(args.senderIdentityKey, 'senderIdentityKey')
|
|
542
448
|
}
|
|
543
449
|
return v
|
|
544
450
|
}
|
|
@@ -549,18 +455,11 @@ export interface ValidBasketInsertion {
|
|
|
549
455
|
tags: BasketStringUnder300Bytes[]
|
|
550
456
|
}
|
|
551
457
|
|
|
552
|
-
export function validateBasketInsertion(
|
|
553
|
-
args?: BasketInsertion
|
|
554
|
-
): ValidBasketInsertion | undefined {
|
|
458
|
+
export function validateBasketInsertion(args?: BasketInsertion): ValidBasketInsertion | undefined {
|
|
555
459
|
if (args === undefined) return undefined
|
|
556
460
|
const v: ValidBasketInsertion = {
|
|
557
461
|
basket: validateBasket(args.basket),
|
|
558
|
-
customInstructions: validateOptionalStringLength(
|
|
559
|
-
args.customInstructions,
|
|
560
|
-
'customInstructions',
|
|
561
|
-
0,
|
|
562
|
-
1000
|
|
563
|
-
), // TODO: real max??
|
|
462
|
+
customInstructions: validateOptionalStringLength(args.customInstructions, 'customInstructions', 0, 1000), // TODO: real max??
|
|
564
463
|
tags: defaultEmpty(args.tags).map(t => validateTag(t))
|
|
565
464
|
}
|
|
566
465
|
return v
|
|
@@ -573,17 +472,9 @@ export interface ValidInternalizeOutput {
|
|
|
573
472
|
insertionRemittance?: ValidBasketInsertion
|
|
574
473
|
}
|
|
575
474
|
|
|
576
|
-
export function validateInternalizeOutput(
|
|
577
|
-
args
|
|
578
|
-
|
|
579
|
-
if (
|
|
580
|
-
args.protocol !== 'basket insertion' &&
|
|
581
|
-
args.protocol !== 'wallet payment'
|
|
582
|
-
)
|
|
583
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
584
|
-
'protocol',
|
|
585
|
-
`'basket insertion' or 'wallet payment'`
|
|
586
|
-
)
|
|
475
|
+
export function validateInternalizeOutput(args: InternalizeOutput): ValidInternalizeOutput {
|
|
476
|
+
if (args.protocol !== 'basket insertion' && args.protocol !== 'wallet payment')
|
|
477
|
+
throw new sdk.WERR_INVALID_PARAMETER('protocol', `'basket insertion' or 'wallet payment'`)
|
|
587
478
|
const v: ValidInternalizeOutput = {
|
|
588
479
|
outputIndex: validatePositiveIntegerOrZero(args.outputIndex, 'outputIndex'),
|
|
589
480
|
protocol: args.protocol,
|
|
@@ -611,9 +502,7 @@ export function validateOriginator(s?: string): string | undefined {
|
|
|
611
502
|
}
|
|
612
503
|
}
|
|
613
504
|
|
|
614
|
-
export function validateInternalizeActionArgs(
|
|
615
|
-
args: InternalizeActionArgs
|
|
616
|
-
): ValidInternalizeActionArgs {
|
|
505
|
+
export function validateInternalizeActionArgs(args: InternalizeActionArgs): ValidInternalizeActionArgs {
|
|
617
506
|
const vargs: ValidInternalizeActionArgs = {
|
|
618
507
|
tx: args.tx,
|
|
619
508
|
outputs: args.outputs.map(o => validateInternalizeOutput(o)),
|
|
@@ -625,29 +514,17 @@ export function validateInternalizeActionArgs(
|
|
|
625
514
|
try {
|
|
626
515
|
const beef = Beef.fromBinary(vargs.tx)
|
|
627
516
|
if (beef.txs.length < 1)
|
|
628
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
629
|
-
'tx',
|
|
630
|
-
`at least one transaction to internalize an output from`
|
|
631
|
-
)
|
|
517
|
+
throw new sdk.WERR_INVALID_PARAMETER('tx', `at least one transaction to internalize an output from`)
|
|
632
518
|
} catch {
|
|
633
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
634
|
-
'tx',
|
|
635
|
-
`valid with at least one transaction to internalize an output from`
|
|
636
|
-
)
|
|
519
|
+
throw new sdk.WERR_INVALID_PARAMETER('tx', `valid with at least one transaction to internalize an output from`)
|
|
637
520
|
}
|
|
638
521
|
if (vargs.outputs.length < 1)
|
|
639
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
640
|
-
'outputs',
|
|
641
|
-
`at least one output to internalize from the transaction`
|
|
642
|
-
)
|
|
522
|
+
throw new sdk.WERR_INVALID_PARAMETER('outputs', `at least one output to internalize from the transaction`)
|
|
643
523
|
|
|
644
524
|
return vargs
|
|
645
525
|
}
|
|
646
526
|
|
|
647
|
-
export function validateOptionalOutpointString(
|
|
648
|
-
outpoint: string | undefined,
|
|
649
|
-
name: string
|
|
650
|
-
): string | undefined {
|
|
527
|
+
export function validateOptionalOutpointString(outpoint: string | undefined, name: string): string | undefined {
|
|
651
528
|
if (outpoint === undefined) return undefined
|
|
652
529
|
return validateOutpointString(outpoint, name)
|
|
653
530
|
}
|
|
@@ -655,10 +532,7 @@ export function validateOptionalOutpointString(
|
|
|
655
532
|
export function validateOutpointString(outpoint: string, name: string): string {
|
|
656
533
|
const s = outpoint.split('.')
|
|
657
534
|
if (s.length !== 2 || !Number.isInteger(Number(s[1])))
|
|
658
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
659
|
-
name,
|
|
660
|
-
`txid as hex string and numeric output index joined with '.'`
|
|
661
|
-
)
|
|
535
|
+
throw new sdk.WERR_INVALID_PARAMETER(name, `txid as hex string and numeric output index joined with '.'`)
|
|
662
536
|
const txid = validateHexString(s[0], `${name} txid`, undefined, 64)
|
|
663
537
|
const vout = validatePositiveIntegerOrZero(Number(s[1]), `${name} vout`)
|
|
664
538
|
return `${txid}.${vout}`
|
|
@@ -669,9 +543,7 @@ export interface ValidRelinquishOutputArgs extends ValidWalletSignerArgs {
|
|
|
669
543
|
output: OutpointString
|
|
670
544
|
}
|
|
671
545
|
|
|
672
|
-
export function validateRelinquishOutputArgs(
|
|
673
|
-
args: RelinquishOutputArgs
|
|
674
|
-
): ValidRelinquishOutputArgs {
|
|
546
|
+
export function validateRelinquishOutputArgs(args: RelinquishOutputArgs): ValidRelinquishOutputArgs {
|
|
675
547
|
const vargs: ValidRelinquishOutputArgs = {
|
|
676
548
|
basket: validateBasket(args.basket),
|
|
677
549
|
output: validateOutpointString(args.output, 'output')
|
|
@@ -686,9 +558,7 @@ export interface ValidRelinquishCertificateArgs extends ValidWalletSignerArgs {
|
|
|
686
558
|
certifier: PubKeyHex
|
|
687
559
|
}
|
|
688
560
|
|
|
689
|
-
export function validateRelinquishCertificateArgs(
|
|
690
|
-
args: RelinquishCertificateArgs
|
|
691
|
-
): ValidRelinquishCertificateArgs {
|
|
561
|
+
export function validateRelinquishCertificateArgs(args: RelinquishCertificateArgs): ValidRelinquishCertificateArgs {
|
|
692
562
|
const vargs: ValidRelinquishCertificateArgs = {
|
|
693
563
|
type: validateBase64String(args.type, 'type'),
|
|
694
564
|
serialNumber: validateBase64String(args.serialNumber, 'serialNumber'),
|
|
@@ -715,25 +585,14 @@ export interface ValidListCertificatesArgs extends ValidWalletSignerArgs {
|
|
|
715
585
|
privilegedReason?: DescriptionString5to50Bytes
|
|
716
586
|
}
|
|
717
587
|
|
|
718
|
-
export function validateListCertificatesArgs(
|
|
719
|
-
args: ListCertificatesArgs
|
|
720
|
-
): ValidListCertificatesArgs {
|
|
588
|
+
export function validateListCertificatesArgs(args: ListCertificatesArgs): ValidListCertificatesArgs {
|
|
721
589
|
const vargs: ValidListCertificatesArgs = {
|
|
722
|
-
certifiers: defaultEmpty(
|
|
723
|
-
|
|
724
|
-
),
|
|
725
|
-
types: defaultEmpty(
|
|
726
|
-
args.types.map(t => validateBase64String(t.trim(), 'types'))
|
|
727
|
-
),
|
|
590
|
+
certifiers: defaultEmpty(args.certifiers.map(c => validateHexString(c.trim(), 'certifiers'))),
|
|
591
|
+
types: defaultEmpty(args.types.map(t => validateBase64String(t.trim(), 'types'))),
|
|
728
592
|
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
729
593
|
offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
|
|
730
594
|
privileged: defaultFalse(args.privileged),
|
|
731
|
-
privilegedReason: validateOptionalStringLength(
|
|
732
|
-
args.privilegedReason,
|
|
733
|
-
'privilegedReason',
|
|
734
|
-
5,
|
|
735
|
-
50
|
|
736
|
-
),
|
|
595
|
+
privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50),
|
|
737
596
|
partial: undefined
|
|
738
597
|
}
|
|
739
598
|
return vargs
|
|
@@ -767,18 +626,12 @@ function validateCertificateFields(
|
|
|
767
626
|
return fields
|
|
768
627
|
}
|
|
769
628
|
|
|
770
|
-
function validateKeyringRevealer(
|
|
771
|
-
kr: KeyringRevealer,
|
|
772
|
-
name: string
|
|
773
|
-
): KeyringRevealer {
|
|
629
|
+
function validateKeyringRevealer(kr: KeyringRevealer, name: string): KeyringRevealer {
|
|
774
630
|
if (kr === 'certifier') return kr
|
|
775
631
|
return validateHexString(kr, name)
|
|
776
632
|
}
|
|
777
633
|
|
|
778
|
-
function validateOptionalKeyringRevealer(
|
|
779
|
-
kr: KeyringRevealer | undefined,
|
|
780
|
-
name: string
|
|
781
|
-
): KeyringRevealer | undefined {
|
|
634
|
+
function validateOptionalKeyringRevealer(kr: KeyringRevealer | undefined, name: string): KeyringRevealer | undefined {
|
|
782
635
|
if (kr === undefined) return undefined
|
|
783
636
|
return validateKeyringRevealer(kr, name)
|
|
784
637
|
}
|
|
@@ -814,61 +667,31 @@ export async function validateAcquireCertificateArgs(
|
|
|
814
667
|
const vargs: ValidAcquireCertificateArgs = {
|
|
815
668
|
acquisitionProtocol: args.acquisitionProtocol,
|
|
816
669
|
type: validateBase64String(args.type, 'type'),
|
|
817
|
-
serialNumber: validateOptionalBase64String(
|
|
818
|
-
args.serialNumber,
|
|
819
|
-
'serialNumber'
|
|
820
|
-
),
|
|
670
|
+
serialNumber: validateOptionalBase64String(args.serialNumber, 'serialNumber'),
|
|
821
671
|
certifier: validateHexString(args.certifier, 'certifier'),
|
|
822
|
-
revocationOutpoint: validateOptionalOutpointString(
|
|
823
|
-
args.revocationOutpoint,
|
|
824
|
-
'revocationOutpoint'
|
|
825
|
-
),
|
|
672
|
+
revocationOutpoint: validateOptionalOutpointString(args.revocationOutpoint, 'revocationOutpoint'),
|
|
826
673
|
fields: validateCertificateFields(args.fields),
|
|
827
674
|
signature: validateOptionalHexString(args.signature, 'signature'),
|
|
828
675
|
certifierUrl: args.certifierUrl,
|
|
829
|
-
keyringRevealer: validateOptionalKeyringRevealer(
|
|
830
|
-
|
|
831
|
-
'keyringRevealer'
|
|
832
|
-
),
|
|
833
|
-
keyringForSubject: validateOptionalKeyringForSubject(
|
|
834
|
-
args.keyringForSubject,
|
|
835
|
-
'keyringForSubject'
|
|
836
|
-
),
|
|
676
|
+
keyringRevealer: validateOptionalKeyringRevealer(args.keyringRevealer, 'keyringRevealer'),
|
|
677
|
+
keyringForSubject: validateOptionalKeyringForSubject(args.keyringForSubject, 'keyringForSubject'),
|
|
837
678
|
privileged: defaultFalse(args.privileged),
|
|
838
|
-
privilegedReason: validateOptionalStringLength(
|
|
839
|
-
args.privilegedReason,
|
|
840
|
-
'privilegedReason',
|
|
841
|
-
5,
|
|
842
|
-
50
|
|
843
|
-
)
|
|
679
|
+
privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50)
|
|
844
680
|
}
|
|
845
681
|
if (vargs.privileged && !vargs.privilegedReason)
|
|
846
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
847
|
-
'privilegedReason',
|
|
848
|
-
`valid when 'privileged' is true `
|
|
849
|
-
)
|
|
682
|
+
throw new sdk.WERR_INVALID_PARAMETER('privilegedReason', `valid when 'privileged' is true `)
|
|
850
683
|
if (vargs.acquisitionProtocol === 'direct') {
|
|
851
684
|
if (!vargs.serialNumber)
|
|
852
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
853
|
-
'serialNumber',
|
|
854
|
-
'valid when acquisitionProtocol is "direct"'
|
|
855
|
-
)
|
|
685
|
+
throw new sdk.WERR_INVALID_PARAMETER('serialNumber', 'valid when acquisitionProtocol is "direct"')
|
|
856
686
|
if (!vargs.signature)
|
|
857
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
858
|
-
'signature',
|
|
859
|
-
'valid when acquisitionProtocol is "direct"'
|
|
860
|
-
)
|
|
687
|
+
throw new sdk.WERR_INVALID_PARAMETER('signature', 'valid when acquisitionProtocol is "direct"')
|
|
861
688
|
if (!vargs.revocationOutpoint)
|
|
862
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
863
|
-
'revocationOutpoint',
|
|
864
|
-
'valid when acquisitionProtocol is "direct"'
|
|
865
|
-
)
|
|
689
|
+
throw new sdk.WERR_INVALID_PARAMETER('revocationOutpoint', 'valid when acquisitionProtocol is "direct"')
|
|
866
690
|
}
|
|
867
691
|
return vargs
|
|
868
692
|
}
|
|
869
693
|
|
|
870
|
-
export interface ValidAcquireDirectCertificateArgs
|
|
871
|
-
extends ValidWalletSignerArgs {
|
|
694
|
+
export interface ValidAcquireDirectCertificateArgs extends ValidWalletSignerArgs {
|
|
872
695
|
type: Base64String
|
|
873
696
|
serialNumber: Base64String
|
|
874
697
|
certifier: PubKeyHex
|
|
@@ -889,8 +712,7 @@ export interface ValidAcquireDirectCertificateArgs
|
|
|
889
712
|
privilegedReason?: DescriptionString5to50Bytes
|
|
890
713
|
}
|
|
891
714
|
|
|
892
|
-
export interface ValidAcquireIssuanceCertificateArgs
|
|
893
|
-
extends ValidWalletSignerArgs {
|
|
715
|
+
export interface ValidAcquireIssuanceCertificateArgs extends ValidWalletSignerArgs {
|
|
894
716
|
type: Base64String
|
|
895
717
|
certifier: PubKeyHex
|
|
896
718
|
certifierUrl: string
|
|
@@ -910,44 +732,20 @@ export function validateAcquireIssuanceCertificateArgs(
|
|
|
910
732
|
args: AcquireCertificateArgs
|
|
911
733
|
): ValidAcquireIssuanceCertificateArgs {
|
|
912
734
|
if (args.acquisitionProtocol !== 'issuance')
|
|
913
|
-
throw new sdk.WERR_INTERNAL(
|
|
914
|
-
'Only acquire certificate via issuance requests allowed here.'
|
|
915
|
-
)
|
|
735
|
+
throw new sdk.WERR_INTERNAL('Only acquire certificate via issuance requests allowed here.')
|
|
916
736
|
if (args.serialNumber)
|
|
917
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
918
|
-
|
|
919
|
-
'valid when acquisitionProtocol is "direct"'
|
|
920
|
-
)
|
|
921
|
-
if (args.signature)
|
|
922
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
923
|
-
'signature',
|
|
924
|
-
'valid when acquisitionProtocol is "direct"'
|
|
925
|
-
)
|
|
737
|
+
throw new sdk.WERR_INVALID_PARAMETER('serialNumber', 'valid when acquisitionProtocol is "direct"')
|
|
738
|
+
if (args.signature) throw new sdk.WERR_INVALID_PARAMETER('signature', 'valid when acquisitionProtocol is "direct"')
|
|
926
739
|
if (args.revocationOutpoint)
|
|
927
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
928
|
-
'revocationOutpoint',
|
|
929
|
-
'valid when acquisitionProtocol is "direct"'
|
|
930
|
-
)
|
|
740
|
+
throw new sdk.WERR_INVALID_PARAMETER('revocationOutpoint', 'valid when acquisitionProtocol is "direct"')
|
|
931
741
|
if (args.keyringRevealer)
|
|
932
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
933
|
-
'keyringRevealer',
|
|
934
|
-
'valid when acquisitionProtocol is "direct"'
|
|
935
|
-
)
|
|
742
|
+
throw new sdk.WERR_INVALID_PARAMETER('keyringRevealer', 'valid when acquisitionProtocol is "direct"')
|
|
936
743
|
if (args.keyringForSubject)
|
|
937
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
938
|
-
'keyringForSubject',
|
|
939
|
-
'valid when acquisitionProtocol is "direct"'
|
|
940
|
-
)
|
|
744
|
+
throw new sdk.WERR_INVALID_PARAMETER('keyringForSubject', 'valid when acquisitionProtocol is "direct"')
|
|
941
745
|
if (!args.certifierUrl)
|
|
942
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
943
|
-
'certifierUrl',
|
|
944
|
-
'valid when acquisitionProtocol is "issuance"'
|
|
945
|
-
)
|
|
746
|
+
throw new sdk.WERR_INVALID_PARAMETER('certifierUrl', 'valid when acquisitionProtocol is "issuance"')
|
|
946
747
|
if (args.privileged && !args.privilegedReason)
|
|
947
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
948
|
-
'privilegedReason',
|
|
949
|
-
`valid when 'privileged' is true `
|
|
950
|
-
)
|
|
748
|
+
throw new sdk.WERR_INVALID_PARAMETER('privilegedReason', `valid when 'privileged' is true `)
|
|
951
749
|
|
|
952
750
|
const vargs: ValidAcquireIssuanceCertificateArgs = {
|
|
953
751
|
type: validateBase64String(args.type, 'type'),
|
|
@@ -955,79 +753,37 @@ export function validateAcquireIssuanceCertificateArgs(
|
|
|
955
753
|
certifierUrl: args.certifierUrl,
|
|
956
754
|
fields: validateCertificateFields(args.fields),
|
|
957
755
|
privileged: defaultFalse(args.privileged),
|
|
958
|
-
privilegedReason: validateOptionalStringLength(
|
|
959
|
-
args.privilegedReason,
|
|
960
|
-
'privilegedReason',
|
|
961
|
-
5,
|
|
962
|
-
50
|
|
963
|
-
),
|
|
756
|
+
privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50),
|
|
964
757
|
subject: ''
|
|
965
758
|
}
|
|
966
759
|
return vargs
|
|
967
760
|
}
|
|
968
|
-
export function validateAcquireDirectCertificateArgs(
|
|
969
|
-
args: AcquireCertificateArgs
|
|
970
|
-
): ValidAcquireDirectCertificateArgs {
|
|
761
|
+
export function validateAcquireDirectCertificateArgs(args: AcquireCertificateArgs): ValidAcquireDirectCertificateArgs {
|
|
971
762
|
if (args.acquisitionProtocol !== 'direct')
|
|
972
|
-
throw new sdk.WERR_INTERNAL(
|
|
973
|
-
'Only acquire direct certificate requests allowed here.'
|
|
974
|
-
)
|
|
763
|
+
throw new sdk.WERR_INTERNAL('Only acquire direct certificate requests allowed here.')
|
|
975
764
|
if (!args.serialNumber)
|
|
976
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
977
|
-
|
|
978
|
-
'valid when acquisitionProtocol is "direct"'
|
|
979
|
-
)
|
|
980
|
-
if (!args.signature)
|
|
981
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
982
|
-
'signature',
|
|
983
|
-
'valid when acquisitionProtocol is "direct"'
|
|
984
|
-
)
|
|
765
|
+
throw new sdk.WERR_INVALID_PARAMETER('serialNumber', 'valid when acquisitionProtocol is "direct"')
|
|
766
|
+
if (!args.signature) throw new sdk.WERR_INVALID_PARAMETER('signature', 'valid when acquisitionProtocol is "direct"')
|
|
985
767
|
if (!args.revocationOutpoint)
|
|
986
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
987
|
-
'revocationOutpoint',
|
|
988
|
-
'valid when acquisitionProtocol is "direct"'
|
|
989
|
-
)
|
|
768
|
+
throw new sdk.WERR_INVALID_PARAMETER('revocationOutpoint', 'valid when acquisitionProtocol is "direct"')
|
|
990
769
|
if (!args.keyringRevealer)
|
|
991
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
992
|
-
'keyringRevealer',
|
|
993
|
-
'valid when acquisitionProtocol is "direct"'
|
|
994
|
-
)
|
|
770
|
+
throw new sdk.WERR_INVALID_PARAMETER('keyringRevealer', 'valid when acquisitionProtocol is "direct"')
|
|
995
771
|
if (!args.keyringForSubject)
|
|
996
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
997
|
-
'keyringForSubject',
|
|
998
|
-
'valid when acquisitionProtocol is "direct"'
|
|
999
|
-
)
|
|
772
|
+
throw new sdk.WERR_INVALID_PARAMETER('keyringForSubject', 'valid when acquisitionProtocol is "direct"')
|
|
1000
773
|
if (args.privileged && !args.privilegedReason)
|
|
1001
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1002
|
-
'privilegedReason',
|
|
1003
|
-
`valid when 'privileged' is true `
|
|
1004
|
-
)
|
|
774
|
+
throw new sdk.WERR_INVALID_PARAMETER('privilegedReason', `valid when 'privileged' is true `)
|
|
1005
775
|
|
|
1006
776
|
const vargs: ValidAcquireDirectCertificateArgs = {
|
|
1007
777
|
type: validateBase64String(args.type, 'type'),
|
|
1008
778
|
serialNumber: validateBase64String(args.serialNumber, 'serialNumber'),
|
|
1009
779
|
certifier: validateHexString(args.certifier, 'certifier'),
|
|
1010
|
-
revocationOutpoint: validateOutpointString(
|
|
1011
|
-
args.revocationOutpoint,
|
|
1012
|
-
'revocationOutpoint'
|
|
1013
|
-
),
|
|
780
|
+
revocationOutpoint: validateOutpointString(args.revocationOutpoint, 'revocationOutpoint'),
|
|
1014
781
|
fields: validateCertificateFields(args.fields),
|
|
1015
782
|
signature: validateHexString(args.signature, 'signature'),
|
|
1016
|
-
keyringRevealer: validateKeyringRevealer(
|
|
1017
|
-
|
|
1018
|
-
'keyringRevealer'
|
|
1019
|
-
),
|
|
1020
|
-
keyringForSubject: validateKeyringForSubject(
|
|
1021
|
-
args.keyringForSubject,
|
|
1022
|
-
'keyringForSubject'
|
|
1023
|
-
),
|
|
783
|
+
keyringRevealer: validateKeyringRevealer(args.keyringRevealer, 'keyringRevealer'),
|
|
784
|
+
keyringForSubject: validateKeyringForSubject(args.keyringForSubject, 'keyringForSubject'),
|
|
1024
785
|
privileged: defaultFalse(args.privileged),
|
|
1025
|
-
privilegedReason: validateOptionalStringLength(
|
|
1026
|
-
args.privilegedReason,
|
|
1027
|
-
'privilegedReason',
|
|
1028
|
-
5,
|
|
1029
|
-
50
|
|
1030
|
-
),
|
|
786
|
+
privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50),
|
|
1031
787
|
subject: ''
|
|
1032
788
|
}
|
|
1033
789
|
return vargs
|
|
@@ -1047,51 +803,26 @@ export interface ValidProveCertificateArgs extends ValidWalletSignerArgs {
|
|
|
1047
803
|
privilegedReason?: DescriptionString5to50Bytes
|
|
1048
804
|
}
|
|
1049
805
|
|
|
1050
|
-
export function validateProveCertificateArgs(
|
|
1051
|
-
args: ProveCertificateArgs
|
|
1052
|
-
): ValidProveCertificateArgs {
|
|
806
|
+
export function validateProveCertificateArgs(args: ProveCertificateArgs): ValidProveCertificateArgs {
|
|
1053
807
|
if (args.privileged && !args.privilegedReason)
|
|
1054
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1055
|
-
'privilegedReason',
|
|
1056
|
-
`valid when 'privileged' is true `
|
|
1057
|
-
)
|
|
808
|
+
throw new sdk.WERR_INVALID_PARAMETER('privilegedReason', `valid when 'privileged' is true `)
|
|
1058
809
|
|
|
1059
810
|
const vargs: ValidProveCertificateArgs = {
|
|
1060
|
-
type: validateOptionalBase64String(
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
),
|
|
1064
|
-
serialNumber: validateOptionalBase64String(
|
|
1065
|
-
args.certificate.serialNumber,
|
|
1066
|
-
'certificate.serialNumber'
|
|
1067
|
-
),
|
|
1068
|
-
certifier: validateOptionalHexString(
|
|
1069
|
-
args.certificate.certifier,
|
|
1070
|
-
'certificate.certifier'
|
|
1071
|
-
),
|
|
1072
|
-
subject: validateOptionalHexString(
|
|
1073
|
-
args.certificate.subject,
|
|
1074
|
-
'certificate.subject'
|
|
1075
|
-
),
|
|
811
|
+
type: validateOptionalBase64String(args.certificate.type, 'certificate.type'),
|
|
812
|
+
serialNumber: validateOptionalBase64String(args.certificate.serialNumber, 'certificate.serialNumber'),
|
|
813
|
+
certifier: validateOptionalHexString(args.certificate.certifier, 'certificate.certifier'),
|
|
814
|
+
subject: validateOptionalHexString(args.certificate.subject, 'certificate.subject'),
|
|
1076
815
|
revocationOutpoint: validateOptionalOutpointString(
|
|
1077
816
|
args.certificate.revocationOutpoint,
|
|
1078
817
|
'certificate.revocationOutpoint'
|
|
1079
818
|
),
|
|
1080
|
-
signature: validateOptionalHexString(
|
|
1081
|
-
args.certificate.signature,
|
|
1082
|
-
'certificate.signature'
|
|
1083
|
-
),
|
|
819
|
+
signature: validateOptionalHexString(args.certificate.signature, 'certificate.signature'),
|
|
1084
820
|
fieldsToReveal: defaultEmpty(args.fieldsToReveal).map(fieldName =>
|
|
1085
821
|
validateStringLength(fieldName, `fieldsToReveal ${fieldName}`, 1, 50)
|
|
1086
822
|
),
|
|
1087
823
|
verifier: validateHexString(args.verifier, 'verifier'),
|
|
1088
824
|
privileged: defaultFalse(args.privileged),
|
|
1089
|
-
privilegedReason: validateOptionalStringLength(
|
|
1090
|
-
args.privilegedReason,
|
|
1091
|
-
'privilegedReason',
|
|
1092
|
-
5,
|
|
1093
|
-
50
|
|
1094
|
-
)
|
|
825
|
+
privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50)
|
|
1095
826
|
}
|
|
1096
827
|
return vargs
|
|
1097
828
|
}
|
|
@@ -1103,9 +834,7 @@ export interface ValidDiscoverByIdentityKeyArgs extends ValidWalletSignerArgs {
|
|
|
1103
834
|
seekPermission: boolean
|
|
1104
835
|
}
|
|
1105
836
|
|
|
1106
|
-
export function validateDiscoverByIdentityKeyArgs(
|
|
1107
|
-
args: DiscoverByIdentityKeyArgs
|
|
1108
|
-
): ValidDiscoverByIdentityKeyArgs {
|
|
837
|
+
export function validateDiscoverByIdentityKeyArgs(args: DiscoverByIdentityKeyArgs): ValidDiscoverByIdentityKeyArgs {
|
|
1109
838
|
const vargs: ValidDiscoverByIdentityKeyArgs = {
|
|
1110
839
|
identityKey: validateHexString(args.identityKey, 'identityKey', 66, 66),
|
|
1111
840
|
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
@@ -1131,9 +860,7 @@ function validateAttributes(
|
|
|
1131
860
|
return attributes
|
|
1132
861
|
}
|
|
1133
862
|
|
|
1134
|
-
export function validateDiscoverByAttributesArgs(
|
|
1135
|
-
args: DiscoverByAttributesArgs
|
|
1136
|
-
): ValidDiscoverByAttributesArgs {
|
|
863
|
+
export function validateDiscoverByAttributesArgs(args: DiscoverByAttributesArgs): ValidDiscoverByAttributesArgs {
|
|
1137
864
|
const vargs: ValidDiscoverByAttributesArgs = {
|
|
1138
865
|
attributes: validateAttributes(args.attributes),
|
|
1139
866
|
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|
|
@@ -1171,18 +898,11 @@ export interface ValidListOutputsArgs extends ValidWalletSignerArgs {
|
|
|
1171
898
|
* @param {PositiveIntegerOrZero} [args.offset] - Optional. Number of outputs to skip before starting to return results.
|
|
1172
899
|
* @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.
|
|
1173
900
|
*/
|
|
1174
|
-
export function validateListOutputsArgs(
|
|
1175
|
-
args: ListOutputsArgs
|
|
1176
|
-
): ValidListOutputsArgs {
|
|
901
|
+
export function validateListOutputsArgs(args: ListOutputsArgs): ValidListOutputsArgs {
|
|
1177
902
|
let tagQueryMode: 'any' | 'all'
|
|
1178
|
-
if (args.tagQueryMode === undefined || args.tagQueryMode === 'any')
|
|
1179
|
-
tagQueryMode = 'any'
|
|
903
|
+
if (args.tagQueryMode === undefined || args.tagQueryMode === 'any') tagQueryMode = 'any'
|
|
1180
904
|
else if (args.tagQueryMode === 'all') tagQueryMode = 'all'
|
|
1181
|
-
else
|
|
1182
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1183
|
-
'tagQueryMode',
|
|
1184
|
-
`undefined, 'any', or 'all'`
|
|
1185
|
-
)
|
|
905
|
+
else throw new sdk.WERR_INVALID_PARAMETER('tagQueryMode', `undefined, 'any', or 'all'`)
|
|
1186
906
|
|
|
1187
907
|
const vargs: ValidListOutputsArgs = {
|
|
1188
908
|
basket: validateStringLength(args.basket, 'basket', 1, 300),
|
|
@@ -1229,30 +949,19 @@ export interface ValidListActionsArgs extends ValidWalletSignerArgs {
|
|
|
1229
949
|
* @param {PositiveIntegerOrZero} [args.offset] - Optional. Number of transactions to skip before starting to return the results.
|
|
1230
950
|
* @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.
|
|
1231
951
|
*/
|
|
1232
|
-
export function validateListActionsArgs(
|
|
1233
|
-
args: ListActionsArgs
|
|
1234
|
-
): ValidListActionsArgs {
|
|
952
|
+
export function validateListActionsArgs(args: ListActionsArgs): ValidListActionsArgs {
|
|
1235
953
|
let labelQueryMode: 'any' | 'all'
|
|
1236
|
-
if (args.labelQueryMode === undefined || args.labelQueryMode === 'any')
|
|
1237
|
-
labelQueryMode = 'any'
|
|
954
|
+
if (args.labelQueryMode === undefined || args.labelQueryMode === 'any') labelQueryMode = 'any'
|
|
1238
955
|
else if (args.labelQueryMode === 'all') labelQueryMode = 'all'
|
|
1239
|
-
else
|
|
1240
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
1241
|
-
'labelQueryMode',
|
|
1242
|
-
`undefined, 'any', or 'all'`
|
|
1243
|
-
)
|
|
956
|
+
else throw new sdk.WERR_INVALID_PARAMETER('labelQueryMode', `undefined, 'any', or 'all'`)
|
|
1244
957
|
|
|
1245
958
|
const vargs: ValidListActionsArgs = {
|
|
1246
959
|
labels: (args.labels || []).map(t => validateLabel(t)),
|
|
1247
960
|
labelQueryMode,
|
|
1248
961
|
includeLabels: defaultFalse(args.includeLabels),
|
|
1249
962
|
includeInputs: defaultFalse(args.includeInputs),
|
|
1250
|
-
includeInputSourceLockingScripts: defaultFalse(
|
|
1251
|
-
|
|
1252
|
-
),
|
|
1253
|
-
includeInputUnlockingScripts: defaultFalse(
|
|
1254
|
-
args.includeInputUnlockingScripts
|
|
1255
|
-
),
|
|
963
|
+
includeInputSourceLockingScripts: defaultFalse(args.includeInputSourceLockingScripts),
|
|
964
|
+
includeInputUnlockingScripts: defaultFalse(args.includeInputUnlockingScripts),
|
|
1256
965
|
includeOutputs: defaultFalse(args.includeOutputs),
|
|
1257
966
|
includeOutputLockingScripts: defaultFalse(args.includeOutputLockingScripts),
|
|
1258
967
|
limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
|