Esempio n. 1
0
 def get_library_not_available_message(self) -> str:
     if hasattr(self, 'libraries_available_message'):
         message = self.libraries_available_message
     else:
         message = _("Missing libraries for {}.").format(self.name)
     message += '\n' + _("Make sure you install it with python3")
     return message
Esempio n. 2
0
 def get_tooltip(self, pos, fee_rate):
     mempool = self.config.use_mempool_fees()
     target, estimate = self.config.get_fee_text(pos, self.dyn, mempool, fee_rate)
     if self.dyn:
         return _('Target') + ': ' + target + '\n' + _('Current rate') + ': ' + estimate
     else:
         return _('Fixed rate') + ': ' + target + '\n' + _('Estimate') + ': ' + estimate
Esempio n. 3
0
 def toggle_passphrase(self):
     if self.features.passphrase_protection:
         self.msg = _("Confirm on your {} device to disable passphrases")
     else:
         self.msg = _("Confirm on your {} device to enable passphrases")
     enabled = not self.features.passphrase_protection
     self.apply_settings(use_passphrase=enabled)
Esempio n. 4
0
 def show_address(self, sequence, txin_type):
     client = self.get_client()
     address_path = self.get_derivation()[2:] + "/%d/%d" % sequence
     self.handler.show_message(_("Showing address ..."))
     segwit = Transaction.is_segwit_inputtype(txin_type)
     segwitNative = txin_type == 'p2wpkh'
     try:
         client.getWalletPublicKey(address_path,
                                   showOnScreen=True,
                                   segwit=segwit,
                                   segwitNative=segwitNative)
     except BTChipException as e:
         if e.sw == 0x6985:  # cancelled by user
             pass
         elif e.sw == 0x6982:
             raise  # pin lock. decorator will catch it
         elif e.sw == 0x6b00:  # hw.1 raises this
             self.handler.show_error('{}\n{}\n{}'.format(
                 _('Error showing address') + ':', e,
                 _('Your device might not have support for this functionality.'
                   )))
         else:
             traceback.print_exc(file=sys.stderr)
             self.handler.show_error(e)
     except BaseException as e:
         traceback.print_exc(file=sys.stderr)
         self.handler.show_error(e)
     finally:
         self.handler.finished()
Esempio n. 5
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()
Esempio n. 6
0
    def make_cypherseed(self, img, rawnoise, calibration=False, is_seed = True):
        img = img.convertToFormat(QImage.Format_Mono)
        p = QPainter()
        p.begin(img)
        p.setCompositionMode(26) #xor
        p.drawImage(0, 0, rawnoise)
        p.end()
        cypherseed = self.pixelcode_2x2(img)
        cypherseed = QBitmap.fromImage(cypherseed)
        cypherseed = cypherseed.scaled(self.f_size, Qt.KeepAspectRatio)
        cypherseed = self.overlay_marks(cypherseed, True, calibration)

        if not is_seed:
            self.filename = _('custom_secret')+'_'
            self.was = _('Custom secret')
        else:
            self.filename = self.wallet_name+'_'+ _('seed')+'_'
            self.was = self.wallet_name +' ' + _('seed')

        if self.has_extension:
            self.ext_warning(self.c_dialog)

        if not calibration:
            self.toPdf(QImage(cypherseed))
            QDesktopServices.openUrl (QUrl.fromLocalFile(os.path.abspath(self.base_dir+self.filename+self.version+'_'+self.code_id+'.pdf')))
            cypherseed.save(self.base_dir + self.filename +self.version + '_'+ self.code_id + '.png')
            self.bcrypt(self.c_dialog)
        return cypherseed
 def dbb_load_backup(self, show_msg=True):
     backups = self.hid_send_encrypt(b'{"backup":"list"}')
     if 'error' in backups:
         raise Exception(backups['error']['message'])
     try:
         f = self.handler.win.query_choice(_("Choose a backup file:"),
                                           backups['backup'])
     except Exception:
         return False  # Back button pushed
     key = self.backup_password_dialog()
     if key is None:
         raise Exception('Canceled by user')
     key = self.stretch_key(key)
     if show_msg:
         self.handler.show_message(
             _("Loading backup...") + "\n\n" +
             _("To continue, touch the Digital Bitbox's light for 3 seconds."
               ) + "\n\n" +
             _("To cancel, briefly touch the light or wait for the timeout."
               ))
     msg = ('{"seed":{"source": "backup", "key": "%s", "filename": "%s"}}' %
            (key, backups['backup'][f])).encode('utf8')
     hid_reply = self.hid_send_encrypt(msg)
     self.handler.finished()
     if 'error' in hid_reply:
         raise Exception(hid_reply['error']['message'])
     return True
 def show_address(self, wallet, address, keystore=None):
     if keystore is None:
         keystore = wallet.get_keystore()
     if not self.show_address_helper(wallet, address, keystore):
         return
     if type(wallet) is not Standard_Wallet:
         keystore.handler.show_error(
             _('This function is only available for standard wallets when using {}.'
               ).format(self.device))
         return
     if not self.is_mobile_paired():
         keystore.handler.show_error(
             _('This function is only available after pairing your {} with a mobile device.'
               ).format(self.device))
         return
     if not keystore.is_p2pkh():
         keystore.handler.show_error(
             _('This function is only available for p2pkh keystores when using {}.'
               ).format(self.device))
         return
     change, index = wallet.get_address_index(address)
     keypath = '%s/%d/%d' % (keystore.derivation, change, index)
     xpub = self.get_client(keystore)._get_xpub(keypath)
     verify_request_payload = {
         "type": 'p2pkh',
         "echo": xpub['echo'],
     }
     self.comserver_post_notification(verify_request_payload)
 def create_menu(self, position):
     item = self.itemAt(position)
     if not item:
         return
     addr = str(item.text(1))
     req = self.wallet.receive_requests.get(addr)
     if req is None:
         self.update()
         return
     column = self.currentColumn()
     column_title = self.headerItem().text(column)
     column_data = item.text(column)
     menu = QMenu(self)
     menu.addAction(
         _("Copy {}").format(column_title),
         lambda: self.parent.app.clipboard().setText(column_data))
     menu.addAction(
         _("Copy URI"), lambda: self.parent.view_and_paste(
             'URI', '', self.parent.get_request_URI(addr)))
     menu.addAction(_("Save as BIP70 file"),
                    lambda: self.parent.export_payment_request(addr))
     menu.addAction(_("Delete"),
                    lambda: self.parent.delete_payment_request(addr))
     run_hook('receive_list_menu', menu, addr)
     menu.exec_(self.viewport().mapToGlobal(position))
Esempio n. 10
0
    def __init__(self, parent):
        super(MatrixDialog, self).__init__(parent)
        self.setWindowTitle(_("Trezor Matrix Recovery"))
        self.num = 9
        self.loop = QEventLoop()

        vbox = QVBoxLayout(self)
        vbox.addWidget(WWLabel(MATRIX_RECOVERY))

        grid = QGridLayout()
        grid.setSpacing(0)
        self.char_buttons = []
        for y in range(3):
            for x in range(3):
                button = QPushButton('?')
                button.clicked.connect(
                    partial(self.process_key,
                            ord('1') + y * 3 + x))
                grid.addWidget(button, 3 - y, x)
                self.char_buttons.append(button)
        vbox.addLayout(grid)

        self.backspace_button = QPushButton("<=")
        self.backspace_button.clicked.connect(
            partial(self.process_key, Qt.Key_Backspace))
        self.cancel_button = QPushButton(_("Cancel"))
        self.cancel_button.clicked.connect(
            partial(self.process_key, Qt.Key_Escape))
        buttons = Buttons(self.backspace_button, self.cancel_button)
        vbox.addSpacing(40)
        vbox.addLayout(buttons)
        self.refresh()
        self.show()
Esempio n. 11
0
 def set_pin(self, remove):
     if remove:
         self.msg = _("Confirm on your {} device to disable PIN protection")
     elif self.features.pin_protection:
         self.msg = _("Confirm on your {} device to change your PIN")
     else:
         self.msg = _("Confirm on your {} device to set a PIN")
     self.change_pin(remove)
Esempio n. 12
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)
Esempio n. 13
0
 def setup_device(self, device_info, wizard, purpose):
     devmgr = self.device_manager()
     device_id = device_info.device.id_
     client = devmgr.client_by_id(device_id)
     if client is None:
         raise Exception(
             _('Failed to create a client for this device.') + '\n' +
             _('Make sure it is in the correct state.'))
     client.handler = self.create_handler(wizard)
Esempio n. 14
0
 def create_password_layout(self, wallet, is_encrypted, OK_button):
     if not is_encrypted:
         msg = _('Your wallet file is NOT encrypted.')
     else:
         msg = _('Your wallet file is encrypted.')
     msg += '\n' + _(
         'Note: If you enable this setting, you will need your hardware device to open your wallet.'
     )
     msg += '\n' + _('Use this dialog to toggle encryption.')
     self.playout = PasswordLayoutForHW(wallet, msg, PW_CHANGE, OK_button)
Esempio n. 15
0
 def create_toolbar_buttons(self):
     self.period_combo = QComboBox()
     self.start_button = QPushButton('-')
     self.start_button.pressed.connect(self.select_start_date)
     self.start_button.setEnabled(False)
     self.end_button = QPushButton('-')
     self.end_button.pressed.connect(self.select_end_date)
     self.end_button.setEnabled(False)
     self.period_combo.addItems([_('All'), _('Custom')])
     self.period_combo.activated.connect(self.on_combo)
 def export(self):
     name = 'signed_%s.txn' % (
         self.tx.txid()[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 exported successfully"))
         self.saved = True
Esempio n. 17
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 litecoins in it!")
         if not self.question(
                 msg, title=title, icon=QMessageBox.Critical):
             return
     invoke_client('wipe_device', unpair_after=True)
 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()
         try:
             dialogs.remove(self)
         except ValueError:
             pass  # was not in list already
 def show_qr(self):
     text = bfh(str(self.tx))
     text = base_encode(text, base=43)
     try:
         self.main_window.show_qrcode(text, 'Transaction', parent=self)
     except qrcode.exceptions.DataOverflowError:
         self.show_error(
             _('Failed to display QR code.') + '\n' +
             _('Transaction is too large in size.'))
     except Exception as e:
         self.show_error(_('Failed to display QR code.') + '\n' + str(e))
Esempio n. 20
0
 def setup_device(self, device_info, wizard, purpose):
     devmgr = self.device_manager()
     device_id = device_info.device.id_
     client = devmgr.client_by_id(device_id)
     if client is None:
         raise Exception(
             _('Failed to create a client for this device.') + '\n' +
             _('Make sure it is in the correct state.'))
     client.handler = self.create_handler(wizard)
     client.get_xpub(
         "m/44'/2'",
         'standard')  # TODO replace by direct derivation once Nano S > 1.1
Esempio n. 21
0
 def setup_device(self, device_info, wizard, purpose):
     devmgr = self.device_manager()
     device_id = device_info.device.id_
     client = devmgr.client_by_id(device_id)
     if client is None:
         raise Exception(
             _('Failed to create a client for this device.') + '\n' +
             _('Make sure it is in the correct state.'))
     client.handler = self.create_handler(wizard)
     if purpose == HWD_SETUP_NEW_WALLET:
         client.setupRunning = True
     client.get_xpub("m/44'/2'", 'standard')
Esempio n. 22
0
def trezor_validate_op_return_output_and_get_data(output: TxOutput) -> bytes:
    if output.type != TYPE_SCRIPT:
        raise Exception("Unexpected output type: {}".format(output.type))
    script = bfh(output.address)
    if not (script[0] == opcodes.OP_RETURN and script[1] == len(script) - 2
            and script[1] <= 75):
        raise Exception(
            _("Only OP_RETURN scripts, with one constant push, are supported.")
        )
    if output.value != 0:
        raise Exception(_("Amount for OP_RETURN output must be zero."))
    return script[2:]
Esempio n. 23
0
 def plot_history_dialog(self):
     if plot_history is None:
         self.parent.show_message(
             _("Can't plot history.") + '\n' +
             _("Perhaps some dependencies are missing...") +
             " (matplotlib?)")
         return
     try:
         plt = plot_history(self.transactions)
         plt.show()
     except NothingToPlotException as e:
         self.parent.show_message(str(e))
Esempio n. 24
0
 def show_address_helper(self, wallet, address, keystore=None):
     if keystore is None:
         keystore = wallet.get_keystore()
     if not is_address(address):
         keystore.handler.show_error(_('Invalid GameCredits Address'))
         return False
     if not wallet.is_mine(address):
         keystore.handler.show_error(_('Address not in wallet.'))
         return False
     if type(keystore) != self.keystore_class:
         return False
     return True
Esempio n. 25
0
 def dbb_erase(self):
     self.handler.show_message(
         _("Are you sure you want to erase the Digital Bitbox?") + "\n\n" +
         _("To continue, touch the Digital Bitbox's light for 3 seconds.") +
         "\n\n" +
         _("To cancel, briefly touch the light or wait for the timeout."))
     hid_reply = self.hid_send_encrypt(b'{"reset":"__ERASE__"}')
     self.handler.finished()
     if 'error' in hid_reply:
         raise Exception(hid_reply['error']['message'])
     else:
         self.password = None
         raise Exception('Device erased')
Esempio n. 26
0
 def setup_device(self, device_info, wizard, purpose):
     devmgr = self.device_manager()
     device_id = device_info.device.id_
     client = devmgr.client_by_id(device_id)
     if client is None:
         raise Exception(_('Failed to create a client for this device.') + '\n' +
                         _('Make sure it is in the correct state.'))
     # fixme: we should use: client.handler = wizard
     client.handler = self.create_handler(wizard)
     if not device_info.initialized:
         self.initialize_device(device_id, wizard, client.handler)
     client.get_xpub('m', 'standard')
     client.used()
Esempio n. 27
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)
Esempio n. 28
0
def import_meta_gui(electrum_window, title, importer, on_success):
    filter_ = "JSON (*.json);;All files (*)"
    filename = electrum_window.getOpenFileName(
        _("Open {} file").format(title), filter_)
    if not filename:
        return
    try:
        importer(filename)
    except FileImportFailed as e:
        electrum_window.show_critical(str(e))
    else:
        electrum_window.show_message(
            _("Your {} were successfully imported").format(title))
        on_success()
Esempio n. 29
0
def export_meta_gui(electrum_window, title, exporter):
    filter_ = "JSON (*.json);;All files (*)"
    filename = electrum_window.getSaveFileName(
        _("Select file to save your {}").format(title),
        'electrum-game_{}.json'.format(title), filter_)
    if not filename:
        return
    try:
        exporter(filename)
    except FileExportFailed as e:
        electrum_window.show_critical(str(e))
    else:
        electrum_window.show_message(
            _("Your {0} were exported to '{1}'").format(title, str(filename)))