Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    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 = HistoryList(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()
Exemplo 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()
Exemplo n.º 4
0
 def start_new_window(self, path, uri):
     '''Raises the window for the wallet if it is open.  Otherwise
     opens the wallet and creates a new window for it.'''
     for w in self.windows:
         if w.wallet.storage.path == path:
             w.bring_to_top()
             break
     else:
         try:
             wallet = self.daemon.load_wallet(path)
         except BaseException as e:
             QMessageBox.information(None, _('Error'), str(e), _('OK'))
             return
         if wallet is None:
             wizard = InstallWizard(self.config, self.app, self.plugins,
                                    path)
             wallet = wizard.run_and_get_wallet()
             if not wallet:
                 return
             wallet.start_threads(self.daemon.network)
             self.daemon.add_wallet(wallet)
         w = self.create_window_for_wallet(wallet)
     if uri:
         w.pay_to_URI(uri)
     return w
Exemplo n.º 5
0
 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")
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
    def create_menu(self, position):
        self.selectedIndexes()
        item = self.currentItem()
        if not item:
            return
        column = self.currentColumn()
        tx_hash = str(item.data(0, Qt.UserRole).toString())
        if not tx_hash:
            return
        if column is 0:
            column_title = "ID"
            column_data = tx_hash
        else:
            column_title = self.headerItem().text(column)
            column_data = item.text(column)

        tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
        height, conf, timestamp = self.wallet.get_tx_height(tx_hash)
        tx = self.wallet.transactions.get(tx_hash)
        is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
        rbf = is_mine and height <=0 and tx and not tx.is_final()
        menu = QMenu()

        menu.addAction(_("Copy %s")%column_title, lambda: self.parent.app.clipboard().setText(column_data))
        if column in self.editable_columns:
            menu.addAction(_("Edit %s")%column_title, lambda: self.editItem(item, column))

        menu.addAction(_("Details"), lambda: self.parent.show_transaction(tx))
        if rbf:
            menu.addAction(_("Increase fee"), lambda: self.parent.bump_fee_dialog(tx))
        if tx_URL:
            menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
        menu.exec_(self.viewport().mapToGlobal(position))
Exemplo n.º 8
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)
Exemplo n.º 9
0
 def __init__(self, parent=None):
     MyTreeWidget.__init__(
         self, parent, self.create_menu,
         [_('Output'),
          _('Address'),
          _('Label'),
          _('Amount'), ''], 2)
     self.setSelectionMode(QAbstractItemView.ExtendedSelection)
 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)
Exemplo n.º 11
0
 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 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
Exemplo n.º 13
0
 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)
Exemplo n.º 14
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 twists in it!")
         if not self.question(
                 msg, title=title, icon=QMessageBox.Critical):
             return
     invoke_client('wipe_device', unpair_after=True)
Exemplo n.º 15
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)
Exemplo n.º 16
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.set_main_layout(vbox, _('Master Public Key'))
     return None
Exemplo n.º 17
0
 def __init__(self, parent, seed, passphrase):
     WindowModalDialog.__init__(self, parent, ('Electrum - ' + _('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)))
Exemplo n.º 18
0
 def __init__(self, parent):
     MyTreeWidget.__init__(self, parent, self.create_menu, [
         _('Expires'),
         _('Requestor'),
         _('Description'),
         _('Amount'),
         _('Status')
     ], 2)
     self.setSortingEnabled(True)
     self.header().setResizeMode(1, QHeaderView.Interactive)
     self.setColumnWidth(1, 200)
Exemplo n.º 19
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
Exemplo n.º 20
0
 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-twist"), self.close)
     self.tray.setContextMenu(m)
Exemplo n.º 21
0
 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)
Exemplo n.º 22
0
 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)
     if msg:
         msg = seed_warning_msg(seed)
         self.addWidget(WWLabel(msg))
Exemplo n.º 23
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)
Exemplo n.º 24
0
 def callback_PassphraseRequest(self, req):
     if self.creating_wallet:
         msg = _("Enter a passphrase to generate this wallet.  Each time "
                 "you use this wallet your %s will prompt you for the "
                 "passphrase.  If you forget the passphrase you cannot "
                 "access the twists in the wallet.") % self.device
     else:
         msg = _("Enter the passphrase to unlock this wallet:")
     passphrase = self.handler.get_passphrase(msg, self.creating_wallet)
     if passphrase is None:
         return self.proto.Cancel()
     passphrase = bip39_normalize_passphrase(passphrase)
     return self.proto.PassphraseAck(passphrase=passphrase)
Exemplo n.º 25
0
        def update(features):
            self.features = features
            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)
Exemplo n.º 26
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)
Exemplo n.º 27
0
 def on_update(self):
     self.wallet = self.parent.wallet
     item = self.currentItem()
     current_address = item.data(0,
                                 Qt.UserRole).toString() if item else None
     self.clear()
     receiving_addresses = self.wallet.get_receiving_addresses()
     change_addresses = self.wallet.get_change_addresses()
     if True:
         account_item = self
         sequences = [0, 1] if change_addresses else [0]
         for is_change in sequences:
             if len(sequences) > 1:
                 name = _("Receiving") if not is_change else _("Change")
                 seq_item = QTreeWidgetItem([name, '', '', '', ''])
                 account_item.addChild(seq_item)
                 if not is_change:
                     seq_item.setExpanded(True)
             else:
                 seq_item = account_item
             used_item = QTreeWidgetItem([_("Used"), '', '', '', ''])
             used_flag = False
             addr_list = change_addresses if is_change else receiving_addresses
             for address in addr_list:
                 num = len(self.wallet.history.get(address, []))
                 is_used = self.wallet.is_used(address)
                 label = self.wallet.labels.get(address, '')
                 c, u, x = self.wallet.get_addr_balance(address)
                 balance = self.parent.format_amount(c + u + x)
                 address_item = QTreeWidgetItem(
                     [address, label, balance,
                      "%d" % num])
                 address_item.setFont(0, QFont(MONOSPACE_FONT))
                 address_item.setData(0, Qt.UserRole, address)
                 address_item.setData(0, Qt.UserRole + 1,
                                      True)  # label can be edited
                 if self.wallet.is_frozen(address):
                     address_item.setBackgroundColor(0, QColor('lightblue'))
                 if self.wallet.is_beyond_limit(address, is_change):
                     address_item.setBackgroundColor(0, QColor('red'))
                 if is_used:
                     if not used_flag:
                         seq_item.insertChild(0, used_item)
                         used_flag = True
                     used_item.addChild(address_item)
                 else:
                     seq_item.addChild(address_item)
                 if address == current_address:
                     self.setCurrentItem(address_item)
Exemplo n.º 28
0
    def __init__(self, config, app, plugins, storage):

        BaseWizard.__init__(self, config, storage)
        QDialog.__init__(self, None)

        self.setWindowTitle('Electrum  -  ' + _('Install Wizard'))
        self.app = app
        self.config = config

        # Set for base base class
        self.plugins = plugins
        self.language_for_seed = config.get('language')
        self.setMinimumSize(600, 400)
        self.connect(self, QtCore.SIGNAL('accept'), self.accept)
        self.title = QLabel()
        self.main_widget = QWidget()
        self.back_button = QPushButton(_("Back"), self)
        self.next_button = QPushButton(_("Next"), self)
        self.next_button.setDefault(True)
        self.logo = QLabel()
        self.please_wait = QLabel(_("Please wait..."))
        self.please_wait.setAlignment(Qt.AlignCenter)
        self.icon_filename = None
        self.loop = QEventLoop()
        self.rejected.connect(lambda: self.loop.exit(0))
        self.back_button.clicked.connect(lambda: self.loop.exit(1))
        self.next_button.clicked.connect(lambda: self.loop.exit(2))
        outer_vbox = QVBoxLayout(self)
        inner_vbox = QVBoxLayout()
        inner_vbox = QVBoxLayout()
        inner_vbox.addWidget(self.title)
        inner_vbox.addWidget(self.main_widget)
        inner_vbox.addStretch(1)
        inner_vbox.addWidget(self.please_wait)
        inner_vbox.addStretch(1)
        icon_vbox = QVBoxLayout()
        icon_vbox.addWidget(self.logo)
        icon_vbox.addStretch(1)
        hbox = QHBoxLayout()
        hbox.addLayout(icon_vbox)
        hbox.addSpacing(5)
        hbox.addLayout(inner_vbox)
        hbox.setStretchFactor(inner_vbox, 1)
        outer_vbox.addLayout(hbox)
        outer_vbox.addLayout(Buttons(self.back_button, self.next_button))
        self.set_icon(':icons/electrum-twist.png')
        self.show()
        self.raise_()
        self.refresh_gui()  # Need for QT on MacOSX.  Lame.
Exemplo n.º 29
0
    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_()
Exemplo n.º 30
0
 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)