Merge branch 'hook_transaction_dialog_address_menu': hww show addr opt
hardware wallets: add "show address on device" option also to tx dialog context menu
This commit is contained in:
@@ -397,6 +397,7 @@ class TxInOutWidget(QWidget):
|
||||
for item in copy_list:
|
||||
menu.addAction(*item)
|
||||
|
||||
run_hook('transaction_dialog_address_menu', menu, addr, self.wallet)
|
||||
menu.addSeparator()
|
||||
std_menu = o_text.createStandardContextMenu()
|
||||
menu.addActions(std_menu.actions())
|
||||
|
||||
@@ -29,7 +29,7 @@ from functools import partial
|
||||
from typing import TYPE_CHECKING, Union, Optional, Sequence, Tuple
|
||||
|
||||
from PyQt6.QtCore import QObject, pyqtSignal, Qt
|
||||
from PyQt6.QtWidgets import QVBoxLayout, QLineEdit, QHBoxLayout, QLabel
|
||||
from PyQt6.QtWidgets import QVBoxLayout, QLineEdit, QHBoxLayout, QLabel, QMenu
|
||||
|
||||
from electrum.gui.common_qt.util import TaskThread
|
||||
from electrum.gui.qt.password_dialog import PasswordLayout, PW_PASSPHRASE
|
||||
@@ -43,6 +43,7 @@ from electrum.i18n import _
|
||||
from electrum.logging import Logger
|
||||
from electrum.util import UserCancelled, UserFacingException, ChoiceItem
|
||||
from electrum.plugin import hook, DeviceUnpairableError
|
||||
from electrum.wallet import Standard_Wallet
|
||||
|
||||
from .plugin import OutdatedHwFirmwareException, HW_PluginBase, HardwareHandlerBase
|
||||
|
||||
@@ -299,3 +300,13 @@ class QtPluginBase(object):
|
||||
|
||||
def create_handler(self, window: Union['ElectrumWindow', 'QENewWalletWizard']) -> 'QtHandlerBase':
|
||||
raise NotImplementedError()
|
||||
|
||||
def _add_menu_action(self, menu: QMenu, address: str, wallet: 'Abstract_Wallet'):
|
||||
if not wallet.is_mine(address):
|
||||
return
|
||||
for keystore in wallet.get_keystores():
|
||||
if type(keystore) == self.keystore_class:
|
||||
def show_address(keystore=keystore):
|
||||
keystore.thread.add(partial(self.show_address, wallet, address, keystore=keystore))
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
menu.addAction(read_QIcon("eye1.png"), _("Show address on {}").format(device_name), show_address)
|
||||
|
||||
@@ -30,19 +30,13 @@ class Plugin(BitBox02Plugin, QtPluginBase):
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
# Context menu on each address in the Addresses Tab, right click...
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
for keystore in wallet.get_keystores():
|
||||
if type(keystore) == self.keystore_class:
|
||||
if len(addrs) == 1:
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
def show_address(keystore=keystore):
|
||||
keystore.thread.add(
|
||||
partial(self.show_address, wallet, addrs[0], keystore=keystore)
|
||||
)
|
||||
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
menu.addAction(_("Show on {}").format(device_name), show_address)
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
|
||||
@@ -38,15 +38,14 @@ class Plugin(ColdcardPlugin, QtPluginBase):
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
# Context menu on each address in the Addresses Tab, right click...
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
for keystore in wallet.get_keystores():
|
||||
if type(keystore) == self.keystore_class:
|
||||
def show_address(keystore=keystore):
|
||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0], keystore=keystore))
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
menu.addAction(_("Show on {}").format(device_name), show_address)
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
|
||||
@@ -29,26 +29,23 @@ class Plugin(DigitalBitboxPlugin, QtPluginBase):
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def receive_menu(self, menu, addrs, wallet: Abstract_Wallet):
|
||||
if type(wallet) is not Standard_Wallet:
|
||||
return
|
||||
|
||||
keystore = wallet.get_keystore()
|
||||
if type(keystore) is not self.keystore_class:
|
||||
return
|
||||
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
if not self.is_mobile_paired():
|
||||
return
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
if wallet.get_txin_type(addrs[0]) != 'p2pkh':
|
||||
return
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
if len(addrs) == 1:
|
||||
addr = addrs[0]
|
||||
if wallet.get_txin_type(addr) != 'p2pkh':
|
||||
return
|
||||
|
||||
def show_address():
|
||||
keystore.thread.add(partial(self.show_address, wallet, addr, keystore))
|
||||
|
||||
menu.addAction(_("Show on {}").format(self.device), show_address)
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
if not self.is_mobile_paired():
|
||||
return
|
||||
if wallet.get_txin_type(addr) != 'p2pkh':
|
||||
return
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
|
||||
@@ -9,6 +9,7 @@ from electrum.wallet import Standard_Wallet
|
||||
|
||||
from electrum.hw_wallet.qt import QtHandlerBase, QtPluginBase
|
||||
from electrum.hw_wallet import plugin
|
||||
from electrum.hw_wallet.plugin import only_hook_if_libraries_available
|
||||
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub, WCHWUninitialized
|
||||
|
||||
from .jade import JadePlugin
|
||||
@@ -24,16 +25,21 @@ class Plugin(JadePlugin, QtPluginBase):
|
||||
def create_handler(self, window):
|
||||
return Jade_Handler(window)
|
||||
|
||||
@plugin.only_hook_if_libraries_available
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
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 Jade"), show_address)
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
if type(wallet) is not Standard_Wallet:
|
||||
return
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
|
||||
@@ -207,12 +207,12 @@ class QtPlugin(QtPluginBase):
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
for keystore in wallet.get_keystores():
|
||||
if type(keystore) == self.keystore_class:
|
||||
def show_address(keystore=keystore):
|
||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0], keystore))
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
menu.addAction(_("Show on {}").format(device_name), show_address)
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
def show_settings_dialog(self, window, keystore):
|
||||
def connect():
|
||||
|
||||
@@ -27,13 +27,18 @@ class Plugin(LedgerPlugin, QtPluginBase):
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
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], keystore=keystore))
|
||||
menu.addAction(_("Show on Ledger"), show_address)
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
if type(wallet) is not Standard_Wallet:
|
||||
return
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
|
||||
@@ -84,12 +84,12 @@ class QtPlugin(QtPluginBase):
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
for keystore in wallet.get_keystores():
|
||||
if type(keystore) == self.keystore_class:
|
||||
def show_address(keystore=keystore):
|
||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0], keystore))
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
menu.addAction(_("Show on {}").format(device_name), show_address)
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
def show_settings_dialog(self, window, keystore):
|
||||
def connect():
|
||||
|
||||
@@ -248,12 +248,12 @@ class QtPlugin(QtPluginBase):
|
||||
def receive_menu(self, menu, addrs, wallet):
|
||||
if len(addrs) != 1:
|
||||
return
|
||||
for keystore in wallet.get_keystores():
|
||||
if type(keystore) == self.keystore_class:
|
||||
def show_address(keystore=keystore):
|
||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0], keystore))
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
menu.addAction(_("Show on {}").format(device_name), show_address)
|
||||
self._add_menu_action(menu, addrs[0], wallet)
|
||||
|
||||
@only_hook_if_libraries_available
|
||||
@hook
|
||||
def transaction_dialog_address_menu(self, menu, addr, wallet):
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
def show_settings_dialog(self, window, keystore):
|
||||
def connect():
|
||||
|
||||
Reference in New Issue
Block a user