Ejemplo n.º 1
0
    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_()
Ejemplo n.º 2
0
 def qr_input(self):
     from electrum_rby import qrscanner, get_config
     try:
         data = qrscanner.scan_qr(get_config())
     except BaseException, e:
         QMessageBox.warning(self, _('Error'), _(e), _('OK'))
         return ""
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    def add_io(self, vbox):
        if self.tx.locktime > 0:
            vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime))

        vbox.addWidget(QLabel(_("Inputs") + ' (%d)'%len(self.tx.inputs())))
        ext = QTextCharFormat()
        rec = QTextCharFormat()
        rec.setBackground(QBrush(ColorScheme.GREEN.as_color(background=True)))
        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

        def format_amount(amt):
            return self.main_window.format_amount(amt, whitespaces = True)

        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))
                if x.get('value'):
                    cursor.insertText(format_amount(x['value']), ext)
            cursor.insertBlock()

        vbox.addWidget(i_text)
        vbox.addWidget(QLabel(_("Outputs") + ' (%d)'%len(self.tx.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(format_amount(v), ext)
            cursor.insertBlock()
        vbox.addWidget(o_text)
Ejemplo n.º 5
0
    def context_menu(self):
        view_menu = QMenu()
        themes_menu = view_menu.addMenu(_("&Themes"))
        selected_theme = self.actuator.selected_theme()
        theme_group = QActionGroup(self)
        for theme_name in self.actuator.theme_names():
            theme_action = themes_menu.addAction(theme_name)
            theme_action.setCheckable(True)
            if selected_theme == theme_name:
                theme_action.setChecked(True)
            class SelectThemeFunctor:
                def __init__(self, theme_name, toggle_theme):
                    self.theme_name = theme_name
                    self.toggle_theme = toggle_theme
                def __call__(self, checked):
                    if checked:
                        self.toggle_theme(self.theme_name)
            delegate = SelectThemeFunctor(theme_name, self.toggle_theme)
            theme_action.toggled.connect(delegate)
            theme_group.addAction(theme_action)
        view_menu.addSeparator()

        show_receiving = view_menu.addAction(_("Show Receiving addresses"))
        show_receiving.setCheckable(True)
        show_receiving.toggled.connect(self.toggle_receiving_layout)
        show_receiving.setChecked(self.config.get("gui_show_receiving",False))

        show_history = view_menu.addAction(_("Show History"))
        show_history.setCheckable(True)
        show_history.toggled.connect(self.show_history)
        show_history.setChecked(self.config.get("gui_show_history",False))

        return view_menu
Ejemplo n.º 6
0
 def __init__(self, text=""):
     ButtonsTextEdit.__init__(self, text)
     self.setReadOnly(0)
     self.addButton(":icons/file.png", self.file_input, _("Read file"))
     icon = ":icons/qrcode_white.png" if ColorScheme.dark_scheme else ":icons/qrcode.png"
     self.addButton(icon, self.qr_input, _("Read QR code"))
     run_hook('scan_text_edit', self)
Ejemplo n.º 7
0
 def seed_options(self):
     dialog = QDialog()
     vbox = QVBoxLayout(dialog)
     if 'ext' in self.options:
         cb_ext = QCheckBox(_('Extend this seed with custom words'))
         cb_ext.setChecked(self.is_ext)
         vbox.addWidget(cb_ext)
     if 'bip39' in self.options:
         def f(b):
             self.is_seed = (lambda x: bool(x)) if b else self.saved_is_seed
             self.on_edit()
             self.is_bip39 = b
             if b:
                 msg = ' '.join([
                     '<b>' + _('Warning') + ':</b>  ',
                     _('BIP39 seeds can be imported in Electrum, so that users can access funds locked in other wallets.'),
                     _('However, we do not generate BIP39 seeds, because they do not meet our safety standard.'),
                     _('BIP39 seeds do not include a version number, which compromises compatibility with future software.'),
                     _('We do not guarantee that BIP39 imports will always be supported in Electrum.'),
                 ])
             else:
                 msg = ''
             self.seed_warning.setText(msg)
         cb_bip39 = QCheckBox(_('BIP39 seed'))
         cb_bip39.toggled.connect(f)
         cb_bip39.setChecked(self.is_bip39)
         vbox.addWidget(cb_bip39)
     vbox.addLayout(Buttons(OkButton(dialog)))
     if not dialog.exec_():
         return None
     self.is_ext = cb_ext.isChecked() if 'ext' in self.options else False
     self.is_bip39 = cb_bip39.isChecked() if 'bip39' in self.options else False
    def mouseReleaseEvent(self, event):
        dialog = QDialog(self)
        dialog.setWindowTitle(_('Electrum update'))
        dialog.setModal(1)

        main_layout = QGridLayout()
        main_layout.addWidget(QLabel(_("A new version of Electrum is available:")+" " + self.latest_version), 0,0,1,3)

        ignore_version = QPushButton(_("Ignore this version"))
        ignore_version.clicked.connect(self.ignore_this_version)

        ignore_all_versions = QPushButton(_("Ignore all versions"))
        ignore_all_versions.clicked.connect(self.ignore_all_version)

        open_website = QPushButton(_("Goto download page"))
        open_website.clicked.connect(self.open_website)

        main_layout.addWidget(ignore_version, 1, 0)
        main_layout.addWidget(ignore_all_versions, 1, 1)
        main_layout.addWidget(open_website, 1, 2)

        dialog.setLayout(main_layout)

        self.dialog = dialog

        if not dialog.exec_(): return
Ejemplo n.º 9
0
 def refresh_headers(self):
     headers = [_('Address'), _('Label'), _('Balance')]
     fx = self.parent.fx
     if fx and fx.get_fiat_address_config():
         headers.extend([_(fx.get_currency() + ' Balance')])
     headers.extend([_('Tx')])
     self.update_headers(headers)
Ejemplo n.º 10
0
 def task():
     wallet.wait_until_synchronized()
     if wallet.is_found():
         msg = _("Recovery successful")
     else:
         msg = _("No transactions found for this seed")
     self.synchronized_signal.emit(msg)
Ejemplo n.º 11
0
 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-RBY"), self.close)
     self.tray.setContextMenu(m)
Ejemplo n.º 12
0
    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
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
 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 on_change_hist(checked):
     if checked:
         self.config.set_key('history_rates', 'checked')
         self.request_history_rates()
     else:
         self.config.set_key('history_rates', 'unchecked')
         self.win.history_list.setHeaderLabels( [ '', _('Date'), _('Description') , _('Amount'), _('Balance')] )
         self.win.history_list.setColumnCount(5)
 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
Ejemplo n.º 17
0
 def __init__(self, parent, seed, passphrase):
     WindowModalDialog.__init__(self, parent, ('Electrum-RBY - ' + _('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)))
Ejemplo n.º 18
0
 def __init__(self, parent=None):
     MyTreeWidget.__init__(self, parent, self.create_menu, [
         _('Address'),
         _('Label'),
         _('Amount'),
         _('Height'),
         _('Output point')
     ], 1)
     self.setSelectionMode(QAbstractItemView.ExtendedSelection)
Ejemplo n.º 19
0
 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 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
Ejemplo n.º 21
0
 def load_wallet(self, wallet):
     self.wallet = wallet
     if self.trezor_is_connected():
         if not self.wallet.check_proper_device():
             QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK'))
             self.wallet.force_watching_only = True
     else:
         QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK'))
         self.wallet.force_watching_only = True
Ejemplo n.º 22
0
 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
Ejemplo n.º 23
0
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
Ejemplo n.º 24
0
 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)
Ejemplo n.º 25
0
 def wipe_device():
     wallet = window.wallet
     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 rubycoins in it!")
         if not self.question(
                 msg, title=title, icon=QMessageBox.Critical):
             return
     invoke_client('wipe_device', unpair_after=True)
Ejemplo n.º 26
0
 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 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 __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)
Ejemplo n.º 29
0
 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
Ejemplo n.º 30
0
 def load_wallet(self, wallet):
     if self.btchip_is_connected():
         if not self.wallet.check_proper_device():
             QMessageBox.information(
                 self.window, _("Error"), _("This wallet does not match your BTChip device"), _("OK")
             )
             self.wallet.force_watching_only = True
     else:
         QMessageBox.information(
             self.window, _("Error"), _("BTChip device not detected.\nContinuing in watching-only mode."), _("OK")
         )
         self.wallet.force_watching_only = True
    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.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
Ejemplo n.º 32
0
    def close(self):
        self.d.accept()
        if self.error:
            QMessageBox.warning(self.parent, _('Error'), self.error, _('OK'))
        else:
            if self.on_success:
                if type(self.result) is not tuple:
                    self.result = (self.result,)
                self.on_success(*self.result)

        if self.on_complete:
            self.on_complete()
Ejemplo n.º 33
0
 def __init__(self, parent):
     MyTreeWidget.__init__(self, parent, self.create_menu, [
         _('Date'),
         _('Address'), '',
         _('Description'),
         _('Amount'),
         _('Status')
     ], 3)
     self.currentItemChanged.connect(self.item_changed)
     self.itemClicked.connect(self.item_changed)
     self.setSortingEnabled(True)
     self.setColumnWidth(0, 180)
     self.hideColumn(1)
Ejemplo n.º 34
0
 def get_tooltip(self, pos, fee_rate):
     from electrum_rby.util import fee_levels
     rate_str = self.window.format_fee_rate(fee_rate) if fee_rate else _(
         'unknown')
     if self.dyn:
         tooltip = fee_levels[pos] + '\n' + rate_str
     else:
         tooltip = 'Fixed rate: ' + rate_str
         if self.config.has_fee_estimates():
             i = self.config.reverse_dynfee(fee_rate)
             tooltip += '\n' + (_('Low fee')
                                if i < 0 else 'Within %d blocks' % i)
     return tooltip
Ejemplo n.º 35
0
        def update(features):
            self.features = features
            set_label_enabled()
            bl_hash = bh2u(features.bootloader_hash)
            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)
Ejemplo n.º 36
0
 def passphrase_dialog(self):
     from electrum_rby_gui.qt.password_dialog import make_password_dialog, run_password_dialog
     d = QDialog()
     d.setModal(1)
     d.setLayout(make_password_dialog(d, None, self.message, False))
     confirmed, p, passphrase = run_password_dialog(d, None, None)
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         self.passphrase = None
     else:
         if passphrase is None:
             passphrase = '' # Even blank string is valid Trezor passphrase
         self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase))
     self.done.set()
Ejemplo n.º 37
0
 def seed_device_dialog(self):
     msg = _("Choose how to initialize your Digital Bitbox:\n")
     choices = [(_("Generate a new random wallet")),
                (_("Load a wallet from the micro SD card"))]
     try:
         reply = self.handler.win.query_choice(msg, choices)
     except Exception:
         return  # Back button pushed
     if reply == 0:
         self.dbb_generate_wallet()
     else:
         if not self.dbb_load_backup(show_msg=False):
             return
     self.isInitialized = True
 def close(self):
     if not self.saved:
         if (
             QMessageBox.question(
                 self,
                 _("Message"),
                 _("This transaction is not saved. Close anyway?"),
                 QMessageBox.Yes | QMessageBox.No,
                 QMessageBox.No,
             )
             == QMessageBox.No
         ):
             return
     self.done(0)
Ejemplo n.º 39
0
 def populate_modes(self):
     self.modes.blockSignals(True)
     self.modes.clear()
     self.modes.addItem(
         _("Summary Text PIN (requires dongle replugging)"
           ) if self.txdata['confirmationType'] ==
         1 else _("Summary Text PIN is Disabled"))
     if self.txdata['confirmationType'] > 1:
         self.modes.addItem(_("Security Card Challenge"))
         if not self.cfg['pair']:
             self.modes.addItem(_("Mobile - Not paired"))
         else:
             self.modes.addItem(_("Mobile - %s") % self.cfg['pair'][1])
     self.modes.blockSignals(False)
    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()
        own = QTextCharFormat()
        own.setBackground(QBrush(QColor("lightgreen")))
        own.setToolTip(_("Own address"))

        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] + "..." + prevout_hash[-8:] + ":%d" % prevout_n, ext)
                cursor.insertText("\t")
                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, own if self.wallet.is_mine(addr) else ext)
            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, own if self.wallet.is_mine(addr) else ext)
            if v is not None:
                cursor.insertText("\t", ext)
                cursor.insertText(self.parent.format_amount(v), ext)
            cursor.insertBlock()
        vbox.addWidget(o_text)
 def question(self, msg, yes_label=_('OK'), no_label=_('Cancel'), icon=None):
     vbox = QVBoxLayout()
     self.set_layout(vbox)
     if icon:
         logo = QLabel()
         logo.setPixmap(icon)
         vbox.addWidget(logo)
     label = QLabel(msg)
     label.setWordWrap(True)
     vbox.addWidget(label)
     vbox.addStretch(1)
     vbox.addLayout(Buttons(CancelButton(self, no_label), OkButton(self, yes_label)))
     if not self.exec_():
         return None
     return True
Ejemplo n.º 42
0
    def setup(self, address):
        label = QLabel(_("Copied your RubyCoin address to the clipboard!"))
        address_display = QLineEdit(address)
        address_display.setReadOnly(True)
        resize_line_edit_width(address_display, address)

        main_layout = QVBoxLayout(self)
        main_layout.addWidget(label)
        main_layout.addWidget(address_display)

        self.setMouseTracking(True)
        self.setWindowTitle("Electrum - " + _("Receive RubyCoin payment"))
        self.setWindowFlags(Qt.Window|Qt.FramelessWindowHint|
                            Qt.MSWindowsFixedSizeDialogHint)
        self.layout().setSizeConstraint(QLayout.SetFixedSize)
Ejemplo n.º 43
0
 def __init__(self, parent=None, msg=None):
     msg = msg or _('Please enter your password')
     WindowModalDialog.__init__(self, parent, _("Enter Password"))
     self.pw = pw = QLineEdit()
     pw.setEchoMode(2)
     vbox = QVBoxLayout()
     vbox.addWidget(QLabel(msg))
     grid = QGridLayout()
     grid.setSpacing(8)
     grid.addWidget(QLabel(_('Password')), 1, 0)
     grid.addWidget(pw, 1, 1)
     vbox.addLayout(grid)
     vbox.addLayout(Buttons(CancelButton(self), OkButton(self)))
     self.setLayout(vbox)
     run_hook('password_dialog', pw, grid, 1)
Ejemplo n.º 44
0
 def show_network_dialog(self, parent):
     if not self.daemon.network:
         parent.show_warning(_(
             'You are using Electrum in offline mode; restart Electrum if you want to get connected'
         ),
                             title=_('Offline'))
         return
     if self.nd:
         self.nd.on_update()
         self.nd.show()
         self.nd.raise_()
         return
     self.nd = NetworkDialog(self.daemon.network, self.config,
                             self.network_updated_signal_obj)
     self.nd.show()
Ejemplo n.º 45
0
 def build_tray_menu(self):
     # Avoid immediate GC of old menu when window closed via its action
     if self.tray.contextMenu() is None:
         m = QMenu()
         self.tray.setContextMenu(m)
     else:
         m = self.tray.contextMenu()
         m.clear()
     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-RBY"), self.close)
Ejemplo n.º 46
0
 def create_menu(self, position):
     item = self.currentItem()
     if not item:
         return
     is_server = not bool(item.data(0, Qt.UserRole))
     menu = QMenu()
     if is_server:
         server = item.data(1, Qt.UserRole)
         menu.addAction(_("Use as server"),
                        lambda: self.parent.follow_server(server))
     else:
         index = item.data(1, Qt.UserRole)
         menu.addAction(_("Follow this branch"),
                        lambda: self.parent.follow_branch(index))
     menu.exec_(self.viewport().mapToGlobal(position))
Ejemplo n.º 47
0
    def create_menu(self, position):
        selected = [x.data(0, Qt.UserRole) for x in self.selectedItems()]
        if not selected:
            return
        menu = QMenu()
        coins = filter(lambda x: self.get_name(x) in selected, self.utxos)

        menu.addAction(_("Spend"), lambda: self.parent.spend_coins(coins))
        if len(selected) == 1:
            txid = selected[0].split(':')[0]
            tx = self.wallet.transactions.get(txid)
            menu.addAction(_("Details"),
                           lambda: self.parent.show_transaction(tx))

        menu.exec_(self.viewport().mapToGlobal(position))
Ejemplo n.º 48
0
 def f(b):
     self.is_seed = (lambda x: bool(x)) if b else self.saved_is_seed
     self.on_edit()
     self.is_bip39 = b
     if b:
         msg = ' '.join([
             '<b>' + _('Warning') + ':</b>  ',
             _('BIP39 seeds can be imported in Electrum, so that users can access funds locked in other wallets.'),
             _('However, we do not generate BIP39 seeds, because they do not meet our safety standard.'),
             _('BIP39 seeds do not include a version number, which compromises compatibility with future software.'),
             _('We do not guarantee that BIP39 imports will always be supported in Electrum.'),
         ])
     else:
         msg = ''
     self.seed_warning.setText(msg)
 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
Ejemplo n.º 50
0
    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 on_receive(self):
        if self.wallet.use_encryption:
            password = self.win.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 self.win.question(_("An encrypted transaction was retrieved from cosigning pool.\nDo you want to open it now?")):
                return

        message = self.listener.message
        key = self.listener.keyname
        xprv = self.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)
            self.win.show_message(str(e))
            return

        self.listener.clear()
        tx = transaction.Transaction(message)
        d = transaction_dialog.TxDialog(tx, self.win)
        d.saved = False
        d.exec_()
Ejemplo n.º 52
0
 def password_dialog(self, msg):
     while True:
         password = self.handler.get_passphrase(msg, False)
         if password is None:
             return False
         if len(password) < 4:
             msg = _(
                 "Password must have at least 4 characters.\r\n\r\nEnter password:"******"Password must have less than 64 characters.\r\n\r\nEnter password:"
             )
         else:
             self.password = password.encode('utf8')
             return True
Ejemplo n.º 53
0
 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)
Ejemplo n.º 54
0
 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
Ejemplo n.º 55
0
    def create_client(self, device, handler):
        # disable bridge because it seems to never returns if keepkey is plugged
        #transport = self._try_bridge(device) or self._try_hid(device)
        transport = self._try_hid(device)
        if not transport:
            self.print_error("cannot connect to device")
            return

        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))
            self.print_error(msg)
            handler.show_error(msg)
            return None

        return client
Ejemplo n.º 56
0
 def __init__(self, change_quote_currency, parent=None):
     super(QLabel, self).__init__(_("Connecting..."), parent)
     self.change_quote_currency = change_quote_currency
     self.state = self.SHOW_CONNECTING
     self.balance_text = ""
     self.amount_text = ""
     self.parent = parent
Ejemplo n.º 57
0
    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.has_password():
            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.keystore.get_master_private_key(password)
        if not xprv:
            return
        try:
            k = bh2u(bitcoin.deserialize_xprv(xprv)[-1])
            EC = bitcoin.EC_KEY(bfh(k))
            message = bh2u(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 create_menu(self, position):
     self.selectedIndexes()
     item = self.currentItem()
     if not item:
         return
     tx_hash = str(item.data(0, Qt.UserRole).toString())
     if not tx_hash:
         return
     tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
     if not tx_URL:
         return
     menu = QMenu()
     menu.addAction(_("Copy ID to Clipboard"), lambda: self.parent.app.clipboard().setText(tx_hash))
     menu.addAction(_("Details"), lambda: self.parent.show_transaction(self.wallet.transactions.get(tx_hash)))
     menu.addAction(_("Edit description"), lambda: self.edit_label(item))
     menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
     menu.exec_(self.viewport().mapToGlobal(position))
Ejemplo n.º 59
0
 def __init__(self, parent, seed, imported_keys):
     QDialog.__init__(self, parent)
     self.setModal(1)
     self.setMinimumWidth(400)
     self.setWindowTitle("Electrum" + " - " + _("Seed"))
     vbox = show_seed_box_msg(seed)
     if imported_keys:
         vbox.addWidget(
             QLabel(
                 "<b>"
                 + _("WARNING")
                 + ":</b> "
                 + _("Your wallet contains imported keys. These keys cannot be recovered from seed.")
                 + "</b><p>"
             )
         )
     vbox.addLayout(Buttons(CloseButton(self)))
     self.setLayout(vbox)
Ejemplo n.º 60
0
    def __init__(self, data, parent=None, title = "", show_text=False):
        QDialog.__init__(self, parent)

        d = self
        d.setWindowTitle(title)
        vbox = QVBoxLayout()
        qrw = QRCodeWidget(data)
        vbox.addWidget(qrw, 1)
        if show_text:
            text = QTextEdit()
            text.setText(data)
            text.setReadOnly(True)
            vbox.addWidget(text)
        hbox = QHBoxLayout()
        hbox.addStretch(1)

        config = electrum_rby.get_config()
        if config:
            filename = os.path.join(config.path, "qrcode.bmp")

            def print_qr():
                bmp.save_qrcode(qrw.qr, filename)
                QMessageBox.information(None, _('Message'), _("QR code saved to file") + " " + filename, _('OK'))

            def copy_to_clipboard():
                bmp.save_qrcode(qrw.qr, filename)
                QApplication.clipboard().setImage(QImage(filename))
                QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK'))

            b = QPushButton(_("Copy"))
            hbox.addWidget(b)
            b.clicked.connect(copy_to_clipboard)

            b = QPushButton(_("Save"))
            hbox.addWidget(b)
            b.clicked.connect(print_qr)

        b = QPushButton(_("Close"))
        hbox.addWidget(b)
        b.clicked.connect(d.accept)
        b.setDefault(True)

        vbox.addLayout(hbox)
        d.setLayout(vbox)