示例#1
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)
示例#2
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)
示例#3
0
    def on_reset_auth(self, wizard, short_id, seed, passphrase, xpub3):
        xprv1, xpub1, xprv2, xpub2 = self.xkeys_from_seed(seed, passphrase)
        try:
            assert xpub1 == wizard.storage.get('x1/')['xpub']
            assert xpub2 == wizard.storage.get('x2/')['xpub']
        except:
            wizard.show_message(_('Incorrect seed'))
            return
        r = server.get_challenge(short_id)
        challenge = r.get('challenge')
        message = 'TRUSTEDCOIN CHALLENGE: ' + challenge
        def f(xprv):
            _, _, _, _, c, k = deserialize_xprv(xprv)
            pk = bip32_private_key([0, 0], k, c)
            key = regenerate_key(pk)
            compressed = is_compressed(pk)
            sig = key.sign_message(message, compressed)
            return base64.b64encode(sig)

        signatures = [f(x) for x in [xprv1, xprv2]]
        r = server.reset_auth(short_id, challenge, signatures)
        new_secret = r.get('otp_secret')
        if not new_secret:
            wizard.show_message(_('Request rejected by server'))
            return
        self.check_otp(wizard, short_id, new_secret, xpub3)
示例#4
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):
             if b:
                 msg = ' '.join([
                     '<b>' + _('Warning') + '</b>' + ': ',
                     _('BIP39 seeds may not be supported in the future.'),
                     '<br/><br/>',
                     _('As technology matures, Bitcoin address generation may change.'),
                     _('However, BIP39 seeds do not include a version number.'),
                     _('As a result, it is not possible to infer your wallet type from a BIP39 seed.'),
                     '<br/><br/>',
                     _('We do not guarantee that BIP39 seeds will be supported in future versions of Electrum.'),
                     _('We recommend to use seeds generated by Electrum or compatible wallets.'),
                 ])
                 #self.parent.show_warning(msg)
             self.seed_type_label.setVisible(not b)
             self.is_seed = (lambda x: bool(x)) if b else self.saved_is_seed
             self.on_edit()
         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
示例#5
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.is_bip39 = b
             self.on_edit()
             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
示例#6
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()
示例#7
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)
示例#8
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)
示例#9
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()
示例#10
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['type'] == '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)
示例#11
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)
示例#12
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)
示例#13
0
 def choose_seed(self, wizard):
     title = _('Create or restore')
     message = _('Do you want to create a new seed, or to restore a wallet using an existing seed?')
     choices = [
         ('create_seed', _('Create a new seed')),
         ('restore_wallet', _('I already have a seed')),
     ]
     wizard.choice_dialog(title=title, message=message, choices=choices, run_next=wizard.run)
示例#14
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)))
示例#15
0
 def __init__(self, parent=None):
     MyTreeWidget.__init__(
         self, parent, self.create_menu,
         [_('Address'),
          _('Output point'),
          _('Label'),
          _('Amount'), ''], 2)
     self.setSelectionMode(QAbstractItemView.ExtendedSelection)
示例#16
0
 def __init__(self, text="", allow_multi=False):
     ButtonsTextEdit.__init__(self, text)
     self.allow_multi = allow_multi
     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)
示例#17
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
示例#18
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)
示例#19
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 argentums in it!")
         if not self.question(
                 msg, title=title, icon=QMessageBox.Critical):
             return
     invoke_client('wipe_device', unpair_after=True)
示例#20
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)
示例#21
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
示例#22
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)
示例#23
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
示例#24
0
 def load_wallet(self, wallet, window):
     if type(wallet) != BTChipWallet:
         return
     wallet.handler = BTChipQTHandler(window)
     if self.btchip_is_connected(wallet):
         if not wallet.check_proper_device():
             window.show_error(_("This wallet does not match your Ledger device"))
             wallet.force_watching_only = True
     else:
         window.show_error(_("Ledger device not detected.\nContinuing in watching-only mode."))
         wallet.force_watching_only = True
示例#25
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)
示例#26
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)
示例#27
0
 def backup_password_dialog(self):
     msg = _("Enter the password used when the backup was created:")
     while True:
         password = self.handler.get_passphrase(msg, False)
         if password is None:
             return None
         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:
             return password.encode('utf8')
示例#28
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
示例#29
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)
示例#30
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 (Argentum)"), self.close)
     self.tray.setContextMenu(m)