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)
def load_wallet(self, wallet, window): 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.show_settings_dialog, window, 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))
def transaction_dialog(self, dialog): b = QPushButton() b.setIcon(read_QIcon("speaker.png")) def handler(): blob = json.dumps(dialog.tx.as_dict()) self._send(parent=dialog, blob=blob) b.clicked.connect(handler) dialog.sharing_buttons.insert(-1, b)
def transaction_dialog(self, dialog: 'TxDialog'): b = QPushButton() b.setIcon(read_QIcon("speaker.png")) def handler(): blob = dialog.tx.serialize() self._send(parent=dialog, blob=blob) b.clicked.connect(handler) dialog.sharing_buttons.insert(-1, b)
def build_chaingame_list(self): sports = ["Dice"] self.setEditTriggers(QAbstractItemView.NoEditTriggers) model = QStandardItemModel(self) model.setColumnCount(2) self.setSpacing(10) for s in sports: model.appendRow([ QStandardItem(read_QIcon(''.join([s, ".png"])), " {0}".format(s)) ]) self.setModel(model) self.setMinimumWidth(self.sizeHintForColumn(0) + 10)
def load_wallet(self, wallet: 'Abstract_Wallet', window: 'ElectrumWindow'): if not isinstance(wallet, self.wallet_class): return wallet.handler_2fa = HandlerTwoFactor(self, window) if wallet.can_sign_without_server(): msg = ' '.join([ _('This wallet was restored from seed, and it contains two master private keys.' ), _('Therefore, two-factor authentication is disabled.') ]) action = lambda: window.show_message(msg) else: action = partial(self.settings_dialog, window) button = StatusBarButton(read_QIcon("trustedcoin-status.png"), _("TrustedCoin"), action) window.statusBar().addPermanentWidget(button) self.start_request_thread(window.wallet)
def update(self): current_schedule = read_schedule_file() _list = current_schedule.get('items', []) self.model().clear() self.update_headers(self.__class__.headers) for idx, cron_item in enumerate(_list): item = cron_item['invoice'] schedule = cron_item['schedule'] invoice_type = item['type'] if invoice_type == PR_TYPE_LN: key = item['rhash'] icon_name = 'lightning.png' elif invoice_type == PR_TYPE_ONCHAIN: key = bh2u(sha256(repr(item))[0:16]) icon_name = 'bitcoin.png' if item.get('bip70'): icon_name = 'seal.png' else: raise Exception('Unsupported type') address_str = item['outputs'][0][1] message = item['message'] amount = item['amount'] amount_str = self.parent.format_amount(amount, whitespaces=True) last_str = '' next_str = '' try: from croniter import croniter cron = '{minute} {hour} {day} {month} {week}'.format(**schedule) item = croniter(cron, datetime.now()) next_str = item.get_next(datetime).isoformat() except: pass labels = [address_str, amount_str, message, last_str, next_str, ] items = [QStandardItem(e) for e in labels] self.set_editability(items) items[self.Columns.ADDRESS].setIcon(read_QIcon(icon_name)) items[self.Columns.ADDRESS].setData(key, role=ROLE_REQUEST_ID) items[self.Columns.ADDRESS].setData(invoice_type, role=ROLE_REQUEST_TYPE) self.model().insertRow(idx, items) self.selectionModel().select(self.model().index(0,0), QItemSelectionModel.SelectCurrent) self.filter()
def load_wallet(self, wallet, window): 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.show_settings_dialog, window, 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, 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))
def load_wallet(self, wallet, main_window): self.wallet = wallet self.window = main_window max_fee = self.config.get('bitpost_max_fee', self.default_max_fee) self.config.set_key('bitpost_max_fee', max_fee) max_fee_unit = self.config.get('bitpost_max_fee_unit', self.default_max_fee_unit) self.config.set_key('bitpost_max_fee_unit', max_fee_unit) num_txs = self.config.get('bitpost_num_txs', self.default_num_txs) self.config.set_key('bitpost_num_txs', num_txs) delay = self.config.get('bitpost_delay', self.default_delay) self.config.set_key('bitpost_delay', delay) target_interval = self.config.get('bitpost_target_interval', self.default_target_mins) self.config.set_key('bitpost_target_interval', target_interval) self.config.set_key( 'bitpost_notification_platform', self.config.get('bitpost_notification_platform', self.default_notification_platform)) self.config.set_key( 'bitpost_notification_address', self.config.get('bitpost_notification_address', '')) self.config.set_key( 'bitpost_notification_subscriptions', self.config.get('bitpost_notification_subscriptions', [])) self.bitpost_list = BitPostList(self.window) self.window.tabs.addTab(self.window.create_list_tab(self.bitpost_list), read_QIcon("tab_bitpost.png"), _('BitPost')) if self.config.get('batch_rbf', False): self.window.show_error(_( "Warning: batch rbf transaction is not supported by bitpost"), parent=self.window)
def _update_status(self, paired): if hasattr(self, 'button'): button = self.button icon_name = button.icon_paired if paired else button.icon_unpaired button.setIcon(read_QIcon(icon_name))
def create_status_bar(self, parent): b = StatusBarButton(read_QIcon('revealer.png'), "Revealer " + _("Visual Cryptography Plugin"), partial(self.setup_dialog, parent)) parent.addPermanentWidget(b)
def create_status_bar(self, parent): b = StatusBarButton(read_QIcon('revealer.png'), "Revealer " + _("secret backup utility"), partial(self.setup_dialog, parent)) parent.addPermanentWidget(b)
def create_status_bar(self, parent): b = StatusBarButton(read_QIcon('revealer.png'), "Revealer "+_("secret backup utility"), partial(self.setup_dialog, parent)) parent.addPermanentWidget(b)