def __init__(self, parent, address): WindowModalDialog.__init__(self, parent, _("Address")) self.address = address self.parent = parent self.config = parent.config self.wallet = parent.wallet self.app = parent.app self.saved = True self.setMinimumWidth(700) vbox = QVBoxLayout() self.setLayout(vbox) vbox.addWidget(QLabel(_("Address:"))) self.addr_e = ButtonsLineEdit(self.address) self.addr_e.addCopyButton(self.app) self.addr_e.addButton(":icons/qrcode.png", self.show_qr, _("Show QR Code")) self.addr_e.setReadOnly(True) vbox.addWidget(self.addr_e) vbox.addWidget(QLabel(_("History"))) self.hw = HistoryWidget(self.parent) self.hw.get_domain = self.get_domain vbox.addWidget(self.hw) vbox.addStretch(1) vbox.addLayout(Buttons(CloseButton(self))) self.format_amount = self.parent.format_amount self.hw.update()
def value_str(self, satoshis, rate): if satoshis is None: # Can happen with incomplete history return _("Unknown") if rate: value = Decimal(satoshis) / COIN * Decimal(rate) return "%s" % (self.ccy_amount_str(value, True)) return _("No data")
def update(self): self.menu_actions = [(_('Pay'), self.do_pay), (_('Delete'), self.do_delete)] invoices_list = self.screen.ids.invoices_container invoices_list.clear_widgets() _list = self.app.invoices.sorted_list() for pr in _list: ci = Factory.InvoiceItem() ci.key = pr.get_id() ci.requestor = pr.get_requestor() ci.memo = pr.memo ci.amount = self.app.format_amount_and_units(pr.get_amount()) status = self.app.invoices.get_status(ci.key) if status == PR_PAID: ci.icon = "atlas://gui/kivy/theming/light/confirmed" elif status == PR_EXPIRED: ci.icon = "atlas://gui/kivy/theming/light/important" else: ci.icon = "atlas://gui/kivy/theming/light/important" exp = pr.get_expiration_date() ci.date = format_time(exp) if exp else _('Never') ci.screen = self invoices_list.add_widget(ci) if not _list: msg = _('This screen shows the list of payment requests that have been sent to you.') invoices_list.add_widget(EmptyLabel(text=msg))
def update(self): self.menu_actions = [(_('Show'), self.do_show), (_('Delete'), self.do_delete)] requests_list = self.screen.ids.requests_container requests_list.clear_widgets() _list = self.app.wallet.get_sorted_requests(self.app.electrum_config) for req in _list: address = req['address'] timestamp = req.get('time', 0) amount = req.get('amount') expiration = req.get('exp', None) status = req.get('status') signature = req.get('sig') ci = Factory.RequestItem() ci.address = req['address'] ci.memo = self.app.wallet.get_label(address) status = req.get('status') if status == PR_PAID: ci.icon = "atlas://gui/kivy/theming/light/confirmed" elif status == PR_EXPIRED: ci.icon = "atlas://gui/kivy/theming/light/important" else: ci.icon = "atlas://gui/kivy/theming/light/important" ci.amount = self.app.format_amount_and_units(amount) if amount else '' ci.date = format_time(timestamp) ci.screen = self requests_list.add_widget(ci) if not _list: msg = _('This screen shows the list of payment requests you made.') requests_list.add_widget(EmptyLabel(text=msg))
def notify_transactions(self, *dt): ''' ''' if not self.network or not self.network.is_connected(): return # temporarily disabled for merge return iface = self.network ptfn = iface.pending_transactions_for_notifications if len(ptfn) > 0: # Combine the transactions if there are more then three tx_amount = len(ptfn) if(tx_amount >= 3): total_amount = 0 for tx in ptfn: is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx) if(v > 0): total_amount += v self.notify(_("{txs}s new transactions received. Total amount" "received in the new transactions {amount}s" "{unit}s").format(txs=tx_amount, amount=self.format_amount(total_amount), unit=self.base_unit())) iface.pending_transactions_for_notifications = [] else: for tx in iface.pending_transactions_for_notifications: if tx: iface.pending_transactions_for_notifications.remove(tx) is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx) if(v > 0): self.notify( _("{txs} new transaction received. {amount} {unit}"). format(txs=tx_amount, amount=self.format_amount(v), unit=self.base_unit))
def create_extended_seed(self, wallet, window): seed = wallet.make_seed() window.show_and_verify_seed(seed, is_valid=self.is_valid_seed) password = window.request_password() wallet.storage.put('seed_version', wallet.seed_version) wallet.storage.put('use_encryption', password is not None) words = seed.split() n = len(words)/2 wallet.add_xprv_from_seed(' '.join(words[0:n]), 'x1/', password) wallet.add_xpub_from_seed(' '.join(words[n:]), 'x2/') wallet.storage.write() msg = [ _("Your wallet file is: %s.")%os.path.abspath(wallet.storage.path), _("You need to be online in order to complete the creation of " "your wallet. If you generated your seed on an offline " 'computer, click on "%s" to close this window, move your ' "wallet file to an online computer, and reopen it with " "Electrum.") % _('Cancel'), _('If you are online, click on "%s" to continue.') % _('Next') ] msg = '\n\n'.join(msg) self.confirm(window, msg)
def task(): wallet.wait_until_synchronized() if wallet.is_found(): msg = _("Recovery successful") else: msg = _("No transactions found for this seed") self.emit(QtCore.SIGNAL('synchronized'), msg)
def query_multisig(self, action): cw = CosignWidget(2, 2) m_edit = QSpinBox() n_edit = QSpinBox() m_edit.setValue(2) n_edit.setValue(2) n_edit.setMinimum(2) n_edit.setMaximum(15) m_edit.setMinimum(1) m_edit.setMaximum(2) n_edit.valueChanged.connect(m_edit.setMaximum) n_edit.valueChanged.connect(cw.set_n) m_edit.valueChanged.connect(cw.set_m) hbox = QHBoxLayout() hbox.addWidget(QLabel(_('Require'))) hbox.addWidget(m_edit) hbox.addWidget(QLabel(_('of'))) hbox.addWidget(n_edit) hbox.addWidget(QLabel(_('signatures'))) hbox.addStretch(1) vbox = QVBoxLayout() vbox.addWidget(cw) vbox.addWidget(WWLabel(_("Choose the number of signatures needed " "to unlock funds in your wallet:"))) vbox.addLayout(hbox) self.set_main_layout(vbox, _("Multi-Signature Wallet")) m = int(m_edit.value()) n = int(n_edit.value()) wallet_type = '%dof%d'%(m,n) return wallet_type
def update(self): self.menu_actions = [(_('Show'), self.do_show), (_('Delete'), self.do_delete)] requests_list = self.screen.ids.requests_container requests_list.clear_widgets() _list = self.app.wallet.get_sorted_requests(self.app.electrum_config) for req in _list: address = req['address'] timestamp = req.get('time', 0) amount = req.get('amount') expiration = req.get('exp', None) status = req.get('status') signature = req.get('sig') ci = Factory.RequestItem() ci.address = req['address'] ci.memo = self.app.wallet.get_label(address) status = req.get('status') if status == PR_PAID: ci.icon = "atlas://gui/kivy/theming/light/confirmed" elif status == PR_EXPIRED: ci.icon = "atlas://gui/kivy/theming/light/important" else: ci.icon = "atlas://gui/kivy/theming/light/important" ci.amount = self.app.format_amount_and_units(amount) if amount else '' ci.date = format_time(timestamp) ci.screen = self requests_list.add_widget(ci) if not _list: msg = _('This screen shows the list of payment requests you made.') requests_list.add_widget(EmptyLabel(text=msg))
def value_str(self, satoshis, rate): if satoshis is None: # Can happen with incomplete history return _("Unknown") if rate: value = Decimal(satoshis) / COIN * Decimal(rate) return "%s" % (self.ccy_amount_str(value, True)) return _("No data")
def __init__(self, parent, address): WindowModalDialog.__init__(self, parent, _("Address")) self.address = address self.parent = parent self.config = parent.config self.wallet = parent.wallet self.app = parent.app self.saved = True self.setMinimumWidth(700) vbox = QVBoxLayout() self.setLayout(vbox) vbox.addWidget(QLabel(_("Address:"))) self.addr_e = ButtonsLineEdit(self.address) self.addr_e.addCopyButton(self.app) self.addr_e.addButton(":icons/qrcode.png", self.show_qr, _("Show QR Code")) self.addr_e.setReadOnly(True) vbox.addWidget(self.addr_e) vbox.addWidget(QLabel(_("History"))) self.hw = HistoryWidget(self.parent) self.hw.get_domain = self.get_domain vbox.addWidget(self.hw) vbox.addStretch(1) vbox.addLayout(Buttons(CloseButton(self))) self.format_amount = self.parent.format_amount self.hw.update()
def __init__(self, parent): super(CharacterDialog, self).__init__(parent) self.setWindowTitle(_("KeepKey Seed Recovery")) self.character_pos = 0 self.word_pos = 0 self.loop = QEventLoop() self.word_help = QLabel() self.char_buttons = [] vbox = QVBoxLayout(self) vbox.addWidget(WWLabel(CHARACTER_RECOVERY)) hbox = QHBoxLayout() hbox.addWidget(self.word_help) for i in range(4): char_button = CharacterButton('*') char_button.setMaximumWidth(36) self.char_buttons.append(char_button) hbox.addWidget(char_button) self.accept_button = CharacterButton(_("Accept Word")) self.accept_button.clicked.connect(partial(self.process_key, 32)) self.rejected.connect(partial(self.loop.exit, 1)) hbox.addWidget(self.accept_button) hbox.addStretch(1) vbox.addLayout(hbox) self.finished_button = QPushButton(_("Seed Entered")) self.cancel_button = QPushButton(_("Cancel")) self.finished_button.clicked.connect(partial(self.process_key, Qt.Key_Return)) self.cancel_button.clicked.connect(self.rejected) buttons = Buttons(self.finished_button, self.cancel_button) vbox.addSpacing(40) vbox.addLayout(buttons) self.refresh() self.show()
def query_multisig(self, action): cw = CosignWidget(2, 2) m_edit = QSpinBox() n_edit = QSpinBox() m_edit.setValue(2) n_edit.setValue(2) n_edit.setMinimum(2) n_edit.setMaximum(15) m_edit.setMinimum(1) m_edit.setMaximum(2) n_edit.valueChanged.connect(m_edit.setMaximum) n_edit.valueChanged.connect(cw.set_n) m_edit.valueChanged.connect(cw.set_m) hbox = QHBoxLayout() hbox.addWidget(QLabel(_('Require'))) hbox.addWidget(m_edit) hbox.addWidget(QLabel(_('of'))) hbox.addWidget(n_edit) hbox.addWidget(QLabel(_('signatures'))) hbox.addStretch(1) vbox = QVBoxLayout() vbox.addWidget(cw) vbox.addWidget( WWLabel( _("Choose the number of signatures needed " "to unlock funds in your wallet:"))) vbox.addLayout(hbox) self.set_main_layout(vbox, _("Multi-Signature Wallet")) m = int(m_edit.value()) n = int(n_edit.value()) wallet_type = '%dof%d' % (m, n) return wallet_type
def parse_history(self, items): for item in items: tx_hash, conf, value, timestamp, balance = item time_str = _("unknown") if conf > 0: try: time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] except Exception: time_str = _("error") if conf == -1: time_str = _('unverified') icon = "atlas://gui/kivy/theming/light/close" elif conf == 0: time_str = _('pending') icon = "atlas://gui/kivy/theming/light/unconfirmed" elif conf < 6: conf = max(1, conf) icon = "atlas://gui/kivy/theming/light/clock{}".format(conf) else: icon = "atlas://gui/kivy/theming/light/confirmed" label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs') date = timestamp_to_datetime(timestamp) rate = run_hook('history_rate', date) if self.app.fiat_unit: quote_text = "..." if rate is None else "{0:.3} {1}".format(Decimal(value) / 100000000 * Decimal(rate), self.app.fiat_unit) else: quote_text = '' yield (conf, icon, time_str, label, value, tx_hash, quote_text)
def task(): wallet.wait_until_synchronized() if wallet.is_found(): msg = _("Recovery successful") else: msg = _("No transactions found for this seed") self.emit(QtCore.SIGNAL('synchronized'), msg)
def update(self): self.menu_actions = [(_('Pay'), self.do_pay), (_('Delete'), self.do_delete)] invoices_list = self.screen.ids.invoices_container invoices_list.clear_widgets() _list = self.app.invoices.sorted_list() for pr in _list: ci = Factory.InvoiceItem() ci.key = pr.get_id() ci.requestor = pr.get_requestor() ci.memo = pr.memo ci.amount = self.app.format_amount_and_units(pr.get_amount()) status = self.app.invoices.get_status(ci.key) if status == PR_PAID: ci.icon = "atlas://gui/kivy/theming/light/confirmed" elif status == PR_EXPIRED: ci.icon = "atlas://gui/kivy/theming/light/important" else: ci.icon = "atlas://gui/kivy/theming/light/important" exp = pr.get_expiration_date() ci.date = format_time(exp) if exp else _('Never') ci.screen = self invoices_list.add_widget(ci) if not _list: msg = _('This screen shows the list of payment requests that have been sent to you.') invoices_list.add_widget(EmptyLabel(text=msg))
def parse_history(self, items): for item in items: tx_hash, conf, value, timestamp, balance = item time_str = _("unknown") if conf > 0: try: time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] except Exception: time_str = _("error") if conf == -1: time_str = _('unverified') icon = "atlas://gui/kivy/theming/light/close" elif conf == 0: time_str = _('pending') icon = "atlas://gui/kivy/theming/light/unconfirmed" elif conf < 6: conf = max(1, conf) icon = "atlas://gui/kivy/theming/light/clock{}".format(conf) else: icon = "atlas://gui/kivy/theming/light/confirmed" label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs') date = timestamp_to_datetime(timestamp) rate = run_hook('history_rate', date) if self.app.fiat_unit: quote_text = "..." if rate is None else "{0:.3} {1}".format(Decimal(value) / 100000000 * Decimal(rate), self.app.fiat_unit) else: quote_text = '' yield (conf, icon, time_str, label, value, tx_hash, quote_text)
def save(self): name = 'signed_%s.txn' % (self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn' fileName = self.main_window.getSaveFileName(_("Select where to save your signed transaction"), name, "*.txn") if fileName: with open(fileName, "w+") as f: f.write(json.dumps(self.tx.as_dict(), indent=4) + '\n') self.show_message(_("Transaction saved successfully")) self.saved = True
def closeEvent(self, event): if (self.prompt_if_unsaved and not self.saved and not self.question( _('This transaction is not saved. Close anyway?'), title=_("Warning"))): event.ignore() else: event.accept() dialogs.remove(self)
def wipe_device(): if wallet and sum(wallet.get_balance()): title = _("Confirm Device Wipe") msg = _("Are you SURE you want to wipe the device?\n" "Your wallet still has bitcoins in it!") if not self.question(msg, title=title, icon=QMessageBox.Critical): return invoke_client('wipe_device', unpair_after=True)
def save(self): name = 'signed_%s.txn' % ( self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn' fileName = self.main_window.getSaveFileName( _("Select where to save your signed transaction"), name, "*.txn") if fileName: with open(fileName, "w+") as f: f.write(json.dumps(self.tx.as_dict(), indent=4) + '\n') self.show_message(_("Transaction saved successfully")) self.saved = True
def export_history_dialog(self, window, hbox): wallet = window.wallet history = wallet.get_history() if len(history) > 0: b = QPushButton(_("Preview plot")) hbox.addWidget(b) b.clicked.connect(lambda: self.do_plot(wallet, history)) else: b = QPushButton(_("No history to plot")) hbox.addWidget(b)
def give_error(self, message, clear_client = False): print_error(message) if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client: self.plugin.client = None self.device_checked = False raise Exception(message)
def export_history_dialog(self, window, hbox): wallet = window.wallet history = wallet.get_history() if len(history) > 0: b = QPushButton(_("Preview plot")) hbox.addWidget(b) b.clicked.connect(lambda: self.do_plot(wallet, history)) else: b = QPushButton(_("No history to plot")) hbox.addWidget(b)
def give_error(self, message, clear_client=False): print_error(message) if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client: self.plugin.client = None self.device_checked = False raise Exception(message)
def load_wallet(self, wallet, window): if type(wallet) != BTChipWallet: return wallet.handler = BTChipQTHandler(window) if self.btchip_is_connected(wallet): if not wallet.check_proper_device(): window.show_error(_("This wallet does not match your Ledger device")) wallet.force_watching_only = True else: window.show_error(_("Ledger device not detected.\nContinuing in watching-only mode.")) wallet.force_watching_only = True
def __init__(self, parent, seed, imported_keys): WindowModalDialog.__init__(self, parent, ('Electrum - ' + _('Seed'))) self.setMinimumWidth(400) vbox = QVBoxLayout(self) vbox.addLayout(SeedWarningLayout(seed).layout()) if imported_keys: warning = ("<b>" + _("WARNING") + ":</b> " + _("Your wallet contains imported keys. These keys " "cannot be recovered from your seed.") + "</b><p>") vbox.addWidget(WWLabel(warning)) vbox.addLayout(Buttons(CloseButton(self)))
def __init__(self, parent, seed, imported_keys): WindowModalDialog.__init__(self, parent, ('Electrum - ' + _('Seed'))) self.setMinimumWidth(400) vbox = QVBoxLayout(self) vbox.addLayout(SeedWarningLayout(seed).layout()) if imported_keys: warning = ("<b>" + _("WARNING") + ":</b> " + _("Your wallet contains imported keys. These keys " "cannot be recovered from your seed.") + "</b><p>") vbox.addWidget(WWLabel(warning)) vbox.addLayout(Buttons(CloseButton(self)))
def build_tray_menu(self): # Avoid immediate GC of old menu when window closed via its action self.old_menu = self.tray.contextMenu() m = QMenu() for window in self.windows: submenu = m.addMenu(window.wallet.basename()) submenu.addAction(_("Show/Hide"), window.show_or_hide) submenu.addAction(_("Close"), window.close) m.addAction(_("Dark/Light"), self.toggle_tray_icon) m.addSeparator() m.addAction(_("Exit Electrum"), self.close) self.tray.setContextMenu(m)
def toggle_passphrase(): title = _("Confirm Toggle Passphrase Protection") msg = _("This will cause your Electrum wallet to be unpaired " "unless your passphrase was or will be empty.\n\n" "This is because addresses will no " "longer correspond to those used by your %s.\n\n" "You will need to create a new Electrum wallet " "with the install wizard so that they match.\n\n" "Are you sure you want to proceed?") % plugin.device if not self.question(msg, title=title): return invoke_client('toggle_passphrase', unpair_after=True)
def build_tray_menu(self): # Avoid immediate GC of old menu when window closed via its action self.old_menu = self.tray.contextMenu() m = QMenu() for window in self.windows: submenu = m.addMenu(window.wallet.basename()) submenu.addAction(_("Show/Hide"), window.show_or_hide) submenu.addAction(_("Close"), window.close) m.addAction(_("Dark/Light"), self.toggle_tray_icon) m.addSeparator() m.addAction(_("Exit Electrum"), self.close) self.tray.setContextMenu(m)
def update(features): self.current_label = features.label set_label_enabled() bl_hash = features.bootloader_hash.encode('hex') bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]]) noyes = [_("No"), _("Yes")] endis = [_("Enable Passphrases"), _("Disable Passphrases")] disen = [_("Disabled"), _("Enabled")] setchange = [_("Set a PIN"), _("Change PIN")] version = "%d.%d.%d" % (features.major_version, features.minor_version, features.patch_version) coins = ", ".join(coin.coin_name for coin in features.coins) device_label.setText(features.label) pin_set_label.setText(noyes[features.pin_protection]) passphrases_label.setText(disen[features.passphrase_protection]) bl_hash_label.setText(bl_hash) label_edit.setText(features.label) device_id_label.setText(features.device_id) initialized_label.setText(noyes[features.initialized]) version_label.setText(version) coins_label.setText(coins) clear_pin_button.setVisible(features.pin_protection) clear_pin_warning.setVisible(features.pin_protection) pin_button.setText(setchange[features.pin_protection]) pin_msg.setVisible(not features.pin_protection) passphrase_button.setText(endis[features.passphrase_protection]) language_label.setText(features.language)
def load_wallet(self, wallet, window): if type(wallet) != BTChipWallet: return wallet.handler = BTChipQTHandler(window) if self.btchip_is_connected(wallet): if not wallet.check_proper_device(): window.show_error( _("This wallet does not match your Ledger device")) wallet.force_watching_only = True else: window.show_error( _("Ledger device not detected.\nContinuing in watching-only mode." )) wallet.force_watching_only = True
def callback_PinMatrixRequest(self, msg): if msg.type == 1: msg = _("Enter your current %s PIN:") elif msg.type == 2: msg = _("Enter a new %s PIN:") elif msg.type == 3: msg = (_("Please re-enter your new %s PIN.\n" "Note the numbers have been shuffled!")) else: msg = _("Please enter %s PIN") pin = self.handler.get_pin(msg % self.device) if not pin: return self.proto.Cancel() return self.proto.PinMatrixAck(pin=pin)
def settings_dialog(self, window): d = WindowModalDialog(window, _("Exchange Rate Settings")) layout = QGridLayout(d) layout.addWidget(QLabel(_('Exchange rate API: ')), 0, 0) layout.addWidget(QLabel(_('Currency: ')), 1, 0) layout.addWidget(QLabel(_('History Rates: ')), 2, 0) # Currency list self.ccy_combo = QComboBox() self.ccy_combo.currentIndexChanged.connect(self.on_ccy_combo_change) self.populate_ccy_combo() def on_change_ex(idx): exchange = str(combo_ex.currentText()) if exchange != self.exchange.name(): self.set_exchange(exchange) self.hist_checkbox_update() def on_change_hist(checked): if checked: self.config.set_key('history_rates', 'checked') self.get_historical_rates() else: self.config.set_key('history_rates', 'unchecked') self.emit(SIGNAL('refresh_headers')) def ok_clicked(): self.timeout = 0 self.ccy_combo = None d.accept() combo_ex = QComboBox() combo_ex.addItems(sorted(self.exchanges.keys())) combo_ex.setCurrentIndex(combo_ex.findText(self.config_exchange())) combo_ex.currentIndexChanged.connect(on_change_ex) self.hist_checkbox = QCheckBox() self.hist_checkbox.stateChanged.connect(on_change_hist) self.hist_checkbox_update() ok_button = QPushButton(_("OK")) ok_button.clicked.connect(lambda: ok_clicked()) layout.addWidget(self.ccy_combo,1,1) layout.addWidget(combo_ex,0,1) layout.addWidget(self.hist_checkbox,2,1) layout.addWidget(ok_button,3,1) return d.exec_()
def settings_dialog(self, window): d = WindowModalDialog(window, _("Exchange Rate Settings")) layout = QGridLayout(d) layout.addWidget(QLabel(_('Exchange rate API: ')), 0, 0) layout.addWidget(QLabel(_('Currency: ')), 1, 0) layout.addWidget(QLabel(_('History Rates: ')), 2, 0) # Currency list self.ccy_combo = QComboBox() self.ccy_combo.currentIndexChanged.connect(self.on_ccy_combo_change) self.populate_ccy_combo() def on_change_ex(idx): exchange = str(combo_ex.currentText()) if exchange != self.exchange.name(): self.set_exchange(exchange) self.hist_checkbox_update() def on_change_hist(checked): if checked: self.config.set_key('history_rates', 'checked') self.get_historical_rates() else: self.config.set_key('history_rates', 'unchecked') self.emit(SIGNAL('refresh_headers')) def ok_clicked(): self.timeout = 0 self.ccy_combo = None d.accept() combo_ex = QComboBox() combo_ex.addItems(sorted(self.exchanges.keys())) combo_ex.setCurrentIndex(combo_ex.findText(self.config_exchange())) combo_ex.currentIndexChanged.connect(on_change_ex) self.hist_checkbox = QCheckBox() self.hist_checkbox.stateChanged.connect(on_change_hist) self.hist_checkbox_update() ok_button = QPushButton(_("OK")) ok_button.clicked.connect(lambda: ok_clicked()) layout.addWidget(self.ccy_combo, 1, 1) layout.addWidget(combo_ex, 0, 1) layout.addWidget(self.hist_checkbox, 2, 1) layout.addWidget(ok_button, 3, 1) return d.exec_()
def auth_dialog(self, window): d = WindowModalDialog(window, _("Authorization")) vbox = QVBoxLayout(d) pw = AmountEdit(None, is_int = True) msg = _('Please enter your Google Authenticator code') vbox.addWidget(QLabel(msg)) grid = QGridLayout() grid.setSpacing(8) grid.addWidget(QLabel(_('Code')), 1, 0) grid.addWidget(pw, 1, 1) vbox.addLayout(grid) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) if not d.exec_(): return return pw.get_amount()
def auth_dialog(self, window): d = WindowModalDialog(window, _("Authorization")) vbox = QVBoxLayout(d) pw = AmountEdit(None, is_int=True) msg = _('Please enter your Google Authenticator code') vbox.addWidget(QLabel(msg)) grid = QGridLayout() grid.setSpacing(8) grid.addWidget(QLabel(_('Code')), 1, 0) grid.addWidget(pw, 1, 1) vbox.addLayout(grid) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) if not d.exec_(): return return pw.get_amount()
def password_dialog(self, pw, grid, pos): vkb_button = QPushButton(_("+")) vkb_button.setFixedWidth(20) vkb_button.clicked.connect(lambda: self.toggle_vkb(grid, pw)) grid.addWidget(vkb_button, pos, 2) self.kb_pos = 2 self.vkb = None
def create_client(self, device, handler): if device.interface_number == 1: pair = [None, device.path] else: pair = [device.path, None] try: transport = self.HidTransport(pair) except BaseException as e: # We were probably just disconnected; never mind self.print_error("cannot connect at", device.path, str(e)) return None self.print_error("connected to device at", device.path) client = self.client_class(transport, handler, self) # Try a ping for device sanity try: client.ping('t') except BaseException as e: self.print_error("ping failed", str(e)) return None if not client.atleast_version(*self.minimum_firmware): msg = (_('Outdated %s firmware for device labelled %s. Please ' 'download the updated firmware from %s') % (self.device, client.label(), self.firmware_URL)) handler.show_error(msg) return None return client
def password_dialog(self, pw, grid, pos): vkb_button = QPushButton(_("+")) vkb_button.setFixedWidth(20) vkb_button.clicked.connect(lambda: self.toggle_vkb(grid, pw)) grid.addWidget(vkb_button, pos, 2) self.kb_pos = 2 self.vkb = None
def do_save(self): addr = str(self.screen.address) amount = str(self.screen.amount) message = str(self.screen.message) #.ids.message_input.text) if not message and not amount: self.app.show_error(_('No message or amount')) return if amount: amount = self.app.get_amount(amount) else: amount = 0 print "saving", amount, message req = self.app.wallet.make_payment_request(addr, amount, message, None) self.app.wallet.add_payment_request(req, self.app.electrum_config) self.app.show_error(_('Request saved')) self.app.update_tab('requests')
def update(self, see_all=False): if self.app.wallet is None: return history = self.parse_history(reversed( self.app.wallet.get_history(self.app.current_account))) # repopulate History Card history_card = self.screen.ids.history_container history_card.clear_widgets() count = 0 for item in history: count += 1 conf, icon, date_time, message, value, tx, quote_text = item ri = Factory.HistoryItem() ri.icon = icon ri.date = date_time ri.message = message ri.value = value ri.quote_text = quote_text ri.confirmations = conf ri.tx_hash = tx ri.screen = self history_card.add_widget(ri) if count == 8 and not see_all: break if count == 0: msg = _('This screen shows your list of transactions. It is currently empty.') history_card.add_widget(EmptyLabel(text=msg))
def __init__(self, win): QWidget.__init__(self) self.win = win self.setWindowTitle('Electrum - '+_('Payment Request')) self.setMinimumSize(800, 250) self.address = '' self.label = '' self.amount = 0 self.setFocusPolicy(QtCore.Qt.NoFocus) main_box = QHBoxLayout() self.qrw = QRCodeWidget() main_box.addWidget(self.qrw, 1) vbox = QVBoxLayout() main_box.addLayout(vbox) self.address_label = QLabel("") #self.address_label.setFont(QFont(MONOSPACE_FONT)) vbox.addWidget(self.address_label) self.label_label = QLabel("") vbox.addWidget(self.label_label) self.amount_label = QLabel("") vbox.addWidget(self.amount_label) vbox.addStretch(1) self.setLayout(main_box)
def create_client(self, device, handler): if device.interface_number == 1: pair = [None, device.path] else: pair = [device.path, None] try: transport = self.HidTransport(pair) except BaseException as e: # We were probably just disconnected; never mind self.print_error("cannot connect at", device.path, str(e)) return None self.print_error("connected to device at", device.path) client = self.client_class(transport, handler, self) # Try a ping for device sanity try: client.ping('t') except BaseException as e: self.print_error("ping failed", str(e)) return None if not client.atleast_version(*self.minimum_firmware): msg = (_('Outdated %s firmware for device labelled %s. Please ' 'download the updated firmware from %s') % (self.device, client.label(), self.firmware_URL)) handler.show_error(msg) return None return client
def __init__(self, network, config, parent): WindowModalDialog.__init__(self, parent, _('Network')) self.setMinimumSize(375, 20) self.nlayout = NetworkChoiceLayout(network, config) vbox = QVBoxLayout(self) vbox.addLayout(self.nlayout.layout()) vbox.addLayout(Buttons(CancelButton(self), OkButton(self)))
def on_receive(self, keyhash, message): self.print_error("signal arrived for", keyhash) for key, _hash, window in self.keys: if _hash == keyhash: break else: self.print_error("keyhash not found") return wallet = window.wallet if wallet.use_encryption: password = window.password_dialog('An encrypted transaction was retrieved from cosigning pool.\nPlease enter your password to decrypt it.') if not password: return else: password = None if not window.question(_("An encrypted transaction was retrieved from cosigning pool.\nDo you want to open it now?")): return xprv = wallet.get_master_private_key(key, password) if not xprv: return try: k = bitcoin.deserialize_xkey(xprv)[-1].encode('hex') EC = bitcoin.EC_KEY(k.decode('hex')) message = EC.decrypt_message(message) except Exception as e: traceback.print_exc(file=sys.stdout) window.show_message(str(e)) return self.listener.clear(keyhash) tx = transaction.Transaction(message) show_transaction(tx, window, prompt_if_unsaved=True)
def description_dialog(self, screen): from uix.dialogs.label_dialog import LabelDialog text = screen.message def callback(text): screen.message = text d = LabelDialog(_('Enter description'), text, callback) d.open()
def do_save(self): addr = str(self.screen.address) amount = str(self.screen.amount) message = str(self.screen.message) #.ids.message_input.text) if not message and not amount: self.app.show_error(_('No message or amount')) return if amount: amount = self.app.get_amount(amount) else: amount = 0 print "saving", amount, message req = self.app.wallet.make_payment_request(addr, amount, message, None) self.app.wallet.add_payment_request(req, self.app.electrum_config) self.app.show_error(_('Request saved')) self.app.update_tab('requests')
def callback_WordRequest(self, msg): self.step += 1 msg = _("Step %d/24. Enter seed word as explained on " "your %s:") % (self.step, self.device) word = self.handler.get_word(msg) # Unfortunately the device can't handle self.proto.Cancel() return self.proto.WordAck(word=word)
def update(self, see_all=False): if self.app.wallet is None: return history = self.parse_history(reversed( self.app.wallet.get_history(self.app.current_account))) # repopulate History Card history_card = self.screen.ids.history_container history_card.clear_widgets() count = 0 for item in history: count += 1 conf, icon, date_time, message, value, tx, quote_text = item ri = Factory.HistoryItem() ri.icon = icon ri.date = date_time ri.message = message ri.value = value ri.quote_text = quote_text ri.confirmations = conf ri.tx_hash = tx ri.screen = self history_card.add_widget(ri) if count == 8 and not see_all: break if count == 0: msg = _('This screen shows your list of transactions. It is currently empty.') history_card.add_widget(EmptyLabel(text=msg))
def show_address(self, wallet, address): client = self.get_client(wallet) if not client.atleast_version(1, 3): wallet.handler.show_error(_("Your device firmware is too old")) return address_path = wallet.address_id(address) address_n = client.expand_path(address_path) client.get_address('Bitcoin', address_n, True)
def _change_password(self, old_password): if self.wallet.use_encryption: try: self.wallet.check_password(old_password) except InvalidPassword: self.show_error("Invalid PIN") return self.password_dialog(_('Enter new PIN'), self._change_password2, (old_password,))