Browse Source

Fix trezor restore

Broken by my recent changes
283
Neil Booth 9 years ago
parent
commit
669cf74789
  1. 5
      lib/wallet.py
  2. 19
      plugins/trezor/qt_generic.py

5
lib/wallet.py

@ -26,6 +26,7 @@ import json
import copy
from functools import partial
from struct import pack
from unicodedata import normalize
from i18n import _
from util import NotEnoughFunds, PrintError, profiler
@ -1764,8 +1765,8 @@ class BIP32_Hardware_Wallet(BIP32_HD_Wallet):
# trezor uses bip39
import pbkdf2, hashlib, hmac
PBKDF2_ROUNDS = 2048
mnemonic = unicodedata.normalize('NFKD', ' '.join(mnemonic.split()))
passphrase = unicodedata.normalize('NFKD', passphrase)
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
passphrase = normalize('NFKD', passphrase)
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
iterations = PBKDF2_ROUNDS, macmodule = hmac,
digestmodule = hashlib.sha512).read(64)

19
plugins/trezor/qt_generic.py

@ -6,7 +6,6 @@ from PyQt4.Qt import QGridLayout, QInputDialog, QPushButton
from PyQt4.Qt import QVBoxLayout, QLabel, SIGNAL
from trezor import TrezorPlugin
from electrum_gui.qt.main_window import ElectrumWindow, StatusBarButton
from electrum_gui.qt.installwizard import InstallWizard
from electrum_gui.qt.password_dialog import PasswordDialog
from electrum_gui.qt.util import *
@ -62,19 +61,11 @@ class QtHandler:
self.done.set()
def passphrase_dialog(self, msg):
if type(self.win) is ElectrumWindow:
msg = _("Please enter your %s passphrase") % self.device
passphrase = self.win.password_dialog(msg)
else:
assert type(self.win) is InstallWizard
d = PasswordDialog(self.win, None, None, msg, False)
confirmed, p, passphrase = d.run()
if passphrase is None:
self.win.show_critical(_("Passphrase request canceled"))
else:
passphrase = normalize('NFKD', unicode(passphrase))
self.passphrase = passphrase
d = PasswordDialog(self.win, None, None, msg, False)
confirmed, p, phrase = d.run()
if confirmed:
phrase = normalize('NFKD', unicode(phrase or ''))
self.passphrase = phrase
self.done.set()
def message_dialog(self, msg, cancel_callback):

Loading…
Cancel
Save