@bsv/wallet-toolbox 1.1.60 → 1.1.62
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/ARC.test.js +9 -0
- package/out/src/services/__tests/ARC.test.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 +2 -3
- 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 +5 -12
- 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 +39 -31
- 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.js.map +1 -1
- package/out/test/wallet/action/createAction.test.js +1 -2
- package/out/test/wallet/action/createAction.test.js.map +1 -1
- package/out/test/wallet/action/createAction2.test.d.ts.map +1 -1
- package/out/test/wallet/action/createAction2.test.js +6 -16
- package/out/test/wallet/action/createAction2.test.js.map +1 -1
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -1
- package/out/test/wallet/action/relinquishOutput.test.js.map +1 -1
- package/out/test/wallet/list/listActions.test.js.map +1 -1
- package/out/test/wallet/list/listActions2.test.js.map +1 -1
- package/out/test/wallet/list/listCertificates.test.js +2 -6
- package/out/test/wallet/list/listCertificates.test.js.map +1 -1
- package/out/test/wallet/list/listOutputs.test.js +2 -10
- package/out/test/wallet/list/listOutputs.test.js.map +1 -1
- package/out/test/wallet/sync/Wallet.sync.test.js +4 -6
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -1
- 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/ARC.test.ts +14 -1
- 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/processingErrors/arcSuccessError.json +76 -0
- package/src/services/providers/ARC.ts +6 -25
- 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 +15 -69
- 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 +45 -102
- 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/action/abortAction.test.ts +4 -12
- package/test/wallet/action/createAction.test.ts +4 -14
- package/test/wallet/action/createAction2.test.ts +74 -208
- package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +8 -11
- package/test/wallet/action/internalizeAction.test.ts +20 -72
- package/test/wallet/action/relinquishOutput.test.ts +3 -9
- package/test/wallet/list/listActions.test.ts +2 -9
- package/test/wallet/list/listActions2.test.ts +8 -34
- package/test/wallet/list/listCertificates.test.ts +5 -16
- package/test/wallet/list/listOutputs.test.ts +15 -54
- package/test/wallet/sync/Wallet.sync.test.ts +18 -49
|
@@ -7,10 +7,7 @@ export async function updateChaintracksFiatExchangeRates(
|
|
|
7
7
|
): Promise<sdk.FiatExchangeRates> {
|
|
8
8
|
const url = options.chaintracksFiatExchangeRatesUrl
|
|
9
9
|
|
|
10
|
-
if (!url)
|
|
11
|
-
throw new sdk.WERR_MISSING_PARAMETER(
|
|
12
|
-
'options.chaintracksFiatExchangeRatesUrl'
|
|
13
|
-
)
|
|
10
|
+
if (!url) throw new sdk.WERR_MISSING_PARAMETER('options.chaintracksFiatExchangeRatesUrl')
|
|
14
11
|
|
|
15
12
|
const r = await axios.get(url)
|
|
16
13
|
|
|
@@ -28,20 +25,14 @@ export async function updateExchangeratesapi(
|
|
|
28
25
|
targetCurrencies: string[],
|
|
29
26
|
options: sdk.WalletServicesOptions
|
|
30
27
|
): Promise<sdk.FiatExchangeRates> {
|
|
31
|
-
if (!options.exchangeratesapiKey)
|
|
32
|
-
throw new sdk.WERR_MISSING_PARAMETER('options.exchangeratesapiKey')
|
|
28
|
+
if (!options.exchangeratesapiKey) throw new sdk.WERR_MISSING_PARAMETER('options.exchangeratesapiKey')
|
|
33
29
|
|
|
34
30
|
const iorates = await getExchangeRatesIo(options.exchangeratesapiKey)
|
|
35
31
|
|
|
36
|
-
if (!iorates.success)
|
|
37
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
38
|
-
`getExchangeRatesIo returned success ${iorates.success}`
|
|
39
|
-
)
|
|
32
|
+
if (!iorates.success) throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo returned success ${iorates.success}`)
|
|
40
33
|
|
|
41
34
|
if (!iorates.rates['USD'] || !iorates.rates[iorates.base])
|
|
42
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
43
|
-
`getExchangeRatesIo missing rates for 'USD' or base`
|
|
44
|
-
)
|
|
35
|
+
throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo missing rates for 'USD' or base`)
|
|
45
36
|
|
|
46
37
|
const r: sdk.FiatExchangeRates = {
|
|
47
38
|
timestamp: new Date(iorates.timestamp * 1000),
|
|
@@ -60,9 +51,7 @@ export async function updateExchangeratesapi(
|
|
|
60
51
|
}
|
|
61
52
|
|
|
62
53
|
if (updates !== targetCurrencies.length)
|
|
63
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
64
|
-
`getExchangeRatesIo failed to update all target currencies`
|
|
65
|
-
)
|
|
54
|
+
throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo failed to update all target currencies`)
|
|
66
55
|
|
|
67
56
|
//console.log(`new fiat rates=${JSON.stringify(r)}`)
|
|
68
57
|
|
|
@@ -77,17 +66,13 @@ export interface ExchangeRatesIoApi {
|
|
|
77
66
|
rates: Record<string, number>
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
export async function getExchangeRatesIo(
|
|
81
|
-
key: string
|
|
82
|
-
): Promise<ExchangeRatesIoApi> {
|
|
69
|
+
export async function getExchangeRatesIo(key: string): Promise<ExchangeRatesIoApi> {
|
|
83
70
|
const url = `http://api.exchangeratesapi.io/v1/latest?access_key=${key}`
|
|
84
71
|
|
|
85
72
|
const r = await axios.get(url)
|
|
86
73
|
|
|
87
74
|
if (r.status !== 200 || !r.data) {
|
|
88
|
-
throw new sdk.WERR_BAD_REQUEST(
|
|
89
|
-
`getExchangeRatesIo returned status ${r.status}`
|
|
90
|
-
)
|
|
75
|
+
throw new sdk.WERR_BAD_REQUEST(`getExchangeRatesIo returned status ${r.status}`)
|
|
91
76
|
}
|
|
92
77
|
|
|
93
78
|
const rates = <ExchangeRatesIoApi>r.data
|
|
@@ -9,11 +9,7 @@ export class WalletSigner {
|
|
|
9
9
|
keyDeriver: KeyDeriver
|
|
10
10
|
storage: WalletStorageManager
|
|
11
11
|
|
|
12
|
-
constructor(
|
|
13
|
-
chain: sdk.Chain,
|
|
14
|
-
keyDeriver: KeyDeriver,
|
|
15
|
-
storage: WalletStorageManager
|
|
16
|
-
) {
|
|
12
|
+
constructor(chain: sdk.Chain, keyDeriver: KeyDeriver, storage: WalletStorageManager) {
|
|
17
13
|
this.chain = chain
|
|
18
14
|
this.keyDeriver = keyDeriver
|
|
19
15
|
this.storage = storage
|
|
@@ -14,10 +14,7 @@ export async function acquireDirectCertificate(
|
|
|
14
14
|
userId: auth.userId!,
|
|
15
15
|
type: vargs.type,
|
|
16
16
|
subject: vargs.subject,
|
|
17
|
-
verifier:
|
|
18
|
-
vargs.keyringRevealer === 'certifier'
|
|
19
|
-
? vargs.certifier
|
|
20
|
-
: vargs.keyringRevealer,
|
|
17
|
+
verifier: vargs.keyringRevealer === 'certifier' ? vargs.certifier : vargs.keyringRevealer,
|
|
21
18
|
serialNumber: vargs.serialNumber,
|
|
22
19
|
certifier: vargs.certifier,
|
|
23
20
|
revocationOutpoint: vargs.revocationOutpoint,
|
|
@@ -29,11 +29,7 @@ export function buildSignableTransaction(
|
|
|
29
29
|
const voutToIndex = Array<number>(storageOutputs.length)
|
|
30
30
|
for (let vout = 0; vout < storageOutputs.length; vout++) {
|
|
31
31
|
const i = storageOutputs.findIndex(o => o.vout === vout)
|
|
32
|
-
if (i < 0)
|
|
33
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
34
|
-
'output.vout',
|
|
35
|
-
`sequential. ${vout} is missing`
|
|
36
|
-
)
|
|
32
|
+
if (i < 0) throw new sdk.WERR_INVALID_PARAMETER('output.vout', `sequential. ${vout} is missing`)
|
|
37
33
|
voutToIndex[vout] = i
|
|
38
34
|
}
|
|
39
35
|
|
|
@@ -44,10 +40,7 @@ export function buildSignableTransaction(
|
|
|
44
40
|
const i = voutToIndex[vout]
|
|
45
41
|
const out = storageOutputs[i]
|
|
46
42
|
if (vout !== out.vout)
|
|
47
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
48
|
-
'output.vout',
|
|
49
|
-
`equal to array index. ${out.vout} !== ${vout}`
|
|
50
|
-
)
|
|
43
|
+
throw new sdk.WERR_INVALID_PARAMETER('output.vout', `equal to array index. ${out.vout} !== ${vout}`)
|
|
51
44
|
|
|
52
45
|
const change = out.providedBy === 'storage' && out.purpose === 'change'
|
|
53
46
|
|
|
@@ -78,11 +71,7 @@ export function buildSignableTransaction(
|
|
|
78
71
|
inputs.push({ argsInput, storageInput })
|
|
79
72
|
}
|
|
80
73
|
inputs.sort((a, b) =>
|
|
81
|
-
a.storageInput.vin! < b.storageInput.vin!
|
|
82
|
-
? -1
|
|
83
|
-
: a.storageInput.vin! === b.storageInput.vin!
|
|
84
|
-
? 0
|
|
85
|
-
: 1
|
|
74
|
+
a.storageInput.vin! < b.storageInput.vin! ? -1 : a.storageInput.vin! === b.storageInput.vin! ? 0 : 1
|
|
86
75
|
)
|
|
87
76
|
|
|
88
77
|
const pendingStorageInputs: PendingStorageInput[] = []
|
|
@@ -97,12 +86,8 @@ export function buildSignableTransaction(
|
|
|
97
86
|
// Type 1: User supplied input, with or without an explicit unlockingScript.
|
|
98
87
|
// If without, signAction must be used to provide the actual unlockScript.
|
|
99
88
|
const hasUnlock = typeof argsInput.unlockingScript === 'string'
|
|
100
|
-
const unlock = hasUnlock
|
|
101
|
-
|
|
102
|
-
: new Script()
|
|
103
|
-
const sourceTransaction = args.isSignAction
|
|
104
|
-
? inputBeef?.findTxid(argsInput.outpoint.txid)?.tx
|
|
105
|
-
: undefined
|
|
89
|
+
const unlock = hasUnlock ? asBsvSdkScript(argsInput.unlockingScript!) : new Script()
|
|
90
|
+
const sourceTransaction = args.isSignAction ? inputBeef?.findTxid(argsInput.outpoint.txid)?.tx : undefined
|
|
106
91
|
const inputToAdd: TransactionInput = {
|
|
107
92
|
sourceTXID: argsInput.outpoint.txid,
|
|
108
93
|
sourceOutputIndex: argsInput.outpoint.vout,
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Beef,
|
|
3
|
-
CreateActionResult,
|
|
4
|
-
SendWithResult,
|
|
5
|
-
SignActionResult,
|
|
6
|
-
SignActionSpend
|
|
7
|
-
} from '@bsv/sdk'
|
|
1
|
+
import { Beef, CreateActionResult, SendWithResult, SignActionResult, SignActionSpend } from '@bsv/sdk'
|
|
8
2
|
import { Script, Transaction } from '@bsv/sdk'
|
|
9
3
|
import {
|
|
10
4
|
asBsvSdkScript,
|
|
@@ -36,11 +30,8 @@ export async function createAction(
|
|
|
36
30
|
prior.tx = await completeSignedTransaction(prior, {}, wallet)
|
|
37
31
|
|
|
38
32
|
r.txid = prior.tx.id('hex')
|
|
39
|
-
r.noSendChange = prior.dcr.noSendChangeOutputVouts?.map(
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
if (!vargs.options.returnTXIDOnly)
|
|
43
|
-
r.tx = makeAtomicBeef(prior.tx, prior.dcr.inputBeef!)
|
|
33
|
+
r.noSendChange = prior.dcr.noSendChangeOutputVouts?.map(vout => `${r.txid}.${vout}`)
|
|
34
|
+
if (!vargs.options.returnTXIDOnly) r.tx = makeAtomicBeef(prior.tx, prior.dcr.inputBeef!)
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
r.sendWithResults = await processAction(prior, wallet, auth, vargs)
|
|
@@ -48,10 +39,7 @@ export async function createAction(
|
|
|
48
39
|
return r
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
async function createNewTx(
|
|
52
|
-
wallet: Wallet,
|
|
53
|
-
args: sdk.ValidCreateActionArgs
|
|
54
|
-
): Promise<PendingSignAction> {
|
|
42
|
+
async function createNewTx(wallet: Wallet, args: sdk.ValidCreateActionArgs): Promise<PendingSignAction> {
|
|
55
43
|
const storageArgs = removeUnlockScripts(args)
|
|
56
44
|
const dcr = await wallet.storage.createAction(storageArgs)
|
|
57
45
|
|
|
@@ -69,15 +57,12 @@ function makeSignableTransactionResult(
|
|
|
69
57
|
wallet: Wallet,
|
|
70
58
|
args: sdk.ValidCreateActionArgs
|
|
71
59
|
): CreateActionResult {
|
|
72
|
-
if (!prior.dcr.inputBeef)
|
|
73
|
-
throw new sdk.WERR_INTERNAL('prior.dcr.inputBeef must be valid')
|
|
60
|
+
if (!prior.dcr.inputBeef) throw new sdk.WERR_INTERNAL('prior.dcr.inputBeef must be valid')
|
|
74
61
|
|
|
75
62
|
const txid = prior.tx.id('hex')
|
|
76
63
|
|
|
77
64
|
const r: CreateActionResult = {
|
|
78
|
-
noSendChange: args.isNoSend
|
|
79
|
-
? prior.dcr.noSendChangeOutputVouts?.map(vout => `${txid}.${vout}`)
|
|
80
|
-
: undefined,
|
|
65
|
+
noSendChange: args.isNoSend ? prior.dcr.noSendChangeOutputVouts?.map(vout => `${txid}.${vout}`) : undefined,
|
|
81
66
|
signableTransaction: {
|
|
82
67
|
reference: prior.dcr.reference,
|
|
83
68
|
tx: makeSignableTransactionBeef(prior.tx, prior.dcr.inputBeef)
|
|
@@ -89,18 +74,13 @@ function makeSignableTransactionResult(
|
|
|
89
74
|
return r
|
|
90
75
|
}
|
|
91
76
|
|
|
92
|
-
function makeSignableTransactionBeef(
|
|
93
|
-
tx: Transaction,
|
|
94
|
-
inputBEEF: number[]
|
|
95
|
-
): number[] {
|
|
77
|
+
function makeSignableTransactionBeef(tx: Transaction, inputBEEF: number[]): number[] {
|
|
96
78
|
// This is a special case beef for transaction signing.
|
|
97
79
|
// We only need the transaction being signed, and for each input, the raw source transaction.
|
|
98
80
|
const beef = new Beef()
|
|
99
81
|
for (const input of tx.inputs) {
|
|
100
82
|
if (!input.sourceTransaction)
|
|
101
|
-
throw new sdk.WERR_INTERNAL(
|
|
102
|
-
'Every signableTransaction input must have a sourceTransaction'
|
|
103
|
-
)
|
|
83
|
+
throw new sdk.WERR_INTERNAL('Every signableTransaction input must have a sourceTransaction')
|
|
104
84
|
beef.mergeRawTx(input.sourceTransaction!.toBinary())
|
|
105
85
|
}
|
|
106
86
|
beef.mergeRawTx(tx.toBinary())
|
|
@@ -140,12 +120,7 @@ export async function completeSignedTransaction(
|
|
|
140
120
|
const vin = Number(key)
|
|
141
121
|
const createInput = prior.args.inputs[vin]
|
|
142
122
|
const input = prior.tx.inputs[vin]
|
|
143
|
-
if (
|
|
144
|
-
!createInput ||
|
|
145
|
-
!input ||
|
|
146
|
-
createInput.unlockingScript ||
|
|
147
|
-
!Number.isInteger(createInput.unlockingScriptLength)
|
|
148
|
-
)
|
|
123
|
+
if (!createInput || !input || createInput.unlockingScript || !Number.isInteger(createInput.unlockingScriptLength))
|
|
149
124
|
throw new sdk.WERR_INVALID_PARAMETER(
|
|
150
125
|
'args',
|
|
151
126
|
`spend does not correspond to prior input with valid unlockingScriptLength.`
|
|
@@ -156,8 +131,7 @@ export async function completeSignedTransaction(
|
|
|
156
131
|
`spend unlockingScript length ${spend.unlockingScript.length} exceeds expected length ${createInput.unlockingScriptLength}`
|
|
157
132
|
)
|
|
158
133
|
input.unlockingScript = asBsvSdkScript(spend.unlockingScript)
|
|
159
|
-
if (spend.sequenceNumber !== undefined)
|
|
160
|
-
input.sequence = spend.sequenceNumber
|
|
134
|
+
if (spend.sequenceNumber !== undefined) input.sequence = spend.sequenceNumber
|
|
161
135
|
}
|
|
162
136
|
|
|
163
137
|
const results = {
|
|
@@ -178,12 +152,7 @@ export async function completeSignedTransaction(
|
|
|
178
152
|
const unlockerPubKey = pdi.unlockerPubKey || keys.publicKey
|
|
179
153
|
const sourceSatoshis = pdi.sourceSatoshis
|
|
180
154
|
const lockingScript = asBsvSdkScript(pdi.lockingScript)
|
|
181
|
-
const unlockTemplate = sabppp.unlock(
|
|
182
|
-
lockerPrivKey,
|
|
183
|
-
unlockerPubKey,
|
|
184
|
-
sourceSatoshis,
|
|
185
|
-
lockingScript
|
|
186
|
-
)
|
|
155
|
+
const unlockTemplate = sabppp.unlock(lockerPrivKey, unlockerPubKey, sourceSatoshis, lockingScript)
|
|
187
156
|
const input = prior.tx.inputs[pdi.vin]
|
|
188
157
|
input.unlockingScriptTemplate = unlockTemplate
|
|
189
158
|
}
|
|
@@ -203,10 +172,7 @@ function removeUnlockScripts(args: sdk.ValidCreateActionArgs) {
|
|
|
203
172
|
for (const i of args.inputs) {
|
|
204
173
|
const di: sdk.ValidCreateActionInput = {
|
|
205
174
|
...i,
|
|
206
|
-
unlockingScriptLength:
|
|
207
|
-
i.unlockingScript !== undefined
|
|
208
|
-
? i.unlockingScript.length
|
|
209
|
-
: i.unlockingScriptLength
|
|
175
|
+
unlockingScriptLength: i.unlockingScript !== undefined ? i.unlockingScript.length : i.unlockingScriptLength
|
|
210
176
|
}
|
|
211
177
|
delete di.unlockingScript
|
|
212
178
|
storageArgs.inputs.push(di)
|
|
@@ -231,19 +197,14 @@ export async function processAction(
|
|
|
231
197
|
rawTx: prior ? prior.tx.toBinary() : undefined,
|
|
232
198
|
sendWith: vargs.isSendWith ? vargs.options.sendWith : []
|
|
233
199
|
}
|
|
234
|
-
const r: sdk.StorageProcessActionResults =
|
|
235
|
-
await wallet.storage.processAction(args)
|
|
200
|
+
const r: sdk.StorageProcessActionResults = await wallet.storage.processAction(args)
|
|
236
201
|
|
|
237
202
|
return r.sendWithResults
|
|
238
203
|
}
|
|
239
204
|
|
|
240
|
-
function makeDummyTransactionForOutputSatoshis(
|
|
241
|
-
vout: number,
|
|
242
|
-
satoshis: number
|
|
243
|
-
): Transaction {
|
|
205
|
+
function makeDummyTransactionForOutputSatoshis(vout: number, satoshis: number): Transaction {
|
|
244
206
|
const tx = new Transaction()
|
|
245
|
-
for (let i = 0; i < vout; i++)
|
|
246
|
-
tx.addOutput({ lockingScript: new Script(), satoshis: 0 })
|
|
207
|
+
for (let i = 0; i < vout; i++) tx.addOutput({ lockingScript: new Script(), satoshis: 0 })
|
|
247
208
|
tx.addOutput({ lockingScript: new Script(), satoshis })
|
|
248
209
|
return tx
|
|
249
210
|
}
|
|
@@ -47,10 +47,7 @@ export async function internalizeAction(
|
|
|
47
47
|
|
|
48
48
|
for (const o of vargs.outputs) {
|
|
49
49
|
if (o.outputIndex < 0 || o.outputIndex >= tx.outputs.length)
|
|
50
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
51
|
-
'outputIndex',
|
|
52
|
-
`a valid output index in range 0 to ${tx.outputs.length - 1}`
|
|
53
|
-
)
|
|
50
|
+
throw new sdk.WERR_INVALID_PARAMETER('outputIndex', `a valid output index in range 0 to ${tx.outputs.length - 1}`)
|
|
54
51
|
switch (o.protocol) {
|
|
55
52
|
case 'basket insertion':
|
|
56
53
|
setupBasketInsertionForOutput(o, vargs)
|
|
@@ -63,42 +60,24 @@ export async function internalizeAction(
|
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
const r: InternalizeActionResult =
|
|
67
|
-
await wallet.storage.internalizeAction(args)
|
|
63
|
+
const r: InternalizeActionResult = await wallet.storage.internalizeAction(args)
|
|
68
64
|
|
|
69
65
|
return r
|
|
70
66
|
|
|
71
|
-
function setupWalletPaymentForOutput(
|
|
72
|
-
o: InternalizeOutput,
|
|
73
|
-
dargs: sdk.ValidInternalizeActionArgs
|
|
74
|
-
) {
|
|
67
|
+
function setupWalletPaymentForOutput(o: InternalizeOutput, dargs: sdk.ValidInternalizeActionArgs) {
|
|
75
68
|
const p = o.paymentRemittance
|
|
76
69
|
const output = tx.outputs[o.outputIndex]
|
|
77
|
-
if (!p)
|
|
78
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
79
|
-
'paymentRemitance',
|
|
80
|
-
`valid for protocol ${o.protocol}`
|
|
81
|
-
)
|
|
70
|
+
if (!p) throw new sdk.WERR_INVALID_PARAMETER('paymentRemitance', `valid for protocol ${o.protocol}`)
|
|
82
71
|
|
|
83
72
|
const keyID = `${p.derivationPrefix} ${p.derivationSuffix}`
|
|
84
73
|
|
|
85
|
-
const privKey = wallet.keyDeriver!.derivePrivateKey(
|
|
86
|
-
brc29ProtocolID,
|
|
87
|
-
keyID,
|
|
88
|
-
p.senderIdentityKey
|
|
89
|
-
)
|
|
74
|
+
const privKey = wallet.keyDeriver!.derivePrivateKey(brc29ProtocolID, keyID, p.senderIdentityKey)
|
|
90
75
|
const expectedLockScript = new P2PKH().lock(privKey.toAddress())
|
|
91
76
|
if (output.lockingScript.toHex() !== expectedLockScript.toHex())
|
|
92
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
93
|
-
'paymentRemitance',
|
|
94
|
-
`locked by script conforming to BRC-29`
|
|
95
|
-
)
|
|
77
|
+
throw new sdk.WERR_INVALID_PARAMETER('paymentRemitance', `locked by script conforming to BRC-29`)
|
|
96
78
|
}
|
|
97
79
|
|
|
98
|
-
function setupBasketInsertionForOutput(
|
|
99
|
-
o: InternalizeOutput,
|
|
100
|
-
dargs: sdk.ValidInternalizeActionArgs
|
|
101
|
-
) {
|
|
80
|
+
function setupBasketInsertionForOutput(o: InternalizeOutput, dargs: sdk.ValidInternalizeActionArgs) {
|
|
102
81
|
/*
|
|
103
82
|
No additional validations...
|
|
104
83
|
*/
|
|
@@ -109,19 +88,11 @@ export async function internalizeAction(
|
|
|
109
88
|
|
|
110
89
|
// TODO: Add support for known txids...
|
|
111
90
|
|
|
112
|
-
const txValid = await ab.verify(
|
|
113
|
-
|
|
114
|
-
false
|
|
115
|
-
)
|
|
116
|
-
if (!txValid || !ab.atomicTxid)
|
|
117
|
-
throw new sdk.WERR_INVALID_PARAMETER('tx', 'valid AtomicBEEF')
|
|
91
|
+
const txValid = await ab.verify(await wallet.getServices().getChainTracker(), false)
|
|
92
|
+
if (!txValid || !ab.atomicTxid) throw new sdk.WERR_INVALID_PARAMETER('tx', 'valid AtomicBEEF')
|
|
118
93
|
const txid = ab.atomicTxid
|
|
119
94
|
const btx = ab.findTxid(txid)
|
|
120
|
-
if (!btx)
|
|
121
|
-
throw new sdk.WERR_INVALID_PARAMETER(
|
|
122
|
-
'tx',
|
|
123
|
-
`valid AtomicBEEF with newest txid of ${txid}`
|
|
124
|
-
)
|
|
95
|
+
if (!btx) throw new sdk.WERR_INVALID_PARAMETER('tx', `valid AtomicBEEF with newest txid of ${txid}`)
|
|
125
96
|
const tx = btx.tx!
|
|
126
97
|
|
|
127
98
|
/*
|
|
@@ -24,16 +24,13 @@ export async function proveCertificate(
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const lcr = await wallet.storage.listCertificates(lcargs)
|
|
27
|
-
if (lcr.certificates.length != 1)
|
|
28
|
-
throw new sdk.WERR_INVALID_PARAMETER('args', `a unique certificate match`)
|
|
27
|
+
if (lcr.certificates.length != 1) throw new sdk.WERR_INVALID_PARAMETER('args', `a unique certificate match`)
|
|
29
28
|
const storageCert = lcr.certificates[0]
|
|
30
29
|
let proveWallet: CertOpsWallet = wallet
|
|
31
30
|
if (storageCert.subject != wallet.identityKey) {
|
|
32
31
|
// Certificate must have been issued to privileged identity
|
|
33
32
|
if (!wallet.privilegedKeyManager)
|
|
34
|
-
throw new sdk.WERR_INVALID_OPERATION(
|
|
35
|
-
'Wallet is not privileged. proveCertificate fails.'
|
|
36
|
-
)
|
|
33
|
+
throw new sdk.WERR_INVALID_OPERATION('Wallet is not privileged. proveCertificate fails.')
|
|
37
34
|
proveWallet = wallet.privilegedKeyManager
|
|
38
35
|
}
|
|
39
36
|
const co = await sdk.CertOps.fromCounterparty(proveWallet, {
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
Transaction as BsvTransaction,
|
|
6
|
-
SignActionResult,
|
|
7
|
-
SignActionSpend
|
|
8
|
-
} from '@bsv/sdk'
|
|
9
|
-
import {
|
|
10
|
-
asBsvSdkScript,
|
|
11
|
-
PendingSignAction,
|
|
12
|
-
ScriptTemplateBRC29,
|
|
13
|
-
sdk,
|
|
14
|
-
Wallet
|
|
15
|
-
} from '../../index.client'
|
|
3
|
+
import { Beef, Transaction as BsvTransaction, SignActionResult, SignActionSpend } from '@bsv/sdk'
|
|
4
|
+
import { asBsvSdkScript, PendingSignAction, ScriptTemplateBRC29, sdk, Wallet } from '../../index.client'
|
|
16
5
|
import { processAction } from './createAction'
|
|
17
6
|
|
|
18
7
|
export async function signAction(
|
|
@@ -22,11 +11,8 @@ export async function signAction(
|
|
|
22
11
|
): Promise<SignActionResult> {
|
|
23
12
|
const prior = wallet.pendingSignActions[vargs.reference]
|
|
24
13
|
if (!prior)
|
|
25
|
-
throw new sdk.WERR_NOT_IMPLEMENTED(
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
if (!prior.dcr.inputBeef)
|
|
29
|
-
throw new sdk.WERR_INTERNAL('prior.dcr.inputBeef must be valid')
|
|
14
|
+
throw new sdk.WERR_NOT_IMPLEMENTED('recovery of out-of-session signAction reference data is not yet implemented.')
|
|
15
|
+
if (!prior.dcr.inputBeef) throw new sdk.WERR_INTERNAL('prior.dcr.inputBeef must be valid')
|
|
30
16
|
|
|
31
17
|
prior.tx = await completeSignedTransaction(prior, vargs.spends, wallet)
|
|
32
18
|
|
|
@@ -34,19 +20,14 @@ export async function signAction(
|
|
|
34
20
|
|
|
35
21
|
const r: SignActionResult = {
|
|
36
22
|
txid: prior.tx.id('hex'),
|
|
37
|
-
tx: vargs.options.returnTXIDOnly
|
|
38
|
-
? undefined
|
|
39
|
-
: makeAtomicBeef(prior.tx, prior.dcr.inputBeef),
|
|
23
|
+
tx: vargs.options.returnTXIDOnly ? undefined : makeAtomicBeef(prior.tx, prior.dcr.inputBeef),
|
|
40
24
|
sendWithResults
|
|
41
25
|
}
|
|
42
26
|
|
|
43
27
|
return r
|
|
44
28
|
}
|
|
45
29
|
|
|
46
|
-
export function makeAtomicBeef(
|
|
47
|
-
tx: BsvTransaction,
|
|
48
|
-
beef: number[] | Beef
|
|
49
|
-
): number[] {
|
|
30
|
+
export function makeAtomicBeef(tx: BsvTransaction, beef: number[] | Beef): number[] {
|
|
50
31
|
if (Array.isArray(beef)) beef = Beef.fromBinary(beef)
|
|
51
32
|
beef.mergeTransaction(tx)
|
|
52
33
|
return beef.toBinaryAtomic(tx.id('hex'))
|
|
@@ -64,12 +45,7 @@ export async function completeSignedTransaction(
|
|
|
64
45
|
const vin = Number(key)
|
|
65
46
|
const createInput = prior.args.inputs[vin]
|
|
66
47
|
const input = prior.tx.inputs[vin]
|
|
67
|
-
if (
|
|
68
|
-
!createInput ||
|
|
69
|
-
!input ||
|
|
70
|
-
createInput.unlockingScript ||
|
|
71
|
-
!Number.isInteger(createInput.unlockingScriptLength)
|
|
72
|
-
)
|
|
48
|
+
if (!createInput || !input || createInput.unlockingScript || !Number.isInteger(createInput.unlockingScriptLength))
|
|
73
49
|
throw new sdk.WERR_INVALID_PARAMETER(
|
|
74
50
|
'args',
|
|
75
51
|
`spend does not correspond to prior input with valid unlockingScriptLength.`
|
|
@@ -80,8 +56,7 @@ export async function completeSignedTransaction(
|
|
|
80
56
|
`spend unlockingScript length ${spend.unlockingScript.length} exceeds expected length ${createInput.unlockingScriptLength}`
|
|
81
57
|
)
|
|
82
58
|
input.unlockingScript = asBsvSdkScript(spend.unlockingScript)
|
|
83
|
-
if (spend.sequenceNumber !== undefined)
|
|
84
|
-
input.sequence = spend.sequenceNumber
|
|
59
|
+
if (spend.sequenceNumber !== undefined) input.sequence = spend.sequenceNumber
|
|
85
60
|
}
|
|
86
61
|
|
|
87
62
|
const results = {
|
|
@@ -102,12 +77,7 @@ export async function completeSignedTransaction(
|
|
|
102
77
|
const unlockerPubKey = pdi.unlockerPubKey || keys.publicKey
|
|
103
78
|
const sourceSatoshis = pdi.sourceSatoshis
|
|
104
79
|
const lockingScript = asBsvSdkScript(pdi.lockingScript)
|
|
105
|
-
const unlockTemplate = sabppp.unlock(
|
|
106
|
-
lockerPrivKey,
|
|
107
|
-
unlockerPubKey,
|
|
108
|
-
sourceSatoshis,
|
|
109
|
-
lockingScript
|
|
110
|
-
)
|
|
80
|
+
const unlockTemplate = sabppp.unlock(lockerPrivKey, unlockerPubKey, sourceSatoshis, lockingScript)
|
|
111
81
|
const input = prior.tx.inputs[pdi.vin]
|
|
112
82
|
input.unlockingScriptTemplate = unlockTemplate
|
|
113
83
|
}
|