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.wallet import Wallet
|
||||||
from electrum.mnemonic import prepare_seed
|
from electrum.mnemonic import prepare_seed
|
||||||
|
from electrum.util import SilentException
|
||||||
from electrum.wizard import (WizardBase, UserCancelled,
|
from electrum.wizard import (WizardBase, UserCancelled,
|
||||||
MSG_ENTER_PASSWORD, MSG_RESTORE_PASSPHRASE,
|
MSG_ENTER_PASSWORD, MSG_RESTORE_PASSPHRASE,
|
||||||
MSG_COSIGNER, MSG_ENTER_SEED_OR_MPK,
|
MSG_COSIGNER, MSG_ENTER_SEED_OR_MPK,
|
||||||
|
@ -116,6 +117,11 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
self.accept()
|
self.accept()
|
||||||
self.refresh_gui()
|
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):
|
def set_icon(self, filename):
|
||||||
prior_filename, self.icon_filename = self.icon_filename, filename
|
prior_filename, self.icon_filename = self.icon_filename, filename
|
||||||
self.logo.setPixmap(QPixmap(filename).scaledToWidth(60))
|
self.logo.setPixmap(QPixmap(filename).scaledToWidth(60))
|
||||||
|
|
|
@ -285,26 +285,30 @@ class TrezorCompatiblePlugin(BasePlugin, ThreadJob):
|
||||||
(item, label, pin_protection, passphrase_protection) \
|
(item, label, pin_protection, passphrase_protection) \
|
||||||
= wallet.handler.request_trezor_init_settings(method, self.device)
|
= wallet.handler.request_trezor_init_settings(method, self.device)
|
||||||
|
|
||||||
client = self.get_client(wallet)
|
|
||||||
language = 'english'
|
language = 'english'
|
||||||
|
|
||||||
if method == TIM_NEW:
|
def initialize_device():
|
||||||
strength = 64 * (item + 2) # 128, 192 or 256
|
client = self.get_client(wallet)
|
||||||
client.reset_device(True, strength, passphrase_protection,
|
|
||||||
pin_protection, label, language)
|
if method == TIM_NEW:
|
||||||
elif method == TIM_RECOVER:
|
strength = 64 * (item + 2) # 128, 192 or 256
|
||||||
word_count = 6 * (item + 2) # 12, 18 or 24
|
client.reset_device(True, strength, passphrase_protection,
|
||||||
client.recovery_device(word_count, passphrase_protection,
|
pin_protection, label, language)
|
||||||
pin_protection, label, language)
|
elif method == TIM_RECOVER:
|
||||||
elif method == TIM_MNEMONIC:
|
word_count = 6 * (item + 2) # 12, 18 or 24
|
||||||
pin = pin_protection # It's the pin, not a boolean
|
client.recovery_device(word_count, passphrase_protection,
|
||||||
client.load_device_by_mnemonic(str(item), pin,
|
pin_protection, label, language)
|
||||||
passphrase_protection,
|
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)
|
label, language)
|
||||||
else:
|
|
||||||
pin = pin_protection # It's the pin, not a boolean
|
wallet.thread.add(initialize_device)
|
||||||
client.load_device_by_xprv(item, pin, passphrase_protection,
|
|
||||||
label, language)
|
|
||||||
|
|
||||||
def unpaired_clients(self, handler):
|
def unpaired_clients(self, handler):
|
||||||
'''Returns all connected, unpaired devices as a list of clients and a
|
'''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):
|
def on_create_wallet(self, wallet, wizard):
|
||||||
assert type(wallet) == self.wallet_class
|
assert type(wallet) == self.wallet_class
|
||||||
wallet.handler = self.create_handler(wizard)
|
wallet.handler = self.create_handler(wizard)
|
||||||
|
wallet.thread = TaskThread(wizard, wizard.on_error)
|
||||||
self.select_device(wallet)
|
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
|
@hook
|
||||||
def receive_menu(self, menu, addrs, wallet):
|
def receive_menu(self, menu, addrs, wallet):
|
||||||
|
|
Loading…
Reference in New Issue