|
|
|
|
@ -1,29 +1,20 @@
|
|
|
|
|
import threading |
|
|
|
|
from functools import partial |
|
|
|
|
from typing import TYPE_CHECKING |
|
|
|
|
|
|
|
|
|
from PyQt5.QtWidgets import ( |
|
|
|
|
QPushButton, |
|
|
|
|
QLabel, |
|
|
|
|
QVBoxLayout, |
|
|
|
|
QLineEdit, |
|
|
|
|
QHBoxLayout, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
from PyQt5.QtCore import Qt, QMetaObject, Q_RETURN_ARG, pyqtSlot |
|
|
|
|
|
|
|
|
|
from electrum.gui.qt.util import ( |
|
|
|
|
WindowModalDialog, |
|
|
|
|
OkButton, |
|
|
|
|
ButtonsTextEdit, |
|
|
|
|
) |
|
|
|
|
from PyQt5.QtCore import Qt, QMetaObject, Q_RETURN_ARG, pyqtSlot, pyqtSignal |
|
|
|
|
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QLineEdit, QHBoxLayout |
|
|
|
|
|
|
|
|
|
from electrum.i18n import _ |
|
|
|
|
from electrum.plugin import hook |
|
|
|
|
from electrum.util import UserCancelled, UserFacingException |
|
|
|
|
|
|
|
|
|
from .bitbox02 import BitBox02Plugin |
|
|
|
|
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase |
|
|
|
|
from ..hw_wallet.plugin import only_hook_if_libraries_available |
|
|
|
|
from ..hw_wallet.plugin import only_hook_if_libraries_available, OperationCancelled |
|
|
|
|
|
|
|
|
|
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWUninitialized, WCHWXPub |
|
|
|
|
from electrum.gui.qt.util import WindowModalDialog, OkButton, ButtonsTextEdit |
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
|
from electrum.gui.qt.wizard.wallet import QENewWalletWizard |
|
|
|
|
@ -77,7 +68,7 @@ class Plugin(BitBox02Plugin, QtPluginBase):
|
|
|
|
|
def extend_wizard(self, wizard: 'QENewWalletWizard'): |
|
|
|
|
super().extend_wizard(wizard) |
|
|
|
|
views = { |
|
|
|
|
'bitbox02_start': {'gui': WCScriptAndDerivation}, |
|
|
|
|
'bitbox02_start': {'gui': WCBitbox02ScriptAndDerivation}, |
|
|
|
|
'bitbox02_xpub': {'gui': WCHWXPub}, |
|
|
|
|
'bitbox02_not_initialized': {'gui': WCHWUninitialized}, |
|
|
|
|
'bitbox02_unlock': {'gui': WCHWUnlock} |
|
|
|
|
@ -92,12 +83,7 @@ class BitBox02_Handler(QtHandlerBase):
|
|
|
|
|
super(BitBox02_Handler, self).__init__(win, "BitBox02") |
|
|
|
|
|
|
|
|
|
def name_multisig_account(self): |
|
|
|
|
return QMetaObject.invokeMethod( |
|
|
|
|
self, |
|
|
|
|
"_name_multisig_account", |
|
|
|
|
Qt.BlockingQueuedConnection, |
|
|
|
|
Q_RETURN_ARG(str), |
|
|
|
|
) |
|
|
|
|
return QMetaObject.invokeMethod(self, "_name_multisig_account", Qt.BlockingQueuedConnection, Q_RETURN_ARG(str)) |
|
|
|
|
|
|
|
|
|
@pyqtSlot(result=str) |
|
|
|
|
def _name_multisig_account(self): |
|
|
|
|
@ -125,3 +111,46 @@ class BitBox02_Handler(QtHandlerBase):
|
|
|
|
|
dialog.setLayout(vbox) |
|
|
|
|
dialog.exec_() |
|
|
|
|
return name.text().strip() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WCBitbox02ScriptAndDerivation(WCScriptAndDerivation): |
|
|
|
|
def __init__(self, parent, wizard): |
|
|
|
|
WCScriptAndDerivation.__init__(self, parent, wizard) |
|
|
|
|
self._busy = True |
|
|
|
|
self.title = '' |
|
|
|
|
self.client = None |
|
|
|
|
|
|
|
|
|
def on_ready(self): |
|
|
|
|
super().on_ready() |
|
|
|
|
_name, _info = self.wizard_data['hardware_device'] |
|
|
|
|
plugin = self.wizard.plugins.get_plugin(_info.plugin_name) |
|
|
|
|
|
|
|
|
|
device_id = _info.device.id_ |
|
|
|
|
self.client = self.wizard.plugins.device_manager.client_by_id(device_id, scan_now=False) |
|
|
|
|
if not self.client.handler: |
|
|
|
|
self.client.handler = plugin.create_handler(self.wizard) |
|
|
|
|
self.client.setupRunning = True |
|
|
|
|
self.check_device() |
|
|
|
|
|
|
|
|
|
def check_device(self): |
|
|
|
|
self.error = None |
|
|
|
|
self.valid = False |
|
|
|
|
self.busy = True |
|
|
|
|
|
|
|
|
|
def check_task(): |
|
|
|
|
try: |
|
|
|
|
self.client.pairing_dialog() |
|
|
|
|
self.title = _('Script type and Derivation path') |
|
|
|
|
self.valid = True |
|
|
|
|
except (UserCancelled, OperationCancelled): |
|
|
|
|
self.error = _('Cancelled') |
|
|
|
|
self.wizard.requestPrev.emit() |
|
|
|
|
except UserFacingException as e: |
|
|
|
|
self.error = str(e) |
|
|
|
|
except Exception as e: |
|
|
|
|
self.error = repr(e) |
|
|
|
|
finally: |
|
|
|
|
self.busy = False |
|
|
|
|
|
|
|
|
|
t = threading.Thread(target=check_task, daemon=True) |
|
|
|
|
t.start() |
|
|
|
|
|