wizard: add ledger
This commit is contained in:
@@ -1465,3 +1465,30 @@ class LedgerPlugin(HW_PluginBase):
|
|||||||
txin_type = wallet.get_txin_type(address)
|
txin_type = wallet.get_txin_type(address)
|
||||||
|
|
||||||
keystore.show_address(sequence, txin_type)
|
keystore.show_address(sequence, txin_type)
|
||||||
|
|
||||||
|
# new wizard
|
||||||
|
|
||||||
|
def wizard_entry_for_device(self, device_info: 'DeviceInfo', *, new_wallet=True) -> str:
|
||||||
|
if new_wallet:
|
||||||
|
return 'ledger_start' if device_info.initialized else 'ledger_not_initialized'
|
||||||
|
else:
|
||||||
|
return 'ledger_unlock'
|
||||||
|
|
||||||
|
# insert ledger pages in new wallet wizard
|
||||||
|
def extend_wizard(self, wizard: 'NewWalletWizard'):
|
||||||
|
views = {
|
||||||
|
'ledger_start': {
|
||||||
|
'next': 'ledger_xpub',
|
||||||
|
},
|
||||||
|
'ledger_xpub': {
|
||||||
|
'next': lambda d: wizard.wallet_password_view(d) if wizard.last_cosigner(d) else 'multisig_cosigner_keystore',
|
||||||
|
'accept': wizard.maybe_master_pubkey,
|
||||||
|
'last': lambda d: wizard.is_single_password() and wizard.last_cosigner(d)
|
||||||
|
},
|
||||||
|
'ledger_not_initialized': {},
|
||||||
|
'ledger_unlock': {
|
||||||
|
'last': True
|
||||||
|
},
|
||||||
|
}
|
||||||
|
wizard.navmap_merge(views)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal
|
from PyQt5.QtCore import pyqtSignal
|
||||||
from PyQt5.QtWidgets import QInputDialog, QLabel, QVBoxLayout, QLineEdit
|
from PyQt5.QtWidgets import QInputDialog, QLabel, QVBoxLayout, QLineEdit
|
||||||
@@ -11,6 +12,10 @@ from electrum.gui.qt.util import WindowModalDialog
|
|||||||
from .ledger import LedgerPlugin, Ledger_Client
|
from .ledger import LedgerPlugin, Ledger_Client
|
||||||
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
|
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
|
||||||
|
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUninitialized, WCHWUnlock, WCHWXPub
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.gui.qt.wizard.wallet import QENewWalletWizard
|
||||||
|
|
||||||
|
|
||||||
class Plugin(LedgerPlugin, QtPluginBase):
|
class Plugin(LedgerPlugin, QtPluginBase):
|
||||||
@@ -31,6 +36,22 @@ class Plugin(LedgerPlugin, QtPluginBase):
|
|||||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0], keystore=keystore))
|
keystore.thread.add(partial(self.show_address, wallet, addrs[0], keystore=keystore))
|
||||||
menu.addAction(_("Show on Ledger"), show_address)
|
menu.addAction(_("Show on Ledger"), show_address)
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||||
|
self.extend_wizard(wizard)
|
||||||
|
|
||||||
|
# insert ledger pages in new wallet wizard
|
||||||
|
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||||
|
super().extend_wizard(wizard)
|
||||||
|
views = {
|
||||||
|
'ledger_start': {'gui': WCScriptAndDerivation},
|
||||||
|
'ledger_xpub': {'gui': WCHWXPub},
|
||||||
|
'ledger_not_initialized': {'gui': WCHWUninitialized},
|
||||||
|
'ledger_unlock': {'gui': WCHWUnlock}
|
||||||
|
}
|
||||||
|
wizard.navmap_merge(views)
|
||||||
|
|
||||||
|
|
||||||
class Ledger_Handler(QtHandlerBase):
|
class Ledger_Handler(QtHandlerBase):
|
||||||
setup_signal = pyqtSignal()
|
setup_signal = pyqtSignal()
|
||||||
auth_signal = pyqtSignal(object, object)
|
auth_signal = pyqtSignal(object, object)
|
||||||
|
|||||||
Reference in New Issue
Block a user