@bopen-io/wallet-toolbox 1.7.18
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/.claude/settings.local.json +10 -0
- 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 +22 -0
- package/.github/workflows/push.yaml +145 -0
- package/.prettierrc +10 -0
- package/CHANGELOG.md +280 -0
- package/CONTRIBUTING.md +89 -0
- package/README.md +43 -0
- package/docs/README.md +85 -0
- package/docs/client.md +19627 -0
- package/docs/monitor.md +953 -0
- package/docs/open-rpc/index.html +46 -0
- package/docs/services.md +6377 -0
- package/docs/setup.md +1268 -0
- package/docs/storage.md +5367 -0
- package/docs/wallet.md +19626 -0
- package/jest.config.ts +25 -0
- package/license.md +28 -0
- package/out/tsconfig.all.tsbuildinfo +1 -0
- package/package.json +63 -0
- package/src/CWIStyleWalletManager.ts +1999 -0
- package/src/Setup.ts +579 -0
- package/src/SetupClient.ts +322 -0
- package/src/SetupWallet.ts +108 -0
- package/src/SimpleWalletManager.ts +526 -0
- package/src/Wallet.ts +1169 -0
- package/src/WalletAuthenticationManager.ts +153 -0
- package/src/WalletLogger.ts +213 -0
- package/src/WalletPermissionsManager.ts +3660 -0
- package/src/WalletSettingsManager.ts +114 -0
- package/src/__tests/CWIStyleWalletManager.test.d.ts.map +1 -0
- package/src/__tests/CWIStyleWalletManager.test.js.map +1 -0
- package/src/__tests/CWIStyleWalletManager.test.ts +675 -0
- package/src/__tests/WalletPermissionsManager.callbacks.test.ts +323 -0
- package/src/__tests/WalletPermissionsManager.checks.test.ts +844 -0
- package/src/__tests/WalletPermissionsManager.encryption.test.ts +412 -0
- package/src/__tests/WalletPermissionsManager.fixtures.ts +307 -0
- package/src/__tests/WalletPermissionsManager.flows.test.ts +462 -0
- package/src/__tests/WalletPermissionsManager.initialization.test.ts +300 -0
- package/src/__tests/WalletPermissionsManager.pmodules.test.ts +798 -0
- package/src/__tests/WalletPermissionsManager.proxying.test.ts +724 -0
- package/src/__tests/WalletPermissionsManager.tokens.test.ts +503 -0
- package/src/index.all.ts +27 -0
- package/src/index.client.ts +25 -0
- package/src/index.mobile.ts +21 -0
- package/src/index.ts +1 -0
- package/src/monitor/Monitor.ts +412 -0
- package/src/monitor/MonitorDaemon.ts +188 -0
- package/src/monitor/README.md +3 -0
- package/src/monitor/__test/MonitorDaemon.man.test.ts +45 -0
- package/src/monitor/tasks/TaskCheckForProofs.ts +243 -0
- package/src/monitor/tasks/TaskCheckNoSends.ts +73 -0
- package/src/monitor/tasks/TaskClock.ts +33 -0
- package/src/monitor/tasks/TaskFailAbandoned.ts +54 -0
- package/src/monitor/tasks/TaskMonitorCallHistory.ts +26 -0
- package/src/monitor/tasks/TaskNewHeader.ts +93 -0
- package/src/monitor/tasks/TaskPurge.ts +68 -0
- package/src/monitor/tasks/TaskReorg.ts +89 -0
- package/src/monitor/tasks/TaskReviewStatus.ts +48 -0
- package/src/monitor/tasks/TaskSendWaiting.ts +122 -0
- package/src/monitor/tasks/TaskSyncWhenIdle.ts +26 -0
- package/src/monitor/tasks/TaskUnFail.ts +151 -0
- package/src/monitor/tasks/WalletMonitorTask.ts +47 -0
- package/src/sdk/CertOpsWallet.ts +18 -0
- package/src/sdk/PrivilegedKeyManager.ts +372 -0
- package/src/sdk/README.md +13 -0
- package/src/sdk/WERR_errors.ts +234 -0
- package/src/sdk/WalletError.ts +170 -0
- package/src/sdk/WalletErrorFromJson.ts +80 -0
- package/src/sdk/WalletServices.interfaces.ts +700 -0
- package/src/sdk/WalletSigner.interfaces.ts +11 -0
- package/src/sdk/WalletStorage.interfaces.ts +606 -0
- package/src/sdk/__test/CertificateLifeCycle.test.ts +131 -0
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +738 -0
- package/src/sdk/__test/WalletError.test.ts +318 -0
- package/src/sdk/__test/validationHelpers.test.ts +21 -0
- package/src/sdk/index.ts +10 -0
- package/src/sdk/types.ts +226 -0
- package/src/services/README.md +11 -0
- package/src/services/ServiceCollection.ts +248 -0
- package/src/services/Services.ts +603 -0
- package/src/services/__tests/ARC.man.test.ts +123 -0
- package/src/services/__tests/ARC.timeout.man.test.ts +79 -0
- package/src/services/__tests/ArcGorillaPool.man.test.ts +108 -0
- package/src/services/__tests/arcServices.test.ts +8 -0
- package/src/services/__tests/bitrails.test.ts +56 -0
- package/src/services/__tests/getMerklePath.test.ts +15 -0
- package/src/services/__tests/getRawTx.test.ts +13 -0
- package/src/services/__tests/postBeef.test.ts +104 -0
- package/src/services/__tests/verifyBeef.test.ts +50 -0
- package/src/services/chaintracker/BHServiceClient.ts +212 -0
- package/src/services/chaintracker/ChaintracksChainTracker.ts +71 -0
- package/src/services/chaintracker/__tests/ChaintracksChainTracker.test.ts +33 -0
- package/src/services/chaintracker/__tests/ChaintracksServiceClient.test.ts +29 -0
- package/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.ts +72 -0
- package/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.ts +83 -0
- package/src/services/chaintracker/chaintracks/Api/BulkStorageApi.ts +92 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksApi.ts +64 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.ts +189 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.ts +18 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.ts +58 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.ts +386 -0
- package/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.ts +25 -0
- package/src/services/chaintracker/chaintracks/Chaintracks.ts +609 -0
- package/src/services/chaintracker/chaintracks/ChaintracksService.ts +199 -0
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +154 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.ts +176 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.ts +174 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.ts +18 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.ts +113 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.ts +81 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.ts +86 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.ts +59 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.ts +104 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.ts +66 -0
- package/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.ts +566 -0
- package/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.ts +219 -0
- package/src/services/chaintracker/chaintracks/Ingest/__tests/BulkIngestorCDNBabbage.test.ts +54 -0
- package/src/services/chaintracker/chaintracks/Ingest/__tests/LiveIngestorWhatsOnChainPoll.test.ts +33 -0
- package/src/services/chaintracker/chaintracks/Ingest/__tests/WhatsOnChainServices.test.ts +124 -0
- package/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.ts +92 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.ts +104 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.ts +382 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.ts +574 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.ts +438 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageMemory.ts +29 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.ts +304 -0
- package/src/services/chaintracker/chaintracks/Storage/__tests/ChaintracksStorageIdb.test.ts +102 -0
- package/src/services/chaintracker/chaintracks/Storage/__tests/ChaintracksStorageKnex.test.ts +45 -0
- package/src/services/chaintracker/chaintracks/__tests/Chaintracks.test.ts +77 -0
- package/src/services/chaintracker/chaintracks/__tests/ChaintracksClientApi.test.ts +192 -0
- package/src/services/chaintracker/chaintracks/__tests/LocalCdnServer.ts +75 -0
- package/src/services/chaintracker/chaintracks/__tests/createIdbChaintracks.test.ts +62 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_4.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_4.headers +0 -0
- package/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.ts +92 -0
- package/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.ts +111 -0
- package/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.ts +91 -0
- package/src/services/chaintracker/chaintracks/createIdbChaintracks.ts +60 -0
- package/src/services/chaintracker/chaintracks/createKnexChaintracks.ts +65 -0
- package/src/services/chaintracker/chaintracks/createNoDbChaintracks.ts +60 -0
- package/src/services/chaintracker/chaintracks/index.all.ts +12 -0
- package/src/services/chaintracker/chaintracks/index.client.ts +4 -0
- package/src/services/chaintracker/chaintracks/index.mobile.ts +37 -0
- package/src/services/chaintracker/chaintracks/util/BulkFileDataManager.ts +975 -0
- package/src/services/chaintracker/chaintracks/util/BulkFileDataReader.ts +60 -0
- package/src/services/chaintracker/chaintracks/util/BulkFilesReader.ts +336 -0
- package/src/services/chaintracker/chaintracks/util/BulkHeaderFile.ts +247 -0
- package/src/services/chaintracker/chaintracks/util/ChaintracksFetch.ts +69 -0
- package/src/services/chaintracker/chaintracks/util/ChaintracksFs.ts +141 -0
- package/src/services/chaintracker/chaintracks/util/HeightRange.ts +153 -0
- package/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.ts +76 -0
- package/src/services/chaintracker/chaintracks/util/__tests/BulkFileDataManager.test.ts +304 -0
- package/src/services/chaintracker/chaintracks/util/__tests/ChaintracksFetch.test.ts +60 -0
- package/src/services/chaintracker/chaintracks/util/__tests/HeightRange.test.ts +67 -0
- package/src/services/chaintracker/chaintracks/util/__tests/SingleWriterMultiReaderLock.test.ts +49 -0
- package/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.ts +573 -0
- package/src/services/chaintracker/chaintracks/util/dirtyHashes.ts +29 -0
- package/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.ts +432 -0
- package/src/services/chaintracker/index.all.ts +4 -0
- package/src/services/chaintracker/index.client.ts +4 -0
- package/src/services/chaintracker/index.mobile.ts +4 -0
- package/src/services/createDefaultWalletServicesOptions.ts +77 -0
- package/src/services/index.ts +1 -0
- package/src/services/processingErrors/arcSuccessError.json +76 -0
- package/src/services/providers/ARC.ts +350 -0
- package/src/services/providers/Bitails.ts +256 -0
- package/src/services/providers/SdkWhatsOnChain.ts +83 -0
- package/src/services/providers/WhatsOnChain.ts +883 -0
- package/src/services/providers/__tests/WhatsOnChain.test.ts +242 -0
- package/src/services/providers/__tests/exchangeRates.test.ts +18 -0
- package/src/services/providers/exchangeRates.ts +265 -0
- package/src/services/providers/getBeefForTxid.ts +369 -0
- package/src/signer/README.md +5 -0
- package/src/signer/WalletSigner.ts +17 -0
- package/src/signer/methods/acquireDirectCertificate.ts +52 -0
- package/src/signer/methods/buildSignableTransaction.ts +183 -0
- package/src/signer/methods/completeSignedTransaction.ts +117 -0
- package/src/signer/methods/createAction.ts +172 -0
- package/src/signer/methods/internalizeAction.ts +106 -0
- package/src/signer/methods/proveCertificate.ts +43 -0
- package/src/signer/methods/signAction.ts +54 -0
- package/src/storage/README.md +14 -0
- package/src/storage/StorageIdb.ts +2304 -0
- package/src/storage/StorageKnex.ts +1425 -0
- package/src/storage/StorageProvider.ts +810 -0
- package/src/storage/StorageReader.ts +194 -0
- package/src/storage/StorageReaderWriter.ts +432 -0
- package/src/storage/StorageSyncReader.ts +34 -0
- package/src/storage/WalletStorageManager.ts +943 -0
- package/src/storage/__test/StorageIdb.test.ts +43 -0
- package/src/storage/__test/WalletStorageManager.test.ts +275 -0
- package/src/storage/__test/adminStats.man.test.ts +89 -0
- package/src/storage/__test/getBeefForTransaction.test.ts +385 -0
- package/src/storage/index.all.ts +11 -0
- package/src/storage/index.client.ts +7 -0
- package/src/storage/index.mobile.ts +6 -0
- package/src/storage/methods/ListActionsSpecOp.ts +70 -0
- package/src/storage/methods/ListOutputsSpecOp.ts +129 -0
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +1057 -0
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +20 -0
- package/src/storage/methods/__test/offsetKey.test.ts +274 -0
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +389 -0
- package/src/storage/methods/createAction.ts +947 -0
- package/src/storage/methods/generateChange.ts +556 -0
- package/src/storage/methods/getBeefForTransaction.ts +139 -0
- package/src/storage/methods/getSyncChunk.ts +293 -0
- package/src/storage/methods/internalizeAction.ts +562 -0
- package/src/storage/methods/listActionsIdb.ts +183 -0
- package/src/storage/methods/listActionsKnex.ts +226 -0
- package/src/storage/methods/listCertificates.ts +73 -0
- package/src/storage/methods/listOutputsIdb.ts +203 -0
- package/src/storage/methods/listOutputsKnex.ts +263 -0
- package/src/storage/methods/offsetKey.ts +89 -0
- package/src/storage/methods/processAction.ts +420 -0
- package/src/storage/methods/purgeData.ts +251 -0
- package/src/storage/methods/purgeDataIdb.ts +10 -0
- package/src/storage/methods/reviewStatus.ts +101 -0
- package/src/storage/methods/reviewStatusIdb.ts +43 -0
- package/src/storage/methods/utils.Buffer.ts +33 -0
- package/src/storage/methods/utils.ts +56 -0
- package/src/storage/remoting/StorageClient.ts +567 -0
- package/src/storage/remoting/StorageMobile.ts +544 -0
- package/src/storage/remoting/StorageServer.ts +291 -0
- package/src/storage/remoting/__test/StorageClient.test.ts +113 -0
- package/src/storage/schema/KnexMigrations.ts +489 -0
- package/src/storage/schema/StorageIdbSchema.ts +150 -0
- package/src/storage/schema/entities/EntityBase.ts +210 -0
- package/src/storage/schema/entities/EntityCertificate.ts +188 -0
- package/src/storage/schema/entities/EntityCertificateField.ts +136 -0
- package/src/storage/schema/entities/EntityCommission.ts +148 -0
- package/src/storage/schema/entities/EntityOutput.ts +290 -0
- package/src/storage/schema/entities/EntityOutputBasket.ts +153 -0
- package/src/storage/schema/entities/EntityOutputTag.ts +121 -0
- package/src/storage/schema/entities/EntityOutputTagMap.ts +123 -0
- package/src/storage/schema/entities/EntityProvenTx.ts +319 -0
- package/src/storage/schema/entities/EntityProvenTxReq.ts +580 -0
- package/src/storage/schema/entities/EntitySyncState.ts +389 -0
- package/src/storage/schema/entities/EntityTransaction.ts +306 -0
- package/src/storage/schema/entities/EntityTxLabel.ts +121 -0
- package/src/storage/schema/entities/EntityTxLabelMap.ts +123 -0
- package/src/storage/schema/entities/EntityUser.ts +112 -0
- package/src/storage/schema/entities/MergeEntity.ts +73 -0
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +353 -0
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +354 -0
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +371 -0
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +278 -0
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +242 -0
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +288 -0
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +464 -0
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +340 -0
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +504 -0
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +288 -0
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +604 -0
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +361 -0
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +198 -0
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +90 -0
- package/src/storage/schema/entities/__tests/usersTests.test.ts +340 -0
- package/src/storage/schema/entities/index.ts +16 -0
- package/src/storage/schema/tables/TableCertificate.ts +21 -0
- package/src/storage/schema/tables/TableCertificateField.ts +12 -0
- package/src/storage/schema/tables/TableCommission.ts +13 -0
- package/src/storage/schema/tables/TableMonitorEvent.ts +9 -0
- package/src/storage/schema/tables/TableOutput.ts +64 -0
- package/src/storage/schema/tables/TableOutputBasket.ts +12 -0
- package/src/storage/schema/tables/TableOutputTag.ts +10 -0
- package/src/storage/schema/tables/TableOutputTagMap.ts +9 -0
- package/src/storage/schema/tables/TableProvenTx.ts +14 -0
- package/src/storage/schema/tables/TableProvenTxReq.ts +65 -0
- package/src/storage/schema/tables/TableSettings.ts +17 -0
- package/src/storage/schema/tables/TableSyncState.ts +18 -0
- package/src/storage/schema/tables/TableTransaction.ts +54 -0
- package/src/storage/schema/tables/TableTxLabel.ts +10 -0
- package/src/storage/schema/tables/TableTxLabelMap.ts +9 -0
- package/src/storage/schema/tables/TableUser.ts +16 -0
- package/src/storage/schema/tables/index.ts +16 -0
- package/src/storage/sync/StorageMySQLDojoReader.ts +696 -0
- package/src/storage/sync/index.ts +1 -0
- package/src/utility/Format.ts +133 -0
- package/src/utility/README.md +3 -0
- package/src/utility/ReaderUint8Array.ts +187 -0
- package/src/utility/ScriptTemplateBRC29.ts +73 -0
- package/src/utility/__tests/utilityHelpers.noBuffer.test.ts +109 -0
- package/src/utility/aggregateResults.ts +68 -0
- package/src/utility/identityUtils.ts +159 -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 +69 -0
- package/src/utility/tscProofToMerklePath.ts +48 -0
- package/src/utility/utilityHelpers.buffer.ts +34 -0
- package/src/utility/utilityHelpers.noBuffer.ts +60 -0
- package/src/utility/utilityHelpers.ts +275 -0
- package/src/wab-client/WABClient.ts +94 -0
- package/src/wab-client/__tests/WABClient.man.test.ts +59 -0
- package/src/wab-client/auth-method-interactors/AuthMethodInteractor.ts +47 -0
- package/src/wab-client/auth-method-interactors/DevConsoleInteractor.ts +73 -0
- package/src/wab-client/auth-method-interactors/PersonaIDInteractor.ts +35 -0
- package/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.ts +72 -0
- package/syncVersions.js +71 -0
- package/test/Wallet/StorageClient/storageClient.man.test.ts +75 -0
- package/test/Wallet/action/abortAction.test.ts +47 -0
- package/test/Wallet/action/createAction.test.ts +299 -0
- package/test/Wallet/action/createAction2.test.ts +1273 -0
- package/test/Wallet/action/createActionToGenerateBeefs.man.test.ts +293 -0
- package/test/Wallet/action/internalizeAction.a.test.ts +286 -0
- package/test/Wallet/action/internalizeAction.test.ts +682 -0
- package/test/Wallet/action/relinquishOutput.test.ts +37 -0
- package/test/Wallet/certificate/acquireCertificate.test.ts +298 -0
- package/test/Wallet/certificate/listCertificates.test.ts +346 -0
- package/test/Wallet/construct/Wallet.constructor.test.ts +57 -0
- package/test/Wallet/get/getHeaderForHeight.test.ts +82 -0
- package/test/Wallet/get/getHeight.test.ts +52 -0
- package/test/Wallet/get/getKnownTxids.test.ts +86 -0
- package/test/Wallet/get/getNetwork.test.ts +27 -0
- package/test/Wallet/get/getVersion.test.ts +27 -0
- package/test/Wallet/list/listActions.test.ts +279 -0
- package/test/Wallet/list/listActions2.test.ts +1381 -0
- package/test/Wallet/list/listCertificates.test.ts +118 -0
- package/test/Wallet/list/listOutputs.test.ts +447 -0
- package/test/Wallet/live/walletLive.man.test.ts +521 -0
- package/test/Wallet/local/localWallet.man.test.ts +93 -0
- package/test/Wallet/local/localWallet2.man.test.ts +277 -0
- package/test/Wallet/signAction/mountaintop.man.test.ts +130 -0
- package/test/Wallet/specOps/specOps.man.test.ts +220 -0
- package/test/Wallet/support/janitor.man.test.ts +40 -0
- package/test/Wallet/support/operations.man.test.ts +407 -0
- package/test/Wallet/support/reqErrorReview.2025.05.06.man.test.ts +347 -0
- package/test/Wallet/sync/Wallet.sync.test.ts +215 -0
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +203 -0
- package/test/Wallet/sync/setActive.test.ts +170 -0
- package/test/WalletClient/LocalKVStore.man.test.ts +114 -0
- package/test/WalletClient/WERR.man.test.ts +35 -0
- package/test/bsv-ts-sdk/LocalKVStore.test.ts +102 -0
- package/test/checkDB.ts +57 -0
- package/test/checkdb +0 -0
- package/test/examples/backup.man.test.ts +59 -0
- package/test/examples/pushdrop.test.ts +282 -0
- package/test/monitor/Monitor.test.ts +620 -0
- package/test/services/Services.test.ts +263 -0
- package/test/storage/KnexMigrations.test.ts +86 -0
- package/test/storage/StorageMySQLDojoReader.man.test.ts +60 -0
- package/test/storage/count.test.ts +177 -0
- package/test/storage/find.test.ts +195 -0
- package/test/storage/findLegacy.test.ts +67 -0
- package/test/storage/idb/allocateChange.test.ts +251 -0
- package/test/storage/idb/count.test.ts +158 -0
- package/test/storage/idb/find.test.ts +177 -0
- package/test/storage/idb/idbSpeed.test.ts +36 -0
- package/test/storage/idb/insert.test.ts +268 -0
- package/test/storage/idb/transactionAbort.test.ts +108 -0
- package/test/storage/idb/update.test.ts +999 -0
- package/test/storage/insert.test.ts +278 -0
- package/test/storage/update.test.ts +1021 -0
- package/test/storage/update2.test.ts +897 -0
- package/test/utils/TestUtilsWalletStorage.ts +2526 -0
- package/test/utils/localWalletMethods.ts +363 -0
- package/test/utils/removeFailedFromDatabase.sql +17 -0
- package/ts2md.json +44 -0
- package/tsconfig.all.json +31 -0
- package/tsconfig.client.json +29 -0
- package/tsconfig.json +17 -0
- package/tsconfig.mobile.json +28 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Setup, SetupEnv, SetupWallet } from '../../src'
|
|
2
|
+
import dotenv from 'dotenv'
|
|
3
|
+
dotenv.config()
|
|
4
|
+
|
|
5
|
+
describe('backup example tests', () => {
|
|
6
|
+
jest.setTimeout(99999999)
|
|
7
|
+
|
|
8
|
+
test('0', () => {})
|
|
9
|
+
if (Setup.noEnv('test')) return
|
|
10
|
+
const env = Setup.getEnv('test')
|
|
11
|
+
|
|
12
|
+
test('1 backup MY_TEST_IDENTITY', async () => {
|
|
13
|
+
await backupWalletClient(env, process.env.MY_TEST_IDENTITY || '')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('2 backup MY_TEST_IDENTITY2', async () => {
|
|
17
|
+
await backupWalletClient(env, process.env.MY_TEST_IDENTITY2 || '')
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @publicbody
|
|
23
|
+
*/
|
|
24
|
+
export async function backup(): Promise<void> {
|
|
25
|
+
const env = Setup.getEnv('test')
|
|
26
|
+
await backupWalletClient(env, env.identityKey)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @publicbody
|
|
31
|
+
*/
|
|
32
|
+
export async function backupWalletClient(env: SetupEnv, identityKey: string): Promise<void> {
|
|
33
|
+
const setup = await Setup.createWalletClient({
|
|
34
|
+
env,
|
|
35
|
+
rootKeyHex: env.devKeys[identityKey]
|
|
36
|
+
})
|
|
37
|
+
await backupToSQLite(setup)
|
|
38
|
+
await setup.wallet.destroy()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @publicbody
|
|
43
|
+
*/
|
|
44
|
+
export async function backupToSQLite(setup: SetupWallet, filePath?: string, databaseName?: string): Promise<void> {
|
|
45
|
+
const env = Setup.getEnv(setup.chain)
|
|
46
|
+
filePath ||= `backup_${setup.identityKey}.sqlite`
|
|
47
|
+
databaseName ||= `${setup.identityKey} backup`
|
|
48
|
+
|
|
49
|
+
const backup = await Setup.createStorageKnex({
|
|
50
|
+
env,
|
|
51
|
+
knex: Setup.createSQLiteKnex(filePath),
|
|
52
|
+
databaseName,
|
|
53
|
+
rootKeyHex: setup.keyDeriver.rootKey.toHex()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
await setup.storage.addWalletStorageProvider(backup)
|
|
57
|
+
|
|
58
|
+
await setup.storage.updateBackups()
|
|
59
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { Beef, PushDrop, SignActionArgs, WalletProtocol } from '@bsv/sdk'
|
|
2
|
+
import { Setup, SetupWallet } from '../../src'
|
|
3
|
+
import { logger } from '../utils/TestUtilsWalletStorage'
|
|
4
|
+
|
|
5
|
+
describe('pushdrop example tests', () => {
|
|
6
|
+
jest.setTimeout(99999999)
|
|
7
|
+
|
|
8
|
+
test('0 pushdrop', async () => {
|
|
9
|
+
if (Setup.noEnv('main')) return
|
|
10
|
+
await transferPushDrop()
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Example of moving satoshis from one wallet to another using the BRC29 script template.
|
|
16
|
+
*
|
|
17
|
+
* This example can be run by the following command:
|
|
18
|
+
*
|
|
19
|
+
* ```bash
|
|
20
|
+
* npx tsx brc29.ts
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Combine this with the [balances](./README.md#function-balances) example to observe satoshis being transfered between
|
|
24
|
+
* two wallets.
|
|
25
|
+
*
|
|
26
|
+
* @publicbody
|
|
27
|
+
*/
|
|
28
|
+
export async function transferPushDrop() {
|
|
29
|
+
// obtain the secrets environment for the testnet network.
|
|
30
|
+
const env = Setup.getEnv('main')
|
|
31
|
+
// setup1 will be the sending wallet using the rootKey associated with identityKey, which is the default.
|
|
32
|
+
const setup1 = await Setup.createWalletClient({ env })
|
|
33
|
+
|
|
34
|
+
// setup2 will be the receiving wallet using the rootKey associated with identityKey2
|
|
35
|
+
const setup2 = setup1
|
|
36
|
+
|
|
37
|
+
// create a new transaction with an output for setup2 in the amount of 42 satoshis.
|
|
38
|
+
const o = await outputPushDrop(setup1, setup2.identityKey, 42)
|
|
39
|
+
|
|
40
|
+
// use setup2 to consume the new output to demonstrate unlocking the output and adding it to the wallet's "change" outputs.
|
|
41
|
+
await inputPushDrop(setup2, o)
|
|
42
|
+
|
|
43
|
+
await setup1.wallet.destroy()
|
|
44
|
+
await setup2.wallet.destroy()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function outputPushDrop(
|
|
48
|
+
setup: SetupWallet,
|
|
49
|
+
toIdentityKey: string,
|
|
50
|
+
satoshis: number
|
|
51
|
+
): Promise<{
|
|
52
|
+
beef: Beef
|
|
53
|
+
outpoint: string
|
|
54
|
+
fromIdentityKey: string
|
|
55
|
+
satoshis: number
|
|
56
|
+
protocol: WalletProtocol
|
|
57
|
+
keyId: string
|
|
58
|
+
}> {
|
|
59
|
+
const t = new PushDrop(setup.wallet)
|
|
60
|
+
|
|
61
|
+
const protocol: WalletProtocol = [2, 'pushdropexample']
|
|
62
|
+
const keyId: string = '7'
|
|
63
|
+
|
|
64
|
+
const lock = await t.lock(
|
|
65
|
+
[
|
|
66
|
+
[1, 2, 3],
|
|
67
|
+
[4, 5, 6]
|
|
68
|
+
],
|
|
69
|
+
protocol,
|
|
70
|
+
keyId,
|
|
71
|
+
toIdentityKey,
|
|
72
|
+
false,
|
|
73
|
+
true,
|
|
74
|
+
'before'
|
|
75
|
+
)
|
|
76
|
+
const lockingScript = lock.toHex()
|
|
77
|
+
|
|
78
|
+
// Use this label the new transaction can be found by `listActions` and as a "description" value.
|
|
79
|
+
const label = 'outputPushDrop'
|
|
80
|
+
|
|
81
|
+
// This call to `createAction` will create a new funded transaction containing the new output,
|
|
82
|
+
// as well as sign and broadcast the transaction to the network.
|
|
83
|
+
const car = await setup.wallet.createAction({
|
|
84
|
+
outputs: [
|
|
85
|
+
// Explicitly specify the new output to be created.
|
|
86
|
+
// When outputs are explictly added to an action they must be funded:
|
|
87
|
+
// Typically, at least one "change" input will automatically be added to fund the transaction,
|
|
88
|
+
// and at least one output will be added to recapture excess funding.
|
|
89
|
+
{
|
|
90
|
+
lockingScript,
|
|
91
|
+
satoshis,
|
|
92
|
+
outputDescription: label,
|
|
93
|
+
tags: ['relinquish'],
|
|
94
|
+
customInstructions: JSON.stringify({
|
|
95
|
+
protocol,
|
|
96
|
+
keyId,
|
|
97
|
+
counterparty: toIdentityKey,
|
|
98
|
+
type: 'PushDrop'
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
options: {
|
|
103
|
+
// Turn off automatic output order randomization to avoid having to figure out which output is the explicit one.
|
|
104
|
+
// It will always be output zero.
|
|
105
|
+
randomizeOutputs: false,
|
|
106
|
+
// This example prefers to immediately wait for the new transaction to be broadcast to the network.
|
|
107
|
+
// Typically, most production applications benefit from performance gains when broadcasts are handled in the background.
|
|
108
|
+
acceptDelayedBroadcast: true
|
|
109
|
+
},
|
|
110
|
+
labels: [label],
|
|
111
|
+
description: label
|
|
112
|
+
})
|
|
113
|
+
if (car.sendWithResults!.some(r => r.status === 'failed'))
|
|
114
|
+
throw new Error('failed to send output creating transaction')
|
|
115
|
+
|
|
116
|
+
// Both the "tx" and "txid" results are expected to be valid when an action is created that does not need explicit input signing,
|
|
117
|
+
// and when the "signAndProcess" option is allowed to default to true.
|
|
118
|
+
|
|
119
|
+
// The `Beef` class is used here to decode the AtomicBEEF binary format of the new transaction.
|
|
120
|
+
const beef = Beef.fromBinary(car.tx!)
|
|
121
|
+
// The outpoint string is constructed from the new transaction's txid and the output index: zero.
|
|
122
|
+
const outpoint = `${car.txid!}.0`
|
|
123
|
+
|
|
124
|
+
logger(`
|
|
125
|
+
outputPushDrop to ${toIdentityKey}
|
|
126
|
+
outpoint ${outpoint}
|
|
127
|
+
satoshis ${satoshis}
|
|
128
|
+
BEEF
|
|
129
|
+
${beef.toHex()}
|
|
130
|
+
${beef.toLogString()}
|
|
131
|
+
`)
|
|
132
|
+
|
|
133
|
+
// Return the bits and pieces of the new output created.
|
|
134
|
+
return {
|
|
135
|
+
beef,
|
|
136
|
+
outpoint,
|
|
137
|
+
fromIdentityKey: setup.identityKey,
|
|
138
|
+
satoshis,
|
|
139
|
+
protocol,
|
|
140
|
+
keyId
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Consume a PushDrop output.
|
|
146
|
+
*
|
|
147
|
+
* To spend a PushDrop output a transaction input must be created and signed using the
|
|
148
|
+
* associated private key.
|
|
149
|
+
*
|
|
150
|
+
* In this example, an initial `createAction` call constructs the overall shape of a
|
|
151
|
+
* new transaction, returning a `signableTransaction`.
|
|
152
|
+
*
|
|
153
|
+
* The `tx` property of the `signableTransaction` should be parsed using
|
|
154
|
+
* the standard `Beef` class. Note that it is not an ordinary AtomicBEEF for the
|
|
155
|
+
* simple reason that the transaction has not yet been fully signed.
|
|
156
|
+
*
|
|
157
|
+
* You can either use the method shown here to obtain a signable `Transaction` object
|
|
158
|
+
* from this beef or you can use the `Transaction.fromAtomicBEEF` method.
|
|
159
|
+
*
|
|
160
|
+
* To sign an input, set the corresponding input's `unlockingScriptTemplate` to an appropriately
|
|
161
|
+
* initialized unlock object and call the `Transaction` `sign` method.
|
|
162
|
+
*
|
|
163
|
+
* Once signed, capture the input's now valid `unlockingScript` value and convert it to a hex string.
|
|
164
|
+
*
|
|
165
|
+
* @param {SetupWallet} setup The setup context which will consume a PushDrop output as an input to a new transaction transfering
|
|
166
|
+
* the output's satoshis to the "change" managed by the context's wallet.
|
|
167
|
+
* @param {Beef} outputPushDrop.beef - An object proving the validity of the new output where the last transaction contains the new output.
|
|
168
|
+
* @param {string} outputPushDrop.outpoint - The txid and index of the outpoint in the format `${txid}.${index}`.
|
|
169
|
+
* @param {string} outputPushDrop.fromIdentityKey - The public key that locked the output.
|
|
170
|
+
* @param {number} outputPushDrop.satoshis - The amount assigned to the output.
|
|
171
|
+
*
|
|
172
|
+
* @publicbody
|
|
173
|
+
*/
|
|
174
|
+
export async function inputPushDrop(
|
|
175
|
+
setup: SetupWallet,
|
|
176
|
+
outputPushDrop: {
|
|
177
|
+
beef: Beef
|
|
178
|
+
outpoint: string
|
|
179
|
+
fromIdentityKey: string
|
|
180
|
+
satoshis: number
|
|
181
|
+
protocol: WalletProtocol
|
|
182
|
+
keyId: string
|
|
183
|
+
}
|
|
184
|
+
) {
|
|
185
|
+
const { protocol, keyId, fromIdentityKey, satoshis, beef: inputBeef, outpoint } = outputPushDrop
|
|
186
|
+
|
|
187
|
+
const { keyDeriver } = setup
|
|
188
|
+
|
|
189
|
+
const t = new PushDrop(setup.wallet)
|
|
190
|
+
|
|
191
|
+
// Construct an "unlock" object which is then associated with the input to be signed
|
|
192
|
+
// such that when the "sign" method is called, a signed "unlockingScript" is computed for that input.
|
|
193
|
+
const unlock = t.unlock(protocol, keyId, fromIdentityKey, 'single', false, satoshis)
|
|
194
|
+
|
|
195
|
+
const label = 'inputPushDrop'
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Creating an action with an input that requires it's own signing template is a two step process.
|
|
199
|
+
* The call to createAction must include only the expected maximum script length of the unlockingScript.
|
|
200
|
+
* This causes a "signableTransaction" to be returned instead of a completed "txid" and "tx".
|
|
201
|
+
*/
|
|
202
|
+
const car = await setup.wallet.createAction({
|
|
203
|
+
/**
|
|
204
|
+
* An inputBEEF is always required when there are explicit inputs to the new action.
|
|
205
|
+
* This beef must include each transaction with a corresponding outpoint txid.
|
|
206
|
+
* Unlike an AtomicBEEF, inputBEEF validates the transactions containing the outpoints,
|
|
207
|
+
* and may contain multiple unrelated transaction subtrees.
|
|
208
|
+
*/
|
|
209
|
+
inputBEEF: inputBeef.toBinary(),
|
|
210
|
+
inputs: [
|
|
211
|
+
{
|
|
212
|
+
outpoint,
|
|
213
|
+
// The value of 73 is a constant for the PushDrop template.
|
|
214
|
+
// You could use the `unlock.estimateLength` method to obtain it.
|
|
215
|
+
// Or a quick look at the PushDrop source code to confirm it.
|
|
216
|
+
unlockingScriptLength: 73,
|
|
217
|
+
inputDescription: label
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
labels: [label],
|
|
221
|
+
description: label
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Here is the essense of using `signAction` and custom script template:
|
|
226
|
+
*
|
|
227
|
+
* The `tx` property of the `signableTransaction` result can be parsed using
|
|
228
|
+
* the standard `Beef` class, but it is not an ordinary valid AtomicBEEF for the
|
|
229
|
+
* simple reason that the transaction has not been fully signed.
|
|
230
|
+
*
|
|
231
|
+
* You can either use the method shown here to obtain a signable `Transaction` object
|
|
232
|
+
* from this beef or you can use the `Transaction.fromAtomicBEEF` method.
|
|
233
|
+
*
|
|
234
|
+
* To sign an input, set the corresponding input's `unlockingScriptTemplate` to an appropriately
|
|
235
|
+
* initialized unlock object and call the `Transaction` `sign` method.
|
|
236
|
+
*
|
|
237
|
+
* Once signed, capture the now valid `unlockingScript` valoue for the input and convert it to a hex string.
|
|
238
|
+
*/
|
|
239
|
+
const st = car.signableTransaction!
|
|
240
|
+
const beef = Beef.fromBinary(st.tx)
|
|
241
|
+
const tx = beef.findAtomicTransaction(beef.txs.slice(-1)[0].txid)!
|
|
242
|
+
tx.inputs[0].unlockingScriptTemplate = unlock
|
|
243
|
+
await tx.sign()
|
|
244
|
+
const unlockingScript = tx.inputs[0].unlockingScript!.toHex()
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Note that the `signArgs` use the `reference` property of the `signableTransaction` result to
|
|
248
|
+
* identify the `createAction` result to finish processing and optionally broadcasting.
|
|
249
|
+
*/
|
|
250
|
+
const signArgs: SignActionArgs = {
|
|
251
|
+
reference: st.reference,
|
|
252
|
+
spends: { 0: { unlockingScript } },
|
|
253
|
+
options: {
|
|
254
|
+
// Force an immediate broadcast of the signed transaction.
|
|
255
|
+
acceptDelayedBroadcast: true
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Calling `signAction` completes the action creation process when inputs must be signed
|
|
261
|
+
* using specific script templates.
|
|
262
|
+
*/
|
|
263
|
+
const sar = await setup.wallet.signAction(signArgs)
|
|
264
|
+
if (sar.sendWithResults!.some(r => r.status === 'failed'))
|
|
265
|
+
throw new Error('failed to send output creating transaction')
|
|
266
|
+
|
|
267
|
+
// This completes the example by logging evidence of what was created.
|
|
268
|
+
{
|
|
269
|
+
const beef = Beef.fromBinary(sar.tx!)
|
|
270
|
+
const txid = sar.txid!
|
|
271
|
+
|
|
272
|
+
logger(`
|
|
273
|
+
inputP2PKH to ${setup.identityKey}
|
|
274
|
+
input's outpoint ${outpoint}
|
|
275
|
+
satoshis ${satoshis}
|
|
276
|
+
txid ${txid}
|
|
277
|
+
BEEF
|
|
278
|
+
${beef.toHex()}
|
|
279
|
+
${beef.toLogString()}
|
|
280
|
+
`)
|
|
281
|
+
}
|
|
282
|
+
}
|