add ability to show a receiving address on ledger screen (#3538)
add ability to show a receiving address on ledger screen
This commit is contained in:
parent
c5dae933ee
commit
65eae139af
|
@ -436,6 +436,20 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
||||||
tx.raw = tx.serialize()
|
tx.raw = tx.serialize()
|
||||||
self.signing = False
|
self.signing = False
|
||||||
|
|
||||||
|
def show_address(self, sequence, txin_type):
|
||||||
|
self.signing = True
|
||||||
|
# prompt for the PIN before displaying the dialog if necessary
|
||||||
|
client = self.get_client()
|
||||||
|
address_path = self.get_derivation()[2:] + "/%d/%d"%sequence
|
||||||
|
self.handler.show_message(_("Showing address ..."))
|
||||||
|
segwit = txin_type in ['p2wpkh', 'p2wsh', 'p2wpkh-p2sh', 'p2wsh-p2sh']
|
||||||
|
try:
|
||||||
|
self.get_client().getWalletPublicKey(address_path, showOnScreen=True, segwit=segwit)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.handler.finished()
|
||||||
|
self.signing = False
|
||||||
|
|
||||||
class LedgerPlugin(HW_PluginBase):
|
class LedgerPlugin(HW_PluginBase):
|
||||||
libraries_available = BTCHIP
|
libraries_available = BTCHIP
|
||||||
|
@ -508,3 +522,8 @@ class LedgerPlugin(HW_PluginBase):
|
||||||
if client is not None:
|
if client is not None:
|
||||||
client.checkDevice()
|
client.checkDevice()
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
def show_address(self, wallet, address):
|
||||||
|
sequence = wallet.get_address_index(address)
|
||||||
|
txin_type = wallet.get_txin_type(address)
|
||||||
|
wallet.get_keystore().show_address(sequence, txin_type)
|
||||||
|
|
|
@ -3,6 +3,8 @@ import threading
|
||||||
from PyQt5.Qt import QInputDialog, QLineEdit, QVBoxLayout, QLabel
|
from PyQt5.Qt import QInputDialog, QLineEdit, QVBoxLayout, QLabel
|
||||||
|
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
|
from electrum.plugins import hook
|
||||||
|
from electrum.wallet import Standard_Wallet
|
||||||
from .ledger import LedgerPlugin
|
from .ledger import LedgerPlugin
|
||||||
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
|
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
|
||||||
from electrum_gui.qt.util import *
|
from electrum_gui.qt.util import *
|
||||||
|
@ -16,6 +18,17 @@ class Plugin(LedgerPlugin, QtPluginBase):
|
||||||
def create_handler(self, window):
|
def create_handler(self, window):
|
||||||
return Ledger_Handler(window)
|
return Ledger_Handler(window)
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def receive_menu(self, menu, addrs, wallet):
|
||||||
|
print('receive_menu')
|
||||||
|
if type(wallet) is not Standard_Wallet:
|
||||||
|
return
|
||||||
|
keystore = wallet.get_keystore()
|
||||||
|
if type(keystore) == self.keystore_class and len(addrs) == 1:
|
||||||
|
def show_address():
|
||||||
|
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
|
||||||
|
menu.addAction(_("Show on Ledger"), show_address)
|
||||||
|
|
||||||
class Ledger_Handler(QtHandlerBase):
|
class Ledger_Handler(QtHandlerBase):
|
||||||
setup_signal = pyqtSignal()
|
setup_signal = pyqtSignal()
|
||||||
auth_signal = pyqtSignal(object)
|
auth_signal = pyqtSignal(object)
|
||||||
|
|
Loading…
Reference in New Issue