@trezor/connect 9.0.0-beta.1
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/LICENSE.md +50 -0
- package/README.md +38 -0
- package/lib/api/applyFlags.d.ts +8 -0
- package/lib/api/applyFlags.js +37 -0
- package/lib/api/applySettings.d.ts +8 -0
- package/lib/api/applySettings.js +57 -0
- package/lib/api/authorizeCoinJoin.d.ts +7 -0
- package/lib/api/authorizeCoinJoin.js +45 -0
- package/lib/api/backupDevice.d.ts +7 -0
- package/lib/api/backupDevice.js +31 -0
- package/lib/api/binance/binanceSignTx.d.ts +6 -0
- package/lib/api/binance/binanceSignTx.js +91 -0
- package/lib/api/binanceGetAddress.d.ts +22 -0
- package/lib/api/binanceGetAddress.js +126 -0
- package/lib/api/binanceGetPublicKey.d.ts +10 -0
- package/lib/api/binanceGetPublicKey.js +72 -0
- package/lib/api/binanceSignTransaction.d.ts +12 -0
- package/lib/api/binanceSignTransaction.js +31 -0
- package/lib/api/bitcoin/Fees.d.ts +15 -0
- package/lib/api/bitcoin/Fees.js +175 -0
- package/lib/api/bitcoin/TransactionComposer.d.ts +36 -0
- package/lib/api/bitcoin/TransactionComposer.js +150 -0
- package/lib/api/bitcoin/__fixtures__/inputs.d.ts +112 -0
- package/lib/api/bitcoin/__fixtures__/inputs.js +102 -0
- package/lib/api/bitcoin/__fixtures__/signtxVerify.d.ts +147 -0
- package/lib/api/bitcoin/__fixtures__/signtxVerify.js +216 -0
- package/lib/api/bitcoin/enhanceSignTx.d.ts +4 -0
- package/lib/api/bitcoin/enhanceSignTx.js +63 -0
- package/lib/api/bitcoin/index.d.ts +10 -0
- package/lib/api/bitcoin/index.js +13 -0
- package/lib/api/bitcoin/inputs.d.ts +8 -0
- package/lib/api/bitcoin/inputs.js +60 -0
- package/lib/api/bitcoin/outputs.d.ts +8 -0
- package/lib/api/bitcoin/outputs.js +115 -0
- package/lib/api/bitcoin/refTx.d.ts +11 -0
- package/lib/api/bitcoin/refTx.js +220 -0
- package/lib/api/bitcoin/signtx.d.ts +25 -0
- package/lib/api/bitcoin/signtx.js +164 -0
- package/lib/api/bitcoin/signtxLegacy.d.ts +4 -0
- package/lib/api/bitcoin/signtxLegacy.js +136 -0
- package/lib/api/bitcoin/signtxVerify.d.ts +8 -0
- package/lib/api/bitcoin/signtxVerify.js +130 -0
- package/lib/api/blockchainDisconnect.d.ts +13 -0
- package/lib/api/blockchainDisconnect.js +34 -0
- package/lib/api/blockchainEstimateFee.d.ts +12 -0
- package/lib/api/blockchainEstimateFee.js +70 -0
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +12 -0
- package/lib/api/blockchainGetAccountBalanceHistory.js +41 -0
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +15 -0
- package/lib/api/blockchainGetCurrentFiatRates.js +33 -0
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +17 -0
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +33 -0
- package/lib/api/blockchainGetTransactions.d.ts +12 -0
- package/lib/api/blockchainGetTransactions.js +33 -0
- package/lib/api/blockchainSetCustomBackend.d.ts +11 -0
- package/lib/api/blockchainSetCustomBackend.js +38 -0
- package/lib/api/blockchainSubscribe.d.ts +14 -0
- package/lib/api/blockchainSubscribe.js +38 -0
- package/lib/api/blockchainSubscribeFiatRates.d.ts +14 -0
- package/lib/api/blockchainSubscribeFiatRates.js +33 -0
- package/lib/api/blockchainUnsubscribe.d.ts +14 -0
- package/lib/api/blockchainUnsubscribe.js +38 -0
- package/lib/api/blockchainUnsubscribeFiatRates.d.ts +13 -0
- package/lib/api/blockchainUnsubscribeFiatRates.js +29 -0
- package/lib/api/cardano/cardanoAddressParameters.d.ts +8 -0
- package/lib/api/cardano/cardanoAddressParameters.js +100 -0
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +6 -0
- package/lib/api/cardano/cardanoAuxiliaryData.js +51 -0
- package/lib/api/cardano/cardanoCertificate.d.ts +14 -0
- package/lib/api/cardano/cardanoCertificate.js +149 -0
- package/lib/api/cardano/cardanoInputs.d.ts +13 -0
- package/lib/api/cardano/cardanoInputs.js +34 -0
- package/lib/api/cardano/cardanoOutputs.d.ts +8 -0
- package/lib/api/cardano/cardanoOutputs.js +38 -0
- package/lib/api/cardano/cardanoTokenBundle.d.ts +8 -0
- package/lib/api/cardano/cardanoTokenBundle.js +36 -0
- package/lib/api/cardano/cardanoWitnesses.d.ts +5 -0
- package/lib/api/cardano/cardanoWitnesses.js +48 -0
- package/lib/api/cardanoGetAddress.d.ts +23 -0
- package/lib/api/cardanoGetAddress.js +158 -0
- package/lib/api/cardanoGetNativeScriptHash.d.ts +12 -0
- package/lib/api/cardanoGetNativeScriptHash.js +79 -0
- package/lib/api/cardanoGetPublicKey.d.ts +10 -0
- package/lib/api/cardanoGetPublicKey.js +78 -0
- package/lib/api/cardanoSignTransaction.d.ts +48 -0
- package/lib/api/cardanoSignTransaction.js +283 -0
- package/lib/api/changePin.d.ts +7 -0
- package/lib/api/changePin.js +22 -0
- package/lib/api/cipherKeyValue.d.ts +8 -0
- package/lib/api/cipherKeyValue.js +56 -0
- package/lib/api/common/Discovery.d.ts +35 -0
- package/lib/api/common/Discovery.js +113 -0
- package/lib/api/common/__fixtures__/paramsValidator.d.ts +596 -0
- package/lib/api/common/__fixtures__/paramsValidator.js +355 -0
- package/lib/api/common/paramsValidator.d.ts +14 -0
- package/lib/api/common/paramsValidator.js +140 -0
- package/lib/api/composeTransaction.d.ts +33 -0
- package/lib/api/composeTransaction.js +270 -0
- package/lib/api/customMessage.d.ts +13 -0
- package/lib/api/customMessage.js +56 -0
- package/lib/api/eos/eosSignTx.d.ts +17 -0
- package/lib/api/eos/eosSignTx.js +347 -0
- package/lib/api/eosGetPublicKey.d.ts +10 -0
- package/lib/api/eosGetPublicKey.js +73 -0
- package/lib/api/eosSignTransaction.d.ts +16 -0
- package/lib/api/eosSignTransaction.js +36 -0
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.d.ts +225 -0
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.js +341 -0
- package/lib/api/ethereum/ethereumSignTx.d.ts +13 -0
- package/lib/api/ethereum/ethereumSignTx.js +92 -0
- package/lib/api/ethereum/ethereumSignTypedData.d.ts +9 -0
- package/lib/api/ethereum/ethereumSignTypedData.js +120 -0
- package/lib/api/ethereumGetAddress.d.ts +28 -0
- package/lib/api/ethereumGetAddress.js +133 -0
- package/lib/api/ethereumGetPublicKey.d.ts +15 -0
- package/lib/api/ethereumGetPublicKey.js +79 -0
- package/lib/api/ethereumSignMessage.d.ts +7 -0
- package/lib/api/ethereumSignMessage.js +41 -0
- package/lib/api/ethereumSignTransaction.d.ts +20 -0
- package/lib/api/ethereumSignTransaction.js +82 -0
- package/lib/api/ethereumSignTypedData.d.ts +14 -0
- package/lib/api/ethereumSignTypedData.js +151 -0
- package/lib/api/ethereumVerifyMessage.d.ts +7 -0
- package/lib/api/ethereumVerifyMessage.js +34 -0
- package/lib/api/firmware/getBinary.d.ts +20 -0
- package/lib/api/firmware/getBinary.js +37 -0
- package/lib/api/firmware/modifyFirmware.d.ts +6 -0
- package/lib/api/firmware/modifyFirmware.js +18 -0
- package/lib/api/firmwareUpdate.d.ts +15 -0
- package/lib/api/firmwareUpdate.js +89 -0
- package/lib/api/getAccountInfo.d.ts +98 -0
- package/lib/api/getAccountInfo.js +326 -0
- package/lib/api/getAddress.d.ts +28 -0
- package/lib/api/getAddress.js +152 -0
- package/lib/api/getCoinInfo.d.ts +11 -0
- package/lib/api/getCoinInfo.js +27 -0
- package/lib/api/getDeviceState.d.ts +8 -0
- package/lib/api/getDeviceState.js +15 -0
- package/lib/api/getFeatures.d.ts +6 -0
- package/lib/api/getFeatures.js +18 -0
- package/lib/api/getOwnershipId.d.ts +10 -0
- package/lib/api/getOwnershipId.js +75 -0
- package/lib/api/getOwnershipProof.d.ts +14 -0
- package/lib/api/getOwnershipProof.js +86 -0
- package/lib/api/getPublicKey.d.ts +15 -0
- package/lib/api/getPublicKey.js +84 -0
- package/lib/api/getSettings.d.ts +6 -0
- package/lib/api/getSettings.js +16 -0
- package/lib/api/index.d.ts +64 -0
- package/lib/api/index.js +134 -0
- package/lib/api/management/uploadFirmware.d.ts +6 -0
- package/lib/api/management/uploadFirmware.js +49 -0
- package/lib/api/nem/nemSignTx.d.ts +4 -0
- package/lib/api/nem/nemSignTx.js +139 -0
- package/lib/api/nemGetAddress.d.ts +22 -0
- package/lib/api/nemGetAddress.js +144 -0
- package/lib/api/nemSignTransaction.d.ts +7 -0
- package/lib/api/nemSignTransaction.js +29 -0
- package/lib/api/pushTransaction.d.ts +14 -0
- package/lib/api/pushTransaction.js +40 -0
- package/lib/api/rebootToBootloader.d.ts +8 -0
- package/lib/api/rebootToBootloader.js +43 -0
- package/lib/api/recoveryDevice.d.ts +8 -0
- package/lib/api/recoveryDevice.js +57 -0
- package/lib/api/requestLogin.d.ts +12 -0
- package/lib/api/requestLogin.js +63 -0
- package/lib/api/resetDevice.d.ts +9 -0
- package/lib/api/resetDevice.js +59 -0
- package/lib/api/rippleGetAddress.d.ts +22 -0
- package/lib/api/rippleGetAddress.js +126 -0
- package/lib/api/rippleSignTransaction.d.ts +10 -0
- package/lib/api/rippleSignTransaction.js +54 -0
- package/lib/api/setProxy.d.ts +8 -0
- package/lib/api/setProxy.js +26 -0
- package/lib/api/signMessage.d.ts +7 -0
- package/lib/api/signMessage.js +51 -0
- package/lib/api/signTransaction.d.ts +21 -0
- package/lib/api/signTransaction.js +146 -0
- package/lib/api/stellar/stellarSignTx.d.ts +5 -0
- package/lib/api/stellar/stellarSignTx.js +198 -0
- package/lib/api/stellarGetAddress.d.ts +22 -0
- package/lib/api/stellarGetAddress.js +126 -0
- package/lib/api/stellarSignTransaction.d.ts +23 -0
- package/lib/api/stellarSignTransaction.js +62 -0
- package/lib/api/tezos/tezosSignTx.d.ts +4 -0
- package/lib/api/tezos/tezosSignTx.js +237 -0
- package/lib/api/tezosGetAddress.d.ts +22 -0
- package/lib/api/tezosGetAddress.js +126 -0
- package/lib/api/tezosGetPublicKey.d.ts +10 -0
- package/lib/api/tezosGetPublicKey.js +72 -0
- package/lib/api/tezosSignTransaction.d.ts +7 -0
- package/lib/api/tezosSignTransaction.js +30 -0
- package/lib/api/verifyMessage.d.ts +7 -0
- package/lib/api/verifyMessage.js +47 -0
- package/lib/api/wipeDevice.d.ts +8 -0
- package/lib/api/wipeDevice.js +41 -0
- package/lib/backend/BlockchainLink.d.ts +75 -0
- package/lib/backend/BlockchainLink.js +298 -0
- package/lib/constants/cardano.d.ts +9 -0
- package/lib/constants/cardano.js +14 -0
- package/lib/constants/errors.d.ts +49 -0
- package/lib/constants/errors.js +62 -0
- package/lib/constants/index.d.ts +6 -0
- package/lib/constants/index.js +10 -0
- package/lib/constants/nem.d.ts +22 -0
- package/lib/constants/nem.js +28 -0
- package/lib/constants/network.d.ts +13 -0
- package/lib/constants/network.js +15 -0
- package/lib/core/AbstractMethod.d.ts +59 -0
- package/lib/core/AbstractMethod.js +159 -0
- package/lib/core/index.d.ts +16 -0
- package/lib/core/index.js +671 -0
- package/lib/core/method.d.ts +6 -0
- package/lib/core/method.js +19 -0
- package/lib/data/DataManager.d.ts +31 -0
- package/lib/data/DataManager.js +98 -0
- package/lib/data/coinInfo.d.ts +37 -0
- package/lib/data/coinInfo.js +278 -0
- package/lib/data/config.d.ts +98 -0
- package/lib/data/config.js +201 -0
- package/lib/data/connectSettings.d.ts +6 -0
- package/lib/data/connectSettings.js +150 -0
- package/lib/data/firmwareInfo.d.ts +11 -0
- package/lib/data/firmwareInfo.js +148 -0
- package/lib/data/transportInfo.d.ts +4 -0
- package/lib/data/transportInfo.js +29 -0
- package/lib/data/udevInfo.d.ts +3 -0
- package/lib/data/udevInfo.js +21 -0
- package/lib/data/version.d.ts +3 -0
- package/lib/data/version.js +7 -0
- package/lib/device/AbortController.d.ts +21 -0
- package/lib/device/AbortController.js +40 -0
- package/lib/device/DescriptorStream.d.ts +28 -0
- package/lib/device/DescriptorStream.js +139 -0
- package/lib/device/Device.d.ts +105 -0
- package/lib/device/Device.js +527 -0
- package/lib/device/DeviceCommands.d.ts +63 -0
- package/lib/device/DeviceCommands.js +465 -0
- package/lib/device/DeviceList.d.ts +76 -0
- package/lib/device/DeviceList.js +411 -0
- package/lib/events/blockchain.d.ts +56 -0
- package/lib/events/blockchain.js +18 -0
- package/lib/events/call.d.ts +41 -0
- package/lib/events/call.js +14 -0
- package/lib/events/core.d.ts +20 -0
- package/lib/events/core.js +28 -0
- package/lib/events/device.d.ts +40 -0
- package/lib/events/device.js +28 -0
- package/lib/events/iframe.d.ts +39 -0
- package/lib/events/iframe.js +18 -0
- package/lib/events/index.d.ts +62 -0
- package/lib/events/index.js +21 -0
- package/lib/events/popup.d.ts +51 -0
- package/lib/events/popup.js +22 -0
- package/lib/events/transport.d.ts +62 -0
- package/lib/events/transport.js +21 -0
- package/lib/events/ui-promise.d.ts +12 -0
- package/lib/events/ui-promise.js +3 -0
- package/lib/events/ui-request.d.ts +180 -0
- package/lib/events/ui-request.js +50 -0
- package/lib/events/ui-response.d.ts +97 -0
- package/lib/events/ui-response.js +25 -0
- package/lib/exports.d.ts +5 -0
- package/lib/exports.js +10 -0
- package/lib/factory.d.ts +20 -0
- package/lib/factory.js +122 -0
- package/lib/index-browser.d.ts +4 -0
- package/lib/index-browser.js +29 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +236 -0
- package/lib/types/account.d.ts +37 -0
- package/lib/types/account.js +3 -0
- package/lib/types/api/applyFlags.d.ts +4 -0
- package/lib/types/api/applyFlags.js +3 -0
- package/lib/types/api/applySettings.d.ts +4 -0
- package/lib/types/api/applySettings.js +3 -0
- package/lib/types/api/authorizeCoinJoin.d.ts +14 -0
- package/lib/types/api/authorizeCoinJoin.js +3 -0
- package/lib/types/api/backupDevice.d.ts +4 -0
- package/lib/types/api/backupDevice.js +3 -0
- package/lib/types/api/binanceGetAddress.d.ts +4 -0
- package/lib/types/api/binanceGetAddress.js +3 -0
- package/lib/types/api/binanceGetPublicKey.d.ts +4 -0
- package/lib/types/api/binanceGetPublicKey.js +3 -0
- package/lib/types/api/binanceSignTransaction.d.ts +31 -0
- package/lib/types/api/binanceSignTransaction.js +3 -0
- package/lib/types/api/blockchainDisconnect.d.ts +5 -0
- package/lib/types/api/blockchainDisconnect.js +3 -0
- package/lib/types/api/blockchainEstimateFee.d.ts +29 -0
- package/lib/types/api/blockchainEstimateFee.js +3 -0
- package/lib/types/api/blockchainGetAccountBalanceHistory.d.ts +4 -0
- package/lib/types/api/blockchainGetAccountBalanceHistory.js +3 -0
- package/lib/types/api/blockchainGetCurrentFiatRates.d.ts +4 -0
- package/lib/types/api/blockchainGetCurrentFiatRates.js +3 -0
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.d.ts +4 -0
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.js +3 -0
- package/lib/types/api/blockchainGetTransactions.d.ts +7 -0
- package/lib/types/api/blockchainGetTransactions.js +3 -0
- package/lib/types/api/blockchainSetCustomBackend.d.ts +7 -0
- package/lib/types/api/blockchainSetCustomBackend.js +3 -0
- package/lib/types/api/blockchainSubscribe.d.ts +7 -0
- package/lib/types/api/blockchainSubscribe.js +3 -0
- package/lib/types/api/blockchainSubscribeFiatRates.d.ts +7 -0
- package/lib/types/api/blockchainSubscribeFiatRates.js +3 -0
- package/lib/types/api/blockchainUnsubscribe.d.ts +5 -0
- package/lib/types/api/blockchainUnsubscribe.js +3 -0
- package/lib/types/api/blockchainUnsubscribeFiatRates.d.ts +5 -0
- package/lib/types/api/blockchainUnsubscribeFiatRates.js +3 -0
- package/lib/types/api/cancel.d.ts +2 -0
- package/lib/types/api/cancel.js +3 -0
- package/lib/types/api/cardanoGetAddress.d.ts +35 -0
- package/lib/types/api/cardanoGetAddress.js +3 -0
- package/lib/types/api/cardanoGetNativeScriptHash.d.ts +21 -0
- package/lib/types/api/cardanoGetNativeScriptHash.js +3 -0
- package/lib/types/api/cardanoGetPublicKey.d.ts +16 -0
- package/lib/types/api/cardanoGetPublicKey.js +3 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +130 -0
- package/lib/types/api/cardanoSignTransaction.js +3 -0
- package/lib/types/api/changePin.d.ts +4 -0
- package/lib/types/api/changePin.js +3 -0
- package/lib/types/api/cipherKeyValue.d.ts +17 -0
- package/lib/types/api/cipherKeyValue.js +3 -0
- package/lib/types/api/composeTransaction.d.ts +92 -0
- package/lib/types/api/composeTransaction.js +3 -0
- package/lib/types/api/customMessage.d.ts +12 -0
- package/lib/types/api/customMessage.js +3 -0
- package/lib/types/api/disableWebUSB.d.ts +2 -0
- package/lib/types/api/disableWebUSB.js +3 -0
- package/lib/types/api/dispose.d.ts +2 -0
- package/lib/types/api/dispose.js +3 -0
- package/lib/types/api/eosGetPublicKey.d.ts +14 -0
- package/lib/types/api/eosGetPublicKey.js +3 -0
- package/lib/types/api/eosSignTransaction.d.ts +111 -0
- package/lib/types/api/eosSignTransaction.js +3 -0
- package/lib/types/api/ethereumGetAddress.d.ts +4 -0
- package/lib/types/api/ethereumGetAddress.js +3 -0
- package/lib/types/api/ethereumGetPublicKey.d.ts +5 -0
- package/lib/types/api/ethereumGetPublicKey.js +3 -0
- package/lib/types/api/ethereumSignMessage.d.ts +9 -0
- package/lib/types/api/ethereumSignMessage.js +3 -0
- package/lib/types/api/ethereumSignTransaction.d.ts +40 -0
- package/lib/types/api/ethereumSignTransaction.js +3 -0
- package/lib/types/api/ethereumSignTypedData.d.ts +42 -0
- package/lib/types/api/ethereumSignTypedData.js +3 -0
- package/lib/types/api/ethereumVerifyMessage.d.ts +10 -0
- package/lib/types/api/ethereumVerifyMessage.js +3 -0
- package/lib/types/api/firmwareUpdate.d.ts +14 -0
- package/lib/types/api/firmwareUpdate.js +3 -0
- package/lib/types/api/getAccountInfo.d.ts +14 -0
- package/lib/types/api/getAccountInfo.js +3 -0
- package/lib/types/api/getAddress.d.ts +13 -0
- package/lib/types/api/getAddress.js +3 -0
- package/lib/types/api/getCoinInfo.d.ts +4 -0
- package/lib/types/api/getCoinInfo.js +3 -0
- package/lib/types/api/getDeviceState.d.ts +6 -0
- package/lib/types/api/getDeviceState.js +3 -0
- package/lib/types/api/getFeatures.d.ts +4 -0
- package/lib/types/api/getFeatures.js +3 -0
- package/lib/types/api/getOwnershipId.d.ts +15 -0
- package/lib/types/api/getOwnershipId.js +3 -0
- package/lib/types/api/getOwnershipProof.d.ts +19 -0
- package/lib/types/api/getOwnershipProof.js +3 -0
- package/lib/types/api/getPublicKey.d.ts +19 -0
- package/lib/types/api/getPublicKey.js +3 -0
- package/lib/types/api/getSettings.d.ts +4 -0
- package/lib/types/api/getSettings.js +3 -0
- package/lib/types/api/index.d.ts +149 -0
- package/lib/types/api/index.js +3 -0
- package/lib/types/api/init.d.ts +5 -0
- package/lib/types/api/init.js +3 -0
- package/lib/types/api/manifest.d.ts +3 -0
- package/lib/types/api/manifest.js +3 -0
- package/lib/types/api/nemGetAddress.d.ts +7 -0
- package/lib/types/api/nemGetAddress.js +3 -0
- package/lib/types/api/nemSignTransaction.d.ts +92 -0
- package/lib/types/api/nemSignTransaction.js +3 -0
- package/lib/types/api/off.d.ts +11 -0
- package/lib/types/api/off.js +3 -0
- package/lib/types/api/on.d.ts +14 -0
- package/lib/types/api/on.js +3 -0
- package/lib/types/api/pushTransaction.d.ts +10 -0
- package/lib/types/api/pushTransaction.js +3 -0
- package/lib/types/api/rebootToBootloader.d.ts +4 -0
- package/lib/types/api/rebootToBootloader.js +3 -0
- package/lib/types/api/recoveryDevice.d.ts +7 -0
- package/lib/types/api/recoveryDevice.js +3 -0
- package/lib/types/api/removeAllListeners.d.ts +3 -0
- package/lib/types/api/removeAllListeners.js +3 -0
- package/lib/types/api/renderWebUSBButton.d.ts +2 -0
- package/lib/types/api/renderWebUSBButton.js +3 -0
- package/lib/types/api/requestLogin.d.ts +20 -0
- package/lib/types/api/requestLogin.js +3 -0
- package/lib/types/api/resetDevice.d.ts +16 -0
- package/lib/types/api/resetDevice.js +3 -0
- package/lib/types/api/rippleGetAddress.d.ts +4 -0
- package/lib/types/api/rippleGetAddress.js +3 -0
- package/lib/types/api/rippleSignTransaction.d.ts +23 -0
- package/lib/types/api/rippleSignTransaction.js +3 -0
- package/lib/types/api/setProxy.d.ts +9 -0
- package/lib/types/api/setProxy.js +3 -0
- package/lib/types/api/signMessage.d.ts +11 -0
- package/lib/types/api/signMessage.js +3 -0
- package/lib/types/api/signTransaction.d.ts +70 -0
- package/lib/types/api/signTransaction.js +3 -0
- package/lib/types/api/stellarGetAddress.d.ts +4 -0
- package/lib/types/api/stellarGetAddress.js +3 -0
- package/lib/types/api/stellarSignTransaction.d.ts +182 -0
- package/lib/types/api/stellarSignTransaction.js +3 -0
- package/lib/types/api/tezosGetAddress.d.ts +4 -0
- package/lib/types/api/tezosGetAddress.js +3 -0
- package/lib/types/api/tezosGetPublicKey.d.ts +4 -0
- package/lib/types/api/tezosGetPublicKey.js +3 -0
- package/lib/types/api/tezosSignTransaction.d.ts +61 -0
- package/lib/types/api/tezosSignTransaction.js +3 -0
- package/lib/types/api/uiResponse.d.ts +3 -0
- package/lib/types/api/uiResponse.js +3 -0
- package/lib/types/api/verifyMessage.d.ts +11 -0
- package/lib/types/api/verifyMessage.js +3 -0
- package/lib/types/api/wipeDevice.d.ts +4 -0
- package/lib/types/api/wipeDevice.js +3 -0
- package/lib/types/coinInfo.d.ts +79 -0
- package/lib/types/coinInfo.js +3 -0
- package/lib/types/device.d.ts +92 -0
- package/lib/types/device.js +3 -0
- package/lib/types/firmware.d.ts +36 -0
- package/lib/types/firmware.js +3 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.js +11 -0
- package/lib/types/params.d.ts +56 -0
- package/lib/types/params.js +3 -0
- package/lib/types/settings.d.ts +34 -0
- package/lib/types/settings.js +3 -0
- package/lib/types/utils.d.ts +15 -0
- package/lib/types/utils.js +3 -0
- package/lib/utils/__fixtures__/accountUtils.d.ts +4 -0
- package/lib/utils/__fixtures__/accountUtils.js +32 -0
- package/lib/utils/__fixtures__/addressUtils.d.ts +10 -0
- package/lib/utils/__fixtures__/addressUtils.js +214 -0
- package/lib/utils/__fixtures__/ethereumUtils.d.ts +3 -0
- package/lib/utils/__fixtures__/ethereumUtils.js +20 -0
- package/lib/utils/__fixtures__/formatUtils.d.ts +3 -0
- package/lib/utils/__fixtures__/formatUtils.js +15 -0
- package/lib/utils/__fixtures__/hdnodeUtils.d.ts +186 -0
- package/lib/utils/__fixtures__/hdnodeUtils.js +206 -0
- package/lib/utils/accountUtils.d.ts +11 -0
- package/lib/utils/accountUtils.js +99 -0
- package/lib/utils/addressUtils.d.ts +3 -0
- package/lib/utils/addressUtils.js +32 -0
- package/lib/utils/assets-browser.d.ts +2 -0
- package/lib/utils/assets-browser.js +21 -0
- package/lib/utils/assets.d.ts +2 -0
- package/lib/utils/assets.js +28 -0
- package/lib/utils/bip39.d.ts +3 -0
- package/lib/utils/bip39.js +2053 -0
- package/lib/utils/browserUtils.d.ts +21 -0
- package/lib/utils/browserUtils.js +100 -0
- package/lib/utils/bufferUtils.d.ts +3 -0
- package/lib/utils/bufferUtils.js +11 -0
- package/lib/utils/debug.d.ts +24 -0
- package/lib/utils/debug.js +90 -0
- package/lib/utils/deferred.d.ts +18 -0
- package/lib/utils/deferred.js +66 -0
- package/lib/utils/deviceFeaturesUtils.d.ts +6 -0
- package/lib/utils/deviceFeaturesUtils.js +115 -0
- package/lib/utils/ethereumUtils.d.ts +3 -0
- package/lib/utils/ethereumUtils.js +12 -0
- package/lib/utils/firmwareUtils.d.ts +7 -0
- package/lib/utils/firmwareUtils.js +28 -0
- package/lib/utils/formatUtils.d.ts +8 -0
- package/lib/utils/formatUtils.js +57 -0
- package/lib/utils/hdnodeUtils.d.ts +8 -0
- package/lib/utils/hdnodeUtils.js +80 -0
- package/lib/utils/interactionTimeout.d.ts +10 -0
- package/lib/utils/interactionTimeout.js +34 -0
- package/lib/utils/objectUtils.d.ts +10 -0
- package/lib/utils/objectUtils.js +37 -0
- package/lib/utils/pathUtils.d.ts +20 -0
- package/lib/utils/pathUtils.js +159 -0
- package/lib/utils/promiseUtils.d.ts +2 -0
- package/lib/utils/promiseUtils.js +8 -0
- package/lib/utils/urlUtils.d.ts +5 -0
- package/lib/utils/urlUtils.js +27 -0
- package/lib/utils/versionUtils.d.ts +6 -0
- package/lib/utils/versionUtils.js +72 -0
- package/lib/utils/windowsUtils.d.ts +2 -0
- package/lib/utils/windowsUtils.js +6 -0
- package/lib/workers/RNUsbPlugin.d.ts +31 -0
- package/lib/workers/RNUsbPlugin.js +65 -0
- package/lib/workers/workers-browser.d.ts +8 -0
- package/lib/workers/workers-browser.js +19 -0
- package/lib/workers/workers-react-native.d.ts +8 -0
- package/lib/workers/workers-react-native.js +19 -0
- package/lib/workers/workers.d.ts +10 -0
- package/lib/workers/workers.js +17 -0
- package/package.json +62 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateReferencedTransactions = exports.transformReferencedTransactions = exports.transformOrigTransactions = exports.getOrigTransactions = exports.getReferencedTransactions = exports.requireReferencedTransactions = void 0;
|
|
4
|
+
const utxo_lib_1 = require("@trezor/utxo-lib");
|
|
5
|
+
const bufferUtils_1 = require("../../utils/bufferUtils");
|
|
6
|
+
const pathUtils_1 = require("../../utils/pathUtils");
|
|
7
|
+
const paramsValidator_1 = require("../common/paramsValidator");
|
|
8
|
+
const errors_1 = require("../../constants/errors");
|
|
9
|
+
const requireReferencedTransactions = (inputs, options = {}, coinInfo) => {
|
|
10
|
+
if ((coinInfo === null || coinInfo === void 0 ? void 0 : coinInfo.shortcut) === 'ZEC' || (coinInfo === null || coinInfo === void 0 ? void 0 : coinInfo.shortcut) === 'TAZ') {
|
|
11
|
+
return !(options.version && options.version >= 5);
|
|
12
|
+
}
|
|
13
|
+
const inputTypes = ['SPENDTAPROOT', 'EXTERNAL'];
|
|
14
|
+
return !!inputs.find(input => !inputTypes.find(t => t === input.script_type));
|
|
15
|
+
};
|
|
16
|
+
exports.requireReferencedTransactions = requireReferencedTransactions;
|
|
17
|
+
const getReferencedTransactions = (inputs) => {
|
|
18
|
+
const result = [];
|
|
19
|
+
inputs.forEach(input => {
|
|
20
|
+
if (input.prev_hash && !result.includes(input.prev_hash)) {
|
|
21
|
+
result.push(input.prev_hash);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
exports.getReferencedTransactions = getReferencedTransactions;
|
|
27
|
+
const getOrigTransactions = (inputs, outputs) => {
|
|
28
|
+
const result = [];
|
|
29
|
+
inputs.forEach(input => {
|
|
30
|
+
if (input.orig_hash && !result.includes(input.orig_hash)) {
|
|
31
|
+
result.push(input.orig_hash);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
outputs.forEach(output => {
|
|
35
|
+
if (output.orig_hash && !result.includes(output.orig_hash)) {
|
|
36
|
+
result.push(output.orig_hash);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
exports.getOrigTransactions = getOrigTransactions;
|
|
42
|
+
const enhanceTransaction = (refTx, srcTx) => {
|
|
43
|
+
const extraData = srcTx.getExtraData();
|
|
44
|
+
if (extraData) {
|
|
45
|
+
refTx.extra_data = extraData.toString('hex');
|
|
46
|
+
}
|
|
47
|
+
const specific = srcTx.getSpecificData();
|
|
48
|
+
if (specific) {
|
|
49
|
+
if (specific.type === 'zcash' && specific.versionGroupId && refTx.version >= 3) {
|
|
50
|
+
refTx.version_group_id = specific.versionGroupId;
|
|
51
|
+
}
|
|
52
|
+
if (specific.type === 'dash' && srcTx.type && srcTx.version >= 3) {
|
|
53
|
+
refTx.version |= srcTx.type << 16;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return refTx;
|
|
57
|
+
};
|
|
58
|
+
const transformOrigTransactions = (txs, coinInfo, addresses) => txs.flatMap(raw => {
|
|
59
|
+
if (coinInfo.type !== 'bitcoin' || raw.type !== 'blockbook' || !addresses)
|
|
60
|
+
return [];
|
|
61
|
+
const { hex, vin, vout } = raw.tx;
|
|
62
|
+
const tx = utxo_lib_1.Transaction.fromHex(hex, { network: coinInfo.network });
|
|
63
|
+
const inputAddresses = addresses.used.concat(addresses.change).concat(addresses.unused);
|
|
64
|
+
const inputsMap = (input, i) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const rawInput = vin[i];
|
|
67
|
+
if (!(rawInput === null || rawInput === void 0 ? void 0 : rawInput.value) || !(rawInput === null || rawInput === void 0 ? void 0 : rawInput.addresses) || rawInput.addresses.length !== 1) {
|
|
68
|
+
throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid input at ${raw.tx.txid} [${i}]`);
|
|
69
|
+
}
|
|
70
|
+
const [address] = rawInput.addresses;
|
|
71
|
+
const inputAddress = inputAddresses.find(addr => addr.address === address);
|
|
72
|
+
const address_n = (0, pathUtils_1.getHDPath)((inputAddress === null || inputAddress === void 0 ? void 0 : inputAddress.path) || '');
|
|
73
|
+
return {
|
|
74
|
+
address_n,
|
|
75
|
+
prev_hash: (0, bufferUtils_1.reverseBuffer)(input.hash).toString('hex'),
|
|
76
|
+
prev_index: input.index,
|
|
77
|
+
script_sig: input.script.toString('hex'),
|
|
78
|
+
sequence: input.sequence,
|
|
79
|
+
script_type: (0, pathUtils_1.getScriptType)(address_n),
|
|
80
|
+
multisig: undefined,
|
|
81
|
+
amount: rawInput.value,
|
|
82
|
+
decred_tree: undefined,
|
|
83
|
+
witness: (_a = tx.getWitness(i)) === null || _a === void 0 ? void 0 : _a.toString('hex'),
|
|
84
|
+
ownership_proof: undefined,
|
|
85
|
+
commitment_data: undefined,
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const outputsMap = (output, i) => {
|
|
89
|
+
var _a;
|
|
90
|
+
const rawOutput = vout[i];
|
|
91
|
+
if (!rawOutput.isAddress) {
|
|
92
|
+
const { data } = utxo_lib_1.payments.embed({ output: output.script });
|
|
93
|
+
const op_return_data = (_a = data === null || data === void 0 ? void 0 : data.shift()) === null || _a === void 0 ? void 0 : _a.toString('hex');
|
|
94
|
+
if (typeof op_return_data !== 'string') {
|
|
95
|
+
throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid op_return_data at ${raw.tx.txid} [${i}]`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
script_type: 'PAYTOOPRETURN',
|
|
99
|
+
amount: '0',
|
|
100
|
+
op_return_data,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (!rawOutput.addresses || rawOutput.addresses.length !== 1) {
|
|
104
|
+
throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid output at ${raw.tx.txid} [${i}]`);
|
|
105
|
+
}
|
|
106
|
+
const [address] = rawOutput.addresses;
|
|
107
|
+
const changeAddress = addresses.change.find(addr => addr.address === address);
|
|
108
|
+
const address_n = changeAddress && (0, pathUtils_1.getHDPath)(changeAddress.path);
|
|
109
|
+
const amount = output.value.toString();
|
|
110
|
+
return address_n
|
|
111
|
+
? {
|
|
112
|
+
address_n,
|
|
113
|
+
amount,
|
|
114
|
+
script_type: (0, pathUtils_1.getOutputScriptType)(address_n),
|
|
115
|
+
}
|
|
116
|
+
: {
|
|
117
|
+
address,
|
|
118
|
+
amount,
|
|
119
|
+
script_type: 'PAYTOADDRESS',
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const refTx = {
|
|
123
|
+
version: tx.version,
|
|
124
|
+
hash: tx.getId(),
|
|
125
|
+
inputs: tx.ins.map(inputsMap),
|
|
126
|
+
outputs: tx.outs.map(outputsMap),
|
|
127
|
+
lock_time: tx.locktime,
|
|
128
|
+
timestamp: tx.timestamp,
|
|
129
|
+
expiry: tx.expiry,
|
|
130
|
+
};
|
|
131
|
+
return enhanceTransaction(refTx, tx);
|
|
132
|
+
});
|
|
133
|
+
exports.transformOrigTransactions = transformOrigTransactions;
|
|
134
|
+
const transformReferencedTransactions = (txs, coinInfo) => txs.flatMap(raw => {
|
|
135
|
+
if (coinInfo.type !== 'bitcoin' || raw.type !== 'blockbook')
|
|
136
|
+
return [];
|
|
137
|
+
const { hex } = raw.tx;
|
|
138
|
+
const tx = utxo_lib_1.Transaction.fromHex(hex, { network: coinInfo.network });
|
|
139
|
+
const inputsMap = (input) => ({
|
|
140
|
+
prev_index: input.index,
|
|
141
|
+
sequence: input.sequence,
|
|
142
|
+
prev_hash: (0, bufferUtils_1.reverseBuffer)(input.hash).toString('hex'),
|
|
143
|
+
script_sig: input.script.toString('hex'),
|
|
144
|
+
});
|
|
145
|
+
const binOutputsMap = (output) => ({
|
|
146
|
+
amount: output.value.toString(),
|
|
147
|
+
script_pubkey: output.script.toString('hex'),
|
|
148
|
+
});
|
|
149
|
+
const refTx = {
|
|
150
|
+
version: tx.version,
|
|
151
|
+
hash: tx.getId(),
|
|
152
|
+
inputs: tx.ins.map(inputsMap),
|
|
153
|
+
bin_outputs: tx.outs.map(binOutputsMap),
|
|
154
|
+
lock_time: tx.locktime,
|
|
155
|
+
timestamp: tx.timestamp,
|
|
156
|
+
expiry: tx.expiry,
|
|
157
|
+
};
|
|
158
|
+
return enhanceTransaction(refTx, tx);
|
|
159
|
+
});
|
|
160
|
+
exports.transformReferencedTransactions = transformReferencedTransactions;
|
|
161
|
+
const validateReferencedTransactions = (txs, inputs, outputs) => {
|
|
162
|
+
if (!Array.isArray(txs) || txs.length === 0)
|
|
163
|
+
return;
|
|
164
|
+
const refTxs = (0, exports.getReferencedTransactions)(inputs);
|
|
165
|
+
const origTxs = (0, exports.getOrigTransactions)(inputs, outputs);
|
|
166
|
+
const transformedTxs = txs.map(tx => {
|
|
167
|
+
(0, paramsValidator_1.validateParams)(tx, [
|
|
168
|
+
{ name: 'hash', type: 'string', required: true },
|
|
169
|
+
{ name: 'inputs', type: 'array', required: true },
|
|
170
|
+
{ name: 'version', type: 'number', required: true },
|
|
171
|
+
{ name: 'lock_time', type: 'number', required: true },
|
|
172
|
+
{ name: 'extra_data', type: 'string' },
|
|
173
|
+
{ name: 'timestamp', type: 'number' },
|
|
174
|
+
{ name: 'version_group_id', type: 'number' },
|
|
175
|
+
]);
|
|
176
|
+
if (origTxs.includes(tx.hash)) {
|
|
177
|
+
(0, paramsValidator_1.validateParams)(tx, [{ name: 'outputs', type: 'array', required: true }]);
|
|
178
|
+
return tx;
|
|
179
|
+
}
|
|
180
|
+
(0, paramsValidator_1.validateParams)(tx, [{ name: 'bin_outputs', type: 'array', required: true }]);
|
|
181
|
+
tx.inputs.forEach(input => {
|
|
182
|
+
(0, paramsValidator_1.validateParams)(input, [
|
|
183
|
+
{ name: 'prev_hash', type: 'string', required: true },
|
|
184
|
+
{ name: 'prev_index', type: 'number', required: true },
|
|
185
|
+
{ name: 'script_sig', type: 'string', required: true },
|
|
186
|
+
{ name: 'sequence', type: 'number', required: true },
|
|
187
|
+
{ name: 'decred_tree', type: 'number' },
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
hash: tx.hash,
|
|
192
|
+
version: tx.version,
|
|
193
|
+
extra_data: tx.extra_data,
|
|
194
|
+
lock_time: tx.lock_time,
|
|
195
|
+
timestamp: tx.timestamp,
|
|
196
|
+
version_group_id: tx.version_group_id,
|
|
197
|
+
expiry: tx.expiry,
|
|
198
|
+
inputs: tx.inputs.map(input => ({
|
|
199
|
+
prev_hash: input.prev_hash,
|
|
200
|
+
prev_index: input.prev_index,
|
|
201
|
+
script_sig: input.script_sig,
|
|
202
|
+
sequence: input.sequence,
|
|
203
|
+
decred_tree: input.decred_tree,
|
|
204
|
+
})),
|
|
205
|
+
bin_outputs: tx.bin_outputs.map(output => ({
|
|
206
|
+
amount: output.amount,
|
|
207
|
+
script_pubkey: output.script_pubkey,
|
|
208
|
+
decred_script_version: output.decred_script_version,
|
|
209
|
+
})),
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
refTxs.concat(origTxs).forEach(hash => {
|
|
213
|
+
if (!transformedTxs.find(tx => tx.hash === hash)) {
|
|
214
|
+
throw (0, errors_1.TypedError)('Method_InvalidParameter', `refTx: ${hash} not provided`);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return transformedTxs;
|
|
218
|
+
};
|
|
219
|
+
exports.validateReferencedTransactions = validateReferencedTransactions;
|
|
220
|
+
//# sourceMappingURL=refTx.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PROTO } from '../../constants';
|
|
2
|
+
import type { BitcoinNetworkInfo } from '../../types';
|
|
3
|
+
import type { TypedCall } from '../../device/DeviceCommands';
|
|
4
|
+
import type { RefTransaction, TransactionOptions, SignedTransaction } from '../../types/api/signTransaction';
|
|
5
|
+
export interface SignTxHelperProps {
|
|
6
|
+
typedCall: TypedCall;
|
|
7
|
+
txRequest: PROTO.TxRequest;
|
|
8
|
+
refTxs: Record<string, RefTransaction>;
|
|
9
|
+
inputs: PROTO.TxInputType[];
|
|
10
|
+
outputs: PROTO.TxOutputType[];
|
|
11
|
+
paymentRequests: PROTO.TxAckPaymentRequest[];
|
|
12
|
+
serializedTx: string[];
|
|
13
|
+
signatures: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface SignTxHelperParams {
|
|
16
|
+
typedCall: TypedCall;
|
|
17
|
+
inputs: PROTO.TxInputType[];
|
|
18
|
+
outputs: PROTO.TxOutputType[];
|
|
19
|
+
paymentRequests?: PROTO.TxAckPaymentRequest[];
|
|
20
|
+
refTxs: RefTransaction[];
|
|
21
|
+
options: TransactionOptions;
|
|
22
|
+
coinInfo: BitcoinNetworkInfo;
|
|
23
|
+
}
|
|
24
|
+
export declare const signTx: ({ typedCall, inputs, outputs, paymentRequests, refTxs, options, coinInfo, }: SignTxHelperParams) => Promise<SignedTransaction>;
|
|
25
|
+
//# sourceMappingURL=signtx.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signTx = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const requestPrevTxInfo = ({ typedCall, txRequest: { request_type, details }, refTxs, }) => {
|
|
6
|
+
const { tx_hash } = details;
|
|
7
|
+
if (!tx_hash) {
|
|
8
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestPrevTxInfo: unknown details.tx_hash');
|
|
9
|
+
}
|
|
10
|
+
const tx = refTxs[tx_hash.toLowerCase()];
|
|
11
|
+
if (!tx) {
|
|
12
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown tx: ${tx_hash}`);
|
|
13
|
+
}
|
|
14
|
+
if (request_type === 'TXINPUT') {
|
|
15
|
+
if (!tx.bin_outputs)
|
|
16
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown TXINPUT: ${tx_hash}`);
|
|
17
|
+
return typedCall('TxAckPrevInput', 'TxRequest', {
|
|
18
|
+
tx: { input: tx.inputs[details.request_index] },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (request_type === 'TXOUTPUT') {
|
|
22
|
+
if (!tx.bin_outputs)
|
|
23
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown TXOUTPUT: ${tx_hash}`);
|
|
24
|
+
return typedCall('TxAckPrevOutput', 'TxRequest', {
|
|
25
|
+
tx: { output: tx.bin_outputs[details.request_index] },
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (request_type === 'TXORIGINPUT') {
|
|
29
|
+
if (!tx.outputs)
|
|
30
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown TXORIGINPUT: ${tx_hash}`);
|
|
31
|
+
return typedCall('TxAckInput', 'TxRequest', {
|
|
32
|
+
tx: { input: tx.inputs[details.request_index] },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (request_type === 'TXORIGOUTPUT') {
|
|
36
|
+
if (!tx.outputs)
|
|
37
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown TXORIGOUTPUT: ${tx_hash}`);
|
|
38
|
+
return typedCall('TxAckOutput', 'TxRequest', {
|
|
39
|
+
tx: { output: tx.outputs[details.request_index] },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (request_type === 'TXEXTRADATA') {
|
|
43
|
+
if (typeof details.extra_data_len !== 'number') {
|
|
44
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestPrevTxInfo: Missing extra_data_len');
|
|
45
|
+
}
|
|
46
|
+
if (typeof details.extra_data_offset !== 'number') {
|
|
47
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestPrevTxInfo: Missing extra_data_offset');
|
|
48
|
+
}
|
|
49
|
+
if (typeof tx.extra_data !== 'string') {
|
|
50
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: No extra data for transaction ${tx.hash}`);
|
|
51
|
+
}
|
|
52
|
+
const data = tx.extra_data;
|
|
53
|
+
const dataLen = details.extra_data_len;
|
|
54
|
+
const dataOffset = details.extra_data_offset;
|
|
55
|
+
const extra_data_chunk = data.substring(dataOffset * 2, (dataOffset + dataLen) * 2);
|
|
56
|
+
return typedCall('TxAckPrevExtraData', 'TxRequest', { tx: { extra_data_chunk } });
|
|
57
|
+
}
|
|
58
|
+
if (request_type === 'TXMETA') {
|
|
59
|
+
const data = tx.extra_data;
|
|
60
|
+
const meta = {
|
|
61
|
+
version: tx.version,
|
|
62
|
+
lock_time: tx.lock_time,
|
|
63
|
+
inputs_count: tx.inputs.length,
|
|
64
|
+
outputs_count: tx.outputs ? tx.outputs.length : tx.bin_outputs.length,
|
|
65
|
+
timestamp: tx.timestamp,
|
|
66
|
+
version_group_id: tx.version_group_id,
|
|
67
|
+
expiry: tx.expiry,
|
|
68
|
+
branch_id: tx.branch_id,
|
|
69
|
+
extra_data_len: data ? data.length / 2 : undefined,
|
|
70
|
+
};
|
|
71
|
+
return typedCall('TxAckPrevMeta', 'TxRequest', { tx: meta });
|
|
72
|
+
}
|
|
73
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Unknown request type: ${request_type}`);
|
|
74
|
+
};
|
|
75
|
+
const requestSignedTxInfo = ({ typedCall, txRequest: { request_type, details }, inputs, outputs, paymentRequests, }) => {
|
|
76
|
+
if (request_type === 'TXINPUT') {
|
|
77
|
+
return typedCall('TxAckInput', 'TxRequest', {
|
|
78
|
+
tx: { input: inputs[details.request_index] },
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (request_type === 'TXOUTPUT') {
|
|
82
|
+
return typedCall('TxAckOutput', 'TxRequest', {
|
|
83
|
+
tx: { output: outputs[details.request_index] },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (request_type === 'TXPAYMENTREQ') {
|
|
87
|
+
const req = paymentRequests[details.request_index];
|
|
88
|
+
if (!req) {
|
|
89
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown payment request at ${details.request_index}`);
|
|
90
|
+
}
|
|
91
|
+
return typedCall('TxAckPaymentRequest', 'TxRequest', {
|
|
92
|
+
nonce: req.nonce,
|
|
93
|
+
recipient_name: req.recipient_name,
|
|
94
|
+
memos: req.memos,
|
|
95
|
+
amount: req.amount,
|
|
96
|
+
signature: req.signature,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (request_type === 'TXMETA') {
|
|
100
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestSignedTxInfo: Cannot read TXMETA from signed transaction');
|
|
101
|
+
}
|
|
102
|
+
if (request_type === 'TXEXTRADATA') {
|
|
103
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestSignedTxInfo: Cannot read TXEXTRADATA from signed transaction');
|
|
104
|
+
}
|
|
105
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestSignedTxInfo: Unknown request type: ${request_type}`);
|
|
106
|
+
};
|
|
107
|
+
const requestTxAck = (props) => {
|
|
108
|
+
const { tx_hash } = props.txRequest.details;
|
|
109
|
+
if (tx_hash) {
|
|
110
|
+
return requestPrevTxInfo(props);
|
|
111
|
+
}
|
|
112
|
+
return requestSignedTxInfo(props);
|
|
113
|
+
};
|
|
114
|
+
const saveTxSignatures = (txRequest, serializedTx, signatures) => {
|
|
115
|
+
const { signature_index, signature, serialized_tx } = txRequest;
|
|
116
|
+
if (serialized_tx) {
|
|
117
|
+
serializedTx.push(serialized_tx);
|
|
118
|
+
}
|
|
119
|
+
if (typeof signature_index === 'number') {
|
|
120
|
+
if (!signature) {
|
|
121
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'saveTxSignatures: Unexpected null in trezor:TxRequestSerialized signature.');
|
|
122
|
+
}
|
|
123
|
+
signatures[signature_index] = signature;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const processTxRequest = async (props) => {
|
|
127
|
+
const { txRequest, serializedTx, signatures } = props;
|
|
128
|
+
if (txRequest.serialized)
|
|
129
|
+
saveTxSignatures(txRequest.serialized, serializedTx, signatures);
|
|
130
|
+
if (txRequest.request_type === 'TXFINISHED') {
|
|
131
|
+
return Promise.resolve({
|
|
132
|
+
signatures,
|
|
133
|
+
serializedTx: serializedTx.join(''),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const { message } = await requestTxAck(props);
|
|
137
|
+
return processTxRequest({
|
|
138
|
+
...props,
|
|
139
|
+
txRequest: message,
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const signTx = async ({ typedCall, inputs, outputs, paymentRequests, refTxs, options, coinInfo, }) => {
|
|
143
|
+
const { message } = await typedCall('SignTx', 'TxRequest', {
|
|
144
|
+
...options,
|
|
145
|
+
inputs_count: inputs.length,
|
|
146
|
+
outputs_count: outputs.length,
|
|
147
|
+
coin_name: coinInfo.name,
|
|
148
|
+
});
|
|
149
|
+
return processTxRequest({
|
|
150
|
+
typedCall,
|
|
151
|
+
txRequest: message,
|
|
152
|
+
refTxs: refTxs.reduce((record, tx) => ({
|
|
153
|
+
...record,
|
|
154
|
+
[tx.hash.toLowerCase()]: tx,
|
|
155
|
+
}), {}),
|
|
156
|
+
inputs,
|
|
157
|
+
outputs,
|
|
158
|
+
paymentRequests: paymentRequests || [],
|
|
159
|
+
serializedTx: [],
|
|
160
|
+
signatures: [],
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
exports.signTx = signTx;
|
|
164
|
+
//# sourceMappingURL=signtx.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SignedTransaction } from '../../types/api/signTransaction';
|
|
2
|
+
import type { SignTxHelperParams } from './signtx';
|
|
3
|
+
export declare const signTxLegacy: ({ typedCall, inputs, outputs, refTxs, options, coinInfo, }: SignTxHelperParams) => Promise<SignedTransaction>;
|
|
4
|
+
//# sourceMappingURL=signtxLegacy.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signTxLegacy = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const requestPrevTxInfo = ({ txRequest: { request_type, details }, refTxs, }) => {
|
|
6
|
+
const { tx_hash } = details;
|
|
7
|
+
if (!tx_hash) {
|
|
8
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestPrevTxInfo: unknown details.tx_hash');
|
|
9
|
+
}
|
|
10
|
+
const tx = refTxs[tx_hash.toLowerCase()];
|
|
11
|
+
if (!tx) {
|
|
12
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Requested unknown tx: ${tx_hash}`);
|
|
13
|
+
}
|
|
14
|
+
if (!tx.bin_outputs) {
|
|
15
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: bin_outputs not set tx: ${tx_hash}`);
|
|
16
|
+
}
|
|
17
|
+
if (request_type === 'TXINPUT') {
|
|
18
|
+
return { inputs: [tx.inputs[details.request_index]] };
|
|
19
|
+
}
|
|
20
|
+
if (request_type === 'TXOUTPUT') {
|
|
21
|
+
return { bin_outputs: [tx.bin_outputs[details.request_index]] };
|
|
22
|
+
}
|
|
23
|
+
if (request_type === 'TXEXTRADATA') {
|
|
24
|
+
if (typeof details.extra_data_len !== 'number') {
|
|
25
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestPrevTxInfo: Missing extra_data_len');
|
|
26
|
+
}
|
|
27
|
+
if (typeof details.extra_data_offset !== 'number') {
|
|
28
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestPrevTxInfo: Missing extra_data_offset');
|
|
29
|
+
}
|
|
30
|
+
if (typeof tx.extra_data !== 'string') {
|
|
31
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: No extra data for transaction ${tx.hash}`);
|
|
32
|
+
}
|
|
33
|
+
const data = tx.extra_data;
|
|
34
|
+
const dataLen = details.extra_data_len;
|
|
35
|
+
const dataOffset = details.extra_data_offset;
|
|
36
|
+
const extra_data = data.substring(dataOffset * 2, (dataOffset + dataLen) * 2);
|
|
37
|
+
return { extra_data };
|
|
38
|
+
}
|
|
39
|
+
if (request_type === 'TXMETA') {
|
|
40
|
+
const data = tx.extra_data;
|
|
41
|
+
const meta = {
|
|
42
|
+
version: tx.version,
|
|
43
|
+
lock_time: tx.lock_time,
|
|
44
|
+
inputs_cnt: tx.inputs.length,
|
|
45
|
+
outputs_cnt: tx.bin_outputs.length,
|
|
46
|
+
timestamp: tx.timestamp,
|
|
47
|
+
version_group_id: tx.version_group_id,
|
|
48
|
+
expiry: tx.expiry,
|
|
49
|
+
branch_id: tx.branch_id,
|
|
50
|
+
};
|
|
51
|
+
if (typeof data === 'string' && data.length !== 0) {
|
|
52
|
+
return {
|
|
53
|
+
...meta,
|
|
54
|
+
extra_data_len: data.length / 2,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return meta;
|
|
58
|
+
}
|
|
59
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestPrevTxInfo: Unknown request type: ${request_type}`);
|
|
60
|
+
};
|
|
61
|
+
const requestSignedTxInfo = ({ txRequest: { request_type, details }, inputs, outputs, }) => {
|
|
62
|
+
if (request_type === 'TXINPUT') {
|
|
63
|
+
return { inputs: [inputs[details.request_index]] };
|
|
64
|
+
}
|
|
65
|
+
if (request_type === 'TXOUTPUT') {
|
|
66
|
+
return { outputs: [outputs[details.request_index]] };
|
|
67
|
+
}
|
|
68
|
+
if (request_type === 'TXMETA') {
|
|
69
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestSignedTxInfo: Cannot read TXMETA from signed transaction');
|
|
70
|
+
}
|
|
71
|
+
if (request_type === 'TXEXTRADATA') {
|
|
72
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'requestSignedTxInfo: Cannot read TXEXTRADATA from signed transaction');
|
|
73
|
+
}
|
|
74
|
+
throw constants_1.ERRORS.TypedError('Runtime', `requestSignedTxInfo: Unknown request type: ${request_type}`);
|
|
75
|
+
};
|
|
76
|
+
const requestTxAck = (props) => {
|
|
77
|
+
const { tx_hash } = props.txRequest.details;
|
|
78
|
+
if (tx_hash) {
|
|
79
|
+
return requestPrevTxInfo(props);
|
|
80
|
+
}
|
|
81
|
+
return requestSignedTxInfo(props);
|
|
82
|
+
};
|
|
83
|
+
const saveTxSignatures = (txRequest, serializedTx, signatures) => {
|
|
84
|
+
if (!txRequest)
|
|
85
|
+
return;
|
|
86
|
+
const { signature_index, signature, serialized_tx } = txRequest;
|
|
87
|
+
if (serialized_tx) {
|
|
88
|
+
serializedTx.push(serialized_tx);
|
|
89
|
+
}
|
|
90
|
+
if (typeof signature_index === 'number') {
|
|
91
|
+
if (!signature) {
|
|
92
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'saveTxSignatures: Unexpected null in trezor:TxRequestSerialized signature.');
|
|
93
|
+
}
|
|
94
|
+
signatures[signature_index] = signature;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const processTxRequest = async (props) => {
|
|
98
|
+
const { typedCall, txRequest, serializedTx, signatures } = props;
|
|
99
|
+
if (txRequest.serialized)
|
|
100
|
+
saveTxSignatures(txRequest.serialized, serializedTx, signatures);
|
|
101
|
+
if (txRequest.request_type === 'TXFINISHED') {
|
|
102
|
+
return Promise.resolve({
|
|
103
|
+
signatures,
|
|
104
|
+
serializedTx: serializedTx.join(''),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const txAck = requestTxAck(props);
|
|
108
|
+
const { message } = await typedCall('TxAck', 'TxRequest', { tx: txAck });
|
|
109
|
+
return processTxRequest({
|
|
110
|
+
...props,
|
|
111
|
+
txRequest: message,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const signTxLegacy = async ({ typedCall, inputs, outputs, refTxs, options, coinInfo, }) => {
|
|
115
|
+
const { message } = await typedCall('SignTx', 'TxRequest', {
|
|
116
|
+
...options,
|
|
117
|
+
inputs_count: inputs.length,
|
|
118
|
+
outputs_count: outputs.length,
|
|
119
|
+
coin_name: coinInfo.name,
|
|
120
|
+
});
|
|
121
|
+
return processTxRequest({
|
|
122
|
+
typedCall,
|
|
123
|
+
txRequest: message,
|
|
124
|
+
refTxs: refTxs.reduce((record, tx) => ({
|
|
125
|
+
...record,
|
|
126
|
+
[tx.hash.toLowerCase()]: tx,
|
|
127
|
+
}), {}),
|
|
128
|
+
inputs,
|
|
129
|
+
outputs,
|
|
130
|
+
paymentRequests: [],
|
|
131
|
+
serializedTx: [],
|
|
132
|
+
signatures: [],
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
exports.signTxLegacy = signTxLegacy;
|
|
136
|
+
//# sourceMappingURL=signtxLegacy.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PROTO } from '../../constants';
|
|
2
|
+
import type { BitcoinNetworkInfo } from '../../types';
|
|
3
|
+
import type { HDNodeResponse } from '../../types/api/getPublicKey';
|
|
4
|
+
declare type GetHDNode = (path: number[], coinInfo?: BitcoinNetworkInfo, validation?: boolean) => Promise<HDNodeResponse>;
|
|
5
|
+
export declare const verifyTx: (getHDNode: GetHDNode, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], serializedTx: string, coinInfo: BitcoinNetworkInfo) => Promise<import("packages/utxo-lib/lib/transaction/base").TransactionBase<undefined> | import("packages/utxo-lib/lib/transaction/base").TransactionBase<import("packages/utxo-lib/lib/transaction/dash").DashSpecific> | import("packages/utxo-lib/lib/transaction/base").TransactionBase<import("packages/utxo-lib/lib/transaction/zcash").ZcashSpecific>>;
|
|
6
|
+
export declare const verifyTicketTx: (getHDNode: GetHDNode, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], serializedTx: string, coinInfo: BitcoinNetworkInfo) => Promise<void>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=signtxVerify.d.ts.map
|