trezor: Fix for trezor library version 0.13.9
This enables support for the Trezor Safe 5.
This commit is contained in:
@@ -12,10 +12,18 @@ from electrum.plugins.hw_wallet.plugin import OutdatedHwFirmwareException, Hardw
|
|||||||
|
|
||||||
from trezorlib.client import TrezorClient, PASSPHRASE_ON_DEVICE
|
from trezorlib.client import TrezorClient, PASSPHRASE_ON_DEVICE
|
||||||
from trezorlib.exceptions import TrezorFailure, Cancelled, OutdatedFirmwareError
|
from trezorlib.exceptions import TrezorFailure, Cancelled, OutdatedFirmwareError
|
||||||
from trezorlib.messages import WordRequestType, FailureType, RecoveryDeviceType, ButtonRequestType
|
from trezorlib.messages import WordRequestType, FailureType, ButtonRequestType
|
||||||
import trezorlib.btc
|
import trezorlib.btc
|
||||||
import trezorlib.device
|
import trezorlib.device
|
||||||
|
|
||||||
|
try:
|
||||||
|
# trezor >= 0.13.9
|
||||||
|
from trezorlib.messages import RecoveryDeviceInputMethod
|
||||||
|
except ImportError:
|
||||||
|
# Backward compatibility for trezor < 0.13.9
|
||||||
|
from trezorlib.messages import RecoveryDeviceType as RecoveryDeviceInputMethod
|
||||||
|
|
||||||
|
|
||||||
MESSAGES = {
|
MESSAGES = {
|
||||||
ButtonRequestType.ConfirmOutput:
|
ButtonRequestType.ConfirmOutput:
|
||||||
_("Confirm the transaction output on your {} device"),
|
_("Confirm the transaction output on your {} device"),
|
||||||
@@ -346,7 +354,7 @@ class TrezorClientBase(HardwareClientBase, Logger):
|
|||||||
if recovery_type is None:
|
if recovery_type is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if recovery_type == RecoveryDeviceType.Matrix:
|
if recovery_type == RecoveryDeviceInputMethod.Matrix:
|
||||||
return self._matrix_char
|
return self._matrix_char
|
||||||
|
|
||||||
step = 0
|
step = 0
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from electrum.gui.qt.util import (WindowModalDialog, WWLabel, Buttons, CancelBut
|
|||||||
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub, WalletWizardComponent
|
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub, WalletWizardComponent
|
||||||
|
|
||||||
from .trezor import (TrezorPlugin, TIM_NEW, TIM_RECOVER, TrezorInitSettings,
|
from .trezor import (TrezorPlugin, TIM_NEW, TIM_RECOVER, TrezorInitSettings,
|
||||||
PASSPHRASE_ON_DEVICE, Capability, BackupType, RecoveryDeviceType)
|
PASSPHRASE_ON_DEVICE, Capability, BackupType, RecoveryDeviceInputMethod)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from electrum.gui.qt.wizard.wallet import QENewWalletWizard
|
from electrum.gui.qt.wizard.wallet import QENewWalletWizard
|
||||||
@@ -409,14 +409,14 @@ class InitSettingsLayout(QVBoxLayout):
|
|||||||
rb1 = QRadioButton(gb_rectype)
|
rb1 = QRadioButton(gb_rectype)
|
||||||
rb1.setText(_('Scrambled words'))
|
rb1.setText(_('Scrambled words'))
|
||||||
self.bg_rectype.addButton(rb1)
|
self.bg_rectype.addButton(rb1)
|
||||||
self.bg_rectype.setId(rb1, RecoveryDeviceType.ScrambledWords)
|
self.bg_rectype.setId(rb1, RecoveryDeviceInputMethod.ScrambledWords)
|
||||||
hbox_rectype.addWidget(rb1)
|
hbox_rectype.addWidget(rb1)
|
||||||
rb1.setChecked(True)
|
rb1.setChecked(True)
|
||||||
|
|
||||||
rb2 = QRadioButton(gb_rectype)
|
rb2 = QRadioButton(gb_rectype)
|
||||||
rb2.setText(_('Matrix'))
|
rb2.setText(_('Matrix'))
|
||||||
self.bg_rectype.addButton(rb2)
|
self.bg_rectype.addButton(rb2)
|
||||||
self.bg_rectype.setId(rb2, RecoveryDeviceType.Matrix)
|
self.bg_rectype.setId(rb2, RecoveryDeviceInputMethod.Matrix)
|
||||||
hbox_rectype.addWidget(rb2)
|
hbox_rectype.addWidget(rb2)
|
||||||
|
|
||||||
# no backup
|
# no backup
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ try:
|
|||||||
import trezorlib.transport
|
import trezorlib.transport
|
||||||
from trezorlib.transport.bridge import BridgeTransport, call_bridge
|
from trezorlib.transport.bridge import BridgeTransport, call_bridge
|
||||||
|
|
||||||
from .clientbase import TrezorClientBase
|
from .clientbase import TrezorClientBase, RecoveryDeviceInputMethod
|
||||||
|
|
||||||
from trezorlib.messages import (
|
from trezorlib.messages import (
|
||||||
Capability, BackupType, RecoveryDeviceType, HDNodeType, HDNodePathType,
|
Capability, BackupType, HDNodeType, HDNodePathType,
|
||||||
InputScriptType, OutputScriptType, MultisigRedeemScriptType,
|
InputScriptType, OutputScriptType, MultisigRedeemScriptType,
|
||||||
TxInputType, TxOutputType, TxOutputBinType, TransactionType, AmountUnit)
|
TxInputType, TxOutputType, TxOutputBinType, TransactionType, AmountUnit)
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ except Exception as e:
|
|||||||
|
|
||||||
Capability = _EnumMissing()
|
Capability = _EnumMissing()
|
||||||
BackupType = _EnumMissing()
|
BackupType = _EnumMissing()
|
||||||
RecoveryDeviceType = _EnumMissing()
|
RecoveryDeviceInputMethod = _EnumMissing()
|
||||||
AmountUnit = _EnumMissing()
|
AmountUnit = _EnumMissing()
|
||||||
|
|
||||||
PASSPHRASE_ON_DEVICE = object()
|
PASSPHRASE_ON_DEVICE = object()
|
||||||
@@ -251,7 +251,7 @@ class TrezorPlugin(HW_PluginBase):
|
|||||||
|
|
||||||
@runs_in_hwd_thread
|
@runs_in_hwd_thread
|
||||||
def _initialize_device(self, settings: TrezorInitSettings, method, device_id, handler):
|
def _initialize_device(self, settings: TrezorInitSettings, method, device_id, handler):
|
||||||
if method == TIM_RECOVER and settings.recovery_type == RecoveryDeviceType.ScrambledWords:
|
if method == TIM_RECOVER and settings.recovery_type == RecoveryDeviceInputMethod.ScrambledWords:
|
||||||
handler.show_error(_(
|
handler.show_error(_(
|
||||||
"You will be asked to enter 24 words regardless of your "
|
"You will be asked to enter 24 words regardless of your "
|
||||||
"seed's actual length. If you enter a word incorrectly or "
|
"seed's actual length. If you enter a word incorrectly or "
|
||||||
@@ -281,7 +281,7 @@ class TrezorPlugin(HW_PluginBase):
|
|||||||
passphrase_protection=settings.passphrase_enabled,
|
passphrase_protection=settings.passphrase_enabled,
|
||||||
pin_protection=settings.pin_enabled,
|
pin_protection=settings.pin_enabled,
|
||||||
label=settings.label)
|
label=settings.label)
|
||||||
if settings.recovery_type == RecoveryDeviceType.Matrix:
|
if settings.recovery_type == RecoveryDeviceInputMethod.Matrix:
|
||||||
handler.close_matrix_dialog()
|
handler.close_matrix_dialog()
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Unsupported recovery method")
|
raise RuntimeError("Unsupported recovery method")
|
||||||
|
|||||||
Reference in New Issue
Block a user