@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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
7
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
8
|
+
const helper = (0, tslib_1.__importStar)(require("./binance/binanceSignTx"));
|
|
9
|
+
class BinanceSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
10
|
+
init() {
|
|
11
|
+
this.requiredPermissions = ['read', 'write'];
|
|
12
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('BNB'), this.firmwareRange);
|
|
13
|
+
this.info = 'Sign Binance transaction';
|
|
14
|
+
const { payload } = this;
|
|
15
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
16
|
+
{ name: 'path', type: 'string', required: true },
|
|
17
|
+
{ name: 'transaction', required: true },
|
|
18
|
+
]);
|
|
19
|
+
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
20
|
+
const transaction = helper.validate(payload.transaction);
|
|
21
|
+
this.params = {
|
|
22
|
+
path,
|
|
23
|
+
transaction,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
run() {
|
|
27
|
+
return helper.signTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, this.params.transaction);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = BinanceSignTransaction;
|
|
31
|
+
//# sourceMappingURL=binanceSignTransaction.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Blockchain } from '../../backend/BlockchainLink';
|
|
2
|
+
import type { CoinInfo } from '../../types';
|
|
3
|
+
import type { FeeLevel } from '../../types/account';
|
|
4
|
+
declare type Blocks = Array<string | undefined>;
|
|
5
|
+
export declare class FeeLevels {
|
|
6
|
+
coinInfo: CoinInfo;
|
|
7
|
+
levels: FeeLevel[];
|
|
8
|
+
blocks: Blocks;
|
|
9
|
+
constructor(coinInfo: CoinInfo);
|
|
10
|
+
loadMisc(blockchain: Blockchain): Promise<FeeLevel[]>;
|
|
11
|
+
load(blockchain: Blockchain): Promise<FeeLevel[]>;
|
|
12
|
+
updateCustomFee(feePerUnit: string): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=Fees.d.ts.map
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeeLevels = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
|
|
6
|
+
const BLOCKS = {
|
|
7
|
+
btc: {
|
|
8
|
+
high: 1,
|
|
9
|
+
normal: 6,
|
|
10
|
+
economy: 36,
|
|
11
|
+
low: 144,
|
|
12
|
+
},
|
|
13
|
+
bch: {
|
|
14
|
+
high: 1,
|
|
15
|
+
normal: 5,
|
|
16
|
+
economy: 10,
|
|
17
|
+
low: 10,
|
|
18
|
+
},
|
|
19
|
+
btg: {
|
|
20
|
+
high: 1,
|
|
21
|
+
normal: 5,
|
|
22
|
+
economy: 10,
|
|
23
|
+
low: 10,
|
|
24
|
+
},
|
|
25
|
+
dgb: {
|
|
26
|
+
high: 1,
|
|
27
|
+
normal: 15,
|
|
28
|
+
economy: 30,
|
|
29
|
+
low: 60,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const getDefaultBlocks = (shortcut, label) => BLOCKS[shortcut] && BLOCKS[shortcut][label] ? BLOCKS[shortcut][label] : -1;
|
|
33
|
+
const feePerKB = (fee) => {
|
|
34
|
+
const bn = new bignumber_js_1.default(fee);
|
|
35
|
+
if (bn.isNaN() || bn.lte('0'))
|
|
36
|
+
return;
|
|
37
|
+
return bn.div(1000).integerValue(bignumber_js_1.default.ROUND_HALF_CEIL).toString();
|
|
38
|
+
};
|
|
39
|
+
const fillGap = (from, step, size) => {
|
|
40
|
+
const fill = [];
|
|
41
|
+
for (let i = from + step; i <= from + size; i += step) {
|
|
42
|
+
fill.push(i);
|
|
43
|
+
}
|
|
44
|
+
return fill;
|
|
45
|
+
};
|
|
46
|
+
const findLowest = (blocks) => {
|
|
47
|
+
const unique = [];
|
|
48
|
+
blocks.forEach(item => {
|
|
49
|
+
if (typeof item === 'string' && unique.indexOf(item) < 0) {
|
|
50
|
+
unique.push(item);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return unique[unique.length - 1];
|
|
54
|
+
};
|
|
55
|
+
const findNearest = (requested, blocks) => {
|
|
56
|
+
const len = blocks.length;
|
|
57
|
+
const knownValue = blocks[requested];
|
|
58
|
+
if (typeof knownValue === 'string')
|
|
59
|
+
return knownValue;
|
|
60
|
+
const lastKnownValue = blocks
|
|
61
|
+
.slice()
|
|
62
|
+
.reverse()
|
|
63
|
+
.find(item => typeof item === 'string');
|
|
64
|
+
if (!lastKnownValue)
|
|
65
|
+
return;
|
|
66
|
+
const lastKnownIndex = blocks.indexOf(lastKnownValue);
|
|
67
|
+
if (requested >= lastKnownIndex) {
|
|
68
|
+
return lastKnownValue;
|
|
69
|
+
}
|
|
70
|
+
let index = requested;
|
|
71
|
+
while (typeof blocks[index] !== 'string' && index < len) {
|
|
72
|
+
index++;
|
|
73
|
+
}
|
|
74
|
+
return blocks[index];
|
|
75
|
+
};
|
|
76
|
+
const findBlocksForFee = (feePerUnit, blocks) => {
|
|
77
|
+
const bn = new bignumber_js_1.default(feePerUnit);
|
|
78
|
+
const lower = blocks.find(b => typeof b === 'string' && bn.gte(b));
|
|
79
|
+
if (!lower)
|
|
80
|
+
return -1;
|
|
81
|
+
return blocks.indexOf(lower);
|
|
82
|
+
};
|
|
83
|
+
class FeeLevels {
|
|
84
|
+
constructor(coinInfo) {
|
|
85
|
+
this.blocks = [];
|
|
86
|
+
this.coinInfo = coinInfo;
|
|
87
|
+
const shortcut = coinInfo.shortcut.toLowerCase();
|
|
88
|
+
if (coinInfo.type === 'ethereum') {
|
|
89
|
+
this.levels = coinInfo.defaultFees.map(level => ({
|
|
90
|
+
...level,
|
|
91
|
+
blocks: -1,
|
|
92
|
+
}));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const keys = Object.keys(coinInfo.defaultFees);
|
|
96
|
+
this.levels = keys
|
|
97
|
+
.sort((levelA, levelB) => coinInfo.defaultFees[levelB] - coinInfo.defaultFees[levelA])
|
|
98
|
+
.map(level => {
|
|
99
|
+
const label = level.toLowerCase();
|
|
100
|
+
const blocks = getDefaultBlocks(shortcut, label);
|
|
101
|
+
return {
|
|
102
|
+
label,
|
|
103
|
+
feePerUnit: coinInfo.defaultFees[level].toString(),
|
|
104
|
+
blocks,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async loadMisc(blockchain) {
|
|
109
|
+
try {
|
|
110
|
+
const [response] = await blockchain.estimateFee({ blocks: [1] });
|
|
111
|
+
this.levels[0] = {
|
|
112
|
+
...this.levels[0],
|
|
113
|
+
...response,
|
|
114
|
+
feePerUnit: Math.min(this.coinInfo.maxFee, Math.max(this.coinInfo.minFee, parseInt(response.feePerUnit, 10))).toString(),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
}
|
|
119
|
+
return this.levels;
|
|
120
|
+
}
|
|
121
|
+
async load(blockchain) {
|
|
122
|
+
if (this.coinInfo.type !== 'bitcoin')
|
|
123
|
+
return this.loadMisc(blockchain);
|
|
124
|
+
let blocks = fillGap(0, 1, 10);
|
|
125
|
+
if (this.levels.length > 1) {
|
|
126
|
+
blocks = this.levels
|
|
127
|
+
.map(l => l.blocks)
|
|
128
|
+
.reduce((result, bl) => {
|
|
129
|
+
if (result.length === 0)
|
|
130
|
+
return result.concat([bl]);
|
|
131
|
+
const from = result[result.length - 1];
|
|
132
|
+
const gap = bl - from;
|
|
133
|
+
const incr = gap <= 30 ? 1 : 6;
|
|
134
|
+
const fill = fillGap(from, incr, gap);
|
|
135
|
+
return result.concat(fill);
|
|
136
|
+
}, []);
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const response = await blockchain.estimateFee({ blocks });
|
|
140
|
+
response.forEach((r, i) => {
|
|
141
|
+
this.blocks[blocks[i]] = feePerKB(r.feePerUnit);
|
|
142
|
+
});
|
|
143
|
+
if (this.levels.length === 1) {
|
|
144
|
+
const lowest = findLowest(this.blocks);
|
|
145
|
+
if (typeof lowest === 'string') {
|
|
146
|
+
this.levels[0].blocks = this.blocks.indexOf(lowest);
|
|
147
|
+
this.levels[0].feePerUnit = lowest;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.levels.forEach(l => {
|
|
152
|
+
const updatedValue = findNearest(l.blocks, this.blocks);
|
|
153
|
+
if (typeof updatedValue === 'string') {
|
|
154
|
+
l.blocks = this.blocks.indexOf(updatedValue);
|
|
155
|
+
l.feePerUnit = updatedValue;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
}
|
|
162
|
+
return this.levels;
|
|
163
|
+
}
|
|
164
|
+
updateCustomFee(feePerUnit) {
|
|
165
|
+
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
166
|
+
const blocks = findBlocksForFee(feePerUnit, this.blocks);
|
|
167
|
+
this.levels.push({
|
|
168
|
+
label: 'custom',
|
|
169
|
+
feePerUnit,
|
|
170
|
+
blocks,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.FeeLevels = FeeLevels;
|
|
175
|
+
//# sourceMappingURL=Fees.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComposeInput, ComposeOutput, ComposeResult } from '@trezor/utxo-lib';
|
|
2
|
+
import { FeeLevels } from './Fees';
|
|
3
|
+
import { Blockchain } from '../../backend/BlockchainLink';
|
|
4
|
+
import type { BitcoinNetworkInfo } from '../../types';
|
|
5
|
+
import type { DiscoveryAccount, SelectFeeLevel } from '../../types/account';
|
|
6
|
+
import type { PrecomposeParams } from '../../types/api/composeTransaction';
|
|
7
|
+
declare type Options = {
|
|
8
|
+
account: DiscoveryAccount;
|
|
9
|
+
utxo: PrecomposeParams['account']['utxo'];
|
|
10
|
+
outputs: ComposeOutput[];
|
|
11
|
+
coinInfo: BitcoinNetworkInfo;
|
|
12
|
+
baseFee?: number;
|
|
13
|
+
skipPermutation?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare class TransactionComposer {
|
|
16
|
+
account: DiscoveryAccount;
|
|
17
|
+
utxos: ComposeInput[];
|
|
18
|
+
outputs: ComposeOutput[];
|
|
19
|
+
coinInfo: BitcoinNetworkInfo;
|
|
20
|
+
blockHeight: number;
|
|
21
|
+
baseFee: number;
|
|
22
|
+
skipPermutation: boolean;
|
|
23
|
+
feeLevels: FeeLevels;
|
|
24
|
+
composed: {
|
|
25
|
+
[key: string]: ComposeResult;
|
|
26
|
+
};
|
|
27
|
+
constructor(options: Options);
|
|
28
|
+
init(blockchain: Blockchain): Promise<void>;
|
|
29
|
+
composeAllFeeLevels(): boolean;
|
|
30
|
+
composeCustomFee(fee: string): void;
|
|
31
|
+
getFeeLevelList(): SelectFeeLevel[];
|
|
32
|
+
compose(feeRate: string): ComposeResult;
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=TransactionComposer.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionComposer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
|
|
6
|
+
const utxo_lib_1 = require("@trezor/utxo-lib");
|
|
7
|
+
const Fees_1 = require("./Fees");
|
|
8
|
+
const pathUtils_1 = require("../../utils/pathUtils");
|
|
9
|
+
class TransactionComposer {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.blockHeight = 0;
|
|
12
|
+
this.composed = {};
|
|
13
|
+
this.account = options.account;
|
|
14
|
+
this.outputs = options.outputs;
|
|
15
|
+
this.coinInfo = options.coinInfo;
|
|
16
|
+
this.blockHeight = 0;
|
|
17
|
+
this.baseFee = options.baseFee || 0;
|
|
18
|
+
this.skipPermutation = options.skipPermutation || false;
|
|
19
|
+
this.feeLevels = new Fees_1.FeeLevels(options.coinInfo);
|
|
20
|
+
const { addresses } = options.account;
|
|
21
|
+
const allAddresses = !addresses
|
|
22
|
+
? []
|
|
23
|
+
: addresses.used
|
|
24
|
+
.concat(addresses.unused)
|
|
25
|
+
.concat(addresses.change)
|
|
26
|
+
.map(a => a.address);
|
|
27
|
+
this.utxos = options.utxo.flatMap(u => {
|
|
28
|
+
if (!u.required && new bignumber_js_1.default(u.amount).lte(this.coinInfo.dustLimit))
|
|
29
|
+
return [];
|
|
30
|
+
const addressPath = (0, pathUtils_1.getHDPath)(u.path);
|
|
31
|
+
return {
|
|
32
|
+
index: u.vout,
|
|
33
|
+
transactionHash: u.txid,
|
|
34
|
+
value: u.amount,
|
|
35
|
+
addressPath: [addressPath[3], addressPath[4]],
|
|
36
|
+
height: u.blockHeight,
|
|
37
|
+
tsize: 0,
|
|
38
|
+
vsize: 0,
|
|
39
|
+
coinbase: typeof u.coinbase === 'boolean' ? u.coinbase : false,
|
|
40
|
+
own: allAddresses.indexOf(u.address) >= 0,
|
|
41
|
+
required: u.required,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async init(blockchain) {
|
|
46
|
+
const { blockHeight } = await blockchain.getNetworkInfo();
|
|
47
|
+
this.blockHeight = blockHeight;
|
|
48
|
+
await this.feeLevels.load(blockchain);
|
|
49
|
+
}
|
|
50
|
+
composeAllFeeLevels() {
|
|
51
|
+
const { levels } = this.feeLevels;
|
|
52
|
+
if (this.utxos.length < 1)
|
|
53
|
+
return false;
|
|
54
|
+
this.composed = {};
|
|
55
|
+
let atLeastOneValid = false;
|
|
56
|
+
levels.forEach(level => {
|
|
57
|
+
if (level.feePerUnit !== '0') {
|
|
58
|
+
const tx = this.compose(level.feePerUnit);
|
|
59
|
+
if (tx.type === 'final') {
|
|
60
|
+
atLeastOneValid = true;
|
|
61
|
+
}
|
|
62
|
+
this.composed[level.label] = tx;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
if (!atLeastOneValid) {
|
|
66
|
+
const lastLevel = levels[levels.length - 1];
|
|
67
|
+
let lastFee = new bignumber_js_1.default(lastLevel.feePerUnit);
|
|
68
|
+
while (lastFee.gt(this.coinInfo.minFee) && this.composed.custom === undefined) {
|
|
69
|
+
lastFee = lastFee.minus(1);
|
|
70
|
+
const tx = this.compose(lastFee.toString());
|
|
71
|
+
if (tx.type === 'final') {
|
|
72
|
+
this.feeLevels.updateCustomFee(lastFee.toString());
|
|
73
|
+
this.composed.custom = tx;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
composeCustomFee(fee) {
|
|
82
|
+
const tx = this.compose(fee);
|
|
83
|
+
this.composed.custom = tx;
|
|
84
|
+
if (tx.type === 'final') {
|
|
85
|
+
this.feeLevels.updateCustomFee(tx.feePerByte);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.feeLevels.updateCustomFee(fee);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
getFeeLevelList() {
|
|
92
|
+
const list = [];
|
|
93
|
+
const { levels } = this.feeLevels;
|
|
94
|
+
levels.forEach(level => {
|
|
95
|
+
const tx = this.composed[level.label];
|
|
96
|
+
if (tx && tx.type === 'final') {
|
|
97
|
+
list.push({
|
|
98
|
+
name: level.label,
|
|
99
|
+
fee: tx.fee,
|
|
100
|
+
feePerByte: level.feePerUnit,
|
|
101
|
+
minutes: level.blocks * this.coinInfo.blocktime,
|
|
102
|
+
total: tx.totalSpent,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
list.push({
|
|
107
|
+
name: level.label,
|
|
108
|
+
fee: '0',
|
|
109
|
+
disabled: true,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return list;
|
|
114
|
+
}
|
|
115
|
+
compose(feeRate) {
|
|
116
|
+
const { account, coinInfo, baseFee } = this;
|
|
117
|
+
const { addresses } = account;
|
|
118
|
+
if (!addresses)
|
|
119
|
+
return { type: 'error', error: 'ADDRESSES-NOT-SET' };
|
|
120
|
+
const changeAddress = addresses.change.find(a => !a.transfers) ||
|
|
121
|
+
addresses.change[addresses.change.length - 1];
|
|
122
|
+
const changeId = (0, pathUtils_1.getHDPath)(changeAddress.path).slice(-1)[0];
|
|
123
|
+
const enhancement = {
|
|
124
|
+
baseFee,
|
|
125
|
+
floorBaseFee: false,
|
|
126
|
+
dustOutputFee: 0,
|
|
127
|
+
};
|
|
128
|
+
if (coinInfo.shortcut === 'DOGE') {
|
|
129
|
+
enhancement.dustOutputFee = 1000000;
|
|
130
|
+
}
|
|
131
|
+
return (0, utxo_lib_1.composeTx)({
|
|
132
|
+
txType: account.type,
|
|
133
|
+
utxos: this.utxos,
|
|
134
|
+
outputs: this.outputs,
|
|
135
|
+
height: this.blockHeight,
|
|
136
|
+
feeRate,
|
|
137
|
+
skipPermutation: this.skipPermutation,
|
|
138
|
+
basePath: account.address_n,
|
|
139
|
+
network: coinInfo.network,
|
|
140
|
+
changeId,
|
|
141
|
+
changeAddress: changeAddress.address,
|
|
142
|
+
dustThreshold: coinInfo.dustLimit,
|
|
143
|
+
...enhancement,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
dispose() {
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.TransactionComposer = TransactionComposer;
|
|
150
|
+
//# sourceMappingURL=TransactionComposer.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const validateTrezorInputs: ({
|
|
2
|
+
description: string;
|
|
3
|
+
params: {
|
|
4
|
+
address_n: number[];
|
|
5
|
+
amount: string;
|
|
6
|
+
prev_index: number;
|
|
7
|
+
prev_hash: string;
|
|
8
|
+
}[];
|
|
9
|
+
result: {
|
|
10
|
+
amount: string;
|
|
11
|
+
}[];
|
|
12
|
+
} | {
|
|
13
|
+
description: string;
|
|
14
|
+
params: {
|
|
15
|
+
address_n: number[];
|
|
16
|
+
amount: string;
|
|
17
|
+
prev_index: number;
|
|
18
|
+
prev_hash: string;
|
|
19
|
+
}[];
|
|
20
|
+
result: {
|
|
21
|
+
address_n: number[];
|
|
22
|
+
}[];
|
|
23
|
+
} | {
|
|
24
|
+
description: string;
|
|
25
|
+
params: {
|
|
26
|
+
address_n: number[];
|
|
27
|
+
amount: string;
|
|
28
|
+
prev_index: number;
|
|
29
|
+
prev_hash: string;
|
|
30
|
+
multisig: {
|
|
31
|
+
pubkeys: {
|
|
32
|
+
node: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
}[];
|
|
36
|
+
result: {
|
|
37
|
+
multisig: {
|
|
38
|
+
pubkeys: {
|
|
39
|
+
node: {
|
|
40
|
+
public_key: string;
|
|
41
|
+
chain_code: string;
|
|
42
|
+
depth: number;
|
|
43
|
+
};
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
}[];
|
|
47
|
+
} | {
|
|
48
|
+
description: string;
|
|
49
|
+
params: {
|
|
50
|
+
amount: string;
|
|
51
|
+
prev_index: number;
|
|
52
|
+
prev_hash: string;
|
|
53
|
+
script_type: string;
|
|
54
|
+
script_pubkey: string;
|
|
55
|
+
witness: string;
|
|
56
|
+
}[];
|
|
57
|
+
result: {
|
|
58
|
+
amount: string;
|
|
59
|
+
}[];
|
|
60
|
+
} | {
|
|
61
|
+
description: string;
|
|
62
|
+
params: {
|
|
63
|
+
amount: string;
|
|
64
|
+
prev_index: number;
|
|
65
|
+
prev_hash: string;
|
|
66
|
+
}[];
|
|
67
|
+
result?: undefined;
|
|
68
|
+
} | {
|
|
69
|
+
description: string;
|
|
70
|
+
params: {
|
|
71
|
+
address_n: number[];
|
|
72
|
+
amount: string;
|
|
73
|
+
prev_hash: string;
|
|
74
|
+
}[];
|
|
75
|
+
result?: undefined;
|
|
76
|
+
} | {
|
|
77
|
+
description: string;
|
|
78
|
+
params: {
|
|
79
|
+
address_n: number[];
|
|
80
|
+
amount: string;
|
|
81
|
+
prev_index: number;
|
|
82
|
+
}[];
|
|
83
|
+
result?: undefined;
|
|
84
|
+
} | {
|
|
85
|
+
description: string;
|
|
86
|
+
params: {
|
|
87
|
+
address_n: number[];
|
|
88
|
+
prev_index: number;
|
|
89
|
+
prev_hash: string;
|
|
90
|
+
}[];
|
|
91
|
+
result: {
|
|
92
|
+
prev_index: number;
|
|
93
|
+
}[];
|
|
94
|
+
} | {
|
|
95
|
+
description: string;
|
|
96
|
+
params: {
|
|
97
|
+
address_n: number[];
|
|
98
|
+
prev_index: number;
|
|
99
|
+
prev_hash: string;
|
|
100
|
+
}[];
|
|
101
|
+
result?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
description: string;
|
|
104
|
+
params: {
|
|
105
|
+
amount: string;
|
|
106
|
+
prev_index: number;
|
|
107
|
+
prev_hash: string;
|
|
108
|
+
script_type: string;
|
|
109
|
+
}[];
|
|
110
|
+
result?: undefined;
|
|
111
|
+
})[];
|
|
112
|
+
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateTrezorInputs = void 0;
|
|
4
|
+
exports.validateTrezorInputs = [
|
|
5
|
+
{
|
|
6
|
+
description: 'valid input',
|
|
7
|
+
params: [
|
|
8
|
+
{
|
|
9
|
+
address_n: [1],
|
|
10
|
+
amount: '1',
|
|
11
|
+
prev_index: 1,
|
|
12
|
+
prev_hash: 'txid',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
result: [{ amount: '1' }],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
description: 'input with fixed path',
|
|
19
|
+
params: [
|
|
20
|
+
{
|
|
21
|
+
address_n: [44 | 0x80000000],
|
|
22
|
+
amount: '1',
|
|
23
|
+
prev_index: 1,
|
|
24
|
+
prev_hash: 'txid',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
result: [{ address_n: [(44 | 0x80000000) >>> 0] }],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
description: 'input with converted multisig pubkey',
|
|
31
|
+
params: [
|
|
32
|
+
{
|
|
33
|
+
address_n: [0],
|
|
34
|
+
amount: '1',
|
|
35
|
+
prev_index: 1,
|
|
36
|
+
prev_hash: 'txid',
|
|
37
|
+
multisig: {
|
|
38
|
+
pubkeys: [
|
|
39
|
+
{
|
|
40
|
+
node: 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
result: [
|
|
47
|
+
{
|
|
48
|
+
multisig: {
|
|
49
|
+
pubkeys: [
|
|
50
|
+
{
|
|
51
|
+
node: {
|
|
52
|
+
public_key: '03f645ec6544a92f951f3bca16a2bc1c56846d065594db222725d59b9902528385',
|
|
53
|
+
chain_code: '2fb77e25cd3e2e034bcbafa1f81ec7e4caf927b06c87db296f1186208315525e',
|
|
54
|
+
depth: 0,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
description: 'valid EXTERNAL input',
|
|
64
|
+
params: [
|
|
65
|
+
{
|
|
66
|
+
amount: '1',
|
|
67
|
+
prev_index: 1,
|
|
68
|
+
prev_hash: 'txid',
|
|
69
|
+
script_type: 'EXTERNAL',
|
|
70
|
+
script_pubkey: '0000',
|
|
71
|
+
witness: '00',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
result: [{ amount: '1' }],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
description: 'missing address_n',
|
|
78
|
+
params: [{ amount: '1', prev_index: 1, prev_hash: 'txid' }],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
description: 'missing prev_index',
|
|
82
|
+
params: [{ address_n: [0], amount: '1', prev_hash: 'txid' }],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
description: 'missing prev_hash',
|
|
86
|
+
params: [{ address_n: [0], amount: '1', prev_index: 1 }],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
description: 'missing amount on non segwit path. valid only because of legacy reasons',
|
|
90
|
+
params: [{ address_n: [0], prev_index: 1, prev_hash: 'txid' }],
|
|
91
|
+
result: [{ prev_index: 1 }],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
description: 'missing amount p2sh',
|
|
95
|
+
params: [{ address_n: [49 | 0x80000000], prev_index: 1, prev_hash: 'txid' }],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
description: 'missing script_pubkey in EXTERNAL',
|
|
99
|
+
params: [{ amount: '1', prev_index: 1, prev_hash: 'txid', script_type: 'EXTERNAL' }],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
//# sourceMappingURL=inputs.js.map
|