Example #1
0
 def load_wallet(self: Union['QtPluginBase', HW_PluginBase],
                 wallet: 'Abstract_Wallet', window: ElectrumWindow):
     for keystore in wallet.get_keystores():
         if not isinstance(keystore, self.keystore_class):
             continue
         if not self.libraries_available:
             message = keystore.plugin.get_library_not_available_message()
             window.show_error(message)
             return
         tooltip = self.device + '\n' + (keystore.label or 'unnamed')
         cb = partial(self._on_status_bar_button_click,
                      window=window,
                      keystore=keystore)
         button = StatusBarButton(read_QIcon(self.icon_unpaired), tooltip,
                                  cb)
         button.icon_paired = self.icon_paired
         button.icon_unpaired = self.icon_unpaired
         window.statusBar().addPermanentWidget(button)
         handler = self.create_handler(window)
         handler.button = button
         keystore.handler = handler
         keystore.thread = TaskThread(window,
                                      on_error=partial(
                                          self.on_task_thread_error, window,
                                          keystore))
         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))
Example #2
0
 def load_wallet(self: Union['QtPluginBase', HW_PluginBase], wallet: 'Abstract_Wallet', window: ElectrumWindow):
     relevant_keystores = [keystore for keystore in wallet.get_keystores()
                           if isinstance(keystore, self.keystore_class)]
     if not relevant_keystores:
         return
     for keystore in relevant_keystores:
         if not self.libraries_available:
             message = keystore.plugin.get_library_not_available_message()
             window.show_error(message)
             return
         tooltip = self.device + '\n' + (keystore.label or 'unnamed')
         cb = partial(self._on_status_bar_button_click, window=window, keystore=keystore)
         button = StatusBarButton(read_QIcon(self.icon_unpaired), tooltip, cb)
         button.icon_paired = self.icon_paired
         button.icon_unpaired = self.icon_unpaired
         window.statusBar().addPermanentWidget(button)
         handler = self.create_handler(window)
         handler.button = button
         keystore.handler = handler
         keystore.thread = TaskThread(window, on_error=partial(self.on_task_thread_error, window, keystore))
         self.add_show_address_on_hw_device_button_for_receive_addr(wallet, keystore, window)
     # Trigger pairings
     devmgr = self.device_manager()
     trigger_pairings = partial(devmgr.trigger_pairings, relevant_keystores, allow_user_interaction=True)
     some_keystore = relevant_keystores[0]
     some_keystore.thread.add(trigger_pairings)
Example #3
0
 def on_task_thread_error(self: Union['QtPluginBase', HW_PluginBase], window: ElectrumWindow,
                          keystore: 'Hardware_KeyStore', exc_info):
     e = exc_info[1]
     if isinstance(e, OutdatedHwFirmwareException):
         if window.question(e.text_ignore_old_fw_and_continue(), title=_("Outdated device firmware")):
             self.set_ignore_outdated_fw()
             # will need to re-pair
             devmgr = self.device_manager()
             def re_pair_device():
                 device_id = self.choose_device(window, keystore)
                 devmgr.unpair_id(device_id)
                 self.get_client(keystore)
             keystore.thread.add(re_pair_device)
         return
     else:
         window.on_error(exc_info)
Example #4
0
 def send(self, window: ElectrumWindow, addr):
     from electrum import paymentrequest
     req = window.wallet.receive_requests.get(addr)
     if not isinstance(req, OnchainInvoice):
         window.show_error("Only on-chain requests are supported.")
         return
     message = req.message
     if req.bip70:
         payload = bytes.fromhex(req.bip70)
     else:
         pr = paymentrequest.make_request(self.config, req)
         payload = pr.SerializeToString()
     if not payload:
         return
     recipient, ok = QInputDialog.getText(window, 'Send request',
                                          'Email invoice to:')
     if not ok:
         return
     recipient = str(recipient)
     self.logger.info(f'sending mail to {recipient}')
     try:
         # FIXME this runs in the GUI thread and blocks it...
         self.processor.send(recipient, message, payload)
     except BaseException as e:
         self.logger.exception('')
         window.show_message(repr(e))
     else:
         window.show_message(_('Request sent.'))