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 add_io(self, vbox): if self.tx.locktime > 0: vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime)) vbox.addWidget(QLabel(_("Inputs"))) ext = QTextCharFormat() rec = QTextCharFormat() rec.setBackground(QBrush(QColor("lightgreen"))) rec.setToolTip(_("Wallet receive address")) chg = QTextCharFormat() chg.setBackground(QBrush(QColor("yellow"))) chg.setToolTip(_("Wallet change address")) def text_format(addr): if self.wallet.is_mine(addr): return chg if self.wallet.is_change(addr) else rec return ext i_text = QTextEdit() i_text.setFont(QFont(MONOSPACE_FONT)) i_text.setReadOnly(True) i_text.setMaximumHeight(100) cursor = i_text.textCursor() for x in self.tx.inputs: if x.get('is_coinbase'): cursor.insertText('coinbase') else: prevout_hash = x.get('prevout_hash') prevout_n = x.get('prevout_n') cursor.insertText(prevout_hash[0:8] + '...', ext) cursor.insertText(prevout_hash[-8:] + ":%-4d " % prevout_n, ext) addr = x.get('address') if addr == "(pubkey)": _addr = self.wallet.find_pay_to_pubkey_address( prevout_hash, prevout_n) if _addr: addr = _addr if addr is None: addr = _('unknown') cursor.insertText(addr, text_format(addr)) cursor.insertBlock() vbox.addWidget(i_text) vbox.addWidget(QLabel(_("Outputs"))) o_text = QTextEdit() o_text.setFont(QFont(MONOSPACE_FONT)) o_text.setReadOnly(True) o_text.setMaximumHeight(100) cursor = o_text.textCursor() for addr, v in self.tx.get_outputs(): cursor.insertText(addr, text_format(addr)) if v is not None: cursor.insertText('\t', ext) cursor.insertText( self.parent.format_amount(v, whitespaces=True), ext) cursor.insertBlock() vbox.addWidget(o_text)
def __init__(self, transaction_id, parent): super(TransactionWindow, self).__init__() self.tx_id = str(transaction_id) self.parent = parent self.setModal(True) self.resize(200, 100) self.setWindowTitle(_("Transaction successfully sent")) self.layout = QGridLayout(self) history_label = "%s\n%s" % ( _("Your transaction has been sent."), _("Please enter a label for this transaction for future reference." )) self.layout.addWidget(QLabel(history_label)) self.label_edit = QLineEdit() self.label_edit.setPlaceholderText(_("Transaction label")) self.label_edit.setObjectName("label_input") self.label_edit.setAttribute(Qt.WA_MacShowFocusRect, 0) self.label_edit.setFocusPolicy(Qt.ClickFocus) self.layout.addWidget(self.label_edit) self.save_button = QPushButton(_("Save")) self.layout.addWidget(self.save_button) self.save_button.clicked.connect(self.set_label) self.exec_()
def multi_mpk_dialog(self, xpub_hot, n): vbox = QVBoxLayout() scroll = QScrollArea() scroll.setEnabled(True) scroll.setWidgetResizable(True) vbox.addWidget(scroll) w = QWidget() scroll.setWidget(w) innerVbox = QVBoxLayout() w.setLayout(innerVbox) vbox0 = seed_dialog.show_seed_box(MSG_SHOW_MPK, xpub_hot, 'hot') innerVbox.addLayout(vbox0) entries = [] for i in range(n): msg = _("Please enter the master public key of cosigner") + ' %d'%(i+1) vbox2, seed_e2 = seed_dialog.enter_seed_box(msg, self, 'cold') innerVbox.addLayout(vbox2) entries.append(seed_e2) vbox.addStretch(1) button = OkButton(self, _('Next')) vbox.addLayout(Buttons(CancelButton(self), button)) button.setEnabled(False) f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True]*len(entries)) for e in entries: e.textChanged.connect(f) self.set_layout(vbox) if not self.exec_(): return return map(lambda e: self.get_seed_text(e), entries)
def build_tray_menu(self): m = QMenu() m.addAction(_("Show/Hide"), self.show_or_hide) m.addAction(_("Dark/Light"), self.toggle_tray_icon) m.addSeparator() m.addAction(_("Exit Electrum-ZCL"), self.close) self.tray.setContextMenu(m)
def qr_input(self): from electrum_zcl import qrscanner, get_config try: data = qrscanner.scan_qr(get_config()) except BaseException, e: QMessageBox.warning(self, _('Error'), _(e), _('OK')) return ""
def toggle_passphrase(self): if self.features.passphrase_protection: self.msg = _("Confirm on your %s device to disable passphrases") else: self.msg = _("Confirm on your %s device to enable passphrases") enabled = not self.features.passphrase_protection self.apply_settings(use_passphrase=enabled)
def before_send(self): ''' Change URL to address before making a send. IMPORTANT: return False to continue execution of the send return True to stop execution of the send ''' if self.win.payto_e.is_multiline(): # only supports single line entries atm return False if self.win.payto_e.is_pr: return payto_e = str(self.win.payto_e.toPlainText()) regex = re.compile(r'^([^\s]+) <([A-Za-z0-9]+)>') # only do that for converted addresses try: (url, address) = regex.search(payto_e).groups() except AttributeError: return False if not self.validated: msgBox = QMessageBox() msgBox.setText(_('WARNING: the address ' + address + ' could not be validated via an additional security check, DNSSEC, and thus may not be correct.')) msgBox.setInformativeText(_('Do you wish to continue?')) msgBox.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) msgBox.setDefaultButton(QMessageBox.Cancel) reply = msgBox.exec_() if reply != QMessageBox.Ok: return True return False
def add_cosigner_dialog(self, run_next, index, is_valid): title = _("Add Cosigner") + " %d" % index message = ' '.join([ _('Please enter the master public key (xpub) of your cosigner.'), _('Enter their master private key (xprv) if you want to be able to sign for them.' ) ]) return self.text_input(title, message, is_valid)
def set_pin(self, remove): if remove: self.msg = _("Confirm on your %s device to disable PIN protection") elif self.features.pin_protection: self.msg = _("Confirm on your %s device to change your PIN") else: self.msg = _("Confirm on your %s device to set a PIN") self.change_pin(remove)
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 __init__(self, parent=None): MyTreeWidget.__init__( self, parent, self.create_menu, ['', _('Date'), _('Description'), _('Amount'), _('Balance')], 2) self.config = self.parent.config self.setSortingEnabled(False)
def verify_seed(self, seed, sid, func=None): r = self.enter_seed_dialog(MSG_VERIFY_SEED, sid, func) if not r: return if prepare_seed(r) != prepare_seed(seed): QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK')) return False else: return True
def __init__(self, parent=None): MyTreeWidget.__init__(self, parent, self.create_menu, [ _('Address'), _('Label'), _('Amount'), _('Height'), _('Output point') ], 1) self.setSelectionMode(QAbstractItemView.ExtendedSelection)
def give_error(self, message, clear_client=False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client and self.client is not None: self.client.bad = True self.device_checked = False raise Exception(message)
def save(self): name = 'signed_%s.txn' % ( self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn' fileName = self.parent.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 installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'btchip': return wallet = BTChipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def export_history_dialog(self, d, hbox): self.wallet = d.wallet history = self.wallet.get_history() if len(history) > 0: b = QPushButton(_("Preview plot")) hbox.addWidget(b) b.clicked.connect(lambda: self.do_plot(self.wallet, history)) else: b = QPushButton(_("No history to plot")) hbox.addWidget(b)
def restore_seed_dialog(self, run_next, test): options = [] if self.opt_ext: options.append('ext') if self.opt_bip39: options.append('bip39') title = _('Enter Seed') message = _( 'Please enter your seed phrase in order to restore your wallet.') return self.seed_input(title, message, test, options)
def ok_cancel_buttons(dialog): row_layout = QHBoxLayout() row_layout.addStretch(1) ok_button = QPushButton(_("OK")) row_layout.addWidget(ok_button) ok_button.clicked.connect(dialog.accept) cancel_button = QPushButton(_("Cancel")) row_layout.addWidget(cancel_button) cancel_button.clicked.connect(dialog.reject) return row_layout
def show_xpub_dialog(self, xpub, run_next): msg = ' '.join([ _("Here is your master public key."), _("Please share it with your cosigners.") ]) vbox = QVBoxLayout() layout = SeedLayout(xpub, title=msg, icon=False) vbox.addLayout(layout.layout()) self.exec_layout(vbox, _('Master Public Key')) return None
def closeEvent(self, event): if (self.prompt_if_unsaved and not self.saved and not self.broadcast and QMessageBox.question( self, _('Warning'), _('This transaction is not saved. Close anyway?'), QMessageBox.Yes | QMessageBox.No) == QMessageBox.No): event.ignore() else: event.accept() dialogs.remove(self)
def __init__(self, owner=None): self.owner = owner self.editing = False QTreeWidget.__init__(self, owner) self.setColumnCount(3) self.setHeaderLabels([_("Address"), _("Label"), _("Used")]) self.setIndentation(0) self.hide_used = True self.setColumnHidden(2, True)
def append(self, address, amount, date): if address is None: address = _("Unknown") if amount is None: amount = _("Unknown") if date is None: date = _("Unknown") item = QTreeWidgetItem([amount, address, date]) if amount.find('-') != -1: item.setForeground(0, QBrush(QColor("#BC1E1E"))) self.insertTopLevelItem(0, item)
def confirm_seed_dialog(self, run_next, test): self.app.clipboard().clear() title = _('Confirm Seed') message = ' '.join([ _('Your seed is important!'), _('If you lose your seed, your money will be permanently lost.'), _('To make sure that you have properly saved your seed, please retype it here.' ) ]) seed, is_bip39, is_ext = self.seed_input(title, message, test, None) return seed
def callback_PinMatrixRequest(self, msg): if msg.type == 2: msg = _("Enter a new PIN for your %s:") elif msg.type == 3: msg = (_("Re-enter the new PIN for your %s.\n\n" "NOTE: the positions of the numbers have changed!")) else: msg = _("Enter your current %s PIN:") pin = self.handler.get_pin(msg % self.device) if not pin: return self.proto.Cancel() return self.proto.PinMatrixAck(pin=pin)
def restore_or_create(self): vbox = QVBoxLayout() main_label = QLabel(_("Electrum could not find an existing wallet.")) vbox.addWidget(main_label) grid = QGridLayout() grid.setSpacing(5) gb1 = QGroupBox(_("What do you want to do?")) vbox.addWidget(gb1) b1 = QRadioButton(gb1) b1.setText(_("Create new wallet")) b1.setChecked(True) b2 = QRadioButton(gb1) b2.setText(_("Restore a wallet or import keys")) group1 = QButtonGroup() group1.addButton(b1) group1.addButton(b2) vbox.addWidget(b1) vbox.addWidget(b2) gb2 = QGroupBox(_("Wallet type:")) vbox.addWidget(gb2) group2 = QButtonGroup() self.wallet_types = [ ('standard', _("Standard wallet")), ('twofactor', _("Wallet with two-factor authentication")), ('multisig', _("Multi-signature wallet")), ('hardware', _("Hardware wallet")), ] for i, (wtype,name) in enumerate(self.wallet_types): if not filter(lambda x:x[0]==wtype, electrum_zcl.wallet.wallet_types): continue button = QRadioButton(gb2) button.setText(name) vbox.addWidget(button) group2.addButton(button) group2.setId(button, i) if i==0: button.setChecked(True) vbox.addStretch(1) self.set_layout(vbox) vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next')))) self.show() self.raise_() if not self.exec_(): return None, None action = 'create' if b1.isChecked() else 'restore' wallet_type = self.wallet_types[group2.checkedId()][0] return action, wallet_type
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-zcl"), self.close) self.tray.setContextMenu(m)
def __init__(self, parent, seed, passphrase): WindowModalDialog.__init__(self, parent, ('Electrum-ZCL - ' + _('Seed'))) self.setMinimumWidth(400) vbox = QVBoxLayout(self) title = _("Your wallet generation seed is:") slayout = SeedLayout(title=title, seed=seed, msg=True, passphrase=passphrase) vbox.addLayout(slayout) vbox.addLayout(Buttons(CloseButton(self)))
def __init__(self, seed=None, title=None, icon=True, msg=None, options=None, is_seed=None, passphrase=None, parent=None): QVBoxLayout.__init__(self) self.parent = parent self.options = options if title: self.addWidget(WWLabel(title)) if seed: self.seed_e = ShowQRTextEdit() self.seed_e.setText(seed) else: self.seed_e = ScanQRTextEdit() self.seed_e.setTabChangesFocus(True) self.is_seed = is_seed self.saved_is_seed = self.is_seed self.seed_e.textChanged.connect(self.on_edit) self.seed_e.setMaximumHeight(75) hbox = QHBoxLayout() if icon: logo = QLabel() logo.setPixmap(QPixmap(":icons/seed.png").scaledToWidth(64)) logo.setMaximumWidth(60) hbox.addWidget(logo) hbox.addWidget(self.seed_e) self.addLayout(hbox) hbox = QHBoxLayout() hbox.addStretch(1) self.seed_type_label = QLabel('') hbox.addWidget(self.seed_type_label) if options: opt_button = EnterButton(_('Options'), self.seed_options) hbox.addWidget(opt_button) self.addLayout(hbox) if passphrase: hbox = QHBoxLayout() passphrase_e = QLineEdit() passphrase_e.setText(passphrase) passphrase_e.setReadOnly(True) hbox.addWidget(QLabel(_("Your seed extension is") + ':')) hbox.addWidget(passphrase_e) self.addLayout(hbox) self.addStretch(1) self.seed_warning = WWLabel('') if msg: self.seed_warning.setText(seed_warning_msg(seed)) self.addWidget(self.seed_warning)