@bsv/wallet-toolbox 1.3.21 → 1.3.23
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/mobile/out/src/CWIStyleWalletManager.d.ts +437 -0
- package/mobile/out/src/CWIStyleWalletManager.d.ts.map +1 -0
- package/mobile/out/src/CWIStyleWalletManager.js +1255 -0
- package/mobile/out/src/CWIStyleWalletManager.js.map +1 -0
- package/mobile/out/src/SetupClient.d.ts +126 -0
- package/mobile/out/src/SetupClient.d.ts.map +1 -0
- package/mobile/out/src/SetupClient.js +220 -0
- package/mobile/out/src/SetupClient.js.map +1 -0
- package/mobile/out/src/SetupWallet.d.ts +100 -0
- package/mobile/out/src/SetupWallet.d.ts.map +1 -0
- package/mobile/out/src/SetupWallet.js +3 -0
- package/mobile/out/src/SetupWallet.js.map +1 -0
- package/mobile/out/src/SimpleWalletManager.d.ts +169 -0
- package/mobile/out/src/SimpleWalletManager.d.ts.map +1 -0
- package/mobile/out/src/SimpleWalletManager.js +315 -0
- package/mobile/out/src/SimpleWalletManager.js.map +1 -0
- package/mobile/out/src/Wallet.d.ts +177 -0
- package/mobile/out/src/Wallet.d.ts.map +1 -0
- package/mobile/out/src/Wallet.js +742 -0
- package/mobile/out/src/Wallet.js.map +1 -0
- package/mobile/out/src/WalletAuthenticationManager.d.ts +33 -0
- package/mobile/out/src/WalletAuthenticationManager.d.ts.map +1 -0
- package/mobile/out/src/WalletAuthenticationManager.js +113 -0
- package/mobile/out/src/WalletAuthenticationManager.js.map +1 -0
- package/mobile/out/src/WalletPermissionsManager.d.ts +598 -0
- package/mobile/out/src/WalletPermissionsManager.d.ts.map +1 -0
- package/mobile/out/src/WalletPermissionsManager.js +1868 -0
- package/mobile/out/src/WalletPermissionsManager.js.map +1 -0
- package/mobile/out/src/WalletSettingsManager.d.ts +52 -0
- package/mobile/out/src/WalletSettingsManager.d.ts.map +1 -0
- package/mobile/out/src/WalletSettingsManager.js +82 -0
- package/mobile/out/src/WalletSettingsManager.js.map +1 -0
- package/mobile/out/src/index.client.d.ts +19 -0
- package/mobile/out/src/index.client.d.ts.map +1 -0
- package/mobile/out/src/index.client.js +58 -0
- package/mobile/out/src/index.client.js.map +1 -0
- package/mobile/out/src/index.mobile.d.ts +17 -0
- package/mobile/out/src/index.mobile.d.ts.map +1 -0
- package/mobile/out/src/index.mobile.js +56 -0
- package/mobile/out/src/index.mobile.js.map +1 -0
- package/mobile/out/src/monitor/Monitor.d.ts +91 -0
- package/mobile/out/src/monitor/Monitor.d.ts.map +1 -0
- package/mobile/out/src/monitor/Monitor.js +298 -0
- package/mobile/out/src/monitor/Monitor.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskCheckForProofs.d.ts +53 -0
- package/mobile/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskCheckForProofs.js +194 -0
- package/mobile/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskCheckNoSends.d.ts +33 -0
- package/mobile/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskCheckNoSends.js +65 -0
- package/mobile/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskClock.d.ts +14 -0
- package/mobile/out/src/monitor/tasks/TaskClock.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskClock.js +27 -0
- package/mobile/out/src/monitor/tasks/TaskClock.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskFailAbandoned.d.ts +20 -0
- package/mobile/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskFailAbandoned.js +52 -0
- package/mobile/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskNewHeader.d.ts +15 -0
- package/mobile/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskNewHeader.js +43 -0
- package/mobile/out/src/monitor/tasks/TaskNewHeader.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskPurge.d.ts +45 -0
- package/mobile/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskPurge.js +34 -0
- package/mobile/out/src/monitor/tasks/TaskPurge.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskReviewStatus.d.ts +26 -0
- package/mobile/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskReviewStatus.js +43 -0
- package/mobile/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskSendWaiting.d.ts +35 -0
- package/mobile/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskSendWaiting.js +107 -0
- package/mobile/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts +12 -0
- package/mobile/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskSyncWhenIdle.js +22 -0
- package/mobile/out/src/monitor/tasks/TaskSyncWhenIdle.js.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskUnFail.d.ts +41 -0
- package/mobile/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/TaskUnFail.js +144 -0
- package/mobile/out/src/monitor/tasks/TaskUnFail.js.map +1 -0
- package/mobile/out/src/monitor/tasks/WalletMonitorTask.d.ts +40 -0
- package/mobile/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -0
- package/mobile/out/src/monitor/tasks/WalletMonitorTask.js +37 -0
- package/mobile/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -0
- package/mobile/out/src/sdk/CertOpsWallet.d.ts +7 -0
- package/mobile/out/src/sdk/CertOpsWallet.d.ts.map +1 -0
- package/mobile/out/src/sdk/CertOpsWallet.js +3 -0
- package/mobile/out/src/sdk/CertOpsWallet.js.map +1 -0
- package/mobile/out/src/sdk/PrivilegedKeyManager.d.ts +125 -0
- package/mobile/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -0
- package/mobile/out/src/sdk/PrivilegedKeyManager.js +293 -0
- package/mobile/out/src/sdk/PrivilegedKeyManager.js.map +1 -0
- package/mobile/out/src/sdk/WERR_errors.d.ts +115 -0
- package/mobile/out/src/sdk/WERR_errors.d.ts.map +1 -0
- package/mobile/out/src/sdk/WERR_errors.js +158 -0
- package/mobile/out/src/sdk/WERR_errors.js.map +1 -0
- package/mobile/out/src/sdk/WalletError.d.ts +44 -0
- package/mobile/out/src/sdk/WalletError.d.ts.map +1 -0
- package/mobile/out/src/sdk/WalletError.js +118 -0
- package/mobile/out/src/sdk/WalletError.js.map +1 -0
- package/mobile/out/src/sdk/WalletServices.interfaces.d.ts +430 -0
- package/mobile/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -0
- package/mobile/out/src/sdk/WalletServices.interfaces.js +3 -0
- package/mobile/out/src/sdk/WalletServices.interfaces.js.map +1 -0
- package/mobile/out/src/sdk/WalletSigner.interfaces.d.ts +10 -0
- package/mobile/out/src/sdk/WalletSigner.interfaces.d.ts.map +1 -0
- package/mobile/out/src/sdk/WalletSigner.interfaces.js +3 -0
- package/mobile/out/src/sdk/WalletSigner.interfaces.js.map +1 -0
- package/mobile/out/src/sdk/WalletStorage.interfaces.d.ts +452 -0
- package/mobile/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -0
- package/mobile/out/src/sdk/WalletStorage.interfaces.js +3 -0
- package/mobile/out/src/sdk/WalletStorage.interfaces.js.map +1 -0
- package/mobile/out/src/sdk/index.d.ts +10 -0
- package/mobile/out/src/sdk/index.d.ts.map +1 -0
- package/mobile/out/src/sdk/index.js +26 -0
- package/mobile/out/src/sdk/index.js.map +1 -0
- package/mobile/out/src/sdk/types.d.ts +158 -0
- package/mobile/out/src/sdk/types.d.ts.map +1 -0
- package/mobile/out/src/sdk/types.js +90 -0
- package/mobile/out/src/sdk/types.js.map +1 -0
- package/mobile/out/src/sdk/validationHelpers.d.ts +301 -0
- package/mobile/out/src/sdk/validationHelpers.d.ts.map +1 -0
- package/mobile/out/src/sdk/validationHelpers.js +629 -0
- package/mobile/out/src/sdk/validationHelpers.js.map +1 -0
- package/mobile/out/src/services/ServiceCollection.d.ts +25 -0
- package/mobile/out/src/services/ServiceCollection.d.ts.map +1 -0
- package/mobile/out/src/services/ServiceCollection.js +43 -0
- package/mobile/out/src/services/ServiceCollection.js.map +1 -0
- package/mobile/out/src/services/Services.d.ts +67 -0
- package/mobile/out/src/services/Services.d.ts.map +1 -0
- package/mobile/out/src/services/Services.js +391 -0
- package/mobile/out/src/services/Services.js.map +1 -0
- package/mobile/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +15 -0
- package/mobile/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -0
- package/mobile/out/src/services/chaintracker/ChaintracksChainTracker.js +51 -0
- package/mobile/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts +98 -0
- package/mobile/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js +38 -0
- package/mobile/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +36 -0
- package/mobile/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +128 -0
- package/mobile/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/index.d.ts +3 -0
- package/mobile/out/src/services/chaintracker/chaintracks/index.d.ts.map +1 -0
- package/mobile/out/src/services/chaintracker/chaintracks/index.js +19 -0
- package/mobile/out/src/services/chaintracker/chaintracks/index.js.map +1 -0
- package/mobile/out/src/services/chaintracker/index.d.ts +3 -0
- package/mobile/out/src/services/chaintracker/index.d.ts.map +1 -0
- package/mobile/out/src/services/chaintracker/index.js +19 -0
- package/mobile/out/src/services/chaintracker/index.js.map +1 -0
- package/mobile/out/src/services/createDefaultWalletServicesOptions.d.ts +4 -0
- package/mobile/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -0
- package/mobile/out/src/services/createDefaultWalletServicesOptions.js +46 -0
- package/mobile/out/src/services/createDefaultWalletServicesOptions.js.map +1 -0
- package/mobile/out/src/services/index.d.ts +2 -0
- package/mobile/out/src/services/index.d.ts.map +1 -0
- package/mobile/out/src/services/index.js +18 -0
- package/mobile/out/src/services/index.js.map +1 -0
- package/mobile/out/src/services/providers/ARC.d.ts +91 -0
- package/mobile/out/src/services/providers/ARC.d.ts.map +1 -0
- package/mobile/out/src/services/providers/ARC.js +267 -0
- package/mobile/out/src/services/providers/ARC.js.map +1 -0
- package/mobile/out/src/services/providers/Bitails.d.ts +49 -0
- package/mobile/out/src/services/providers/Bitails.d.ts.map +1 -0
- package/mobile/out/src/services/providers/Bitails.js +222 -0
- package/mobile/out/src/services/providers/Bitails.js.map +1 -0
- package/mobile/out/src/services/providers/SdkWhatsOnChain.d.ts +21 -0
- package/mobile/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -0
- package/mobile/out/src/services/providers/SdkWhatsOnChain.js +67 -0
- package/mobile/out/src/services/providers/SdkWhatsOnChain.js.map +1 -0
- package/mobile/out/src/services/providers/WhatsOnChain.d.ts +71 -0
- package/mobile/out/src/services/providers/WhatsOnChain.d.ts.map +1 -0
- package/mobile/out/src/services/providers/WhatsOnChain.js +582 -0
- package/mobile/out/src/services/providers/WhatsOnChain.js.map +1 -0
- package/mobile/out/src/services/providers/echangeRates.d.ts +12 -0
- package/mobile/out/src/services/providers/echangeRates.d.ts.map +1 -0
- package/mobile/out/src/services/providers/echangeRates.js +237 -0
- package/mobile/out/src/services/providers/echangeRates.js.map +1 -0
- package/mobile/out/src/services/providers/getBeefForTxid.d.ts +4 -0
- package/mobile/out/src/services/providers/getBeefForTxid.d.ts.map +1 -0
- package/mobile/out/src/services/providers/getBeefForTxid.js +286 -0
- package/mobile/out/src/services/providers/getBeefForTxid.js.map +1 -0
- package/mobile/out/src/signer/WalletSigner.d.ts +11 -0
- package/mobile/out/src/signer/WalletSigner.d.ts.map +1 -0
- package/mobile/out/src/signer/WalletSigner.js +13 -0
- package/mobile/out/src/signer/WalletSigner.js.map +1 -0
- package/mobile/out/src/signer/methods/acquireDirectCertificate.d.ts +4 -0
- package/mobile/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -0
- package/mobile/out/src/signer/methods/acquireDirectCertificate.js +45 -0
- package/mobile/out/src/signer/methods/acquireDirectCertificate.js.map +1 -0
- package/mobile/out/src/signer/methods/buildSignableTransaction.d.ts +10 -0
- package/mobile/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -0
- package/mobile/out/src/signer/methods/buildSignableTransaction.js +126 -0
- package/mobile/out/src/signer/methods/buildSignableTransaction.js.map +1 -0
- package/mobile/out/src/signer/methods/createAction.d.ts +20 -0
- package/mobile/out/src/signer/methods/createAction.d.ts.map +1 -0
- package/mobile/out/src/signer/methods/createAction.js +160 -0
- package/mobile/out/src/signer/methods/createAction.js.map +1 -0
- package/mobile/out/src/signer/methods/internalizeAction.d.ts +31 -0
- package/mobile/out/src/signer/methods/internalizeAction.d.ts.map +1 -0
- package/mobile/out/src/signer/methods/internalizeAction.js +95 -0
- package/mobile/out/src/signer/methods/internalizeAction.js.map +1 -0
- package/mobile/out/src/signer/methods/proveCertificate.d.ts +4 -0
- package/mobile/out/src/signer/methods/proveCertificate.d.ts.map +1 -0
- package/mobile/out/src/signer/methods/proveCertificate.js +29 -0
- package/mobile/out/src/signer/methods/proveCertificate.js.map +1 -0
- package/mobile/out/src/signer/methods/signAction.d.ts +13 -0
- package/mobile/out/src/signer/methods/signAction.d.ts.map +1 -0
- package/mobile/out/src/signer/methods/signAction.js +89 -0
- package/mobile/out/src/signer/methods/signAction.js.map +1 -0
- package/mobile/out/src/storage/StorageIdb.d.ts +209 -0
- package/mobile/out/src/storage/StorageIdb.d.ts.map +1 -0
- package/mobile/out/src/storage/StorageIdb.js +2330 -0
- package/mobile/out/src/storage/StorageIdb.js.map +1 -0
- package/mobile/out/src/storage/StorageProvider.d.ts +210 -0
- package/mobile/out/src/storage/StorageProvider.d.ts.map +1 -0
- package/mobile/out/src/storage/StorageProvider.js +585 -0
- package/mobile/out/src/storage/StorageProvider.js.map +1 -0
- package/mobile/out/src/storage/StorageReader.d.ts +77 -0
- package/mobile/out/src/storage/StorageReader.d.ts.map +1 -0
- package/mobile/out/src/storage/StorageReader.js +163 -0
- package/mobile/out/src/storage/StorageReader.js.map +1 -0
- package/mobile/out/src/storage/StorageReaderWriter.d.ts +88 -0
- package/mobile/out/src/storage/StorageReaderWriter.d.ts.map +1 -0
- package/mobile/out/src/storage/StorageReaderWriter.js +338 -0
- package/mobile/out/src/storage/StorageReaderWriter.js.map +1 -0
- package/mobile/out/src/storage/StorageSyncReader.d.ts +18 -0
- package/mobile/out/src/storage/StorageSyncReader.d.ts.map +1 -0
- package/mobile/out/src/storage/StorageSyncReader.js +71 -0
- package/mobile/out/src/storage/StorageSyncReader.js.map +1 -0
- package/mobile/out/src/storage/WalletStorageManager.d.ts +184 -0
- package/mobile/out/src/storage/WalletStorageManager.d.ts.map +1 -0
- package/mobile/out/src/storage/WalletStorageManager.js +665 -0
- package/mobile/out/src/storage/WalletStorageManager.js.map +1 -0
- package/mobile/out/src/storage/index.client.d.ts +8 -0
- package/mobile/out/src/storage/index.client.d.ts.map +1 -0
- package/mobile/out/src/storage/index.client.js +24 -0
- package/mobile/out/src/storage/index.client.js.map +1 -0
- package/mobile/out/src/storage/index.mobile.d.ts +7 -0
- package/mobile/out/src/storage/index.mobile.d.ts.map +1 -0
- package/mobile/out/src/storage/index.mobile.js +23 -0
- package/mobile/out/src/storage/index.mobile.js.map +1 -0
- package/mobile/out/src/storage/methods/ListActionsSpecOp.d.ts +16 -0
- package/mobile/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/ListActionsSpecOp.js +40 -0
- package/mobile/out/src/storage/methods/ListActionsSpecOp.js.map +1 -0
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.d.ts +26 -0
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.js +71 -0
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -0
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +41 -0
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.js +320 -0
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -0
- package/mobile/out/src/storage/methods/createAction.d.ts +24 -0
- package/mobile/out/src/storage/methods/createAction.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/createAction.js +705 -0
- package/mobile/out/src/storage/methods/createAction.js.map +1 -0
- package/mobile/out/src/storage/methods/generateChange.d.ts +119 -0
- package/mobile/out/src/storage/methods/generateChange.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/generateChange.js +448 -0
- package/mobile/out/src/storage/methods/generateChange.js.map +1 -0
- package/mobile/out/src/storage/methods/getBeefForTransaction.d.ts +22 -0
- package/mobile/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/getBeefForTransaction.js +92 -0
- package/mobile/out/src/storage/methods/getBeefForTransaction.js.map +1 -0
- package/mobile/out/src/storage/methods/getSyncChunk.d.ts +10 -0
- package/mobile/out/src/storage/methods/getSyncChunk.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/getSyncChunk.js +271 -0
- package/mobile/out/src/storage/methods/getSyncChunk.js.map +1 -0
- package/mobile/out/src/storage/methods/internalizeAction.d.ts +38 -0
- package/mobile/out/src/storage/methods/internalizeAction.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/internalizeAction.js +371 -0
- package/mobile/out/src/storage/methods/internalizeAction.js.map +1 -0
- package/mobile/out/src/storage/methods/listActionsIdb.d.ts +5 -0
- package/mobile/out/src/storage/methods/listActionsIdb.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/listActionsIdb.js +155 -0
- package/mobile/out/src/storage/methods/listActionsIdb.js.map +1 -0
- package/mobile/out/src/storage/methods/listCertificates.d.ts +5 -0
- package/mobile/out/src/storage/methods/listCertificates.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/listCertificates.js +68 -0
- package/mobile/out/src/storage/methods/listCertificates.js.map +1 -0
- package/mobile/out/src/storage/methods/listOutputsIdb.d.ts +5 -0
- package/mobile/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/listOutputsIdb.js +181 -0
- package/mobile/out/src/storage/methods/listOutputsIdb.js.map +1 -0
- package/mobile/out/src/storage/methods/processAction.d.ts +35 -0
- package/mobile/out/src/storage/methods/processAction.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/processAction.js +311 -0
- package/mobile/out/src/storage/methods/processAction.js.map +1 -0
- package/mobile/out/src/storage/methods/purgeDataIdb.d.ts +4 -0
- package/mobile/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/purgeDataIdb.js +9 -0
- package/mobile/out/src/storage/methods/purgeDataIdb.js.map +1 -0
- package/mobile/out/src/storage/methods/reviewStatusIdb.d.ts +20 -0
- package/mobile/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -0
- package/mobile/out/src/storage/methods/reviewStatusIdb.js +35 -0
- package/mobile/out/src/storage/methods/reviewStatusIdb.js.map +1 -0
- package/mobile/out/src/storage/remoting/StorageClient.d.ts +283 -0
- package/mobile/out/src/storage/remoting/StorageClient.d.ts.map +1 -0
- package/mobile/out/src/storage/remoting/StorageClient.js +477 -0
- package/mobile/out/src/storage/remoting/StorageClient.js.map +1 -0
- package/mobile/out/src/storage/remoting/StorageMobile.d.ts +283 -0
- package/mobile/out/src/storage/remoting/StorageMobile.d.ts.map +1 -0
- package/mobile/out/src/storage/remoting/StorageMobile.js +477 -0
- package/mobile/out/src/storage/remoting/StorageMobile.js.map +1 -0
- package/mobile/out/src/storage/schema/StorageIdbSchema.d.ts +133 -0
- package/mobile/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/StorageIdbSchema.js +3 -0
- package/mobile/out/src/storage/schema/StorageIdbSchema.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityBase.d.ts +105 -0
- package/mobile/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityBase.js +100 -0
- package/mobile/out/src/storage/schema/entities/EntityBase.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificate.d.ts +43 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificate.js +162 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificate.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificateField.d.ts +32 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificateField.js +111 -0
- package/mobile/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityCommission.d.ts +37 -0
- package/mobile/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityCommission.js +127 -0
- package/mobile/out/src/storage/schema/entities/EntityCommission.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutput.d.ts +67 -0
- package/mobile/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutput.js +264 -0
- package/mobile/out/src/storage/schema/entities/EntityOutput.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputBasket.d.ts +35 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputBasket.js +133 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTag.d.ts +31 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTag.js +104 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTagMap.d.ts +28 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTagMap.js +97 -0
- package/mobile/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTx.d.ts +84 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTx.js +276 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +135 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTxReq.js +522 -0
- package/mobile/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntitySyncState.d.ts +67 -0
- package/mobile/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntitySyncState.js +319 -0
- package/mobile/out/src/storage/schema/entities/EntitySyncState.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityTransaction.d.ts +67 -0
- package/mobile/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityTransaction.js +255 -0
- package/mobile/out/src/storage/schema/entities/EntityTransaction.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabel.d.ts +31 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabel.js +104 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabelMap.d.ts +28 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabelMap.js +97 -0
- package/mobile/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityUser.d.ts +29 -0
- package/mobile/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/EntityUser.js +98 -0
- package/mobile/out/src/storage/schema/entities/EntityUser.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/MergeEntity.d.ts +33 -0
- package/mobile/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/MergeEntity.js +62 -0
- package/mobile/out/src/storage/schema/entities/MergeEntity.js.map +1 -0
- package/mobile/out/src/storage/schema/entities/index.d.ts +17 -0
- package/mobile/out/src/storage/schema/entities/index.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/entities/index.js +33 -0
- package/mobile/out/src/storage/schema/entities/index.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableCertificate.d.ts +20 -0
- package/mobile/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableCertificate.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableCertificate.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableCertificateField.d.ts +12 -0
- package/mobile/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableCertificateField.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableCertificateField.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableCommission.d.ts +13 -0
- package/mobile/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableCommission.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableCommission.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableMonitorEvent.d.ts +9 -0
- package/mobile/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableMonitorEvent.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableMonitorEvent.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutput.d.ts +36 -0
- package/mobile/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutput.js +31 -0
- package/mobile/out/src/storage/schema/tables/TableOutput.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutputBasket.d.ts +12 -0
- package/mobile/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutputBasket.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableOutputBasket.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTag.d.ts +10 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTag.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTag.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTagMap.d.ts +9 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTagMap.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableOutputTagMap.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTx.d.ts +14 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTx.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTx.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTxReq.d.ts +64 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTxReq.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableProvenTxReq.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableSettings.d.ts +17 -0
- package/mobile/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableSettings.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableSettings.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableSyncState.d.ts +18 -0
- package/mobile/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableSyncState.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableSyncState.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableTransaction.d.ts +37 -0
- package/mobile/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableTransaction.js +21 -0
- package/mobile/out/src/storage/schema/tables/TableTransaction.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabel.d.ts +10 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabel.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabel.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabelMap.d.ts +9 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabelMap.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableTxLabelMap.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableUser.d.ts +16 -0
- package/mobile/out/src/storage/schema/tables/TableUser.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/TableUser.js +3 -0
- package/mobile/out/src/storage/schema/tables/TableUser.js.map +1 -0
- package/mobile/out/src/storage/schema/tables/index.d.ts +17 -0
- package/mobile/out/src/storage/schema/tables/index.d.ts.map +1 -0
- package/mobile/out/src/storage/schema/tables/index.js +33 -0
- package/mobile/out/src/storage/schema/tables/index.js.map +1 -0
- package/mobile/out/src/utility/ScriptTemplateBRC29.d.ts +25 -0
- package/mobile/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -0
- package/mobile/out/src/utility/ScriptTemplateBRC29.js +48 -0
- package/mobile/out/src/utility/ScriptTemplateBRC29.js.map +1 -0
- package/mobile/out/src/utility/identityUtils.d.ts +31 -0
- package/mobile/out/src/utility/identityUtils.d.ts.map +1 -0
- package/mobile/out/src/utility/identityUtils.js +116 -0
- package/mobile/out/src/utility/identityUtils.js.map +1 -0
- package/mobile/out/src/utility/index.client.d.ts +7 -0
- package/mobile/out/src/utility/index.client.d.ts.map +1 -0
- package/mobile/out/src/utility/index.client.js +23 -0
- package/mobile/out/src/utility/index.client.js.map +1 -0
- package/mobile/out/src/utility/parseTxScriptOffsets.d.ts +14 -0
- package/mobile/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -0
- package/mobile/out/src/utility/parseTxScriptOffsets.js +26 -0
- package/mobile/out/src/utility/parseTxScriptOffsets.js.map +1 -0
- package/mobile/out/src/utility/stampLog.d.ts +18 -0
- package/mobile/out/src/utility/stampLog.d.ts.map +1 -0
- package/mobile/out/src/utility/stampLog.js +72 -0
- package/mobile/out/src/utility/stampLog.js.map +1 -0
- package/mobile/out/src/utility/tscProofToMerklePath.d.ts +8 -0
- package/mobile/out/src/utility/tscProofToMerklePath.d.ts.map +1 -0
- package/mobile/out/src/utility/tscProofToMerklePath.js +41 -0
- package/mobile/out/src/utility/tscProofToMerklePath.js.map +1 -0
- package/mobile/out/src/utility/utilityHelpers.d.ts +129 -0
- package/mobile/out/src/utility/utilityHelpers.d.ts.map +1 -0
- package/mobile/out/src/utility/utilityHelpers.js +266 -0
- package/mobile/out/src/utility/utilityHelpers.js.map +1 -0
- package/mobile/out/src/utility/utilityHelpers.noBuffer.d.ts +9 -0
- package/mobile/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -0
- package/mobile/out/src/utility/utilityHelpers.noBuffer.js +23 -0
- package/mobile/out/src/utility/utilityHelpers.noBuffer.js.map +1 -0
- package/mobile/out/src/wab-client/WABClient.d.ts +49 -0
- package/mobile/out/src/wab-client/WABClient.d.ts.map +1 -0
- package/mobile/out/src/wab-client/WABClient.js +80 -0
- package/mobile/out/src/wab-client/WABClient.js.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +34 -0
- package/mobile/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -0
- package/mobile/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts +7 -0
- package/mobile/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js +36 -0
- package/mobile/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +28 -0
- package/mobile/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +69 -0
- package/mobile/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -0
- package/mobile/out/tsconfig.mobile.tsbuildinfo +1 -0
- package/mobile/package-lock.json +8 -16
- package/mobile/package.json +1 -1
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/index.mobile.d.ts +0 -2
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +0 -2
- package/out/src/index.mobile.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +2 -1
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +63 -29
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +10 -6
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +2 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +75 -40
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts +2 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +45 -11
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts +2 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js +29 -29
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts +2 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js +36 -3
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/index.mobile.d.ts +1 -1
- package/out/src/storage/index.mobile.js +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageMobile.d.ts +283 -0
- package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageMobile.js +477 -0
- package/out/src/storage/remoting/StorageMobile.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/WalletPermissionsManager.ts +19 -8
- package/src/index.mobile.ts +0 -2
- package/src/storage/StorageIdb.ts +4 -5
- package/src/storage/StorageKnex.ts +7 -6
- package/src/storage/StorageProvider.ts +5 -9
- package/src/storage/StorageReader.ts +4 -7
- package/src/storage/StorageReaderWriter.ts +4 -8
- package/src/storage/StorageSyncReader.ts +2 -19
- package/src/storage/index.mobile.ts +1 -1
- package/src/storage/remoting/StorageClient.ts +0 -1
- package/src/storage/remoting/StorageMobile.ts +527 -0
- package/tsconfig.all.json +2 -1
- package/tsconfig.client.json +6 -0
- package/tsconfig.json +3 -0
- package/tsconfig.mobile.json +28 -0
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setDisableDoubleSpendCheckForTest = setDisableDoubleSpendCheckForTest;
|
|
4
|
+
exports.createAction = createAction;
|
|
5
|
+
exports.offsetPubKey = offsetPubKey;
|
|
6
|
+
exports.lockScriptWithKeyOffsetFromPubKey = lockScriptWithKeyOffsetFromPubKey;
|
|
7
|
+
exports.createStorageServiceChargeScript = createStorageServiceChargeScript;
|
|
8
|
+
const sdk_1 = require("@bsv/sdk");
|
|
9
|
+
const index_client_1 = require("../../index.client");
|
|
10
|
+
const generateChange_1 = require("./generateChange");
|
|
11
|
+
let disableDoubleSpendCheckForTest = true;
|
|
12
|
+
function setDisableDoubleSpendCheckForTest(v) {
|
|
13
|
+
disableDoubleSpendCheckForTest = v;
|
|
14
|
+
}
|
|
15
|
+
async function createAction(storage, auth, vargs, originator) {
|
|
16
|
+
//stampLog(vargs, `start storage createTransactionSdk`)
|
|
17
|
+
if (!vargs.isNewTx)
|
|
18
|
+
// The purpose of this function is to create the initial storage records associated
|
|
19
|
+
// with a new transaction. It's an error if we have no new inputs or outputs...
|
|
20
|
+
throw new index_client_1.sdk.WERR_INTERNAL();
|
|
21
|
+
/**
|
|
22
|
+
* Steps to create a transaction:
|
|
23
|
+
* - Verify that all inputs either have proof in vargs.inputBEEF or that options.trustSelf === 'known' and input txid.vout are known valid to storage.
|
|
24
|
+
* - Create a new transaction record with status 'unsigned' as the anchor for construction work and to new outputs.
|
|
25
|
+
* - Create all transaction labels.
|
|
26
|
+
* - Add new commission output
|
|
27
|
+
* - Attempt to fund the transaction by allocating change outputs:
|
|
28
|
+
* - As each change output is selected it is simultaneously locked.
|
|
29
|
+
* - Create all new output, basket, tag records
|
|
30
|
+
* - If requested, create result Beef with complete proofs for all inputs used
|
|
31
|
+
* - Create result inputs with source locking scripts
|
|
32
|
+
* - Create result outputs with new locking scripts.
|
|
33
|
+
* - Create and return result.
|
|
34
|
+
*/
|
|
35
|
+
const userId = auth.userId;
|
|
36
|
+
const { storageBeef, beef, xinputs } = await validateRequiredInputs(storage, userId, vargs);
|
|
37
|
+
const xoutputs = validateRequiredOutputs(storage, userId, vargs);
|
|
38
|
+
const changeBasketName = 'default';
|
|
39
|
+
const changeBasket = (0, index_client_1.verifyOne)(await storage.findOutputBaskets({
|
|
40
|
+
partial: { userId, name: changeBasketName }
|
|
41
|
+
}), `Invalid outputGeneration basket "${changeBasketName}"`);
|
|
42
|
+
const noSendChangeIn = await validateNoSendChange(storage, userId, vargs, changeBasket);
|
|
43
|
+
const availableChangeCount = await storage.countChangeInputs(userId, changeBasket.basketId, !vargs.isDelayed);
|
|
44
|
+
const feeModel = (0, index_client_1.validateStorageFeeModel)(storage.feeModel);
|
|
45
|
+
const newTx = await createNewTxRecord(storage, userId, vargs, storageBeef);
|
|
46
|
+
const ctx = {
|
|
47
|
+
xinputs,
|
|
48
|
+
xoutputs,
|
|
49
|
+
changeBasket,
|
|
50
|
+
noSendChangeIn,
|
|
51
|
+
availableChangeCount,
|
|
52
|
+
feeModel,
|
|
53
|
+
transactionId: newTx.transactionId
|
|
54
|
+
};
|
|
55
|
+
const { allocatedChange, changeOutputs, derivationPrefix, maxPossibleSatoshisAdjustment } = await fundNewTransactionSdk(storage, userId, vargs, ctx);
|
|
56
|
+
if (maxPossibleSatoshisAdjustment) {
|
|
57
|
+
const a = maxPossibleSatoshisAdjustment;
|
|
58
|
+
if (ctx.xoutputs[a.fixedOutputIndex].satoshis !== generateChange_1.maxPossibleSatoshis)
|
|
59
|
+
throw new index_client_1.sdk.WERR_INTERNAL();
|
|
60
|
+
ctx.xoutputs[a.fixedOutputIndex].satoshis = a.satoshis;
|
|
61
|
+
}
|
|
62
|
+
// The satoshis of the transaction is the satoshis we get back in change minus the satoshis we spend.
|
|
63
|
+
const satoshis = changeOutputs.reduce((a, e) => a + e.satoshis, 0) - allocatedChange.reduce((a, e) => a + e.satoshis, 0);
|
|
64
|
+
await storage.updateTransaction(newTx.transactionId, { satoshis });
|
|
65
|
+
const { outputs, changeVouts } = await createNewOutputs(storage, userId, vargs, ctx, changeOutputs);
|
|
66
|
+
const inputBeef = await mergeAllocatedChangeBeefs(storage, userId, vargs, allocatedChange, beef);
|
|
67
|
+
const inputs = await createNewInputs(storage, userId, vargs, ctx, allocatedChange);
|
|
68
|
+
const r = {
|
|
69
|
+
reference: newTx.reference,
|
|
70
|
+
version: newTx.version,
|
|
71
|
+
lockTime: newTx.lockTime,
|
|
72
|
+
inputs,
|
|
73
|
+
outputs,
|
|
74
|
+
derivationPrefix,
|
|
75
|
+
inputBeef,
|
|
76
|
+
noSendChangeOutputVouts: vargs.isNoSend ? changeVouts : undefined
|
|
77
|
+
};
|
|
78
|
+
//stampLog(vargs, `end storage createTransactionSdk`)
|
|
79
|
+
return r;
|
|
80
|
+
}
|
|
81
|
+
function makeDefaultOutput(userId, transactionId, satoshis, vout) {
|
|
82
|
+
const now = new Date();
|
|
83
|
+
const output = {
|
|
84
|
+
created_at: now,
|
|
85
|
+
updated_at: now,
|
|
86
|
+
outputId: 0,
|
|
87
|
+
userId,
|
|
88
|
+
transactionId,
|
|
89
|
+
satoshis: satoshis,
|
|
90
|
+
vout,
|
|
91
|
+
basketId: undefined,
|
|
92
|
+
change: false,
|
|
93
|
+
customInstructions: undefined,
|
|
94
|
+
derivationPrefix: undefined,
|
|
95
|
+
derivationSuffix: undefined,
|
|
96
|
+
outputDescription: '',
|
|
97
|
+
lockingScript: undefined,
|
|
98
|
+
providedBy: 'you',
|
|
99
|
+
purpose: '',
|
|
100
|
+
senderIdentityKey: undefined,
|
|
101
|
+
spendable: true,
|
|
102
|
+
spendingDescription: undefined,
|
|
103
|
+
spentBy: undefined,
|
|
104
|
+
txid: undefined,
|
|
105
|
+
type: ''
|
|
106
|
+
};
|
|
107
|
+
return output;
|
|
108
|
+
}
|
|
109
|
+
async function createNewInputs(storage, userId, vargs, ctx, allocatedChange) {
|
|
110
|
+
const r = [];
|
|
111
|
+
const newInputs = [];
|
|
112
|
+
for (const i of ctx.xinputs) {
|
|
113
|
+
const o = i.output;
|
|
114
|
+
newInputs.push({ i, o });
|
|
115
|
+
if (o) {
|
|
116
|
+
await storage.updateOutput(o.outputId, {
|
|
117
|
+
spendable: false,
|
|
118
|
+
spentBy: ctx.transactionId,
|
|
119
|
+
spendingDescription: i.inputDescription
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const o of allocatedChange) {
|
|
124
|
+
newInputs.push({ o, unlockLen: 107 });
|
|
125
|
+
}
|
|
126
|
+
let vin = -1;
|
|
127
|
+
for (const { i, o, unlockLen } of newInputs) {
|
|
128
|
+
vin++;
|
|
129
|
+
if (o) {
|
|
130
|
+
if (!i && !unlockLen)
|
|
131
|
+
throw new index_client_1.sdk.WERR_INTERNAL(`vin ${vin} non-fixedInput without unlockLen`);
|
|
132
|
+
const sourceTransaction = vargs.includeAllSourceTransactions && vargs.isSignAction
|
|
133
|
+
? await storage.getRawTxOfKnownValidTransaction(o.txid)
|
|
134
|
+
: undefined;
|
|
135
|
+
const ri = {
|
|
136
|
+
vin,
|
|
137
|
+
sourceTxid: o.txid,
|
|
138
|
+
sourceVout: o.vout,
|
|
139
|
+
sourceSatoshis: o.satoshis,
|
|
140
|
+
sourceLockingScript: (0, index_client_1.asString)(o.lockingScript),
|
|
141
|
+
sourceTransaction,
|
|
142
|
+
unlockingScriptLength: unlockLen ? unlockLen : i.unlockingScriptLength,
|
|
143
|
+
providedBy: i && o.providedBy === 'storage' ? 'you-and-storage' : o.providedBy,
|
|
144
|
+
type: o.type,
|
|
145
|
+
spendingDescription: o.spendingDescription || undefined,
|
|
146
|
+
derivationPrefix: o.derivationPrefix || undefined,
|
|
147
|
+
derivationSuffix: o.derivationSuffix || undefined,
|
|
148
|
+
senderIdentityKey: o.senderIdentityKey || undefined
|
|
149
|
+
};
|
|
150
|
+
r.push(ri);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (!i)
|
|
154
|
+
throw new index_client_1.sdk.WERR_INTERNAL(`vin ${vin} without output or xinput`);
|
|
155
|
+
// user specified input with no corresponding output being spent.
|
|
156
|
+
const ri = {
|
|
157
|
+
vin,
|
|
158
|
+
sourceTxid: i.outpoint.txid,
|
|
159
|
+
sourceVout: i.outpoint.vout,
|
|
160
|
+
sourceSatoshis: i.satoshis,
|
|
161
|
+
sourceLockingScript: i.lockingScript.toHex(),
|
|
162
|
+
unlockingScriptLength: i.unlockingScriptLength,
|
|
163
|
+
providedBy: 'you',
|
|
164
|
+
type: 'custom',
|
|
165
|
+
spendingDescription: undefined,
|
|
166
|
+
derivationPrefix: undefined,
|
|
167
|
+
derivationSuffix: undefined,
|
|
168
|
+
senderIdentityKey: undefined
|
|
169
|
+
};
|
|
170
|
+
r.push(ri);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return r;
|
|
174
|
+
}
|
|
175
|
+
async function createNewOutputs(storage, userId, vargs, ctx, changeOutputs) {
|
|
176
|
+
var _a;
|
|
177
|
+
const outputs = [];
|
|
178
|
+
// Lookup output baskets
|
|
179
|
+
const txBaskets = {};
|
|
180
|
+
for (const xo of ctx.xoutputs) {
|
|
181
|
+
if (xo.basket !== undefined && !txBaskets[xo.basket])
|
|
182
|
+
txBaskets[xo.basket] = await storage.findOrInsertOutputBasket(userId, xo.basket);
|
|
183
|
+
}
|
|
184
|
+
// Lookup output tags
|
|
185
|
+
const txTags = {};
|
|
186
|
+
for (const xo of ctx.xoutputs) {
|
|
187
|
+
for (const tag of xo.tags) {
|
|
188
|
+
txTags[tag] = await storage.findOrInsertOutputTag(userId, tag);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const newOutputs = [];
|
|
192
|
+
for (const xo of ctx.xoutputs) {
|
|
193
|
+
const lockingScript = (0, index_client_1.asArray)(xo.lockingScript);
|
|
194
|
+
if (xo.purpose === 'service-charge') {
|
|
195
|
+
const now = new Date();
|
|
196
|
+
await storage.insertCommission({
|
|
197
|
+
userId,
|
|
198
|
+
transactionId: ctx.transactionId,
|
|
199
|
+
lockingScript,
|
|
200
|
+
satoshis: xo.satoshis,
|
|
201
|
+
isRedeemed: false,
|
|
202
|
+
keyOffset: (0, index_client_1.verifyTruthy)(xo.keyOffset),
|
|
203
|
+
created_at: now,
|
|
204
|
+
updated_at: now,
|
|
205
|
+
commissionId: 0
|
|
206
|
+
});
|
|
207
|
+
const o = makeDefaultOutput(userId, ctx.transactionId, xo.satoshis, xo.vout);
|
|
208
|
+
o.lockingScript = lockingScript;
|
|
209
|
+
o.providedBy = 'storage';
|
|
210
|
+
o.purpose = 'storage-commission';
|
|
211
|
+
o.type = 'custom';
|
|
212
|
+
o.spendable = false;
|
|
213
|
+
newOutputs.push({ o, tags: [] });
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// The user wants tracking if they put their output in a basket
|
|
217
|
+
const basketId = !xo.basket ? undefined : txBaskets[xo.basket].basketId;
|
|
218
|
+
const o = makeDefaultOutput(userId, ctx.transactionId, xo.satoshis, xo.vout);
|
|
219
|
+
o.lockingScript = lockingScript;
|
|
220
|
+
o.basketId = basketId;
|
|
221
|
+
o.customInstructions = xo.customInstructions;
|
|
222
|
+
o.outputDescription = xo.outputDescription;
|
|
223
|
+
o.providedBy = xo.providedBy;
|
|
224
|
+
o.purpose = xo.purpose || '';
|
|
225
|
+
o.type = 'custom';
|
|
226
|
+
newOutputs.push({ o, tags: xo.tags });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
for (const o of changeOutputs) {
|
|
230
|
+
o.spendable = true;
|
|
231
|
+
newOutputs.push({ o, tags: [] });
|
|
232
|
+
}
|
|
233
|
+
if (vargs.options.randomizeOutputs) {
|
|
234
|
+
const randomVals = [];
|
|
235
|
+
const nextRandomVal = () => {
|
|
236
|
+
let val = 0;
|
|
237
|
+
if (!randomVals || randomVals.length === 0) {
|
|
238
|
+
val = Math.random();
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
val = randomVals.shift() || 0;
|
|
242
|
+
randomVals.push(val);
|
|
243
|
+
}
|
|
244
|
+
return val;
|
|
245
|
+
};
|
|
246
|
+
/** In-place array shuffle */
|
|
247
|
+
const shuffleArray = (array) => {
|
|
248
|
+
let currentIndex = array.length;
|
|
249
|
+
let temporaryValue;
|
|
250
|
+
let randomIndex;
|
|
251
|
+
while (currentIndex !== 0) {
|
|
252
|
+
randomIndex = Math.floor(nextRandomVal() * currentIndex);
|
|
253
|
+
currentIndex -= 1;
|
|
254
|
+
temporaryValue = array[currentIndex];
|
|
255
|
+
array[currentIndex] = array[randomIndex];
|
|
256
|
+
array[randomIndex] = temporaryValue;
|
|
257
|
+
}
|
|
258
|
+
return array;
|
|
259
|
+
};
|
|
260
|
+
let vout = -1;
|
|
261
|
+
const newVouts = Array(newOutputs.length);
|
|
262
|
+
for (let i = 0; i < newVouts.length; i++)
|
|
263
|
+
newVouts[i] = i;
|
|
264
|
+
shuffleArray(newVouts);
|
|
265
|
+
for (const no of newOutputs) {
|
|
266
|
+
vout++;
|
|
267
|
+
if (no.o.vout !== vout)
|
|
268
|
+
throw new index_client_1.sdk.WERR_INTERNAL(`new output ${vout} has out of order vout ${no.o.vout}`);
|
|
269
|
+
no.o.vout = newVouts[vout];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const changeVouts = [];
|
|
273
|
+
for (const { o, tags } of newOutputs) {
|
|
274
|
+
o.outputId = await storage.insertOutput(o);
|
|
275
|
+
if (o.change && o.purpose === 'change' && o.providedBy === 'storage')
|
|
276
|
+
changeVouts.push(o.vout);
|
|
277
|
+
// Add tags to the output
|
|
278
|
+
for (const tagName of tags) {
|
|
279
|
+
const tag = txTags[tagName];
|
|
280
|
+
await storage.findOrInsertOutputTagMap((0, index_client_1.verifyId)(o.outputId), (0, index_client_1.verifyId)(tag.outputTagId));
|
|
281
|
+
}
|
|
282
|
+
const ro = {
|
|
283
|
+
vout: (0, index_client_1.verifyInteger)(o.vout),
|
|
284
|
+
satoshis: (0, index_client_1.verifyTruthy)(o.satoshis),
|
|
285
|
+
lockingScript: !o.lockingScript ? '' : (0, index_client_1.asString)(o.lockingScript),
|
|
286
|
+
providedBy: (0, index_client_1.verifyTruthy)(o.providedBy),
|
|
287
|
+
purpose: o.purpose || undefined,
|
|
288
|
+
basket: (_a = Object.values(txBaskets).find(b => b.basketId === o.basketId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
289
|
+
tags: tags,
|
|
290
|
+
outputDescription: o.outputDescription,
|
|
291
|
+
derivationSuffix: o.derivationSuffix,
|
|
292
|
+
customInstructions: o.customInstructions
|
|
293
|
+
};
|
|
294
|
+
outputs.push(ro);
|
|
295
|
+
}
|
|
296
|
+
return { outputs, changeVouts };
|
|
297
|
+
}
|
|
298
|
+
async function createNewTxRecord(storage, userId, vargs, storageBeef) {
|
|
299
|
+
const now = new Date();
|
|
300
|
+
const newTx = {
|
|
301
|
+
created_at: now,
|
|
302
|
+
updated_at: now,
|
|
303
|
+
transactionId: 0,
|
|
304
|
+
version: vargs.version,
|
|
305
|
+
lockTime: vargs.lockTime,
|
|
306
|
+
status: 'unsigned',
|
|
307
|
+
reference: (0, index_client_1.randomBytesBase64)(12),
|
|
308
|
+
satoshis: 0, // updated after fundingTransaction
|
|
309
|
+
userId,
|
|
310
|
+
isOutgoing: true,
|
|
311
|
+
inputBEEF: storageBeef.toBinary(),
|
|
312
|
+
description: vargs.description,
|
|
313
|
+
txid: undefined,
|
|
314
|
+
rawTx: undefined
|
|
315
|
+
};
|
|
316
|
+
newTx.transactionId = await storage.insertTransaction(newTx);
|
|
317
|
+
for (const label of vargs.labels) {
|
|
318
|
+
const txLabel = await storage.findOrInsertTxLabel(userId, label);
|
|
319
|
+
await storage.findOrInsertTxLabelMap((0, index_client_1.verifyId)(newTx.transactionId), (0, index_client_1.verifyId)(txLabel.txLabelId));
|
|
320
|
+
}
|
|
321
|
+
return newTx;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Convert vargs.outputs:
|
|
325
|
+
*
|
|
326
|
+
* lockingScript: HexString
|
|
327
|
+
* satoshis: SatoshiValue
|
|
328
|
+
* outputDescription: DescriptionString5to50Bytes
|
|
329
|
+
* basket?: BasketStringUnder300Bytes
|
|
330
|
+
* customInstructions?: string
|
|
331
|
+
* tags: BasketStringUnderBytes[]
|
|
332
|
+
*
|
|
333
|
+
* to XValidCreateActionOutput (which aims for sdk.StorageCreateTransactionSdkOutput)
|
|
334
|
+
*
|
|
335
|
+
* adds:
|
|
336
|
+
* vout: number
|
|
337
|
+
* providedBy: sdk.StorageProvidedBy
|
|
338
|
+
* purpose?: string
|
|
339
|
+
* derivationSuffix?: string
|
|
340
|
+
* keyOffset?: string
|
|
341
|
+
*
|
|
342
|
+
* @param vargs
|
|
343
|
+
* @returns xoutputs
|
|
344
|
+
*/
|
|
345
|
+
function validateRequiredOutputs(storage, userId, vargs) {
|
|
346
|
+
const xoutputs = [];
|
|
347
|
+
let vout = -1;
|
|
348
|
+
for (const output of vargs.outputs) {
|
|
349
|
+
vout++;
|
|
350
|
+
const xo = {
|
|
351
|
+
...output,
|
|
352
|
+
vout,
|
|
353
|
+
providedBy: 'you',
|
|
354
|
+
purpose: undefined,
|
|
355
|
+
derivationSuffix: undefined,
|
|
356
|
+
keyOffset: undefined
|
|
357
|
+
};
|
|
358
|
+
xoutputs.push(xo);
|
|
359
|
+
}
|
|
360
|
+
if (storage.commissionSatoshis > 0 && storage.commissionPubKeyHex) {
|
|
361
|
+
vout++;
|
|
362
|
+
const { script, keyOffset } = createStorageServiceChargeScript(storage.commissionPubKeyHex);
|
|
363
|
+
xoutputs.push({
|
|
364
|
+
lockingScript: script,
|
|
365
|
+
satoshis: storage.commissionSatoshis,
|
|
366
|
+
outputDescription: 'Storage Service Charge',
|
|
367
|
+
basket: undefined,
|
|
368
|
+
tags: [],
|
|
369
|
+
vout,
|
|
370
|
+
providedBy: 'storage',
|
|
371
|
+
purpose: 'service-charge',
|
|
372
|
+
keyOffset
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return xoutputs;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Verify that we are in posession of validity proof data for any inputs being proposed for a new transaction.
|
|
379
|
+
*
|
|
380
|
+
* `vargs.inputs` is the source of inputs.
|
|
381
|
+
* `vargs.inputBEEF` may include new user supplied validity data.
|
|
382
|
+
* 'vargs.options.trustSelf === 'known'` indicates whether we can rely on the storage database records.
|
|
383
|
+
*
|
|
384
|
+
* If there are no inputs, returns an empty `Beef`.
|
|
385
|
+
*
|
|
386
|
+
* Always pulls rawTx data into first level of validity chains so that parsed transaction data is available
|
|
387
|
+
* and checks input sourceSatoshis as well as filling in input sourceLockingScript.
|
|
388
|
+
*
|
|
389
|
+
* This data may be pruned again before being returned to the user based on `vargs.options.knownTxids`.
|
|
390
|
+
*
|
|
391
|
+
* @param storage
|
|
392
|
+
* @param userId
|
|
393
|
+
* @param vargs
|
|
394
|
+
* @returns {storageBeef} containing only validity proof data for only unknown required inputs.
|
|
395
|
+
* @returns {beef} containing verified validity proof data for all required inputs.
|
|
396
|
+
* @returns {xinputs} extended validated required inputs.
|
|
397
|
+
*/
|
|
398
|
+
async function validateRequiredInputs(storage, userId, vargs) {
|
|
399
|
+
//stampLog(vargs, `start storage verifyInputBeef`)
|
|
400
|
+
const beef = new sdk_1.Beef();
|
|
401
|
+
if (vargs.inputs.length === 0)
|
|
402
|
+
return { storageBeef: beef, beef, xinputs: [] };
|
|
403
|
+
if (vargs.inputBEEF)
|
|
404
|
+
beef.mergeBeef(vargs.inputBEEF);
|
|
405
|
+
const xinputs = vargs.inputs.map((input, vin) => ({
|
|
406
|
+
...input,
|
|
407
|
+
vin,
|
|
408
|
+
satoshis: -1,
|
|
409
|
+
lockingScript: new sdk_1.Script()
|
|
410
|
+
}));
|
|
411
|
+
const trustSelf = vargs.options.trustSelf === 'known';
|
|
412
|
+
const inputTxids = {};
|
|
413
|
+
for (const input of xinputs)
|
|
414
|
+
inputTxids[input.outpoint.txid] = true;
|
|
415
|
+
// Check beef from user that either there are no txidOnly entries,
|
|
416
|
+
// or that we can trust storage data and it does indeed vouch
|
|
417
|
+
// for any txidOnly entries
|
|
418
|
+
for (const btx of beef.txs) {
|
|
419
|
+
if (btx.isTxidOnly) {
|
|
420
|
+
if (!trustSelf)
|
|
421
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('inputBEEF', `valid and contain complete proof data for ${btx.txid}`);
|
|
422
|
+
if (!inputTxids[btx.txid]) {
|
|
423
|
+
// inputTxids are checked next
|
|
424
|
+
const isKnown = await storage.verifyKnownValidTransaction(btx.txid);
|
|
425
|
+
if (!isKnown)
|
|
426
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('inputBEEF', `valid and contain complete proof data for unknown ${btx.txid}`);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// Make sure that there's an entry for all inputs txid values:
|
|
431
|
+
for (const txid of Object.keys(inputTxids)) {
|
|
432
|
+
let btx = beef.findTxid(txid);
|
|
433
|
+
if (!btx && trustSelf) {
|
|
434
|
+
if (await storage.verifyKnownValidTransaction(txid))
|
|
435
|
+
btx = beef.mergeTxidOnly(txid);
|
|
436
|
+
}
|
|
437
|
+
if (!btx)
|
|
438
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('inputBEEF', `valid and contain proof data for possibly known ${txid}`);
|
|
439
|
+
}
|
|
440
|
+
if (!(await beef.verify(await storage.getServices().getChainTracker(), true))) {
|
|
441
|
+
console.log(`verifyInputBeef failed, inputBEEF failed to verify.\n${beef.toLogString()}\n`);
|
|
442
|
+
//console.log(`verifyInputBeef failed, inputBEEF failed to verify.\n${stampLogFormat(vargs.log)}\n${beef.toLogString()}\n`)
|
|
443
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('inputBEEF', 'valid Beef when factoring options.trustSelf');
|
|
444
|
+
}
|
|
445
|
+
// beef may now be trusted and has a BeefTx for every input txid.
|
|
446
|
+
const storageBeef = beef.clone();
|
|
447
|
+
for (const input of xinputs) {
|
|
448
|
+
const { txid, vout } = input.outpoint;
|
|
449
|
+
const output = (0, index_client_1.verifyOneOrNone)(await storage.findOutputs({ partial: { userId, txid, vout } }));
|
|
450
|
+
if (output) {
|
|
451
|
+
input.output = output;
|
|
452
|
+
if (!Array.isArray(output.lockingScript) || !Number.isInteger(output.satoshis))
|
|
453
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'output with valid lockingScript and satoshis');
|
|
454
|
+
if (!disableDoubleSpendCheckForTest && !output.spendable && !vargs.isNoSend)
|
|
455
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'spendable output unless noSend is true');
|
|
456
|
+
// input is spending an existing user output which has an lockingScript
|
|
457
|
+
input.satoshis = (0, index_client_1.verifyNumber)(output.satoshis);
|
|
458
|
+
input.lockingScript = sdk_1.Script.fromBinary((0, index_client_1.asArray)(output.lockingScript));
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
let btx = beef.findTxid(txid);
|
|
462
|
+
if (btx.isTxidOnly) {
|
|
463
|
+
const { rawTx, proven } = await storage.getProvenOrRawTx(txid);
|
|
464
|
+
//stampLog(vargs, `... storage verifyInputBeef getProvenOrRawTx ${txid} ${proven ? 'proven' : rawTx ? 'rawTx' : 'unknown'}`)
|
|
465
|
+
if (!rawTx)
|
|
466
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('inputBEEF', `valid and contain proof data for ${txid}`);
|
|
467
|
+
btx = beef.mergeRawTx((0, index_client_1.asArray)(rawTx));
|
|
468
|
+
if (proven)
|
|
469
|
+
beef.mergeBump(new index_client_1.EntityProvenTx(proven).getMerklePath());
|
|
470
|
+
}
|
|
471
|
+
// btx is valid has parsed transaction data.
|
|
472
|
+
if (vout >= btx.tx.outputs.length)
|
|
473
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'valid outpoint');
|
|
474
|
+
const so = btx.tx.outputs[vout];
|
|
475
|
+
input.satoshis = (0, index_client_1.verifyTruthy)(so.satoshis);
|
|
476
|
+
input.lockingScript = so.lockingScript;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return { beef, storageBeef, xinputs };
|
|
480
|
+
}
|
|
481
|
+
async function validateNoSendChange(storage, userId, vargs, changeBasket) {
|
|
482
|
+
const r = [];
|
|
483
|
+
if (!vargs.isNoSend)
|
|
484
|
+
return [];
|
|
485
|
+
const noSendChange = vargs.options.noSendChange;
|
|
486
|
+
if (noSendChange && noSendChange.length > 0) {
|
|
487
|
+
for (const op of noSendChange) {
|
|
488
|
+
const output = (0, index_client_1.verifyOneOrNone)(await storage.findOutputs({
|
|
489
|
+
partial: { userId, txid: op.txid, vout: op.vout }
|
|
490
|
+
}));
|
|
491
|
+
// noSendChange is not marked spendable until sent, may not already be spent, and must have a valid greater than zero satoshis
|
|
492
|
+
if (!output ||
|
|
493
|
+
output.providedBy !== 'storage' ||
|
|
494
|
+
output.purpose !== 'change' ||
|
|
495
|
+
output.spendable === false ||
|
|
496
|
+
Number.isInteger(output.spentBy) ||
|
|
497
|
+
!(0, index_client_1.verifyNumber)(output.satoshis) ||
|
|
498
|
+
output.basketId !== changeBasket.basketId)
|
|
499
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('noSendChange outpoint', 'valid');
|
|
500
|
+
if (-1 < r.findIndex(o => o.outputId === output.outputId))
|
|
501
|
+
// noSendChange duplicate OutPoints are not allowed.
|
|
502
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('noSendChange outpoint', 'unique. Duplicates are not allowed.');
|
|
503
|
+
r.push(output);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return r;
|
|
507
|
+
}
|
|
508
|
+
async function fundNewTransactionSdk(storage, userId, vargs, ctx) {
|
|
509
|
+
const params = {
|
|
510
|
+
fixedInputs: ctx.xinputs.map(xi => ({
|
|
511
|
+
satoshis: xi.satoshis,
|
|
512
|
+
unlockingScriptLength: xi.unlockingScriptLength
|
|
513
|
+
})),
|
|
514
|
+
fixedOutputs: ctx.xoutputs.map(xo => ({
|
|
515
|
+
satoshis: xo.satoshis,
|
|
516
|
+
lockingScriptLength: xo.lockingScript.length / 2
|
|
517
|
+
})),
|
|
518
|
+
feeModel: ctx.feeModel,
|
|
519
|
+
changeInitialSatoshis: ctx.changeBasket.minimumDesiredUTXOValue,
|
|
520
|
+
changeFirstSatoshis: Math.max(1, Math.round(ctx.changeBasket.minimumDesiredUTXOValue / 4)),
|
|
521
|
+
changeLockingScriptLength: 25,
|
|
522
|
+
changeUnlockingScriptLength: 107,
|
|
523
|
+
targetNetCount: ctx.changeBasket.numberOfDesiredUTXOs - ctx.availableChangeCount,
|
|
524
|
+
randomVals: vargs.randomVals
|
|
525
|
+
};
|
|
526
|
+
const noSendChange = [...ctx.noSendChangeIn];
|
|
527
|
+
const outputs = {};
|
|
528
|
+
const allocateChangeInput = async (targetSatoshis, exactSatoshis) => {
|
|
529
|
+
// noSendChange gets allocated first...typically only one input...just allocate in order...
|
|
530
|
+
if (noSendChange.length > 0) {
|
|
531
|
+
const o = noSendChange.pop();
|
|
532
|
+
outputs[o.outputId] = o;
|
|
533
|
+
// allocate the output in storage, noSendChange is by definition spendable false and part of noSpend transaction batch.
|
|
534
|
+
await storage.updateOutput(o.outputId, {
|
|
535
|
+
spendable: false,
|
|
536
|
+
spentBy: ctx.transactionId
|
|
537
|
+
});
|
|
538
|
+
o.spendable = false;
|
|
539
|
+
o.spentBy = ctx.transactionId;
|
|
540
|
+
const r = {
|
|
541
|
+
outputId: o.outputId,
|
|
542
|
+
satoshis: o.satoshis
|
|
543
|
+
};
|
|
544
|
+
return r;
|
|
545
|
+
}
|
|
546
|
+
const basketId = ctx.changeBasket.basketId;
|
|
547
|
+
const o = await storage.allocateChangeInput(userId, basketId, targetSatoshis, exactSatoshis, !vargs.isDelayed, ctx.transactionId);
|
|
548
|
+
if (!o)
|
|
549
|
+
return undefined;
|
|
550
|
+
outputs[o.outputId] = o;
|
|
551
|
+
const r = {
|
|
552
|
+
outputId: o.outputId,
|
|
553
|
+
satoshis: o.satoshis
|
|
554
|
+
};
|
|
555
|
+
return r;
|
|
556
|
+
};
|
|
557
|
+
const releaseChangeInput = async (outputId) => {
|
|
558
|
+
const nsco = ctx.noSendChangeIn.find(o => o.outputId === outputId);
|
|
559
|
+
if (nsco) {
|
|
560
|
+
noSendChange.push(nsco);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
await storage.updateOutput(outputId, {
|
|
564
|
+
spendable: true,
|
|
565
|
+
spentBy: undefined
|
|
566
|
+
});
|
|
567
|
+
};
|
|
568
|
+
const gcr = await (0, generateChange_1.generateChangeSdk)(params, allocateChangeInput, releaseChangeInput);
|
|
569
|
+
const nextRandomVal = () => {
|
|
570
|
+
let val = 0;
|
|
571
|
+
if (!vargs.randomVals || vargs.randomVals.length === 0) {
|
|
572
|
+
val = Math.random();
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
val = vargs.randomVals.shift() || 0;
|
|
576
|
+
vargs.randomVals.push(val);
|
|
577
|
+
}
|
|
578
|
+
return val;
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* @returns a random integer betweenn min and max, inclussive.
|
|
582
|
+
*/
|
|
583
|
+
const rand = (min, max) => {
|
|
584
|
+
if (max < min)
|
|
585
|
+
throw new index_client_1.sdk.WERR_INVALID_PARAMETER('max', `less than min (${min}). max is (${max})`);
|
|
586
|
+
return Math.floor(nextRandomVal() * (max - min + 1) + min);
|
|
587
|
+
};
|
|
588
|
+
const randomDerivation = (count) => {
|
|
589
|
+
let val = [];
|
|
590
|
+
if (!vargs.randomVals || vargs.randomVals.length === 0) {
|
|
591
|
+
val = (0, sdk_1.Random)(count);
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
for (let i = 0; i < count; i++)
|
|
595
|
+
val.push(rand(0, 255));
|
|
596
|
+
}
|
|
597
|
+
return sdk_1.Utils.toBase64(val);
|
|
598
|
+
};
|
|
599
|
+
// Generate a derivation prefix for the payment
|
|
600
|
+
const derivationPrefix = randomDerivation(16);
|
|
601
|
+
const r = {
|
|
602
|
+
maxPossibleSatoshisAdjustment: gcr.maxPossibleSatoshisAdjustment,
|
|
603
|
+
allocatedChange: gcr.allocatedChangeInputs.map(i => outputs[i.outputId]),
|
|
604
|
+
changeOutputs: gcr.changeOutputs.map((o, i) => ({
|
|
605
|
+
// what we knnow now and can insert into the database for this new transaction's change output
|
|
606
|
+
created_at: new Date(),
|
|
607
|
+
updated_at: new Date(),
|
|
608
|
+
outputId: 0,
|
|
609
|
+
userId,
|
|
610
|
+
transactionId: ctx.transactionId,
|
|
611
|
+
vout: params.fixedOutputs.length + i,
|
|
612
|
+
satoshis: o.satoshis,
|
|
613
|
+
basketId: ctx.changeBasket.basketId,
|
|
614
|
+
spendable: false,
|
|
615
|
+
change: true,
|
|
616
|
+
type: 'P2PKH',
|
|
617
|
+
derivationPrefix,
|
|
618
|
+
derivationSuffix: randomDerivation(16),
|
|
619
|
+
providedBy: 'storage',
|
|
620
|
+
purpose: 'change',
|
|
621
|
+
customInstructions: undefined,
|
|
622
|
+
senderIdentityKey: undefined,
|
|
623
|
+
outputDescription: '',
|
|
624
|
+
// what will be known when transaction is signed
|
|
625
|
+
txid: undefined,
|
|
626
|
+
lockingScript: undefined,
|
|
627
|
+
// when this output gets spent
|
|
628
|
+
spentBy: undefined,
|
|
629
|
+
spendingDescription: undefined
|
|
630
|
+
})),
|
|
631
|
+
derivationPrefix
|
|
632
|
+
};
|
|
633
|
+
return r;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Avoid returning any known raw transaction data by converting any known transaction
|
|
637
|
+
* in the `beef` to txidOnly.
|
|
638
|
+
* @returns undefined if `vargs.options.returnTXIDOnly` or trimmed `Beef`
|
|
639
|
+
*/
|
|
640
|
+
function trimInputBeef(beef, vargs) {
|
|
641
|
+
if (vargs.options.returnTXIDOnly)
|
|
642
|
+
return undefined;
|
|
643
|
+
const knownTxids = {};
|
|
644
|
+
for (const txid of vargs.options.knownTxids)
|
|
645
|
+
knownTxids[txid] = true;
|
|
646
|
+
for (const txid of beef.txs.map(btx => btx.txid))
|
|
647
|
+
if (knownTxids[txid])
|
|
648
|
+
beef.makeTxidOnly(txid);
|
|
649
|
+
return beef.toBinary();
|
|
650
|
+
}
|
|
651
|
+
async function mergeAllocatedChangeBeefs(storage, userId, vargs, allocatedChange, beef) {
|
|
652
|
+
const options = {
|
|
653
|
+
trustSelf: undefined,
|
|
654
|
+
knownTxids: vargs.options.knownTxids,
|
|
655
|
+
mergeToBeef: beef,
|
|
656
|
+
ignoreStorage: false,
|
|
657
|
+
ignoreServices: true,
|
|
658
|
+
ignoreNewProven: false,
|
|
659
|
+
minProofLevel: undefined
|
|
660
|
+
};
|
|
661
|
+
if (vargs.options.returnTXIDOnly)
|
|
662
|
+
return undefined;
|
|
663
|
+
for (const o of allocatedChange) {
|
|
664
|
+
if (!beef.findTxid(o.txid) && !vargs.options.knownTxids.find(txid => txid === o.txid)) {
|
|
665
|
+
await storage.getBeefForTransaction(o.txid, options);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return trimInputBeef(beef, vargs);
|
|
669
|
+
}
|
|
670
|
+
function keyOffsetToHashedSecret(pub, keyOffset) {
|
|
671
|
+
let offset;
|
|
672
|
+
if (keyOffset !== undefined && typeof keyOffset === 'string') {
|
|
673
|
+
if (keyOffset.length === 64)
|
|
674
|
+
offset = sdk_1.PrivateKey.fromString(keyOffset, 'hex');
|
|
675
|
+
else
|
|
676
|
+
offset = sdk_1.PrivateKey.fromWif(keyOffset);
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
offset = sdk_1.PrivateKey.fromRandom();
|
|
680
|
+
keyOffset = offset.toWif();
|
|
681
|
+
}
|
|
682
|
+
const sharedSecret = pub.mul(offset).encode(true, undefined);
|
|
683
|
+
const hashedSecret = (0, index_client_1.sha256Hash)(sharedSecret);
|
|
684
|
+
return { hashedSecret: new sdk_1.BigNumber(hashedSecret), keyOffset };
|
|
685
|
+
}
|
|
686
|
+
function offsetPubKey(pubKey, keyOffset) {
|
|
687
|
+
const pub = sdk_1.PublicKey.fromString(pubKey);
|
|
688
|
+
const r = keyOffsetToHashedSecret(pub, keyOffset);
|
|
689
|
+
// The hashed secret is multiplied by the generator point.
|
|
690
|
+
const point = new sdk_1.Curve().g.mul(r.hashedSecret);
|
|
691
|
+
// The resulting point is added to the recipient public key.
|
|
692
|
+
const offsetPubKey = new sdk_1.PublicKey(pub.add(point));
|
|
693
|
+
return { offsetPubKey: offsetPubKey.toString(), keyOffset: r.keyOffset };
|
|
694
|
+
}
|
|
695
|
+
function lockScriptWithKeyOffsetFromPubKey(pubKey, keyOffset) {
|
|
696
|
+
const r = offsetPubKey(pubKey, keyOffset);
|
|
697
|
+
const offsetPub = sdk_1.PublicKey.fromString(r.offsetPubKey);
|
|
698
|
+
const hash = offsetPub.toHash();
|
|
699
|
+
const script = new sdk_1.P2PKH().lock(hash).toHex();
|
|
700
|
+
return { script, keyOffset: r.keyOffset };
|
|
701
|
+
}
|
|
702
|
+
function createStorageServiceChargeScript(pubKeyHex) {
|
|
703
|
+
return lockScriptWithKeyOffsetFromPubKey(pubKeyHex);
|
|
704
|
+
}
|
|
705
|
+
//# sourceMappingURL=createAction.js.map
|