Threaded wallet creation
This commit is contained in:
parent
6e346e52cc
commit
c2efb09734
|
@ -14,6 +14,7 @@ from password_dialog import PasswordLayout, PW_NEW, PW_PASSPHRASE
|
|||
|
||||
from electrum.wallet import Wallet
|
||||
from electrum.mnemonic import prepare_seed
|
||||
from electrum.util import SilentException
|
||||
from electrum.wizard import (WizardBase, UserCancelled,
|
||||
MSG_ENTER_PASSWORD, MSG_RESTORE_PASSPHRASE,
|
||||
MSG_COSIGNER, MSG_ENTER_SEED_OR_MPK,
|
||||
|
@ -116,6 +117,11 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
|||
self.accept()
|
||||
self.refresh_gui()
|
||||
|
||||
def on_error(self, exc_info):
|
||||
if not isinstance(exc_info[1], SilentException):
|
||||
traceback.print_exception(*exc_info)
|
||||
self.show_error(str(exc_info[1]))
|
||||
|
||||
def set_icon(self, filename):
|
||||
prior_filename, self.icon_filename = self.icon_filename, filename
|
||||
self.logo.setPixmap(QPixmap(filename).scaledToWidth(60))
|
||||
|
|
|
@ -285,26 +285,30 @@ class TrezorCompatiblePlugin(BasePlugin, ThreadJob):
|
|||
(item, label, pin_protection, passphrase_protection) \
|
||||
= wallet.handler.request_trezor_init_settings(method, self.device)
|
||||
|
||||
client = self.get_client(wallet)
|
||||
language = 'english'
|
||||
|
||||
if method == TIM_NEW:
|
||||
strength = 64 * (item + 2) # 128, 192 or 256
|
||||
client.reset_device(True, strength, passphrase_protection,
|
||||
pin_protection, label, language)
|
||||
elif method == TIM_RECOVER:
|
||||
word_count = 6 * (item + 2) # 12, 18 or 24
|
||||
client.recovery_device(word_count, passphrase_protection,
|
||||
pin_protection, label, language)
|
||||
elif method == TIM_MNEMONIC:
|
||||
pin = pin_protection # It's the pin, not a boolean
|
||||
client.load_device_by_mnemonic(str(item), pin,
|
||||
passphrase_protection,
|
||||
def initialize_device():
|
||||
client = self.get_client(wallet)
|
||||
|
||||
if method == TIM_NEW:
|
||||
strength = 64 * (item + 2) # 128, 192 or 256
|
||||
client.reset_device(True, strength, passphrase_protection,
|
||||
pin_protection, label, language)
|
||||
elif method == TIM_RECOVER:
|
||||
word_count = 6 * (item + 2) # 12, 18 or 24
|
||||
client.recovery_device(word_count, passphrase_protection,
|
||||
pin_protection, label, language)
|
||||
elif method == TIM_MNEMONIC:
|
||||
pin = pin_protection # It's the pin, not a boolean
|
||||
client.load_device_by_mnemonic(str(item), pin,
|
||||
passphrase_protection,
|
||||
label, language)
|
||||
else:
|
||||
pin = pin_protection # It's the pin, not a boolean
|
||||
client.load_device_by_xprv(item, pin, passphrase_protection,
|
||||
label, language)
|
||||
else:
|
||||
pin = pin_protection # It's the pin, not a boolean
|
||||
client.load_device_by_xprv(item, pin, passphrase_protection,
|
||||
label, language)
|
||||
|
||||
wallet.thread.add(initialize_device)
|
||||
|
||||
def unpaired_clients(self, handler):
|
||||
'''Returns all connected, unpaired devices as a list of clients and a
|
||||
|
|
|
@ -237,8 +237,13 @@ def qt_plugin_class(base_plugin_class):
|
|||
def on_create_wallet(self, wallet, wizard):
|
||||
assert type(wallet) == self.wallet_class
|
||||
wallet.handler = self.create_handler(wizard)
|
||||
wallet.thread = TaskThread(wizard, wizard.on_error)
|
||||
self.select_device(wallet)
|
||||
wallet.create_hd_account(None)
|
||||
# Create accounts in separate thread; wait until done
|
||||
loop = QEventLoop()
|
||||
wallet.thread.add(partial(wallet.create_hd_account, None),
|
||||
on_done=loop.quit)
|
||||
loop.exec_()
|
||||
|
||||
@hook
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
|
|
Loading…
Reference in New Issue