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