URI: 
       tqt.py - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
       tqt.py (3535B)
       ---
            1 from functools import partial
            2 
            3 from PyQt5.QtWidgets import (
            4     QPushButton,
            5     QLabel,
            6     QVBoxLayout,
            7     QLineEdit,
            8     QHBoxLayout,
            9 )
           10 
           11 from PyQt5.QtCore import Qt, QMetaObject, Q_RETURN_ARG, pyqtSlot
           12 
           13 from electrum.gui.qt.util import (
           14     WindowModalDialog,
           15     OkButton,
           16     ButtonsTextEdit,
           17 )
           18 
           19 from electrum.i18n import _
           20 from electrum.plugin import hook
           21 
           22 from .bitbox02 import BitBox02Plugin
           23 from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
           24 from ..hw_wallet.plugin import only_hook_if_libraries_available
           25 
           26 
           27 class Plugin(BitBox02Plugin, QtPluginBase):
           28     icon_unpaired = "bitbox02_unpaired.png"
           29     icon_paired = "bitbox02.png"
           30 
           31     def create_handler(self, window):
           32         return BitBox02_Handler(window)
           33 
           34     @only_hook_if_libraries_available
           35     @hook
           36     def receive_menu(self, menu, addrs, wallet):
           37         # Context menu on each address in the Addresses Tab, right click...
           38         if len(addrs) != 1:
           39             return
           40         for keystore in wallet.get_keystores():
           41             if type(keystore) == self.keystore_class:
           42 
           43                 def show_address(keystore=keystore):
           44                     keystore.thread.add(
           45                         partial(self.show_address, wallet, addrs[0], keystore=keystore)
           46                     )
           47 
           48                 device_name = "{} ({})".format(self.device, keystore.label)
           49                 menu.addAction(_("Show on {}").format(device_name), show_address)
           50 
           51     @only_hook_if_libraries_available
           52     @hook
           53     def show_xpub_button(self, mpk_text: ButtonsTextEdit, keystore):
           54         # user is about to see the "Wallet Information" dialog
           55         # - add a button to show the xpub on the BitBox02 device
           56         if type(keystore) != self.keystore_class:
           57             return
           58 
           59         def on_button_click():
           60             keystore.thread.add(
           61                 partial(self.show_xpub, keystore=keystore)
           62             )
           63 
           64         device_name = "{} ({})".format(self.device, keystore.label)
           65         mpk_text.addButton("eye1.png", on_button_click, _("Show on {}").format(device_name))
           66 
           67 
           68 class BitBox02_Handler(QtHandlerBase):
           69 
           70     def __init__(self, win):
           71         super(BitBox02_Handler, self).__init__(win, "BitBox02")
           72 
           73     def message_dialog(self, msg):
           74         self.clear_dialog()
           75         self.dialog = dialog = WindowModalDialog(
           76             self.top_level_window(), _("BitBox02 Status")
           77         )
           78         l = QLabel(msg)
           79         vbox = QVBoxLayout(dialog)
           80         vbox.addWidget(l)
           81         dialog.show()
           82 
           83     def name_multisig_account(self):
           84         return QMetaObject.invokeMethod(
           85             self,
           86             "_name_multisig_account",
           87             Qt.BlockingQueuedConnection,
           88             Q_RETURN_ARG(str),
           89         )
           90 
           91     @pyqtSlot(result=str)
           92     def _name_multisig_account(self):
           93         dialog = WindowModalDialog(None, "Create Multisig Account")
           94         vbox = QVBoxLayout()
           95         label = QLabel(
           96             _(
           97                 "Enter a descriptive name for your multisig account.\nYou should later be able to use the name to uniquely identify this multisig account"
           98             )
           99         )
          100         hl = QHBoxLayout()
          101         hl.addWidget(label)
          102         name = QLineEdit()
          103         name.setMaxLength(30)
          104         name.resize(200, 40)
          105         he = QHBoxLayout()
          106         he.addWidget(name)
          107         okButton = OkButton(dialog)
          108         hlb = QHBoxLayout()
          109         hlb.addWidget(okButton)
          110         hlb.addStretch(2)
          111         vbox.addLayout(hl)
          112         vbox.addLayout(he)
          113         vbox.addLayout(hlb)
          114         dialog.setLayout(vbox)
          115         dialog.exec_()
          116         return name.text().strip()