Ejemplo n.º 1
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'))
     else:
         QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK'))
    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.º 3
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.º 4
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-IXC"), self.close)
     self.tray.setContextMenu(m)
Ejemplo n.º 5
0
 def qr_input(self):
     from electrum_ixc import qrscanner
     try:
         data = qrscanner.scan_qr(self.win.config)
     except BaseException, e:
         QMessageBox.warning(self, _('Error'), _(e), _('OK'))
         return ""
    def add_io(self, vbox):

        if self.tx.locktime > 0:
            vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime))

        vbox.addWidget(QLabel(_("Inputs")))
        def format_input(x):
            if x.get('is_coinbase'):
                return 'coinbase'
            else:
                _hash = x.get('prevout_hash')
                return _hash[0:8] + '...' + _hash[-8:] + ":%d"%x.get('prevout_n') + u'\t' + "%s"%x.get('address')
        lines = map(format_input, self.tx.inputs )
        i_text = QTextEdit()
        i_text.setFont(QFont(MONOSPACE_FONT))
        i_text.setText('\n'.join(lines))
        i_text.setReadOnly(True)
        i_text.setMaximumHeight(100)
        vbox.addWidget(i_text)

        vbox.addWidget(QLabel(_("Outputs")))
        lines = map(lambda x: x[0] + u'\t\t' + self.parent.format_amount(x[1]) if x[1] else x[0], self.tx.get_outputs())
        o_text = QTextEdit()
        o_text.setFont(QFont(MONOSPACE_FONT))
        o_text.setText('\n'.join(lines))
        o_text.setReadOnly(True)
        o_text.setMaximumHeight(100)
        vbox.addWidget(o_text)
Ejemplo n.º 7
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_()
 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"))
Ejemplo n.º 9
0
 def callback_PassphraseRequest(self, msg):
     confirmed, p, passphrase = self.password_dialog()
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return proto.Cancel()
     if passphrase is None:
         passphrase='' # Even blank string is valid Trezor passphrase
     return proto.PassphraseAck(passphrase=passphrase)
Ejemplo n.º 10
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)                
Ejemplo n.º 11
0
 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.º 12
0
def show_seed_box(seed, sid=None):

    save_msg = _("Please save these %d words on paper (order is important).") % len(seed.split()) + " "
    qr_msg = _("Your seed is also displayed as QR code, in case you want to transfer it to a mobile phone.") + "<p>"
    warning_msg = (
        "<b>" + _("WARNING") + ":</b> " + _("Never disclose your seed. Never type it on a website.") + "</b><p>"
    )

    if sid is None:
        msg = _("Your wallet generation seed is")
        msg2 = (
            save_msg
            + " "
            + _("This seed will allow you to recover your wallet in case of computer failure.")
            + "<br/>"
            + warning_msg
        )

    elif sid == "cold":
        msg = _("Your cold storage seed is")
        msg2 = (
            save_msg
            + " "
            + _(
                "This seed will be permanently deleted from your wallet file. Make sure you have saved it before you press 'next'"
            )
            + " "
        )
    elif sid == "hot":
        msg = _("Your hot seed is")
        msg2 = (
            save_msg
            + " "
            + _("If you ever need to recover your wallet from seed, you will need both this seed and your cold seed.")
            + " "
        )
    label1 = QLabel(msg + ":")
    seed_text = ShowQRTextEdit(text=seed)
    seed_text.setMaximumHeight(130)

    label2 = QLabel(msg2)
    label2.setWordWrap(True)

    logo = QLabel()
    logo.setPixmap(QPixmap(icon_filename(sid)).scaledToWidth(56))
    logo.setMaximumWidth(60)

    grid = QGridLayout()
    grid.addWidget(logo, 0, 0)
    grid.addWidget(label1, 0, 1)
    grid.addWidget(seed_text, 1, 0, 1, 2)
    vbox = QVBoxLayout()
    vbox.addLayout(grid)
    vbox.addWidget(label2)
    vbox.addStretch(1)

    return vbox
Ejemplo n.º 13
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.º 14
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
Ejemplo n.º 15
0
 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)
         for i,width in enumerate(self.win.column_widths['history']):
             self.win.history_list.setColumnWidth(i, width)
Ejemplo n.º 16
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
Ejemplo n.º 17
0
 def __init__(self, parent, seed, imported_keys):
     QDialog.__init__(self, parent)
     self.setModal(1)
     self.setMinimumWidth(400)
     self.setWindowTitle('Electrum-IXC' + ' - ' + _('Seed'))
     vbox = show_seed_box(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(close_button(self))
     self.setLayout(vbox)
Ejemplo n.º 18
0
    def restore_or_create(self):
        vbox = QVBoxLayout()
        main_label = QLabel(_("Electrum-IXC 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 an existing wallet"))
        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)
        hbox, button = ok_cancel_buttons2(self, _('Next'))
        vbox.addLayout(hbox)
        self.set_layout(vbox)
        self.show()
        self.raise_()
        button.setDefault(True)

        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.º 19
0
from electrum_ixc import Wallet, Wallet_2of2, Wallet_2of3
from electrum_ixc import bitcoin
from electrum_ixc import util

import seed_dialog
from network_dialog import NetworkDialog
from util import *
from amountedit import AmountEdit

import sys
import threading
from electrum_ixc.plugins import run_hook
from electrum_ixc.mnemonic import prepare_seed

MSG_ENTER_ANYTHING = _(
    "Please enter a wallet seed, a master public key, a list of Ixcoin addresses, or a list of private keys"
)
MSG_SHOW_MPK = _("This is your master public key")
MSG_ENTER_MPK = _("Please enter your master public key")
MSG_ENTER_COLD_MPK = _(
    "Please enter the master public key of your cosigner wallet")
MSG_ENTER_SEED_OR_MPK = _("Please enter a wallet seed, or master public key")
MSG_VERIFY_SEED = _("Your seed is important!") + "\n" + _(
    "To make sure that you have properly saved your seed, please retype it here."
)


class InstallWizard(QDialog):
    def __init__(self, config, network, storage):
        QDialog.__init__(self)
        self.config = config
Ejemplo n.º 20
0
    def run(self, action):

        if action == 'new':
            action, wallet_type = self.restore_or_create()
            if wallet_type == 'multisig':
                wallet_type = self.choice(_("Multi Signature Wallet"),
                                          'Select wallet type',
                                          [('2of2', _("2 of 2")),
                                           ('2of3', _("2 of 3"))])
                if not wallet_type:
                    return
            elif wallet_type == 'hardware':
                hardware_wallets = map(
                    lambda x: (x[1], x[2]),
                    filter(lambda x: x[0] == 'hardware',
                           electrum.wallet.wallet_types))
                wallet_type = self.choice(_("Hardware Wallet"),
                                          'Select your hardware wallet',
                                          hardware_wallets)
                if not wallet_type:
                    return
            elif wallet_type == 'twofactor':
                wallet_type = '2fa'

            if action == 'create':
                self.storage.put('wallet_type', wallet_type, False)

        if action is None:
            return

        if action == 'restore':
            wallet = self.restore(wallet_type)
            if not wallet:
                return
            action = None
        else:
            wallet = Wallet(self.storage)
            action = wallet.get_action()
            # fixme: password is only needed for multiple accounts
            password = None

        while action is not None:
            util.print_error("installwizard:", wallet, action)

            if action == 'create_seed':
                seed = wallet.make_seed()
                if not self.show_seed(seed, None):
                    return
                if not self.verify_seed(seed, None):
                    return
                password = self.password_dialog()
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)

            elif action == 'add_cosigner':
                xpub1 = wallet.master_public_keys.get("x1/")
                r = self.multi_mpk_dialog(xpub1, 1)
                if not r:
                    return
                xpub2 = r[0]
                wallet.add_master_public_key("x2/", xpub2)

            elif action == 'add_two_cosigners':
                xpub1 = wallet.master_public_keys.get("x1/")
                r = self.multi_mpk_dialog(xpub1, 2)
                if not r:
                    return
                xpub2, xpub3 = r
                wallet.add_master_public_key("x2/", xpub2)
                wallet.add_master_public_key("x3/", xpub3)

            elif action == 'create_accounts':
                try:
                    wallet.create_main_account(password)
                except BaseException as e:
                    import traceback
                    traceback.print_exc(file=sys.stdout)
                    QMessageBox.information(None, _('Error'), str(e), _('OK'))
                    return
                self.waiting_dialog(wallet.synchronize)

            else:
                f = run_hook('get_wizard_action', self, wallet, action)
                if not f:
                    raise BaseException('unknown wizard action', action)
                r = f(wallet, self)
                if not r:
                    return

            # next action
            action = wallet.get_action()

        if self.network:
            if self.network.interfaces:
                self.network_dialog()
            else:
                QMessageBox.information(None, _('Warning'),
                                        _('You are offline'), _('OK'))
                self.network.stop()
                self.network = None

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':
            self.waiting_dialog(
                lambda: wallet.restore(self.waiting_label.setText))
            if self.network:
                msg = _("Recovery successful") if wallet.is_found() else _(
                    "No transactions found for this seed")
            else:
                msg = _(
                    "This wallet was restored offline. It may contain more addresses than displayed."
                )
            QMessageBox.information(None, _('Information'), msg, _('OK'))

        return wallet
Ejemplo n.º 21
0
 def password_dialog(self):
     msg = _("Please choose a password to encrypt your wallet keys.")+'\n'\
           +_("Leave these fields empty if you want to disable encryption.")
     from password_dialog import make_password_dialog, run_password_dialog
     self.set_layout(make_password_dialog(self, None, msg))
     return run_password_dialog(self, None, self)[2]
Ejemplo n.º 22
0
 def show_seed(self, seed, sid):
     vbox = seed_dialog.show_seed_box(seed, sid)
     vbox.addLayout(ok_cancel_buttons(self, _("Next")))
     self.set_layout(vbox)
     return self.exec_()