@bsv/wallet-toolbox 2.4.3 → 2.4.20
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/CHANGELOG.md +81 -1
- package/LICENSE.txt +58 -0
- package/README.md +98 -36
- package/docs/README.md +3 -1
- package/docs/action-batch-planning.md +220 -0
- package/docs/authentication-observability.md +94 -0
- package/docs/client.md +1125 -2776
- package/docs/monitor.md +29 -111
- package/docs/services.md +296 -602
- package/docs/setup.md +48 -28
- package/docs/storage.md +329 -1692
- package/docs/wallet.md +9718 -4890
- package/out/src/CWIStyleWalletManager.d.ts +62 -6
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +584 -181
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/Setup.d.ts +7 -0
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +10 -11
- package/out/src/Setup.js.map +1 -1
- package/out/src/SetupClient.d.ts +2 -0
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +8 -9
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/SetupWallet.d.ts +6 -0
- package/out/src/SetupWallet.d.ts.map +1 -1
- package/out/src/ShamirWalletManager.d.ts.map +1 -1
- package/out/src/ShamirWalletManager.js.map +1 -1
- package/out/src/SimpleWalletManager.d.ts.map +1 -1
- package/out/src/SimpleWalletManager.js +2 -5
- package/out/src/SimpleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +36 -10
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +167 -132
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +30 -6
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +215 -34
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/WalletLogger.d.ts.map +1 -1
- package/out/src/WalletLogger.js +33 -30
- package/out/src/WalletLogger.js.map +1 -1
- package/out/src/WalletPermissionsManager.d.ts +22 -1
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +392 -267
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/WalletSettingsManager.d.ts.map +1 -1
- package/out/src/WalletSettingsManager.js.map +1 -1
- package/out/src/entropy/EntropyCollector.d.ts.map +1 -1
- package/out/src/entropy/EntropyCollector.js +6 -8
- package/out/src/entropy/EntropyCollector.js.map +1 -1
- package/out/src/fundWalletP2PKH.js.map +1 -1
- package/out/src/index.all.d.ts +1 -0
- package/out/src/index.all.d.ts.map +1 -1
- package/out/src/index.all.js +1 -0
- package/out/src/index.all.js.map +1 -1
- package/out/src/index.client.d.ts +2 -0
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +2 -0
- package/out/src/index.client.js.map +1 -1
- package/out/src/index.mobile.d.ts +2 -0
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +2 -0
- package/out/src/index.mobile.js.map +1 -1
- package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
- package/out/src/mockchain/MockChainMigrations.js.map +1 -1
- package/out/src/mockchain/MockChainStorage.d.ts.map +1 -1
- package/out/src/mockchain/MockChainStorage.js.map +1 -1
- package/out/src/mockchain/MockChainTracker.d.ts.map +1 -1
- package/out/src/mockchain/MockChainTracker.js.map +1 -1
- package/out/src/mockchain/MockMiner.d.ts.map +1 -1
- package/out/src/mockchain/MockMiner.js.map +1 -1
- package/out/src/mockchain/MockServices.d.ts +4 -0
- package/out/src/mockchain/MockServices.d.ts.map +1 -1
- package/out/src/mockchain/MockServices.js +69 -74
- package/out/src/mockchain/MockServices.js.map +1 -1
- package/out/src/mockchain/merkleTree.d.ts.map +1 -1
- package/out/src/mockchain/merkleTree.js +51 -56
- package/out/src/mockchain/merkleTree.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts +4 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +60 -57
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts +3 -0
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +65 -56
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/index.all.js.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.d.ts +5 -0
- package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.js +86 -77
- package/out/src/monitor/tasks/TaskArcSSE.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +4 -2
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +132 -131
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +3 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.js +3 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts +13 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js +24 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js.map +1 -0
- package/out/src/monitor/tasks/TaskClock.d.ts +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/TaskMineBlock.d.ts +3 -1
- package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.js +3 -1
- package/out/src/monitor/tasks/TaskMineBlock.js.map +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +4 -3
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +4 -3
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts +3 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js +3 -1
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts +3 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +3 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +3 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js +3 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts +3 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js +3 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +3 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.js +3 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +3 -0
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js +53 -46
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts +1 -1
- package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSyncWhenIdle.js +1 -1
- package/out/src/monitor/tasks/TaskSyncWhenIdle.js.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts +3 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.js +3 -1
- package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -1
- package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -1
- package/out/src/monitor/tasks/index.all.d.ts +1 -0
- package/out/src/monitor/tasks/index.all.d.ts.map +1 -1
- package/out/src/monitor/tasks/index.all.js +1 -0
- package/out/src/monitor/tasks/index.all.js.map +1 -1
- package/out/src/sdk/ActionBatch.interfaces.d.ts +159 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts.map +1 -0
- package/out/src/sdk/ActionBatch.interfaces.js +3 -0
- package/out/src/sdk/ActionBatch.interfaces.js.map +1 -0
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js +3 -3
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js +2 -2
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts +3 -0
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +53 -56
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +3 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +22 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/index.d.ts +1 -0
- package/out/src/sdk/index.d.ts.map +1 -1
- package/out/src/sdk/index.js +1 -0
- package/out/src/sdk/index.js.map +1 -1
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/services/ServiceCollection.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.js.map +1 -1
- package/out/src/services/Services.d.ts +8 -2
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +86 -44
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.d.ts +7 -7
- package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.js +9 -9
- package/out/src/services/chaintracker/BHServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +4 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js +42 -6
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +4 -4
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js +45 -40
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.d.ts +5 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.js +25 -18
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +3 -3
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +6 -7
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +0 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.js +2 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +12 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +110 -103
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +8 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +58 -48
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +55 -54
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts +4 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +97 -72
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts +5 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js +145 -136
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +4 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +92 -68
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.d.ts +43 -0
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js +76 -0
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/configureKnexChaintracks.d.ts +18 -0
- package/out/src/services/chaintracker/chaintracks/configureKnexChaintracks.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/configureKnexChaintracks.js +24 -0
- package/out/src/services/chaintracker/chaintracks/configureKnexChaintracks.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts +2 -3
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js +4 -22
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.d.ts +2 -4
- package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.js +12 -25
- package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts +2 -3
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js +4 -22
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts +2 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js +3 -15
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.js +3 -15
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts +2 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js +3 -15
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts +1 -1
- package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.mobile.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +2 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +64 -61
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +4 -3
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.d.ts +8 -10
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.js +14 -24
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +1 -11
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +20 -49
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js +4 -2
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts +23 -14
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js +1 -14
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/networkConfig.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts +4 -0
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +96 -83
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
- package/out/src/services/providers/ArcSSEClient.js.map +1 -1
- package/out/src/services/providers/Arcade.d.ts +4 -0
- package/out/src/services/providers/Arcade.d.ts.map +1 -1
- package/out/src/services/providers/Arcade.js +118 -92
- package/out/src/services/providers/Arcade.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +107 -86
- 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 +19 -6
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/exchangeRates.js +1 -1
- package/out/src/services/providers/exchangeRates.js.map +1 -1
- package/out/src/services/providers/getBeefForTxid.js.map +1 -1
- package/out/src/services/providers/whatsOnChainHelpers.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/actionBatch/ActionBatchPlanner.d.ts +29 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js +346 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +33 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js +869 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js.map +1 -0
- package/out/src/signer/actionBatch/actionBatchBootstrap.d.ts +11 -0
- package/out/src/signer/actionBatch/actionBatchBootstrap.d.ts.map +1 -0
- package/out/src/signer/actionBatch/actionBatchBootstrap.js +38 -0
- package/out/src/signer/actionBatch/actionBatchBootstrap.js.map +1 -0
- 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 +97 -107
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/completeSignedTransaction.d.ts +3 -7
- package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/completeSignedTransaction.js +14 -57
- package/out/src/signer/methods/completeSignedTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +50 -20
- 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 +4 -4
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/resultBeef.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +29 -4
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/signer/methods/verifyUnlockScripts.d.ts +17 -0
- package/out/src/signer/methods/verifyUnlockScripts.d.ts.map +1 -0
- package/out/src/signer/methods/verifyUnlockScripts.js +137 -0
- package/out/src/signer/methods/verifyUnlockScripts.js.map +1 -0
- package/out/src/storage/StorageIdb.d.ts +19 -3
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +232 -53
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +29 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +225 -10
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +57 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +277 -145
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts +13 -5
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +3 -0
- 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 +10 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +49 -6
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/adminServer/adminServer.d.ts +79 -0
- package/out/src/storage/adminServer/adminServer.d.ts.map +1 -1
- package/out/src/storage/adminServer/adminServer.js +47 -16
- package/out/src/storage/adminServer/adminServer.js.map +1 -1
- package/out/src/storage/adminServer/adminUi.js.map +1 -1
- package/out/src/storage/idbHelpers.d.ts +2 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -1
- package/out/src/storage/idbHelpers.js +19 -0
- package/out/src/storage/idbHelpers.js.map +1 -1
- package/out/src/storage/index.all.js.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.js +48 -71
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.js +29 -27
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/out/src/storage/methods/actionBatch.d.ts +15 -0
- package/out/src/storage/methods/actionBatch.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatch.js +737 -0
- package/out/src/storage/methods/actionBatch.js.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts +15 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.js +184 -0
- package/out/src/storage/methods/actionBatchBlobs.js.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts +17 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.js +416 -0
- package/out/src/storage/methods/actionBatchValidation.js.map +1 -0
- package/out/src/storage/methods/actionPlanning.d.ts +12 -0
- package/out/src/storage/methods/actionPlanning.d.ts.map +1 -0
- package/out/src/storage/methods/actionPlanning.js +48 -0
- package/out/src/storage/methods/actionPlanning.js.map +1 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +0 -21
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +43 -51
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +66 -63
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts +2 -2
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +66 -38
- 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 +48 -42
- 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 +8 -6
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +145 -121
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActionsIdb.js.map +1 -1
- package/out/src/storage/methods/listActionsKnex.js +1 -1
- package/out/src/storage/methods/listActionsKnex.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.js +133 -152
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.d.ts +1 -1
- package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.js +213 -254
- package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
- package/out/src/storage/methods/managedChange.d.ts +3 -3
- package/out/src/storage/methods/managedChange.d.ts.map +1 -1
- package/out/src/storage/methods/managedChange.js +1 -2
- package/out/src/storage/methods/managedChange.js.map +1 -1
- package/out/src/storage/methods/offsetKey.d.ts.map +1 -1
- package/out/src/storage/methods/offsetKey.js +0 -1
- package/out/src/storage/methods/offsetKey.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts +2 -0
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +8 -8
- 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 +157 -179
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/purgeDataIdb.d.ts +1 -1
- package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -1
- package/out/src/storage/methods/purgeDataIdb.js +1 -1
- package/out/src/storage/methods/purgeDataIdb.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +6 -6
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/methods/reviewStatusIdb.js.map +1 -1
- package/out/src/storage/methods/utils.Buffer.js.map +1 -1
- package/out/src/storage/methods/utils.js.map +1 -1
- package/out/src/storage/portable/index.js +2 -2
- package/out/src/storage/portable/index.js.map +1 -1
- package/out/src/storage/remoting/BinaryJson.d.ts.map +1 -1
- package/out/src/storage/remoting/BinaryJson.js +84 -38
- package/out/src/storage/remoting/BinaryJson.js.map +1 -1
- package/out/src/storage/remoting/KnexSessionManager.d.ts.map +1 -1
- package/out/src/storage/remoting/KnexSessionManager.js.map +1 -1
- package/out/src/storage/remoting/RateLimitPolicy.d.ts +10 -0
- package/out/src/storage/remoting/RateLimitPolicy.d.ts.map +1 -0
- package/out/src/storage/remoting/RateLimitPolicy.js +37 -0
- package/out/src/storage/remoting/RateLimitPolicy.js.map +1 -0
- package/out/src/storage/remoting/StorageClient.d.ts +2 -0
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +82 -50
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +23 -4
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.js +97 -4
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -1
- package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageMobile.js +34 -22
- package/out/src/storage/remoting/StorageMobile.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts +62 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +451 -172
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/remoting/edgePolicy.d.ts +57 -0
- package/out/src/storage/remoting/edgePolicy.d.ts.map +1 -0
- package/out/src/storage/remoting/edgePolicy.js +387 -0
- package/out/src/storage/remoting/edgePolicy.js.map +1 -0
- package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +1 -1
- package/out/src/storage/remoting/entityValidationHelpers.js +22 -5
- package/out/src/storage/remoting/entityValidationHelpers.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +56 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts +24 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts.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/EntityCertificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCommission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts +3 -0
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.js +46 -36
- package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +2 -2
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.js +12 -10
- package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.js +25 -34
- package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityUser.js.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +9 -14
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/tables/TableActionBatch.d.ts +26 -0
- package/out/src/storage/schema/tables/TableActionBatch.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableActionBatch.js +3 -0
- package/out/src/storage/schema/tables/TableActionBatch.js.map +1 -0
- package/out/src/storage/schema/tables/TableAuthSession.js.map +1 -1
- package/out/src/storage/schema/tables/index.d.ts +1 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +1 -0
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/storage/storageProviderHelpers.js.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +3 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +30 -16
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/src/utility/Format.d.ts.map +1 -1
- package/out/src/utility/Format.js +2 -2
- package/out/src/utility/Format.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/actionBatchDigest.d.ts +9 -0
- package/out/src/utility/actionBatchDigest.d.ts.map +1 -0
- package/out/src/utility/actionBatchDigest.js +86 -0
- package/out/src/utility/actionBatchDigest.js.map +1 -0
- package/out/src/utility/actionBatchPack.d.ts +16 -0
- package/out/src/utility/actionBatchPack.d.ts.map +1 -0
- package/out/src/utility/actionBatchPack.js +220 -0
- package/out/src/utility/actionBatchPack.js.map +1 -0
- package/out/src/utility/aggregateResults.d.ts.map +1 -1
- package/out/src/utility/aggregateResults.js.map +1 -1
- package/out/src/utility/beefForTxids.d.ts +9 -0
- package/out/src/utility/beefForTxids.d.ts.map +1 -0
- package/out/src/utility/beefForTxids.js +35 -0
- package/out/src/utility/beefForTxids.js.map +1 -0
- package/out/src/utility/brc114ActionTimeLabels.d.ts.map +1 -1
- package/out/src/utility/brc114ActionTimeLabels.js +26 -30
- package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
- package/out/src/utility/formatUnknown.d.ts +6 -0
- package/out/src/utility/formatUnknown.d.ts.map +1 -0
- package/out/src/utility/formatUnknown.js +39 -0
- package/out/src/utility/formatUnknown.js.map +1 -0
- package/out/src/utility/hashWasm.d.ts +5 -0
- package/out/src/utility/hashWasm.d.ts.map +1 -0
- package/out/src/utility/hashWasm.js +15 -0
- package/out/src/utility/hashWasm.js.map +1 -0
- package/out/src/utility/identityUtils.d.ts.map +1 -1
- package/out/src/utility/identityUtils.js +2 -4
- package/out/src/utility/identityUtils.js.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.d.ts +1 -1
- package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.js +1 -1
- package/out/src/utility/parseTxScriptOffsets.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- package/out/src/utility/stampLog.js +49 -42
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/traceContext.d.ts +13 -0
- package/out/src/utility/traceContext.d.ts.map +1 -0
- package/out/src/utility/traceContext.js +34 -0
- package/out/src/utility/traceContext.js.map +1 -0
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js +1 -1
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts +2 -2
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +8 -4
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.js +1 -2
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -1
- package/out/src/wab-client/WABClient.d.ts +36 -90
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +103 -151
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/WABTransport.d.ts +81 -0
- package/out/src/wab-client/WABTransport.d.ts.map +1 -0
- package/out/src/wab-client/WABTransport.js +420 -0
- package/out/src/wab-client/WABTransport.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +10 -10
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -21
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +2 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +14 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -1
- package/package.json +66 -30
- package/license.md +0 -28
|
@@ -0,0 +1,869 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionBatchController = void 0;
|
|
4
|
+
exports.additionalFundingTarget = additionalFundingTarget;
|
|
5
|
+
exports.fundingRunwayExtension = fundingRunwayExtension;
|
|
6
|
+
const sdk_1 = require("@bsv/sdk");
|
|
7
|
+
const actionBatchBootstrap_1 = require("./actionBatchBootstrap");
|
|
8
|
+
const WERR_errors_1 = require("../../sdk/WERR_errors");
|
|
9
|
+
const utilityHelpers_1 = require("../../utility/utilityHelpers");
|
|
10
|
+
const utilityHelpers_noBuffer_1 = require("../../utility/utilityHelpers.noBuffer");
|
|
11
|
+
const types_1 = require("../../sdk/types");
|
|
12
|
+
const actionBatchDigest_1 = require("../../utility/actionBatchDigest");
|
|
13
|
+
const ActionBatchPlanner_1 = require("./ActionBatchPlanner");
|
|
14
|
+
const beefForTxids_1 = require("../../utility/beefForTxids");
|
|
15
|
+
const actionBatchPack_1 = require("../../utility/actionBatchPack");
|
|
16
|
+
function mergeUnique(values) {
|
|
17
|
+
return [...new Set(values)];
|
|
18
|
+
}
|
|
19
|
+
function nextGeometricTarget(value) {
|
|
20
|
+
return Math.min(Number.MAX_SAFE_INTEGER, value * 2);
|
|
21
|
+
}
|
|
22
|
+
function additionalFundingTarget(error) {
|
|
23
|
+
return error.moreSatoshisNeeded;
|
|
24
|
+
}
|
|
25
|
+
function fundingRunwayExtension(runwayTarget, ewmaConfirmedInputs, ewmaConfirmedSatoshis, availableConfirmed) {
|
|
26
|
+
const availableConfirmedCount = availableConfirmed.length;
|
|
27
|
+
const availableConfirmedSatoshis = availableConfirmed
|
|
28
|
+
.reduce((sum, output) => sum + output.satoshis, 0);
|
|
29
|
+
const predictedByInputs = availableConfirmedCount / Math.max(1, ewmaConfirmedInputs);
|
|
30
|
+
const predictedBySatoshis = ewmaConfirmedSatoshis > 0
|
|
31
|
+
? availableConfirmedSatoshis / ewmaConfirmedSatoshis
|
|
32
|
+
: Number.POSITIVE_INFINITY;
|
|
33
|
+
if (Math.min(predictedByInputs, predictedBySatoshis) >= 2)
|
|
34
|
+
return undefined;
|
|
35
|
+
const nextRunwayTarget = nextGeometricTarget(runwayTarget);
|
|
36
|
+
return {
|
|
37
|
+
nextRunwayTarget,
|
|
38
|
+
requestedOutputs: Math.max(1, Math.ceil(nextRunwayTarget * ewmaConfirmedInputs) - availableConfirmedCount),
|
|
39
|
+
targetSatoshis: Math.max(1, nextRunwayTarget * ewmaConfirmedSatoshis - availableConfirmedSatoshis)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function makePlannerState(begin, firstAction) {
|
|
43
|
+
const sharedBeef = new sdk_1.Beef();
|
|
44
|
+
if (begin.inputBeef != null)
|
|
45
|
+
sharedBeef.mergeBeef(begin.inputBeef);
|
|
46
|
+
if (firstAction.inputBEEF != null)
|
|
47
|
+
sharedBeef.mergeBeef(firstAction.inputBEEF);
|
|
48
|
+
for (const output of [...begin.reservedOutputs, ...begin.explicitOutputs]) {
|
|
49
|
+
if (output.sourceTransaction != null)
|
|
50
|
+
sharedBeef.mergeRawTx(output.sourceTransaction);
|
|
51
|
+
}
|
|
52
|
+
const state = {
|
|
53
|
+
begin,
|
|
54
|
+
sharedBeef,
|
|
55
|
+
reserved: new Map(),
|
|
56
|
+
explicit: new Map(),
|
|
57
|
+
staged: new Map(),
|
|
58
|
+
discardedStagedTxids: new Set(),
|
|
59
|
+
consumed: new Set(),
|
|
60
|
+
estimatedChangeCount: begin.availableChangeCount
|
|
61
|
+
};
|
|
62
|
+
(0, ActionBatchPlanner_1.addPlannerOutputs)(state.reserved, begin.reservedOutputs, begin.changeBasket.name);
|
|
63
|
+
(0, ActionBatchPlanner_1.addPlannerOutputs)(state.explicit, begin.explicitOutputs);
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
class ActionBatchWorkspace {
|
|
67
|
+
wallet;
|
|
68
|
+
capabilities;
|
|
69
|
+
batchId;
|
|
70
|
+
state;
|
|
71
|
+
planned = new Map();
|
|
72
|
+
actions = [];
|
|
73
|
+
lockingScripts = new Map();
|
|
74
|
+
ewmaConfirmedInputs = 1;
|
|
75
|
+
ewmaConfirmedSatoshis = 0;
|
|
76
|
+
hasConfirmedSample = false;
|
|
77
|
+
runwayTarget = 4;
|
|
78
|
+
extension;
|
|
79
|
+
renewal;
|
|
80
|
+
expiresAt;
|
|
81
|
+
committed = false;
|
|
82
|
+
eagerEnabled = false;
|
|
83
|
+
eagerLogicalBytes = 0;
|
|
84
|
+
eagerPending = new Map();
|
|
85
|
+
eagerUploadLanes;
|
|
86
|
+
eagerUploadCursor = 0;
|
|
87
|
+
constructor(wallet, begin, firstAction, capabilities) {
|
|
88
|
+
this.wallet = wallet;
|
|
89
|
+
this.capabilities = capabilities;
|
|
90
|
+
this.batchId = begin.batchId;
|
|
91
|
+
this.state = makePlannerState(begin, firstAction);
|
|
92
|
+
this.expiresAt = Date.parse(begin.expiresAt);
|
|
93
|
+
this.eagerUploadLanes = Array.from({
|
|
94
|
+
length: capabilities.packedUploads == null
|
|
95
|
+
? 1
|
|
96
|
+
: Math.max(1, capabilities.maxConcurrentUploads)
|
|
97
|
+
}, async () => { });
|
|
98
|
+
}
|
|
99
|
+
get usesCompactManifest() {
|
|
100
|
+
return this.capabilities.manifestVersion === 2;
|
|
101
|
+
}
|
|
102
|
+
get packedUploads() {
|
|
103
|
+
return this.capabilities.packedUploads?.version === 1
|
|
104
|
+
? this.capabilities.packedUploads
|
|
105
|
+
: undefined;
|
|
106
|
+
}
|
|
107
|
+
ownsReference(reference) {
|
|
108
|
+
if (this.planned.has(reference))
|
|
109
|
+
return true;
|
|
110
|
+
if (this.actions.some(action => action.reference === reference || action.txid === reference))
|
|
111
|
+
return true;
|
|
112
|
+
return Object.entries(this.wallet.pendingSignActions)
|
|
113
|
+
.some(([pendingReference, pending]) => this.planned.has(pendingReference) && pending.tx.id('hex') === reference);
|
|
114
|
+
}
|
|
115
|
+
get isEmpty() {
|
|
116
|
+
return this.planned.size === 0 && this.actions.length === 0;
|
|
117
|
+
}
|
|
118
|
+
overlayListActions(persisted, args) {
|
|
119
|
+
if (args.labels.includes(types_1.specOpFailedActions))
|
|
120
|
+
return persisted;
|
|
121
|
+
const controlLabels = new Set(args.labels.includes(types_1.specOpNoSendActions) ? ['abort'] : []);
|
|
122
|
+
const ordinaryLabels = args.labels.filter(label => !(0, types_1.isListActionsSpecOp)(label) && !controlLabels.has(label));
|
|
123
|
+
const staged = this.actions
|
|
124
|
+
.filter(action => {
|
|
125
|
+
if (ordinaryLabels.length === 0)
|
|
126
|
+
return true;
|
|
127
|
+
const matches = ordinaryLabels.filter(label => action.metadata.labels.includes(label)).length;
|
|
128
|
+
return args.labelQueryMode === 'all' ? matches === ordinaryLabels.length : matches > 0;
|
|
129
|
+
})
|
|
130
|
+
.map(action => {
|
|
131
|
+
const tx = this.state.sharedBeef.findTxid(action.txid)?.tx;
|
|
132
|
+
if (tx == null)
|
|
133
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`missing staged transaction ${action.txid}`);
|
|
134
|
+
const managedInputSatoshis = action.plan.inputs
|
|
135
|
+
.filter(input => input.vin >= action.metadata.inputs.length)
|
|
136
|
+
.reduce((sum, input) => sum + input.sourceSatoshis, 0);
|
|
137
|
+
const changeOutputSatoshis = action.plan.outputs
|
|
138
|
+
.filter(output => output.purpose === 'change')
|
|
139
|
+
.reduce((sum, output) => sum + output.satoshis, 0);
|
|
140
|
+
return {
|
|
141
|
+
txid: action.txid,
|
|
142
|
+
satoshis: changeOutputSatoshis - managedInputSatoshis,
|
|
143
|
+
status: 'nosend',
|
|
144
|
+
isOutgoing: true,
|
|
145
|
+
description: action.metadata.description,
|
|
146
|
+
labels: args.includeLabels ? action.metadata.labels : undefined,
|
|
147
|
+
version: tx.version,
|
|
148
|
+
lockTime: tx.lockTime,
|
|
149
|
+
inputs: args.includeInputs
|
|
150
|
+
? action.plan.inputs.map(input => ({
|
|
151
|
+
sourceOutpoint: `${input.sourceTxid}.${input.sourceVout}`,
|
|
152
|
+
sourceSatoshis: input.sourceSatoshis,
|
|
153
|
+
sourceLockingScript: args.includeInputSourceLockingScripts
|
|
154
|
+
? (0, utilityHelpers_noBuffer_1.asString)((0, ActionBatchPlanner_1.plannerInputLockingScript)(this.state, input))
|
|
155
|
+
: undefined,
|
|
156
|
+
unlockingScript: args.includeInputUnlockingScripts
|
|
157
|
+
? tx.inputs[input.vin]?.unlockingScript?.toHex()
|
|
158
|
+
: undefined,
|
|
159
|
+
inputDescription: input.spendingDescription ?? '',
|
|
160
|
+
sequenceNumber: tx.inputs[input.vin]?.sequence ?? 0
|
|
161
|
+
}))
|
|
162
|
+
: undefined,
|
|
163
|
+
outputs: args.includeOutputs
|
|
164
|
+
? action.plan.outputs.map(output => ({
|
|
165
|
+
satoshis: output.satoshis,
|
|
166
|
+
lockingScript: args.includeOutputLockingScripts
|
|
167
|
+
? tx.outputs[output.vout]?.lockingScript.toHex()
|
|
168
|
+
: undefined,
|
|
169
|
+
spendable: output.purpose !== 'storage-commission',
|
|
170
|
+
customInstructions: undefined,
|
|
171
|
+
tags: output.tags,
|
|
172
|
+
outputIndex: output.vout,
|
|
173
|
+
outputDescription: output.outputDescription,
|
|
174
|
+
basket: output.basket ?? ''
|
|
175
|
+
}))
|
|
176
|
+
: undefined
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
const actions = [...persisted.actions, ...staged];
|
|
180
|
+
return {
|
|
181
|
+
totalActions: persisted.totalActions + staged.length,
|
|
182
|
+
actions: actions.slice(args.offset, args.offset + args.limit)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
overlayListOutputs(persisted, args) {
|
|
186
|
+
const isBalance = args.basket === types_1.specOpWalletBalance || args.tags.includes(types_1.specOpWalletBalance);
|
|
187
|
+
const managedOnly = args.basket === types_1.specOpWalletManagedUtxos || isBalance;
|
|
188
|
+
const consumed = this.state.consumed;
|
|
189
|
+
const stagedLabels = new Map(this.actions.map(action => [action.txid, action.metadata.labels]));
|
|
190
|
+
const staged = [...this.state.staged.entries()]
|
|
191
|
+
.filter(([outpoint, output]) => {
|
|
192
|
+
if (consumed.has(outpoint))
|
|
193
|
+
return false;
|
|
194
|
+
if (managedOnly)
|
|
195
|
+
return output.change;
|
|
196
|
+
if (output.basketName !== args.basket)
|
|
197
|
+
return false;
|
|
198
|
+
const tags = output.tags ?? [];
|
|
199
|
+
if (args.tags.length === 0)
|
|
200
|
+
return true;
|
|
201
|
+
const matches = args.tags.filter(tag => tags.includes(tag)).length;
|
|
202
|
+
return args.tagQueryMode === 'all' ? matches === args.tags.length : matches > 0;
|
|
203
|
+
})
|
|
204
|
+
.map(([outpoint, output]) => ({
|
|
205
|
+
satoshis: output.satoshis,
|
|
206
|
+
lockingScript: args.includeLockingScripts
|
|
207
|
+
? (0, utilityHelpers_noBuffer_1.asString)((0, ActionBatchPlanner_1.plannerOutputLockingScript)(this.state, output))
|
|
208
|
+
: undefined,
|
|
209
|
+
spendable: true,
|
|
210
|
+
customInstructions: args.includeCustomInstructions ? output.customInstructions : undefined,
|
|
211
|
+
tags: args.includeTags ? output.tags ?? [] : undefined,
|
|
212
|
+
outpoint,
|
|
213
|
+
labels: args.includeLabels && output.txid != null ? stagedLabels.get(output.txid) ?? [] : undefined
|
|
214
|
+
}));
|
|
215
|
+
if (isBalance) {
|
|
216
|
+
const consumedConfirmed = [...this.state.reserved.entries()]
|
|
217
|
+
.filter(([outpoint]) => consumed.has(outpoint))
|
|
218
|
+
.reduce((sum, [, output]) => sum + output.satoshis, 0);
|
|
219
|
+
return {
|
|
220
|
+
totalOutputs: persisted.totalOutputs - consumedConfirmed + staged.reduce((sum, output) => sum + output.satoshis, 0),
|
|
221
|
+
outputs: []
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const persistedUnconsumed = persisted.outputs.filter(output => !consumed.has(output.outpoint));
|
|
225
|
+
const outputs = [
|
|
226
|
+
...persistedUnconsumed,
|
|
227
|
+
...staged
|
|
228
|
+
];
|
|
229
|
+
const ordered = args.offset < 0 ? [...outputs].reverse() : outputs;
|
|
230
|
+
const offset = args.offset < 0 ? Math.max(0, -args.offset - 1) : args.offset;
|
|
231
|
+
const result = {
|
|
232
|
+
totalOutputs: persisted.totalOutputs - (persisted.outputs.length - persistedUnconsumed.length) + staged.length,
|
|
233
|
+
outputs: ordered.slice(offset, offset + args.limit)
|
|
234
|
+
};
|
|
235
|
+
if (args.includeTransactions) {
|
|
236
|
+
const beef = new sdk_1.Beef();
|
|
237
|
+
if (persisted.BEEF != null)
|
|
238
|
+
beef.mergeBeef(persisted.BEEF);
|
|
239
|
+
beef.mergeBeef(this.state.sharedBeef);
|
|
240
|
+
for (const txid of args.knownTxids)
|
|
241
|
+
if (beef.findTxid(txid) != null)
|
|
242
|
+
beef.makeTxidOnly(txid);
|
|
243
|
+
result.BEEF = beef.toUint8Array();
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
mergeExtension(extension) {
|
|
248
|
+
for (const output of [...extension.reservedOutputs, ...extension.explicitOutputs]) {
|
|
249
|
+
if (output.sourceTransaction != null) {
|
|
250
|
+
this.state.sharedBeef.mergeRawTx(output.sourceTransaction);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
(0, ActionBatchPlanner_1.addPlannerOutputs)(this.state.reserved, extension.reservedOutputs, this.state.begin.changeBasket.name);
|
|
254
|
+
(0, ActionBatchPlanner_1.addPlannerOutputs)(this.state.explicit, extension.explicitOutputs);
|
|
255
|
+
if (extension.inputBeef != null) {
|
|
256
|
+
this.state.sharedBeef.mergeBeef(extension.inputBeef);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
missingExplicitOutpoints(args) {
|
|
260
|
+
return [...args.inputs.map(input => input.outpoint), ...args.options.noSendChange]
|
|
261
|
+
.filter(outpoint => {
|
|
262
|
+
const key = `${outpoint.txid}.${outpoint.vout}`;
|
|
263
|
+
return !this.state.staged.has(key) && !this.state.explicit.has(key) &&
|
|
264
|
+
!this.state.reserved.has(key) && (this.state.discardedStagedTxids.has(outpoint.txid) ||
|
|
265
|
+
this.state.sharedBeef.findTxid(outpoint.txid)?.tx == null);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
async extend(targetSatoshis, requestedOutputs, explicitOutpoints, includeSourceTransactions) {
|
|
269
|
+
const extension = await this.wallet.storage.extendActionBatch({
|
|
270
|
+
batchId: this.batchId,
|
|
271
|
+
targetSatoshis: Math.max(1, Math.ceil(targetSatoshis)),
|
|
272
|
+
requestedOutputs: Math.max(1, Math.ceil(requestedOutputs)),
|
|
273
|
+
explicitOutpoints,
|
|
274
|
+
includeSourceTransactions
|
|
275
|
+
});
|
|
276
|
+
this.mergeExtension(extension);
|
|
277
|
+
this.expiresAt = Date.parse(extension.expiresAt);
|
|
278
|
+
return {
|
|
279
|
+
outputCount: extension.reservedOutputs.length,
|
|
280
|
+
satoshis: extension.reservedOutputs.reduce((sum, output) => sum + output.satoshis, 0)
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
async renewIfNeeded() {
|
|
284
|
+
if (Date.now() >= this.expiresAt)
|
|
285
|
+
return;
|
|
286
|
+
const renewAt = this.expiresAt - this.capabilities.leaseMs * 0.2;
|
|
287
|
+
if (Date.now() < renewAt)
|
|
288
|
+
return;
|
|
289
|
+
this.renewal ??= this.wallet.storage.renewActionBatch(this.batchId)
|
|
290
|
+
.then(result => { this.expiresAt = Date.parse(result.expiresAt); })
|
|
291
|
+
.finally(() => { this.renewal = undefined; });
|
|
292
|
+
await this.renewal;
|
|
293
|
+
}
|
|
294
|
+
async plan(args) {
|
|
295
|
+
if (this.committed)
|
|
296
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION('action batch is already committed');
|
|
297
|
+
await this.renewIfNeeded();
|
|
298
|
+
if (this.extension != null)
|
|
299
|
+
await this.extension;
|
|
300
|
+
if (args.inputBEEF != null) {
|
|
301
|
+
this.state.sharedBeef.mergeBeef(args.inputBEEF);
|
|
302
|
+
}
|
|
303
|
+
const missing = this.missingExplicitOutpoints(args);
|
|
304
|
+
if (missing.length > 0)
|
|
305
|
+
await this.extend(1, 1, missing, args.isSignAction);
|
|
306
|
+
let planned;
|
|
307
|
+
let requestedOutputs = 8;
|
|
308
|
+
for (;;) {
|
|
309
|
+
try {
|
|
310
|
+
planned = await (0, ActionBatchPlanner_1.planAction)(this.state, args);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (!(error instanceof WERR_errors_1.WERR_INSUFFICIENT_FUNDS))
|
|
315
|
+
throw error;
|
|
316
|
+
// generateChangeSdk has already credited every unconsumed reservation
|
|
317
|
+
// supplied by planFunding. Only the reported shortfall is additional;
|
|
318
|
+
// requesting totalSatoshisNeeded here double-counts the held pool.
|
|
319
|
+
const target = additionalFundingTarget(error);
|
|
320
|
+
const added = await this.extend(target, requestedOutputs, [], args.isSignAction);
|
|
321
|
+
if (added.outputCount === 0 || added.satoshis === 0)
|
|
322
|
+
throw error;
|
|
323
|
+
requestedOutputs = nextGeometricTarget(requestedOutputs);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (planned == null)
|
|
327
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION('unable to plan action batch transaction');
|
|
328
|
+
this.planned.set(planned.dcr.reference, { args, planned });
|
|
329
|
+
return planned.dcr;
|
|
330
|
+
}
|
|
331
|
+
updateEwma(plan) {
|
|
332
|
+
const confirmed = plan.planned.consumedOutpoints
|
|
333
|
+
.map(outpoint => this.state.reserved.get(outpoint))
|
|
334
|
+
.filter((output) => output != null);
|
|
335
|
+
if (confirmed.length === 0)
|
|
336
|
+
return;
|
|
337
|
+
const satoshis = confirmed.reduce((sum, output) => sum + output.satoshis, 0);
|
|
338
|
+
if (!this.hasConfirmedSample) {
|
|
339
|
+
this.ewmaConfirmedInputs = confirmed.length;
|
|
340
|
+
this.ewmaConfirmedSatoshis = satoshis;
|
|
341
|
+
this.hasConfirmedSample = true;
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.ewmaConfirmedInputs = 0.5 * confirmed.length + 0.5 * this.ewmaConfirmedInputs;
|
|
345
|
+
this.ewmaConfirmedSatoshis = 0.5 * satoshis + 0.5 * this.ewmaConfirmedSatoshis;
|
|
346
|
+
}
|
|
347
|
+
stage(prior, processArgs) {
|
|
348
|
+
if (this.actions.some(action => action.reference === prior.reference))
|
|
349
|
+
return;
|
|
350
|
+
const pending = this.planned.get(prior.reference);
|
|
351
|
+
if (pending == null)
|
|
352
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION('signed action does not belong to active action batch');
|
|
353
|
+
const txid = prior.tx.id('hex');
|
|
354
|
+
const rawTx = prior.tx.toUint8Array();
|
|
355
|
+
const rawTxDigest = (0, actionBatchDigest_1.actionBatchBlobDigest)(rawTx);
|
|
356
|
+
const lockingScriptDigests = prior.dcr.outputs.map(output => {
|
|
357
|
+
const lockingScript = prior.tx.outputs[output.vout]?.lockingScript.toHex();
|
|
358
|
+
if (lockingScript == null) {
|
|
359
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`missing staged output script for ${txid}.${String(output.vout)}`);
|
|
360
|
+
}
|
|
361
|
+
if (lockingScript.length === 0 && !this.usesCompactManifest)
|
|
362
|
+
return undefined;
|
|
363
|
+
const digest = (0, actionBatchDigest_1.actionBatchBlobDigest)((0, utilityHelpers_noBuffer_1.asUint8Array)(lockingScript));
|
|
364
|
+
if (!this.usesCompactManifest)
|
|
365
|
+
this.lockingScripts.set(digest, lockingScript);
|
|
366
|
+
return digest;
|
|
367
|
+
});
|
|
368
|
+
const compactPlan = {
|
|
369
|
+
...prior.dcr,
|
|
370
|
+
inputBeef: undefined,
|
|
371
|
+
inputs: prior.dcr.inputs.map(input => ({
|
|
372
|
+
...input,
|
|
373
|
+
sourceLockingScript: this.usesCompactManifest ? undefined : input.sourceLockingScript,
|
|
374
|
+
sourceTransaction: undefined
|
|
375
|
+
})),
|
|
376
|
+
outputs: prior.dcr.outputs.map(output => ({ ...output, lockingScript: '' }))
|
|
377
|
+
};
|
|
378
|
+
const action = {
|
|
379
|
+
reference: prior.reference,
|
|
380
|
+
txid,
|
|
381
|
+
rawTxDigest,
|
|
382
|
+
lockingScriptDigests,
|
|
383
|
+
deriveLockingScripts: this.usesCompactManifest || undefined,
|
|
384
|
+
plan: compactPlan,
|
|
385
|
+
metadata: {
|
|
386
|
+
description: pending.args.description,
|
|
387
|
+
labels: pending.args.labels,
|
|
388
|
+
isNoSend: processArgs.isNoSend,
|
|
389
|
+
isDelayed: processArgs.isDelayed,
|
|
390
|
+
inputs: pending.args.inputs,
|
|
391
|
+
outputs: pending.args.outputs.map(output => ({ ...output, lockingScript: '' }))
|
|
392
|
+
},
|
|
393
|
+
commissionKeyOffset: pending.planned.commissionKeyOffset
|
|
394
|
+
};
|
|
395
|
+
this.actions.push(action);
|
|
396
|
+
this.updateEwma(pending);
|
|
397
|
+
(0, ActionBatchPlanner_1.stageTransactionOutputs)(this.state, prior.tx, prior.dcr);
|
|
398
|
+
(0, ActionBatchPlanner_1.mergePlannerBeef)(this.state, prior.tx);
|
|
399
|
+
this.queueEagerLogicalBlob(rawTxDigest, rawTx);
|
|
400
|
+
this.planned.delete(prior.reference);
|
|
401
|
+
this.scheduleExtensionIfNeeded();
|
|
402
|
+
}
|
|
403
|
+
physicalBlobs(logicalDigest, bytes) {
|
|
404
|
+
const packed = this.packedUploads;
|
|
405
|
+
const maxPhysicalBytes = packed == null
|
|
406
|
+
? this.capabilities.maxBlobBytes
|
|
407
|
+
: Math.min(this.capabilities.maxBlobBytes, Math.max(1, packed.maxPackBytes - (0, actionBatchPack_1.actionBatchPackLength)([{
|
|
408
|
+
digest: logicalDigest,
|
|
409
|
+
bytes: new Uint8Array()
|
|
410
|
+
}])));
|
|
411
|
+
if (bytes.length <= maxPhysicalBytes) {
|
|
412
|
+
return { blobs: [{ digest: logicalDigest, bytes }] };
|
|
413
|
+
}
|
|
414
|
+
const chunks = [];
|
|
415
|
+
const blobs = [];
|
|
416
|
+
for (let offset = 0; offset < bytes.length; offset += maxPhysicalBytes) {
|
|
417
|
+
const chunk = bytes.subarray(offset, Math.min(bytes.length, offset + maxPhysicalBytes));
|
|
418
|
+
const digest = (0, actionBatchDigest_1.actionBatchBlobDigest)(chunk);
|
|
419
|
+
chunks.push(digest);
|
|
420
|
+
blobs.push({ digest, bytes: chunk });
|
|
421
|
+
}
|
|
422
|
+
return { chunks, blobs };
|
|
423
|
+
}
|
|
424
|
+
queueEagerLogicalBlob(digest, bytes) {
|
|
425
|
+
const packed = this.packedUploads;
|
|
426
|
+
if (packed?.eager !== true || !this.usesCompactManifest)
|
|
427
|
+
return;
|
|
428
|
+
const physical = this.physicalBlobs(digest, bytes);
|
|
429
|
+
for (const blob of physical.blobs) {
|
|
430
|
+
if (this.eagerPending.has(blob.digest))
|
|
431
|
+
continue;
|
|
432
|
+
this.eagerPending.set(blob.digest, blob.bytes);
|
|
433
|
+
this.eagerLogicalBytes += blob.bytes.length;
|
|
434
|
+
}
|
|
435
|
+
if (this.eagerLogicalBytes > this.capabilities.maxInlineBytes) {
|
|
436
|
+
this.eagerEnabled = true;
|
|
437
|
+
this.flushEagerPacks(false);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
takePack(final) {
|
|
441
|
+
const packed = this.packedUploads;
|
|
442
|
+
if (packed == null || this.eagerPending.size === 0)
|
|
443
|
+
return [];
|
|
444
|
+
const items = [];
|
|
445
|
+
for (const [digest, bytes] of this.eagerPending) {
|
|
446
|
+
const candidate = [...items, { digest, bytes }];
|
|
447
|
+
if (candidate.length > packed.maxItems ||
|
|
448
|
+
(0, actionBatchPack_1.actionBatchPackLength)(candidate) > packed.maxPackBytes)
|
|
449
|
+
break;
|
|
450
|
+
items.push({ digest, bytes });
|
|
451
|
+
}
|
|
452
|
+
if (items.length === 0)
|
|
453
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION('action batch blob cannot fit provider pack');
|
|
454
|
+
const length = (0, actionBatchPack_1.actionBatchPackLength)(items);
|
|
455
|
+
if (!final && items.length === this.eagerPending.size &&
|
|
456
|
+
length < Math.floor(packed.maxPackBytes * 0.9))
|
|
457
|
+
return [];
|
|
458
|
+
for (const item of items)
|
|
459
|
+
this.eagerPending.delete(item.digest);
|
|
460
|
+
return items;
|
|
461
|
+
}
|
|
462
|
+
schedulePackUpload(items) {
|
|
463
|
+
const packed = this.packedUploads;
|
|
464
|
+
if (packed == null || items.length === 0)
|
|
465
|
+
return;
|
|
466
|
+
const lane = this.eagerUploadCursor++ % this.eagerUploadLanes.length;
|
|
467
|
+
this.eagerUploadLanes[lane] = this.eagerUploadLanes[lane]
|
|
468
|
+
.then(async () => {
|
|
469
|
+
await this.wallet.storage.putActionBatchPack({
|
|
470
|
+
batchId: this.batchId,
|
|
471
|
+
items,
|
|
472
|
+
maxPackBytes: packed.maxPackBytes,
|
|
473
|
+
maxItems: packed.maxItems,
|
|
474
|
+
preferredEncodings: packed.encodings
|
|
475
|
+
});
|
|
476
|
+
})
|
|
477
|
+
.catch(() => {
|
|
478
|
+
// Eager upload is speculative. Prepare remains the source of truth:
|
|
479
|
+
// anything this attempt did not persist is reported missing and
|
|
480
|
+
// retried through the ordinary final upload path.
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
async awaitEagerUploads() {
|
|
484
|
+
await Promise.all(this.eagerUploadLanes);
|
|
485
|
+
}
|
|
486
|
+
flushEagerPacks(final) {
|
|
487
|
+
if (!this.eagerEnabled)
|
|
488
|
+
return;
|
|
489
|
+
for (;;) {
|
|
490
|
+
const items = this.takePack(final);
|
|
491
|
+
if (items.length === 0)
|
|
492
|
+
return;
|
|
493
|
+
this.schedulePackUpload(items);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
scheduleExtensionIfNeeded() {
|
|
497
|
+
if (this.extension != null)
|
|
498
|
+
return;
|
|
499
|
+
const availableConfirmed = [...this.state.reserved.entries()]
|
|
500
|
+
.filter(([outpoint]) => !this.state.consumed.has(outpoint));
|
|
501
|
+
const request = fundingRunwayExtension(this.runwayTarget, this.ewmaConfirmedInputs, this.ewmaConfirmedSatoshis, availableConfirmed.map(([, output]) => output));
|
|
502
|
+
if (request == null)
|
|
503
|
+
return;
|
|
504
|
+
this.extension = this.extend(request.targetSatoshis, request.requestedOutputs, [], false)
|
|
505
|
+
.then(added => {
|
|
506
|
+
// A failed or partial extension must not geometrically inflate the
|
|
507
|
+
// next request against a runway that the wallet never acquired.
|
|
508
|
+
if (added.outputCount >= request.requestedOutputs &&
|
|
509
|
+
added.satoshis >= request.targetSatoshis) {
|
|
510
|
+
this.runwayTarget = request.nextRunwayTarget;
|
|
511
|
+
}
|
|
512
|
+
})
|
|
513
|
+
.catch(() => { })
|
|
514
|
+
.finally(() => { this.extension = undefined; });
|
|
515
|
+
}
|
|
516
|
+
addLockingScriptBlobs(blobs) {
|
|
517
|
+
if (this.usesCompactManifest)
|
|
518
|
+
return;
|
|
519
|
+
for (const [digest, script] of this.lockingScripts) {
|
|
520
|
+
if (!blobs.has(digest))
|
|
521
|
+
blobs.set(digest, (0, utilityHelpers_noBuffer_1.asUint8Array)(script));
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
preparePhysicalUploads(blobs) {
|
|
525
|
+
const uploadBlobs = new Map();
|
|
526
|
+
const blobChunks = {};
|
|
527
|
+
for (const [digest, bytes] of blobs) {
|
|
528
|
+
const physical = this.physicalBlobs(digest, bytes);
|
|
529
|
+
for (const blob of physical.blobs) {
|
|
530
|
+
if (!uploadBlobs.has(blob.digest))
|
|
531
|
+
uploadBlobs.set(blob.digest, blob.bytes);
|
|
532
|
+
}
|
|
533
|
+
if (physical.chunks != null)
|
|
534
|
+
blobChunks[digest] = physical.chunks;
|
|
535
|
+
}
|
|
536
|
+
return { uploadBlobs, blobChunks };
|
|
537
|
+
}
|
|
538
|
+
buildManifest(sendWith, isDelayed) {
|
|
539
|
+
const stagedTxids = new Set(this.actions.map(action => action.txid));
|
|
540
|
+
const externalTxids = this.actions.flatMap(action => action.plan.inputs)
|
|
541
|
+
.map(input => input.sourceTxid)
|
|
542
|
+
.filter(txid => !stagedTxids.has(txid));
|
|
543
|
+
const dependencyBytes = (0, beefForTxids_1.beefForTxids)(this.state.sharedBeef, externalTxids).toUint8Array();
|
|
544
|
+
const rawBytes = this.actions.map(action => {
|
|
545
|
+
const tx = this.state.sharedBeef.findTxid(action.txid)?.tx;
|
|
546
|
+
if (tx == null)
|
|
547
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`missing staged transaction ${action.txid}`);
|
|
548
|
+
return tx.toUint8Array();
|
|
549
|
+
});
|
|
550
|
+
const blobs = new Map();
|
|
551
|
+
const addBlob = (bytes) => {
|
|
552
|
+
const digest = (0, actionBatchDigest_1.actionBatchBlobDigest)(bytes);
|
|
553
|
+
if (!blobs.has(digest))
|
|
554
|
+
blobs.set(digest, bytes);
|
|
555
|
+
return digest;
|
|
556
|
+
};
|
|
557
|
+
const actions = this.actions.map((action, index) => ({
|
|
558
|
+
...action,
|
|
559
|
+
rawTx: undefined,
|
|
560
|
+
rawTxDigest: addBlob(rawBytes[index])
|
|
561
|
+
}));
|
|
562
|
+
const dependencyBeefDigest = addBlob(dependencyBytes);
|
|
563
|
+
this.addLockingScriptBlobs(blobs);
|
|
564
|
+
const totalBytes = [...blobs.values()].reduce((sum, bytes) => sum + bytes.length, 0);
|
|
565
|
+
const useUploads = totalBytes > this.capabilities.maxInlineBytes;
|
|
566
|
+
if (useUploads)
|
|
567
|
+
this.queueEagerLogicalBlob(dependencyBeefDigest, dependencyBytes);
|
|
568
|
+
const { uploadBlobs, blobChunks } = useUploads
|
|
569
|
+
? this.preparePhysicalUploads(blobs)
|
|
570
|
+
: { uploadBlobs: new Map(), blobChunks: {} };
|
|
571
|
+
const withoutDigest = {
|
|
572
|
+
format: this.usesCompactManifest ? 2 : undefined,
|
|
573
|
+
batchId: this.batchId,
|
|
574
|
+
actions,
|
|
575
|
+
dependencyBeefDigest,
|
|
576
|
+
inlineBlobs: useUploads
|
|
577
|
+
? undefined
|
|
578
|
+
: Object.fromEntries(blobs),
|
|
579
|
+
blobChunks: Object.keys(blobChunks).length === 0 ? undefined : blobChunks,
|
|
580
|
+
sendWith: mergeUnique(sendWith),
|
|
581
|
+
isDelayed
|
|
582
|
+
};
|
|
583
|
+
return {
|
|
584
|
+
manifest: { ...withoutDigest, digest: (0, actionBatchDigest_1.actionBatchManifestDigest)(withoutDigest) },
|
|
585
|
+
uploads: [...uploadBlobs].map(([digest, bytes]) => ({ digest, bytes }))
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
async uploadMissing(manifest, uploads) {
|
|
589
|
+
this.flushEagerPacks(true);
|
|
590
|
+
await this.awaitEagerUploads();
|
|
591
|
+
const prepared = await this.wallet.storage.prepareActionBatchCommit(manifest);
|
|
592
|
+
const missing = new Set(prepared.missingDigests);
|
|
593
|
+
const pending = uploads.filter(upload => missing.has(upload.digest));
|
|
594
|
+
const packed = this.packedUploads;
|
|
595
|
+
if (packed != null && manifest.format === 2) {
|
|
596
|
+
const packs = [];
|
|
597
|
+
let current = [];
|
|
598
|
+
for (const upload of pending) {
|
|
599
|
+
const candidate = [...current, upload];
|
|
600
|
+
if (current.length > 0 && (candidate.length > packed.maxItems ||
|
|
601
|
+
(0, actionBatchPack_1.actionBatchPackLength)(candidate) > packed.maxPackBytes)) {
|
|
602
|
+
packs.push(current);
|
|
603
|
+
current = [];
|
|
604
|
+
}
|
|
605
|
+
current.push(upload);
|
|
606
|
+
}
|
|
607
|
+
if (current.length > 0)
|
|
608
|
+
packs.push(current);
|
|
609
|
+
const concurrency = Math.max(1, Math.min(prepared.maxConcurrentUploads, this.capabilities.maxConcurrentUploads, packs.length));
|
|
610
|
+
let packCursor = 0;
|
|
611
|
+
await Promise.all(Array.from({ length: concurrency }, async () => {
|
|
612
|
+
for (;;) {
|
|
613
|
+
const pack = packs[packCursor++];
|
|
614
|
+
if (pack == null)
|
|
615
|
+
return;
|
|
616
|
+
await this.wallet.storage.putActionBatchPack({
|
|
617
|
+
batchId: this.batchId,
|
|
618
|
+
items: pack,
|
|
619
|
+
maxPackBytes: packed.maxPackBytes,
|
|
620
|
+
maxItems: packed.maxItems,
|
|
621
|
+
preferredEncodings: packed.encodings
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}));
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const concurrency = Math.max(1, Math.min(prepared.maxConcurrentUploads, this.capabilities.maxConcurrentUploads, pending.length));
|
|
628
|
+
let cursor = 0;
|
|
629
|
+
await Promise.all(Array.from({ length: concurrency }, async () => {
|
|
630
|
+
for (;;) {
|
|
631
|
+
const index = cursor++;
|
|
632
|
+
if (index >= pending.length)
|
|
633
|
+
return;
|
|
634
|
+
const upload = pending[index];
|
|
635
|
+
if (upload.bytes.length > prepared.maxBlobBytes) {
|
|
636
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`action batch blob ${upload.digest} exceeds provider limit`);
|
|
637
|
+
}
|
|
638
|
+
await this.wallet.storage.putActionBatchBlob({
|
|
639
|
+
batchId: this.batchId,
|
|
640
|
+
digest: upload.digest,
|
|
641
|
+
bytes: upload.bytes
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
}));
|
|
645
|
+
}
|
|
646
|
+
async commit(sendWith, isDelayed) {
|
|
647
|
+
if (this.extension != null)
|
|
648
|
+
await this.extension;
|
|
649
|
+
await this.renewIfNeeded();
|
|
650
|
+
if (this.planned.size > 0)
|
|
651
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION('all two-step actions must be signed before batch commit');
|
|
652
|
+
const { manifest, uploads } = this.buildManifest(sendWith, isDelayed);
|
|
653
|
+
if (uploads.length > 0)
|
|
654
|
+
await this.uploadMissing(manifest, uploads);
|
|
655
|
+
const result = uploads.length > 0 && manifest.format === 2 && this.capabilities.commitByDigest === true
|
|
656
|
+
? await this.wallet.storage.commitActionBatchByDigest({
|
|
657
|
+
batchId: manifest.batchId,
|
|
658
|
+
digest: manifest.digest
|
|
659
|
+
})
|
|
660
|
+
: await this.wallet.storage.commitActionBatch(manifest);
|
|
661
|
+
this.committed = true;
|
|
662
|
+
return result;
|
|
663
|
+
}
|
|
664
|
+
abortAction(referenceOrTxid) {
|
|
665
|
+
let pendingReference;
|
|
666
|
+
if (this.planned.has(referenceOrTxid)) {
|
|
667
|
+
pendingReference = referenceOrTxid;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
pendingReference = Object.entries(this.wallet.pendingSignActions)
|
|
671
|
+
.find(([reference, pending]) => this.planned.has(reference) && pending.tx.id('hex') === referenceOrTxid)?.[0];
|
|
672
|
+
}
|
|
673
|
+
const actionIndex = this.actions.findIndex(action => action.reference === referenceOrTxid || action.txid === referenceOrTxid);
|
|
674
|
+
const action = actionIndex < 0 ? undefined : this.actions[actionIndex];
|
|
675
|
+
const targetTxid = action?.txid ??
|
|
676
|
+
(pendingReference == null ? undefined : this.wallet.pendingSignActions[pendingReference]?.tx.id('hex'));
|
|
677
|
+
if (targetTxid != null && this.hasDependentAction(targetTxid, action?.reference ?? pendingReference)) {
|
|
678
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`cannot abort action ${referenceOrTxid} while another staged action depends on it`);
|
|
679
|
+
}
|
|
680
|
+
if (action != null) {
|
|
681
|
+
this.actions.splice(actionIndex, 1);
|
|
682
|
+
}
|
|
683
|
+
else if (pendingReference != null) {
|
|
684
|
+
this.planned.delete(pendingReference);
|
|
685
|
+
Reflect.deleteProperty(this.wallet.pendingSignActions, pendingReference);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
if (targetTxid != null)
|
|
691
|
+
this.state.discardedStagedTxids.add(targetTxid);
|
|
692
|
+
this.rebuildStagedState();
|
|
693
|
+
return true;
|
|
694
|
+
}
|
|
695
|
+
hasDependentAction(txid, excludedReference) {
|
|
696
|
+
if (this.actions.some(action => action.reference !== excludedReference &&
|
|
697
|
+
action.plan.inputs.some(input => input.sourceTxid === txid)))
|
|
698
|
+
return true;
|
|
699
|
+
return [...this.planned.entries()].some(([reference, pending]) => reference !== excludedReference &&
|
|
700
|
+
pending.planned.dcr.inputs.some(input => input.sourceTxid === txid));
|
|
701
|
+
}
|
|
702
|
+
rebuildStagedState() {
|
|
703
|
+
this.state.consumed.clear();
|
|
704
|
+
this.state.staged.clear();
|
|
705
|
+
this.state.estimatedChangeCount = this.state.begin.availableChangeCount;
|
|
706
|
+
this.lockingScripts.clear();
|
|
707
|
+
for (const action of this.actions) {
|
|
708
|
+
const tx = this.state.sharedBeef.findTxid(action.txid)?.tx;
|
|
709
|
+
if (tx == null)
|
|
710
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`missing staged transaction ${action.txid}`);
|
|
711
|
+
for (const input of action.plan.inputs) {
|
|
712
|
+
this.state.consumed.add(`${input.sourceTxid}.${input.sourceVout}`);
|
|
713
|
+
}
|
|
714
|
+
const managedInputCount = action.plan.inputs.length - action.metadata.inputs.length;
|
|
715
|
+
const changeOutputCount = action.plan.outputs.filter(output => output.purpose === 'change').length;
|
|
716
|
+
this.state.estimatedChangeCount += changeOutputCount - managedInputCount;
|
|
717
|
+
(0, ActionBatchPlanner_1.stageTransactionOutputs)(this.state, tx, action.plan);
|
|
718
|
+
const lockingScriptDigests = action.lockingScriptDigests ?? [];
|
|
719
|
+
lockingScriptDigests.forEach((digest, outputIndex) => {
|
|
720
|
+
if (digest == null)
|
|
721
|
+
return;
|
|
722
|
+
const vout = action.plan.outputs[outputIndex]?.vout;
|
|
723
|
+
const script = vout == null ? undefined : tx.outputs[vout]?.lockingScript;
|
|
724
|
+
if (script == null)
|
|
725
|
+
throw new WERR_errors_1.WERR_INVALID_OPERATION(`missing staged output script for ${action.txid}.${vout}`);
|
|
726
|
+
if (!this.usesCompactManifest)
|
|
727
|
+
this.lockingScripts.set(digest, script.toHex());
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
for (const pending of this.planned.values()) {
|
|
731
|
+
for (const outpoint of pending.planned.consumedOutpoints)
|
|
732
|
+
this.state.consumed.add(outpoint);
|
|
733
|
+
const managedInputCount = pending.planned.dcr.inputs.length - pending.args.inputs.length;
|
|
734
|
+
const changeOutputCount = pending.planned.dcr.outputs.filter(output => output.purpose === 'change').length;
|
|
735
|
+
this.state.estimatedChangeCount += changeOutputCount - managedInputCount;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
async abort() {
|
|
739
|
+
if (this.committed)
|
|
740
|
+
return;
|
|
741
|
+
await this.awaitEagerUploads();
|
|
742
|
+
await this.wallet.storage.abortActionBatch(this.batchId);
|
|
743
|
+
for (const reference of this.planned.keys())
|
|
744
|
+
delete this.wallet.pendingSignActions[reference];
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
class ActionBatchController {
|
|
748
|
+
wallet;
|
|
749
|
+
mode;
|
|
750
|
+
workspace;
|
|
751
|
+
capabilities = new Map();
|
|
752
|
+
serial = Promise.resolve();
|
|
753
|
+
constructor(wallet, mode) {
|
|
754
|
+
this.wallet = wallet;
|
|
755
|
+
this.mode = mode;
|
|
756
|
+
}
|
|
757
|
+
get hasWorkspace() { return this.workspace != null; }
|
|
758
|
+
overlayListActions(persisted, args) {
|
|
759
|
+
return this.workspace?.overlayListActions(persisted, args) ?? persisted;
|
|
760
|
+
}
|
|
761
|
+
overlayListOutputs(persisted, args) {
|
|
762
|
+
return this.workspace?.overlayListOutputs(persisted, args) ?? persisted;
|
|
763
|
+
}
|
|
764
|
+
async runExclusive(operation) {
|
|
765
|
+
const run = this.serial.then(operation);
|
|
766
|
+
this.serial = run.then(() => { }, () => { });
|
|
767
|
+
return await run;
|
|
768
|
+
}
|
|
769
|
+
async negotiate() {
|
|
770
|
+
if (this.mode === 'legacy')
|
|
771
|
+
return undefined;
|
|
772
|
+
const activeStore = this.wallet.storage.getActiveStore();
|
|
773
|
+
let capabilities = this.capabilities.get(activeStore);
|
|
774
|
+
if (capabilities == null) {
|
|
775
|
+
capabilities = this.wallet.storage.getCapabilities()
|
|
776
|
+
.then(result => result.actionBatch?.version === 1 ? result.actionBatch : undefined)
|
|
777
|
+
.catch(() => undefined);
|
|
778
|
+
this.capabilities.set(activeStore, capabilities);
|
|
779
|
+
}
|
|
780
|
+
return await capabilities;
|
|
781
|
+
}
|
|
782
|
+
async begin(args) {
|
|
783
|
+
if (args.inputs.length > 8)
|
|
784
|
+
return undefined;
|
|
785
|
+
const capabilities = await this.negotiate();
|
|
786
|
+
if (capabilities == null)
|
|
787
|
+
return undefined;
|
|
788
|
+
const batchId = (0, utilityHelpers_1.randomBytesBase64)(24);
|
|
789
|
+
const bootstrap = (0, actionBatchBootstrap_1.actionBatchBootstrap)(args, capabilities);
|
|
790
|
+
const begin = await this.wallet.storage.beginActionBatch({ ...bootstrap, batchId });
|
|
791
|
+
this.workspace = new ActionBatchWorkspace(this.wallet, begin, args, capabilities);
|
|
792
|
+
return this.workspace;
|
|
793
|
+
}
|
|
794
|
+
async plan(args) {
|
|
795
|
+
return await this.runExclusive(async () => {
|
|
796
|
+
if (!args.isNewTx)
|
|
797
|
+
return undefined;
|
|
798
|
+
let workspace = this.workspace;
|
|
799
|
+
let beganWorkspace = false;
|
|
800
|
+
if (workspace == null) {
|
|
801
|
+
if (!args.isNoSend)
|
|
802
|
+
return undefined;
|
|
803
|
+
workspace = await this.begin(args);
|
|
804
|
+
if (workspace == null)
|
|
805
|
+
return undefined;
|
|
806
|
+
beganWorkspace = true;
|
|
807
|
+
}
|
|
808
|
+
try {
|
|
809
|
+
return await workspace.plan(args);
|
|
810
|
+
}
|
|
811
|
+
catch (error) {
|
|
812
|
+
if (beganWorkspace) {
|
|
813
|
+
await workspace.abort();
|
|
814
|
+
this.workspace = undefined;
|
|
815
|
+
}
|
|
816
|
+
throw error;
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
async process(prior, args) {
|
|
821
|
+
return await this.runExclusive(async () => {
|
|
822
|
+
const workspace = this.workspace;
|
|
823
|
+
if (workspace == null)
|
|
824
|
+
return undefined;
|
|
825
|
+
if (prior != null && !workspace.ownsReference(prior.reference))
|
|
826
|
+
return undefined;
|
|
827
|
+
if (prior != null)
|
|
828
|
+
workspace.stage(prior, args);
|
|
829
|
+
const shouldCommit = args.isSendWith || (prior != null && !args.isNoSend);
|
|
830
|
+
if (!shouldCommit)
|
|
831
|
+
return { sendWithResults: [] };
|
|
832
|
+
const sendWith = [...args.options.sendWith];
|
|
833
|
+
if (prior != null && !args.isNoSend && !sendWith.includes(prior.tx.id('hex')))
|
|
834
|
+
sendWith.push(prior.tx.id('hex'));
|
|
835
|
+
const result = await workspace.commit(sendWith, args.isDelayed);
|
|
836
|
+
this.workspace = undefined;
|
|
837
|
+
return result;
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
ownsReference(reference) {
|
|
841
|
+
return this.workspace?.ownsReference(reference) ?? false;
|
|
842
|
+
}
|
|
843
|
+
async abort() {
|
|
844
|
+
return await this.runExclusive(async () => {
|
|
845
|
+
if (this.workspace == null)
|
|
846
|
+
return false;
|
|
847
|
+
await this.workspace.abort();
|
|
848
|
+
this.workspace = undefined;
|
|
849
|
+
return true;
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
async abortAction(referenceOrTxid) {
|
|
853
|
+
return await this.runExclusive(async () => {
|
|
854
|
+
const workspace = this.workspace;
|
|
855
|
+
if (workspace == null)
|
|
856
|
+
return false;
|
|
857
|
+
const aborted = workspace.abortAction(referenceOrTxid);
|
|
858
|
+
if (!aborted)
|
|
859
|
+
return false;
|
|
860
|
+
if (workspace.isEmpty) {
|
|
861
|
+
await workspace.abort();
|
|
862
|
+
this.workspace = undefined;
|
|
863
|
+
}
|
|
864
|
+
return true;
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
exports.ActionBatchController = ActionBatchController;
|
|
869
|
+
//# sourceMappingURL=ActionBatchWorkspace.js.map
|