electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 65eae139af5d827ccafc85c2a9e5d0088411ed01
parent c5dae933ee3707ad738decdfece0b0c63010592a
Author: mzhou <mzhou@cse.unsw.edu.au>
Date:   Thu, 11 Jan 2018 04:37:41 +1100

add ability to show a receiving address on ledger screen (#3538)

add ability to show a receiving address on ledger screen
Diffstat:
Mplugins/ledger/ledger.py | 19+++++++++++++++++++
Mplugins/ledger/qt.py | 13+++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py @@ -436,6 +436,20 @@ class Ledger_KeyStore(Hardware_KeyStore): tx.raw = tx.serialize() 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): libraries_available = BTCHIP @@ -508,3 +522,8 @@ class LedgerPlugin(HW_PluginBase): if client is not None: client.checkDevice() 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) diff --git a/plugins/ledger/qt.py b/plugins/ledger/qt.py @@ -3,6 +3,8 @@ import threading from PyQt5.Qt import QInputDialog, QLineEdit, QVBoxLayout, QLabel from electrum.i18n import _ +from electrum.plugins import hook +from electrum.wallet import Standard_Wallet from .ledger import LedgerPlugin from ..hw_wallet.qt import QtHandlerBase, QtPluginBase from electrum_gui.qt.util import * @@ -16,6 +18,17 @@ class Plugin(LedgerPlugin, QtPluginBase): def create_handler(self, 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): setup_signal = pyqtSignal() auth_signal = pyqtSignal(object)