Browse Source

Merge pull request #9141 from dlitz/fixes-for-trezorlib-0.13.9

trezor: Fix for trezor library version 0.13.9
master
ghost43 1 year ago committed by GitHub
parent
commit
d7014c361d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      electrum/plugins/trezor/clientbase.py
  2. 6
      electrum/plugins/trezor/qt.py
  3. 10
      electrum/plugins/trezor/trezor.py

12
electrum/plugins/trezor/clientbase.py

@ -12,10 +12,18 @@ from electrum.plugins.hw_wallet.plugin import OutdatedHwFirmwareException, Hardw
from trezorlib.client import TrezorClient, PASSPHRASE_ON_DEVICE
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.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 = {
ButtonRequestType.ConfirmOutput:
_("Confirm the transaction output on your {} device"),
@ -346,7 +354,7 @@ class TrezorClientBase(HardwareClientBase, Logger):
if recovery_type is None:
return None
if recovery_type == RecoveryDeviceType.Matrix:
if recovery_type == RecoveryDeviceInputMethod.Matrix:
return self._matrix_char
step = 0

6
electrum/plugins/trezor/qt.py

@ -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 .trezor import (TrezorPlugin, TIM_NEW, TIM_RECOVER, TrezorInitSettings,
PASSPHRASE_ON_DEVICE, Capability, BackupType, RecoveryDeviceType)
PASSPHRASE_ON_DEVICE, Capability, BackupType, RecoveryDeviceInputMethod)
if TYPE_CHECKING:
from electrum.gui.qt.wizard.wallet import QENewWalletWizard
@ -409,14 +409,14 @@ class InitSettingsLayout(QVBoxLayout):
rb1 = QRadioButton(gb_rectype)
rb1.setText(_('Scrambled words'))
self.bg_rectype.addButton(rb1)
self.bg_rectype.setId(rb1, RecoveryDeviceType.ScrambledWords)
self.bg_rectype.setId(rb1, RecoveryDeviceInputMethod.ScrambledWords)
hbox_rectype.addWidget(rb1)
rb1.setChecked(True)
rb2 = QRadioButton(gb_rectype)
rb2.setText(_('Matrix'))
self.bg_rectype.addButton(rb2)
self.bg_rectype.setId(rb2, RecoveryDeviceType.Matrix)
self.bg_rectype.setId(rb2, RecoveryDeviceInputMethod.Matrix)
hbox_rectype.addWidget(rb2)
# no backup

10
electrum/plugins/trezor/trezor.py

@ -26,10 +26,10 @@ try:
import trezorlib.transport
from trezorlib.transport.bridge import BridgeTransport, call_bridge
from .clientbase import TrezorClientBase
from .clientbase import TrezorClientBase, RecoveryDeviceInputMethod
from trezorlib.messages import (
Capability, BackupType, RecoveryDeviceType, HDNodeType, HDNodePathType,
Capability, BackupType, HDNodeType, HDNodePathType,
InputScriptType, OutputScriptType, MultisigRedeemScriptType,
TxInputType, TxOutputType, TxOutputBinType, TransactionType, AmountUnit)
@ -56,7 +56,7 @@ except Exception as e:
Capability = _EnumMissing()
BackupType = _EnumMissing()
RecoveryDeviceType = _EnumMissing()
RecoveryDeviceInputMethod = _EnumMissing()
AmountUnit = _EnumMissing()
PASSPHRASE_ON_DEVICE = object()
@ -251,7 +251,7 @@ class TrezorPlugin(HW_PluginBase):
@runs_in_hwd_thread
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(_(
"You will be asked to enter 24 words regardless of your "
"seed's actual length. If you enter a word incorrectly or "
@ -281,7 +281,7 @@ class TrezorPlugin(HW_PluginBase):
passphrase_protection=settings.passphrase_enabled,
pin_protection=settings.pin_enabled,
label=settings.label)
if settings.recovery_type == RecoveryDeviceType.Matrix:
if settings.recovery_type == RecoveryDeviceInputMethod.Matrix:
handler.close_matrix_dialog()
else:
raise RuntimeError("Unsupported recovery method")

Loading…
Cancel
Save