qt receive tab: show address on hw wallet
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
from electrum.plugins import BasePlugin, hook
|
||||
from electrum.i18n import _
|
||||
from electrum.bitcoin import is_address
|
||||
|
||||
|
||||
class HW_PluginBase(BasePlugin):
|
||||
@@ -58,3 +59,19 @@ class HW_PluginBase(BasePlugin):
|
||||
uninitialized, go through the initialization process.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def show_address(self, wallet, address, keystore=None):
|
||||
pass # implemented in child classes
|
||||
|
||||
def show_address_helper(self, wallet, address, keystore=None):
|
||||
if keystore is None:
|
||||
keystore = wallet.get_keystore()
|
||||
if not is_address(address):
|
||||
keystore.handler.show_error(_('Invalid Bitcoin Address'))
|
||||
return False
|
||||
if not wallet.is_mine(address):
|
||||
keystore.handler.show_error(_('Address not in wallet.'))
|
||||
return False
|
||||
if type(keystore) != self.keystore_class:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -201,6 +201,7 @@ class QtPluginBase(object):
|
||||
handler.button = button
|
||||
keystore.handler = handler
|
||||
keystore.thread = TaskThread(window, window.on_error)
|
||||
self.add_show_address_on_hw_device_button_for_receive_addr(wallet, keystore, window)
|
||||
# Trigger a pairing
|
||||
keystore.thread.add(partial(self.get_client, keystore))
|
||||
|
||||
@@ -218,3 +219,13 @@ class QtPluginBase(object):
|
||||
|
||||
def show_settings_dialog(self, window, keystore):
|
||||
device_id = self.choose_device(window, keystore)
|
||||
|
||||
def add_show_address_on_hw_device_button_for_receive_addr(self, wallet, keystore, main_window):
|
||||
plugin = keystore.plugin
|
||||
receive_address_e = main_window.receive_address_e
|
||||
|
||||
def show_address():
|
||||
addr = receive_address_e.text()
|
||||
keystore.thread.add(partial(plugin.show_address, wallet, addr, keystore))
|
||||
# TODO icon
|
||||
receive_address_e.addButton(":icons/tab_console.png", show_address, _("Show on {}").format(plugin.device))
|
||||
|
||||
Reference in New Issue
Block a user