@bsv/wallet-toolbox 1.1.59 → 1.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +1 -1
- package/docs/client.md +39 -5
- package/docs/services.md +1 -0
- package/docs/setup.md +9 -26
- package/docs/storage.md +35 -0
- package/docs/wallet.md +39 -5
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +6 -16
- package/out/src/Setup.js.map +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +4 -11
- package/out/src/Wallet.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +1 -3
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -10
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskClock.js +1 -1
- package/out/src/monitor/tasks/TaskClock.js.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +1 -2
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js +1 -2
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js +1 -2
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/sdk/CertOps.d.ts.map +1 -1
- package/out/src/sdk/CertOps.js +4 -12
- package/out/src/sdk/CertOps.js.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +1 -4
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +2 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/__test/CertificateLifeCycle.test.js +1 -3
- package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -1
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js +13 -26
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -1
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +2 -10
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/sdk/validationHelpers.d.ts.map +1 -1
- package/out/src/sdk/validationHelpers.js +5 -12
- package/out/src/sdk/validationHelpers.js.map +1 -1
- package/out/src/services/Services.d.ts +1 -0
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +29 -38
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/__tests/bitrails.test.js.map +1 -1
- package/out/src/services/__tests/getMerklePath.test.js.map +1 -1
- package/out/src/services/__tests/getRawTx.test.js.map +1 -1
- package/out/src/services/__tests/verifyBeef.test.js +2 -1
- package/out/src/services/__tests/verifyBeef.test.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +1 -3
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +1 -2
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +62 -134
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +6 -21
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/__tests/WhatsOnChain.test.js +1 -2
- package/out/src/services/providers/__tests/WhatsOnChain.test.js.map +1 -1
- package/out/src/services/providers/echangeRates.d.ts.map +1 -1
- package/out/src/services/providers/echangeRates.js.map +1 -1
- package/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/out/src/signer/WalletSigner.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js +1 -3
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +3 -11
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +3 -10
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +2 -7
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +15 -44
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +9 -34
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +5 -10
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/__test/WalletStorageManager.test.js +2 -8
- package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +10 -30
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +17 -28
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +6 -20
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +4 -9
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +7 -18
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +1 -3
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +2 -9
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActions.d.ts.map +1 -1
- package/out/src/storage/methods/listActions.js +3 -15
- package/out/src/storage/methods/listActions.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputs.js +4 -11
- package/out/src/storage/methods/listOutputs.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +4 -10
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +8 -32
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +1 -3
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +15 -41
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +2 -5
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +24 -130
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Certificate.js +1 -1
- package/out/src/storage/schema/entities/Certificate.js.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.js +2 -5
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Commission.js +2 -5
- package/out/src/storage/schema/entities/Commission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +14 -9
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Output.js +8 -25
- package/out/src/storage/schema/entities/Output.js.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.js +1 -1
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.js +3 -7
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.js +10 -20
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.js +8 -18
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/SyncState.d.ts +1 -0
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/SyncState.js +41 -6
- package/out/src/storage/schema/entities/SyncState.js.map +1 -1
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Transaction.js +4 -13
- package/out/src/storage/schema/entities/Transaction.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.js +1 -1
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.js +3 -9
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/User.d.ts.map +1 -1
- package/out/src/storage/schema/entities/User.js +3 -5
- package/out/src/storage/schema/entities/User.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -2
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +2 -2
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +1 -3
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +1 -2
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +1 -3
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -1
- package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -1
- package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -1
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
- package/out/test/Wallet/get/getHeaderForHeight.test.js +2 -6
- package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -1
- package/out/test/Wallet/get/getNetwork.test.js.map +1 -1
- package/out/test/Wallet/get/getVersion.test.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +3 -9
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +15 -22
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/specOps/specOps.man.test.js +1 -4
- package/out/test/Wallet/specOps/specOps.man.test.js.map +1 -1
- package/out/test/Wallet/support/janitor.man.test.js.map +1 -1
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -1
- package/out/test/Wallet/sync/setActive.test.js +73 -50
- package/out/test/Wallet/sync/setActive.test.js.map +1 -1
- package/out/test/checkDB.d.ts.map +1 -1
- package/out/test/checkDB.js.map +1 -1
- package/out/test/examples/backup.man.test.d.ts.map +1 -1
- package/out/test/examples/backup.man.test.js.map +1 -1
- package/out/test/examples/pushdrop.test.d.ts.map +1 -1
- package/out/test/examples/pushdrop.test.js +5 -4
- package/out/test/examples/pushdrop.test.js.map +1 -1
- package/out/test/monitor/Monitor.test.js.map +1 -1
- package/out/test/services/Services.test.js.map +1 -1
- package/out/test/storage/KnexMigrations.test.js.map +1 -1
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -3
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
- package/out/test/storage/count.test.js.map +1 -1
- package/out/test/storage/find.test.js +5 -10
- package/out/test/storage/find.test.js.map +1 -1
- package/out/test/storage/findLegacy.test.js.map +1 -1
- package/out/test/storage/insert.test.js.map +1 -1
- package/out/test/storage/update.test.js +7 -19
- package/out/test/storage/update.test.js.map +1 -1
- package/out/test/storage/update2.test.js +22 -24
- package/out/test/storage/update2.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +3 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +52 -76
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/abortAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/abortAction.test.js.map +1 -0
- package/out/test/wallet/action/createAction.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/createAction.test.js +1 -2
- package/out/test/wallet/action/createAction.test.js.map +1 -0
- package/out/test/{Wallet → wallet}/action/createAction2.test.d.ts.map +1 -1
- package/out/test/{Wallet → wallet}/action/createAction2.test.js +6 -16
- package/out/test/wallet/action/createAction2.test.js.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/test/wallet/action/internalizeAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/relinquishOutput.test.js.map +1 -1
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.js.map +1 -1
- package/out/test/wallet/list/listActions.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions.test.js.map +1 -0
- package/out/test/wallet/list/listActions2.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions2.test.js.map +1 -0
- package/out/test/wallet/list/listCertificates.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/list/listCertificates.test.js +2 -6
- package/out/test/wallet/list/listCertificates.test.js.map +1 -0
- package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/list/listOutputs.test.js +2 -10
- package/out/test/wallet/list/listOutputs.test.js.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/sync/Wallet.sync.test.js +4 -6
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Setup.ts +15 -52
- package/src/Wallet.ts +58 -161
- package/src/monitor/Monitor.ts +7 -22
- package/src/monitor/MonitorDaemon.ts +6 -23
- package/src/monitor/tasks/TaskCheckForProofs.ts +4 -23
- package/src/monitor/tasks/TaskClock.ts +1 -3
- package/src/monitor/tasks/TaskFailAbandoned.ts +1 -3
- package/src/monitor/tasks/TaskNewHeader.ts +1 -4
- package/src/monitor/tasks/TaskPurge.ts +1 -2
- package/src/monitor/tasks/TaskReviewStatus.ts +1 -3
- package/src/monitor/tasks/TaskSendWaiting.ts +3 -10
- package/src/sdk/CertOps.ts +31 -103
- package/src/sdk/PrivilegedKeyManager.ts +18 -48
- package/src/sdk/WERR_errors.ts +6 -25
- package/src/sdk/WalletError.ts +5 -21
- package/src/sdk/WalletServices.interfaces.ts +11 -33
- package/src/sdk/WalletStorage.interfaces.ts +25 -91
- package/src/sdk/__test/CertificateLifeCycle.test.ts +9 -27
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +29 -66
- package/src/sdk/types.ts +6 -26
- package/src/sdk/validationHelpers.ts +111 -402
- package/src/services/Services.ts +51 -114
- package/src/services/__tests/bitrails.test.ts +4 -15
- package/src/services/__tests/getMerklePath.test.ts +1 -2
- package/src/services/__tests/getRawTx.test.ts +1 -3
- package/src/services/__tests/verifyBeef.test.ts +2 -1
- package/src/services/chaintracker/ChaintracksChainTracker.ts +3 -13
- package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +4 -12
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +9 -27
- package/src/services/createDefaultWalletServicesOptions.ts +2 -5
- package/src/services/providers/ARC.ts +5 -24
- package/src/services/providers/Bitails.ts +61 -159
- package/src/services/providers/SdkWhatsOnChain.ts +4 -17
- package/src/services/providers/WhatsOnChain.ts +31 -100
- package/src/services/providers/__tests/WhatsOnChain.test.ts +5 -15
- package/src/services/providers/echangeRates.ts +7 -22
- package/src/signer/WalletSigner.ts +1 -5
- package/src/signer/methods/acquireDirectCertificate.ts +1 -4
- package/src/signer/methods/buildSignableTransaction.ts +5 -20
- package/src/signer/methods/createAction.ts +15 -54
- package/src/signer/methods/internalizeAction.ts +10 -39
- package/src/signer/methods/proveCertificate.ts +2 -5
- package/src/signer/methods/signAction.ts +9 -39
- package/src/storage/StorageKnex.ts +166 -499
- package/src/storage/StorageProvider.ts +75 -291
- package/src/storage/StorageReader.ts +20 -65
- package/src/storage/StorageReaderWriter.ts +67 -264
- package/src/storage/StorageSyncReader.ts +2 -5
- package/src/storage/WalletStorageManager.ts +33 -108
- package/src/storage/__test/WalletStorageManager.test.ts +6 -23
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +53 -171
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +17 -28
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +9 -37
- package/src/storage/methods/createAction.ts +45 -181
- package/src/storage/methods/generateChange.ts +33 -114
- package/src/storage/methods/getBeefForTransaction.ts +7 -37
- package/src/storage/methods/getSyncChunk.ts +18 -69
- package/src/storage/methods/internalizeAction.ts +18 -70
- package/src/storage/methods/listActions.ts +6 -23
- package/src/storage/methods/listCertificates.ts +5 -14
- package/src/storage/methods/listOutputs.ts +14 -68
- package/src/storage/methods/processAction.ts +29 -104
- package/src/storage/methods/purgeData.ts +11 -45
- package/src/storage/methods/reviewStatus.ts +3 -9
- package/src/storage/remoting/StorageClient.ts +43 -146
- package/src/storage/remoting/StorageServer.ts +21 -59
- package/src/storage/schema/KnexMigrations.ts +34 -165
- package/src/storage/schema/entities/Certificate.ts +3 -14
- package/src/storage/schema/entities/CertificateField.ts +6 -28
- package/src/storage/schema/entities/Commission.ts +6 -23
- package/src/storage/schema/entities/EntityBase.ts +1 -6
- package/src/storage/schema/entities/MergeEntity.ts +14 -21
- package/src/storage/schema/entities/Output.ts +10 -39
- package/src/storage/schema/entities/OutputBasket.ts +4 -16
- package/src/storage/schema/entities/OutputTag.ts +4 -17
- package/src/storage/schema/entities/OutputTagMap.ts +7 -30
- package/src/storage/schema/entities/ProvenTx.ts +16 -57
- package/src/storage/schema/entities/ProvenTxReq.ts +29 -93
- package/src/storage/schema/entities/SyncState.ts +64 -116
- package/src/storage/schema/entities/Transaction.ts +10 -35
- package/src/storage/schema/entities/TxLabel.ts +4 -17
- package/src/storage/schema/entities/TxLabelMap.ts +6 -28
- package/src/storage/schema/entities/User.ts +8 -31
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +23 -54
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +26 -59
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +2 -11
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +1 -4
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +3 -14
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +4 -16
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +5 -18
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +5 -26
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +12 -48
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +4 -22
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +3 -10
- package/src/storage/schema/entities/__tests/usersTests.test.ts +4 -7
- package/src/storage/schema/tables/TableSettings.ts +1 -3
- package/src/storage/sync/StorageMySQLDojoReader.ts +47 -148
- package/src/utility/ScriptTemplateBRC29.ts +2 -11
- package/src/utility/stampLog.ts +2 -6
- package/src/utility/tscProofToMerklePath.ts +1 -4
- package/src/utility/utilityHelpers.buffer.ts +3 -12
- package/src/utility/utilityHelpers.ts +14 -49
- package/test/Wallet/StorageClient/storageClient.man.test.ts +2 -8
- package/test/Wallet/action/internalizeAction.a.test.ts +8 -23
- package/test/Wallet/certificate/acquireCertificate.test.ts +10 -24
- package/test/Wallet/certificate/listCertificates.test.ts +8 -18
- package/test/Wallet/get/getHeaderForHeight.test.ts +4 -15
- package/test/Wallet/get/getHeight.test.ts +2 -6
- package/test/Wallet/get/getKnownTxids.test.ts +1 -5
- package/test/Wallet/get/getNetwork.test.ts +1 -2
- package/test/Wallet/get/getVersion.test.ts +1 -2
- package/test/Wallet/live/walletLive.man.test.ts +14 -41
- package/test/Wallet/local/localWallet.man.test.ts +26 -99
- package/test/Wallet/specOps/specOps.man.test.ts +4 -13
- package/test/Wallet/support/janitor.man.test.ts +2 -7
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +11 -34
- package/test/Wallet/sync/setActive.test.ts +75 -61
- package/test/checkDB.ts +2 -8
- package/test/examples/backup.man.test.ts +2 -9
- package/test/examples/pushdrop.test.ts +7 -20
- package/test/monitor/Monitor.test.ts +33 -87
- package/test/services/Services.test.ts +8 -19
- package/test/storage/KnexMigrations.test.ts +3 -18
- package/test/storage/StorageMySQLDojoReader.man.test.ts +4 -15
- package/test/storage/count.test.ts +7 -24
- package/test/storage/find.test.ts +7 -29
- package/test/storage/findLegacy.test.ts +2 -5
- package/test/storage/insert.test.ts +3 -19
- package/test/storage/update.test.ts +47 -179
- package/test/storage/update2.test.ts +54 -176
- package/test/utils/TestUtilsWalletStorage.ts +139 -372
- package/test/{Wallet → wallet}/action/abortAction.test.ts +4 -12
- package/test/{Wallet → wallet}/action/createAction.test.ts +4 -14
- package/test/{Wallet → wallet}/action/createAction2.test.ts +74 -208
- package/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.ts +8 -11
- package/test/{Wallet → wallet}/action/internalizeAction.test.ts +20 -72
- package/test/{Wallet → wallet}/action/relinquishOutput.test.ts +3 -9
- package/test/{Wallet → wallet}/list/listActions.test.ts +2 -9
- package/test/{Wallet → wallet}/list/listActions2.test.ts +8 -34
- package/test/{Wallet → wallet}/list/listCertificates.test.ts +5 -16
- package/test/{Wallet → wallet}/list/listOutputs.test.ts +15 -54
- package/test/{Wallet → wallet}/sync/Wallet.sync.test.ts +18 -49
- package/out/src/sdk/StorageSyncReader.d.ts +0 -121
- package/out/src/sdk/StorageSyncReader.d.ts.map +0 -1
- package/out/src/sdk/StorageSyncReader.js +0 -3
- package/out/src/sdk/StorageSyncReader.js.map +0 -1
- package/out/src/sdk/StorageSyncReaderWriter.d.ts +0 -89
- package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +0 -1
- package/out/src/sdk/StorageSyncReaderWriter.js +0 -3
- package/out/src/sdk/StorageSyncReaderWriter.js.map +0 -1
- package/out/test/Wallet/action/abortAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/abortAction.test.js.map +0 -1
- package/out/test/Wallet/action/createAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/createAction.test.js.map +0 -1
- package/out/test/Wallet/action/createAction2.test.js.map +0 -1
- package/out/test/Wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +0 -1
- package/out/test/Wallet/action/internalizeAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/internalizeAction.test.js.map +0 -1
- package/out/test/Wallet/action/relinquishOutput.test.d.ts.map +0 -1
- package/out/test/Wallet/construct/Wallet.constructor.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions.test.js.map +0 -1
- package/out/test/Wallet/list/listActions2.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions2.test.js.map +0 -1
- package/out/test/Wallet/list/listCertificates.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listCertificates.test.js.map +0 -1
- package/out/test/Wallet/list/listOutputs.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listOutputs.test.js.map +0 -1
- package/out/test/Wallet/sync/Wallet.sync.test.d.ts.map +0 -1
- package/out/test/Wallet/sync/Wallet.sync.test.js.map +0 -1
- /package/out/test/{Wallet → wallet}/action/abortAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/abortAction.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/createAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createAction2.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/internalizeAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/internalizeAction.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/relinquishOutput.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/relinquishOutput.test.js +0 -0
- /package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions2.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions2.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listCertificates.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listOutputs.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/sync/Wallet.sync.test.d.ts +0 -0
- /package/test/{Wallet → wallet}/construct/Wallet.constructor.test.ts +0 -0
|
@@ -29,12 +29,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
29
29
|
public storageIdentityKey: string,
|
|
30
30
|
public maxOutputScriptLength: number
|
|
31
31
|
) {
|
|
32
|
-
this.migrations = this.setupMigrations(
|
|
33
|
-
chain,
|
|
34
|
-
storageName,
|
|
35
|
-
storageIdentityKey,
|
|
36
|
-
maxOutputScriptLength
|
|
37
|
-
)
|
|
32
|
+
this.migrations = this.setupMigrations(chain, storageName, storageIdentityKey, maxOutputScriptLength)
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
async getMigrations(): Promise<string[]> {
|
|
@@ -65,29 +60,13 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
65
60
|
): Record<string, Migration> {
|
|
66
61
|
const migrations: Record<string, Migration> = {}
|
|
67
62
|
|
|
68
|
-
const addTimeStamps = (
|
|
69
|
-
knex: Knex<any, any[]>,
|
|
70
|
-
table: Knex.CreateTableBuilder,
|
|
71
|
-
dbtype: DBType
|
|
72
|
-
) => {
|
|
63
|
+
const addTimeStamps = (knex: Knex<any, any[]>, table: Knex.CreateTableBuilder, dbtype: DBType) => {
|
|
73
64
|
if (dbtype === 'MySQL') {
|
|
74
|
-
table
|
|
75
|
-
|
|
76
|
-
.defaultTo(knex.fn.now(3))
|
|
77
|
-
.notNullable()
|
|
78
|
-
table
|
|
79
|
-
.timestamp('updated_at', { precision: 3 })
|
|
80
|
-
.defaultTo(knex.fn.now(3))
|
|
81
|
-
.notNullable()
|
|
65
|
+
table.timestamp('created_at', { precision: 3 }).defaultTo(knex.fn.now(3)).notNullable()
|
|
66
|
+
table.timestamp('updated_at', { precision: 3 }).defaultTo(knex.fn.now(3)).notNullable()
|
|
82
67
|
} else {
|
|
83
|
-
table
|
|
84
|
-
|
|
85
|
-
.defaultTo(knex.fn.now())
|
|
86
|
-
.notNullable()
|
|
87
|
-
table
|
|
88
|
-
.timestamp('updated_at', { precision: 3 })
|
|
89
|
-
.defaultTo(knex.fn.now())
|
|
90
|
-
.notNullable()
|
|
68
|
+
table.timestamp('created_at', { precision: 3 }).defaultTo(knex.fn.now()).notNullable()
|
|
69
|
+
table.timestamp('updated_at', { precision: 3 }).defaultTo(knex.fn.now()).notNullable()
|
|
91
70
|
}
|
|
92
71
|
}
|
|
93
72
|
|
|
@@ -142,9 +121,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
142
121
|
knex
|
|
143
122
|
})
|
|
144
123
|
const settings = await storage.makeAvailable()
|
|
145
|
-
await knex.raw(
|
|
146
|
-
`update users set activeStorage = '${settings.storageIdentityKey}' where activeStorage is NULL`
|
|
147
|
-
)
|
|
124
|
+
await knex.raw(`update users set activeStorage = '${settings.storageIdentityKey}' where activeStorage is NULL`)
|
|
148
125
|
await knex.schema.alterTable('users', table => {
|
|
149
126
|
table.string('activeStorage').notNullable().alter()
|
|
150
127
|
})
|
|
@@ -187,11 +164,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
187
164
|
await knex.schema.createTable('proven_tx_reqs', table => {
|
|
188
165
|
addTimeStamps(knex, table, dbtype)
|
|
189
166
|
table.increments('provenTxReqId')
|
|
190
|
-
table
|
|
191
|
-
.integer('provenTxId')
|
|
192
|
-
.unsigned()
|
|
193
|
-
.references('provenTxId')
|
|
194
|
-
.inTable('proven_txs')
|
|
167
|
+
table.integer('provenTxId').unsigned().references('provenTxId').inTable('proven_txs')
|
|
195
168
|
table.string('status', 16).notNullable().defaultTo('unknown')
|
|
196
169
|
table.integer('attempts').unsigned().defaultTo(0).notNullable()
|
|
197
170
|
table.boolean('notified').notNullable().defaultTo(false)
|
|
@@ -212,12 +185,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
212
185
|
await knex.schema.createTable('certificates', table => {
|
|
213
186
|
addTimeStamps(knex, table, dbtype)
|
|
214
187
|
table.increments('certificateId')
|
|
215
|
-
table
|
|
216
|
-
.integer('userId')
|
|
217
|
-
.unsigned()
|
|
218
|
-
.references('userId')
|
|
219
|
-
.inTable('users')
|
|
220
|
-
.notNullable()
|
|
188
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
221
189
|
table.string('serialNumber', 100).notNullable()
|
|
222
190
|
table.string('type', 100).notNullable()
|
|
223
191
|
table.string('certifier', 100).notNullable()
|
|
@@ -230,18 +198,8 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
230
198
|
})
|
|
231
199
|
await knex.schema.createTable('certificate_fields', table => {
|
|
232
200
|
addTimeStamps(knex, table, dbtype)
|
|
233
|
-
table
|
|
234
|
-
|
|
235
|
-
.unsigned()
|
|
236
|
-
.references('userId')
|
|
237
|
-
.inTable('users')
|
|
238
|
-
.notNullable()
|
|
239
|
-
table
|
|
240
|
-
.integer('certificateId')
|
|
241
|
-
.unsigned()
|
|
242
|
-
.references('certificateId')
|
|
243
|
-
.inTable('certificates')
|
|
244
|
-
.notNullable()
|
|
201
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
202
|
+
table.integer('certificateId').unsigned().references('certificateId').inTable('certificates').notNullable()
|
|
245
203
|
table.string('fieldName', 100).notNullable()
|
|
246
204
|
table.string('fieldValue').notNullable()
|
|
247
205
|
table.string('masterKey', 255).defaultTo('').notNullable()
|
|
@@ -250,35 +208,18 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
250
208
|
await knex.schema.createTable('output_baskets', table => {
|
|
251
209
|
addTimeStamps(knex, table, dbtype)
|
|
252
210
|
table.increments('basketId')
|
|
253
|
-
table
|
|
254
|
-
.integer('userId')
|
|
255
|
-
.unsigned()
|
|
256
|
-
.references('userId')
|
|
257
|
-
.inTable('users')
|
|
258
|
-
.notNullable()
|
|
211
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
259
212
|
table.string('name', 300).notNullable()
|
|
260
213
|
table.integer('numberOfDesiredUTXOs', 6).defaultTo(6).notNullable()
|
|
261
|
-
table
|
|
262
|
-
.integer('minimumDesiredUTXOValue', 15)
|
|
263
|
-
.defaultTo(10000)
|
|
264
|
-
.notNullable()
|
|
214
|
+
table.integer('minimumDesiredUTXOValue', 15).defaultTo(10000).notNullable()
|
|
265
215
|
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
266
216
|
table.unique(['name', 'userId'])
|
|
267
217
|
})
|
|
268
218
|
await knex.schema.createTable('transactions', table => {
|
|
269
219
|
addTimeStamps(knex, table, dbtype)
|
|
270
220
|
table.increments('transactionId')
|
|
271
|
-
table
|
|
272
|
-
|
|
273
|
-
.unsigned()
|
|
274
|
-
.references('userId')
|
|
275
|
-
.inTable('users')
|
|
276
|
-
.notNullable()
|
|
277
|
-
table
|
|
278
|
-
.integer('provenTxId')
|
|
279
|
-
.unsigned()
|
|
280
|
-
.references('provenTxId')
|
|
281
|
-
.inTable('proven_txs')
|
|
221
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
222
|
+
table.integer('provenTxId').unsigned().references('provenTxId').inTable('proven_txs')
|
|
282
223
|
table.string('status', 64).notNullable()
|
|
283
224
|
table.string('reference', 64).notNullable().unique()
|
|
284
225
|
table.boolean('isOutgoing').notNullable()
|
|
@@ -294,12 +235,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
294
235
|
await knex.schema.createTable('commissions', table => {
|
|
295
236
|
addTimeStamps(knex, table, dbtype)
|
|
296
237
|
table.increments('commissionId')
|
|
297
|
-
table
|
|
298
|
-
.integer('userId')
|
|
299
|
-
.unsigned()
|
|
300
|
-
.references('userId')
|
|
301
|
-
.inTable('users')
|
|
302
|
-
.notNullable()
|
|
238
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
303
239
|
table
|
|
304
240
|
.integer('transactionId')
|
|
305
241
|
.unsigned()
|
|
@@ -316,23 +252,9 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
316
252
|
await knex.schema.createTable('outputs', table => {
|
|
317
253
|
addTimeStamps(knex, table, dbtype)
|
|
318
254
|
table.increments('outputId')
|
|
319
|
-
table
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
.references('userId')
|
|
323
|
-
.inTable('users')
|
|
324
|
-
.notNullable()
|
|
325
|
-
table
|
|
326
|
-
.integer('transactionId')
|
|
327
|
-
.unsigned()
|
|
328
|
-
.references('transactionId')
|
|
329
|
-
.inTable('transactions')
|
|
330
|
-
.notNullable()
|
|
331
|
-
table
|
|
332
|
-
.integer('basketId')
|
|
333
|
-
.unsigned()
|
|
334
|
-
.references('basketId')
|
|
335
|
-
.inTable('output_baskets')
|
|
255
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
256
|
+
table.integer('transactionId').unsigned().references('transactionId').inTable('transactions').notNullable()
|
|
257
|
+
table.integer('basketId').unsigned().references('basketId').inTable('output_baskets')
|
|
336
258
|
table.boolean('spendable').defaultTo(false).notNullable()
|
|
337
259
|
table.boolean('change').defaultTo(false).notNullable()
|
|
338
260
|
table.integer('vout', 10).notNullable()
|
|
@@ -346,11 +268,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
346
268
|
table.string('derivationPrefix', 32)
|
|
347
269
|
table.string('derivationSuffix', 32)
|
|
348
270
|
table.string('customInstructions', 2500)
|
|
349
|
-
table
|
|
350
|
-
.integer('spentBy')
|
|
351
|
-
.unsigned()
|
|
352
|
-
.references('transactionId')
|
|
353
|
-
.inTable('transactions')
|
|
271
|
+
table.integer('spentBy').unsigned().references('transactionId').inTable('transactions')
|
|
354
272
|
table.integer('sequenceNumber').unsigned().nullable()
|
|
355
273
|
table.string('spendingDescription')
|
|
356
274
|
table.bigint('scriptLength').unsigned().nullable()
|
|
@@ -361,30 +279,15 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
361
279
|
await knex.schema.createTable('output_tags', table => {
|
|
362
280
|
addTimeStamps(knex, table, dbtype)
|
|
363
281
|
table.increments('outputTagId')
|
|
364
|
-
table
|
|
365
|
-
.integer('userId')
|
|
366
|
-
.unsigned()
|
|
367
|
-
.references('userId')
|
|
368
|
-
.inTable('users')
|
|
369
|
-
.notNullable()
|
|
282
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
370
283
|
table.string('tag', 150).notNullable()
|
|
371
284
|
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
372
285
|
table.unique(['tag', 'userId'])
|
|
373
286
|
})
|
|
374
287
|
await knex.schema.createTable('output_tags_map', table => {
|
|
375
288
|
addTimeStamps(knex, table, dbtype)
|
|
376
|
-
table
|
|
377
|
-
|
|
378
|
-
.unsigned()
|
|
379
|
-
.references('outputTagId')
|
|
380
|
-
.inTable('output_tags')
|
|
381
|
-
.notNullable()
|
|
382
|
-
table
|
|
383
|
-
.integer('outputId')
|
|
384
|
-
.unsigned()
|
|
385
|
-
.references('outputId')
|
|
386
|
-
.inTable('outputs')
|
|
387
|
-
.notNullable()
|
|
289
|
+
table.integer('outputTagId').unsigned().references('outputTagId').inTable('output_tags').notNullable()
|
|
290
|
+
table.integer('outputId').unsigned().references('outputId').inTable('outputs').notNullable()
|
|
388
291
|
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
389
292
|
table.unique(['outputTagId', 'outputId'])
|
|
390
293
|
table.index('outputId')
|
|
@@ -392,30 +295,15 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
392
295
|
await knex.schema.createTable('tx_labels', table => {
|
|
393
296
|
addTimeStamps(knex, table, dbtype)
|
|
394
297
|
table.increments('txLabelId')
|
|
395
|
-
table
|
|
396
|
-
.integer('userId')
|
|
397
|
-
.unsigned()
|
|
398
|
-
.references('userId')
|
|
399
|
-
.inTable('users')
|
|
400
|
-
.notNullable()
|
|
298
|
+
table.integer('userId').unsigned().references('userId').inTable('users').notNullable()
|
|
401
299
|
table.string('label', 300).notNullable()
|
|
402
300
|
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
403
301
|
table.unique(['label', 'userId'])
|
|
404
302
|
})
|
|
405
303
|
await knex.schema.createTable('tx_labels_map', table => {
|
|
406
304
|
addTimeStamps(knex, table, dbtype)
|
|
407
|
-
table
|
|
408
|
-
|
|
409
|
-
.unsigned()
|
|
410
|
-
.references('txLabelId')
|
|
411
|
-
.inTable('tx_labels')
|
|
412
|
-
.notNullable()
|
|
413
|
-
table
|
|
414
|
-
.integer('transactionId')
|
|
415
|
-
.unsigned()
|
|
416
|
-
.references('transactionId')
|
|
417
|
-
.inTable('transactions')
|
|
418
|
-
.notNullable()
|
|
305
|
+
table.integer('txLabelId').unsigned().references('txLabelId').inTable('tx_labels').notNullable()
|
|
306
|
+
table.integer('transactionId').unsigned().references('transactionId').inTable('transactions').notNullable()
|
|
419
307
|
table.boolean('isDeleted').notNullable().defaultTo(false)
|
|
420
308
|
table.unique(['txLabelId', 'transactionId'])
|
|
421
309
|
table.index('transactionId')
|
|
@@ -437,12 +325,7 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
437
325
|
await knex.schema.createTable('sync_states', table => {
|
|
438
326
|
addTimeStamps(knex, table, dbtype)
|
|
439
327
|
table.increments('syncStateId')
|
|
440
|
-
table
|
|
441
|
-
.integer('userId')
|
|
442
|
-
.unsigned()
|
|
443
|
-
.notNullable()
|
|
444
|
-
.references('userId')
|
|
445
|
-
.inTable('users')
|
|
328
|
+
table.integer('userId').unsigned().notNullable().references('userId').inTable('users')
|
|
446
329
|
table.string('storageIdentityKey', 130).notNullable().defaultTo('')
|
|
447
330
|
table.string('storageName').notNullable()
|
|
448
331
|
table.string('status').notNullable().defaultTo('unknown')
|
|
@@ -458,22 +341,12 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
458
341
|
})
|
|
459
342
|
|
|
460
343
|
if (dbtype === 'MySQL') {
|
|
461
|
-
await knex.raw(
|
|
462
|
-
|
|
463
|
-
)
|
|
464
|
-
await knex.raw(
|
|
465
|
-
'ALTER TABLE proven_tx_reqs MODIFY COLUMN inputBEEF LONGBLOB'
|
|
466
|
-
)
|
|
344
|
+
await knex.raw('ALTER TABLE proven_tx_reqs MODIFY COLUMN rawTx LONGBLOB')
|
|
345
|
+
await knex.raw('ALTER TABLE proven_tx_reqs MODIFY COLUMN inputBEEF LONGBLOB')
|
|
467
346
|
await knex.raw('ALTER TABLE proven_txs MODIFY COLUMN rawTx LONGBLOB')
|
|
468
|
-
await knex.raw(
|
|
469
|
-
|
|
470
|
-
)
|
|
471
|
-
await knex.raw(
|
|
472
|
-
'ALTER TABLE transactions MODIFY COLUMN inputBEEF LONGBLOB'
|
|
473
|
-
)
|
|
474
|
-
await knex.raw(
|
|
475
|
-
'ALTER TABLE outputs MODIFY COLUMN lockingScript LONGBLOB'
|
|
476
|
-
)
|
|
347
|
+
await knex.raw('ALTER TABLE transactions MODIFY COLUMN rawTx LONGBLOB')
|
|
348
|
+
await knex.raw('ALTER TABLE transactions MODIFY COLUMN inputBEEF LONGBLOB')
|
|
349
|
+
await knex.raw('ALTER TABLE outputs MODIFY COLUMN lockingScript LONGBLOB')
|
|
477
350
|
} else {
|
|
478
351
|
await knex.schema.alterTable('proven_tx_reqs', table => {
|
|
479
352
|
table.binary('rawTx', 10000000).alter()
|
|
@@ -538,16 +411,12 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
538
411
|
if (r['rows']) r = r.rows
|
|
539
412
|
const dbtype: 'SQLite' | 'MySQL' | 'Unknown' = r[0].database_type
|
|
540
413
|
if (dbtype === 'Unknown')
|
|
541
|
-
throw new sdk.WERR_NOT_IMPLEMENTED(
|
|
542
|
-
`Attempting to create database on unsuported engine.`
|
|
543
|
-
)
|
|
414
|
+
throw new sdk.WERR_NOT_IMPLEMENTED(`Attempting to create database on unsuported engine.`)
|
|
544
415
|
return dbtype
|
|
545
416
|
} catch (eu: unknown) {
|
|
546
417
|
const e = sdk.WalletError.fromUnknown(eu)
|
|
547
418
|
if (e.code === 'SQLITE_ERROR') return 'SQLite'
|
|
548
|
-
throw new sdk.WERR_NOT_IMPLEMENTED(
|
|
549
|
-
`Attempting to create database on unsuported engine.`
|
|
550
|
-
)
|
|
419
|
+
throw new sdk.WERR_NOT_IMPLEMENTED(`Attempting to create database on unsuported engine.`)
|
|
551
420
|
}
|
|
552
421
|
}
|
|
553
422
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
|
-
import {
|
|
4
|
-
arraysEqual,
|
|
5
|
-
sdk,
|
|
6
|
-
TableCertificate,
|
|
7
|
-
verifyId,
|
|
8
|
-
verifyOneOrNone
|
|
9
|
-
} from '../../../index.client'
|
|
3
|
+
import { arraysEqual, sdk, TableCertificate, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
10
4
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
11
5
|
|
|
12
6
|
export class EntityCertificate extends EntityBase<TableCertificate> {
|
|
@@ -162,12 +156,7 @@ export class EntityCertificate extends EntityBase<TableCertificate> {
|
|
|
162
156
|
}
|
|
163
157
|
}
|
|
164
158
|
|
|
165
|
-
override async mergeNew(
|
|
166
|
-
storage: EntityStorage,
|
|
167
|
-
userId: number,
|
|
168
|
-
syncMap: SyncMap,
|
|
169
|
-
trx?: sdk.TrxToken
|
|
170
|
-
): Promise<void> {
|
|
159
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
171
160
|
this.userId = userId
|
|
172
161
|
this.certificateId = 0
|
|
173
162
|
this.certificateId = await storage.insertCertificate(this.toApi(), trx)
|
|
@@ -189,7 +178,7 @@ export class EntityCertificate extends EntityBase<TableCertificate> {
|
|
|
189
178
|
this.signature = ei.signature
|
|
190
179
|
this.verifier = ei.verifier
|
|
191
180
|
this.isDeleted = ei.isDeleted
|
|
192
|
-
this.updated_at = new Date()
|
|
181
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
193
182
|
await storage.updateCertificate(this.id, this.toApi(), trx)
|
|
194
183
|
wasMerged = true
|
|
195
184
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { MerklePath } from '@bsv/sdk'
|
|
2
|
-
import {
|
|
3
|
-
arraysEqual,
|
|
4
|
-
sdk,
|
|
5
|
-
TableCertificateField,
|
|
6
|
-
verifyId,
|
|
7
|
-
verifyOneOrNone
|
|
8
|
-
} from '../../../index.client'
|
|
2
|
+
import { arraysEqual, sdk, TableCertificateField, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
9
3
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
10
4
|
|
|
11
5
|
export class EntityCertificateField extends EntityBase<TableCertificateField> {
|
|
@@ -81,15 +75,9 @@ export class EntityCertificateField extends EntityBase<TableCertificateField> {
|
|
|
81
75
|
return 'certificate_fields'
|
|
82
76
|
}
|
|
83
77
|
|
|
84
|
-
override equals(
|
|
85
|
-
ei: TableCertificateField,
|
|
86
|
-
syncMap?: SyncMap | undefined
|
|
87
|
-
): boolean {
|
|
78
|
+
override equals(ei: TableCertificateField, syncMap?: SyncMap | undefined): boolean {
|
|
88
79
|
if (
|
|
89
|
-
this.certificateId !==
|
|
90
|
-
(syncMap
|
|
91
|
-
? syncMap.certificate.idMap[ei.certificateId]
|
|
92
|
-
: ei.certificateId) ||
|
|
80
|
+
this.certificateId !== (syncMap ? syncMap.certificate.idMap[ei.certificateId] : ei.certificateId) ||
|
|
93
81
|
this.fieldName !== ei.fieldName ||
|
|
94
82
|
this.fieldValue !== ei.fieldValue ||
|
|
95
83
|
this.masterKey !== ei.masterKey
|
|
@@ -120,12 +108,7 @@ export class EntityCertificateField extends EntityBase<TableCertificateField> {
|
|
|
120
108
|
}
|
|
121
109
|
}
|
|
122
110
|
|
|
123
|
-
override async mergeNew(
|
|
124
|
-
storage: EntityStorage,
|
|
125
|
-
userId: number,
|
|
126
|
-
syncMap: SyncMap,
|
|
127
|
-
trx?: sdk.TrxToken
|
|
128
|
-
): Promise<void> {
|
|
111
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
129
112
|
this.certificateId = syncMap.certificate.idMap[this.certificateId]
|
|
130
113
|
this.userId = userId
|
|
131
114
|
await storage.insertCertificateField(this.toApi(), trx)
|
|
@@ -142,13 +125,8 @@ export class EntityCertificateField extends EntityBase<TableCertificateField> {
|
|
|
142
125
|
if (ei.updated_at > this.updated_at) {
|
|
143
126
|
this.fieldValue = ei.fieldValue
|
|
144
127
|
this.masterKey = ei.masterKey
|
|
145
|
-
this.updated_at = new Date()
|
|
146
|
-
await storage.updateCertificateField(
|
|
147
|
-
this.certificateId,
|
|
148
|
-
this.fieldName,
|
|
149
|
-
this.toApi(),
|
|
150
|
-
trx
|
|
151
|
-
)
|
|
128
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
129
|
+
await storage.updateCertificateField(this.certificateId, this.fieldName, this.toApi(), trx)
|
|
152
130
|
wasMerged = true
|
|
153
131
|
}
|
|
154
132
|
return wasMerged
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
|
-
import {
|
|
4
|
-
arraysEqual,
|
|
5
|
-
sdk,
|
|
6
|
-
TableCommission,
|
|
7
|
-
verifyId,
|
|
8
|
-
verifyOneOrNone
|
|
9
|
-
} from '../../../index.client'
|
|
3
|
+
import { arraysEqual, sdk, TableCommission, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
10
4
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
11
5
|
|
|
12
6
|
export class EntityCommission extends EntityBase<TableCommission> {
|
|
@@ -102,10 +96,7 @@ export class EntityCommission extends EntityBase<TableCommission> {
|
|
|
102
96
|
override equals(ei: TableCommission, syncMap?: SyncMap | undefined): boolean {
|
|
103
97
|
if (
|
|
104
98
|
this.isRedeemed !== ei.isRedeemed ||
|
|
105
|
-
this.transactionId !==
|
|
106
|
-
(syncMap
|
|
107
|
-
? syncMap.transaction.idMap[ei.transactionId]
|
|
108
|
-
: ei.transactionId) ||
|
|
99
|
+
this.transactionId !== (syncMap ? syncMap.transaction.idMap[ei.transactionId] : ei.transactionId) ||
|
|
109
100
|
this.keyOffset !== ei.keyOffset ||
|
|
110
101
|
!arraysEqual(this.lockingScript, ei.lockingScript) ||
|
|
111
102
|
this.satoshis !== ei.satoshis
|
|
@@ -123,9 +114,7 @@ export class EntityCommission extends EntityBase<TableCommission> {
|
|
|
123
114
|
trx?: sdk.TrxToken
|
|
124
115
|
): Promise<{ found: boolean; eo: EntityCommission; eiId: number }> {
|
|
125
116
|
const transactionId = syncMap.transaction.idMap[ei.transactionId]
|
|
126
|
-
const ef = verifyOneOrNone(
|
|
127
|
-
await storage.findCommissions({ partial: { transactionId, userId }, trx })
|
|
128
|
-
)
|
|
117
|
+
const ef = verifyOneOrNone(await storage.findCommissions({ partial: { transactionId, userId }, trx }))
|
|
129
118
|
return {
|
|
130
119
|
found: !!ef,
|
|
131
120
|
eo: new EntityCommission(ef || { ...ei }),
|
|
@@ -133,14 +122,8 @@ export class EntityCommission extends EntityBase<TableCommission> {
|
|
|
133
122
|
}
|
|
134
123
|
}
|
|
135
124
|
|
|
136
|
-
override async mergeNew(
|
|
137
|
-
|
|
138
|
-
userId: number,
|
|
139
|
-
syncMap: SyncMap,
|
|
140
|
-
trx?: sdk.TrxToken
|
|
141
|
-
): Promise<void> {
|
|
142
|
-
if (this.transactionId)
|
|
143
|
-
this.transactionId = syncMap.transaction.idMap[this.transactionId]
|
|
125
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
126
|
+
if (this.transactionId) this.transactionId = syncMap.transaction.idMap[this.transactionId]
|
|
144
127
|
this.userId = userId
|
|
145
128
|
this.commissionId = 0
|
|
146
129
|
this.commissionId = await storage.insertCommission(this.toApi(), trx)
|
|
@@ -156,7 +139,7 @@ export class EntityCommission extends EntityBase<TableCommission> {
|
|
|
156
139
|
let wasMerged = false
|
|
157
140
|
if (ei.updated_at > this.updated_at) {
|
|
158
141
|
this.isRedeemed = ei.isRedeemed
|
|
159
|
-
this.updated_at = new Date()
|
|
142
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
160
143
|
await storage.updateCommission(this.id, this.toApi(), trx)
|
|
161
144
|
wasMerged = true
|
|
162
145
|
}
|
|
@@ -53,12 +53,7 @@ export abstract class EntityBase<T> {
|
|
|
53
53
|
* @param userId local userId
|
|
54
54
|
* @param syncMap
|
|
55
55
|
*/
|
|
56
|
-
abstract mergeNew(
|
|
57
|
-
storage: EntityStorage,
|
|
58
|
-
userId: number,
|
|
59
|
-
syncMap: SyncMap,
|
|
60
|
-
trx?: sdk.TrxToken
|
|
61
|
-
): Promise<void>
|
|
56
|
+
abstract mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void>
|
|
62
57
|
|
|
63
58
|
/**
|
|
64
59
|
* Perform a 'merge' / 'convergent' equality migration of state
|
|
@@ -6,10 +6,7 @@ import { EntityBase, EntityStorage, EntitySyncMap, SyncMap } from './EntityBase'
|
|
|
6
6
|
* @param API one of the storage table interfaces.
|
|
7
7
|
* @param DE the corresponding entity class
|
|
8
8
|
*/
|
|
9
|
-
export class MergeEntity<
|
|
10
|
-
API extends sdk.EntityTimeStamp,
|
|
11
|
-
DE extends EntityBase<API>
|
|
12
|
-
> {
|
|
9
|
+
export class MergeEntity<API extends sdk.EntityTimeStamp, DE extends EntityBase<API>> {
|
|
13
10
|
idMap: Record<number, number>
|
|
14
11
|
|
|
15
12
|
constructor(
|
|
@@ -33,9 +30,7 @@ export class MergeEntity<
|
|
|
33
30
|
if (map[i] === undefined) {
|
|
34
31
|
map[i] = o
|
|
35
32
|
} else if (map[i] !== o)
|
|
36
|
-
throw new sdk.WERR_INTERNAL(
|
|
37
|
-
`updateSyncMap map[${inId}] can't override ${map[i]} with ${o}`
|
|
38
|
-
)
|
|
33
|
+
throw new sdk.WERR_INTERNAL(`updateSyncMap map[${inId}] can't override ${map[i]} with ${o}`)
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
/**
|
|
@@ -57,22 +52,20 @@ export class MergeEntity<
|
|
|
57
52
|
* TODO:
|
|
58
53
|
* Switch to using syncMap. If the ei id is in the map its an existing merge, else its a new merge.
|
|
59
54
|
*/
|
|
60
|
-
|
|
61
|
-
storage,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
updates++
|
|
55
|
+
try {
|
|
56
|
+
const { found, eo, eiId } = await this.find(storage, userId, ei, syncMap, trx)
|
|
57
|
+
if (found) {
|
|
58
|
+
if (await eo.mergeExisting(storage, since, ei, syncMap, trx)) {
|
|
59
|
+
updates++
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
await eo.mergeNew(storage, userId, syncMap, trx)
|
|
63
|
+
inserts++
|
|
70
64
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
if (eiId > -1) this.updateSyncMap(this.idMap, eiId, eo.id)
|
|
66
|
+
} catch (eu: unknown) {
|
|
67
|
+
throw eu
|
|
74
68
|
}
|
|
75
|
-
if (eiId > -1) this.updateSyncMap(this.idMap, eiId, eo.id)
|
|
76
69
|
}
|
|
77
70
|
return { inserts, updates }
|
|
78
71
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
|
-
import {
|
|
4
|
-
arraysEqual,
|
|
5
|
-
optionalArraysEqual,
|
|
6
|
-
sdk,
|
|
7
|
-
TableOutput,
|
|
8
|
-
verifyId,
|
|
9
|
-
verifyOneOrNone
|
|
10
|
-
} from '../../../index.client'
|
|
3
|
+
import { arraysEqual, optionalArraysEqual, sdk, TableOutput, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
11
4
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
12
5
|
|
|
13
6
|
export class EntityOutput extends EntityBase<TableOutput> {
|
|
@@ -209,18 +202,9 @@ export class EntityOutput extends EntityBase<TableOutput> {
|
|
|
209
202
|
|
|
210
203
|
override equals(ei: TableOutput, syncMap?: SyncMap | undefined): boolean {
|
|
211
204
|
if (
|
|
212
|
-
this.transactionId !==
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
: ei.transactionId) ||
|
|
216
|
-
this.basketId !==
|
|
217
|
-
(syncMap && ei.basketId
|
|
218
|
-
? syncMap.outputBasket.idMap[ei.basketId]
|
|
219
|
-
: ei.basketId) ||
|
|
220
|
-
this.spentBy !==
|
|
221
|
-
(syncMap && ei.spentBy
|
|
222
|
-
? syncMap.transaction.idMap[ei.spentBy]
|
|
223
|
-
: ei.spentBy) ||
|
|
205
|
+
this.transactionId !== (syncMap ? syncMap.transaction.idMap[ei.transactionId] : ei.transactionId) ||
|
|
206
|
+
this.basketId !== (syncMap && ei.basketId ? syncMap.outputBasket.idMap[ei.basketId] : ei.basketId) ||
|
|
207
|
+
this.spentBy !== (syncMap && ei.spentBy ? syncMap.transaction.idMap[ei.spentBy] : ei.spentBy) ||
|
|
224
208
|
this.vout !== ei.vout ||
|
|
225
209
|
this.satoshis !== ei.satoshis ||
|
|
226
210
|
this.spendable !== ei.spendable ||
|
|
@@ -252,9 +236,7 @@ export class EntityOutput extends EntityBase<TableOutput> {
|
|
|
252
236
|
trx?: sdk.TrxToken
|
|
253
237
|
): Promise<{ found: boolean; eo: EntityOutput; eiId: number }> {
|
|
254
238
|
const transactionId = syncMap.transaction.idMap[ei.transactionId]
|
|
255
|
-
const basketId = ei.basketId
|
|
256
|
-
? syncMap.outputBasket.idMap[ei.basketId]
|
|
257
|
-
: null
|
|
239
|
+
const basketId = ei.basketId ? syncMap.outputBasket.idMap[ei.basketId] : null
|
|
258
240
|
const ef = verifyOneOrNone(
|
|
259
241
|
await storage.findOutputs({
|
|
260
242
|
partial: { userId, transactionId, vout: ei.vout },
|
|
@@ -268,20 +250,11 @@ export class EntityOutput extends EntityBase<TableOutput> {
|
|
|
268
250
|
}
|
|
269
251
|
}
|
|
270
252
|
|
|
271
|
-
override async mergeNew(
|
|
272
|
-
storage: EntityStorage,
|
|
273
|
-
userId: number,
|
|
274
|
-
syncMap: SyncMap,
|
|
275
|
-
trx?: sdk.TrxToken
|
|
276
|
-
): Promise<void> {
|
|
253
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
277
254
|
this.userId = userId
|
|
278
|
-
this.basketId = this.basketId
|
|
279
|
-
? syncMap.outputBasket.idMap[this.basketId]
|
|
280
|
-
: undefined
|
|
255
|
+
this.basketId = this.basketId ? syncMap.outputBasket.idMap[this.basketId] : undefined
|
|
281
256
|
this.transactionId = syncMap.transaction.idMap[this.transactionId]
|
|
282
|
-
this.spentBy = this.spentBy
|
|
283
|
-
? syncMap.transaction.idMap[this.spentBy]
|
|
284
|
-
: undefined
|
|
257
|
+
this.spentBy = this.spentBy ? syncMap.transaction.idMap[this.spentBy] : undefined
|
|
285
258
|
this.outputId = 0
|
|
286
259
|
this.outputId = await storage.insertOutput(this.toApi(), trx)
|
|
287
260
|
}
|
|
@@ -295,9 +268,7 @@ export class EntityOutput extends EntityBase<TableOutput> {
|
|
|
295
268
|
): Promise<boolean> {
|
|
296
269
|
let wasMerged = false
|
|
297
270
|
if (ei.updated_at > this.updated_at) {
|
|
298
|
-
this.spentBy = ei.spentBy
|
|
299
|
-
? syncMap.transaction.idMap[ei.spentBy]
|
|
300
|
-
: undefined
|
|
271
|
+
this.spentBy = ei.spentBy ? syncMap.transaction.idMap[ei.spentBy] : undefined
|
|
301
272
|
this.spendable = ei.spendable
|
|
302
273
|
this.change = ei.change
|
|
303
274
|
this.type = ei.type
|
|
@@ -310,7 +281,7 @@ export class EntityOutput extends EntityBase<TableOutput> {
|
|
|
310
281
|
this.scriptLength = ei.scriptLength
|
|
311
282
|
this.scriptOffset = ei.scriptOffset
|
|
312
283
|
this.lockingScript = ei.lockingScript
|
|
313
|
-
this.updated_at = new Date()
|
|
284
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
314
285
|
await storage.updateOutput(this.id, this.toApi(), trx)
|
|
315
286
|
wasMerged = true
|
|
316
287
|
}
|