예제 #1
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)
예제 #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 __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)
예제 #4
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)
예제 #5
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)
예제 #6
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)
예제 #7
0
 def __init__(self, parent=None):
     MyTreeWidget.__init__(self, parent, self.create_menu, [
         _('Address'),
         _('Label'),
         _('Amount'),
         _('Height'),
         _('Output point')
     ], 1)
     self.setSelectionMode(QAbstractItemView.ExtendedSelection)
예제 #8
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
예제 #9
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,is_bip39_145 = self.seed_input(title, message, test, None)
     return seed
예제 #10
0
 def __init__(self, parent):
     MyTreeWidget.__init__(self, parent, self.create_menu, [
         _('Expires'),
         _('Requestor'),
         _('Description'),
         _('Amount'),
         _('Status')
     ], 2)
     self.setSortingEnabled(True)
     self.header().setSectionResizeMode(1, QHeaderView.Interactive)
     self.setColumnWidth(1, 200)
예제 #11
0
 def restore_seed_dialog(self, run_next, test):
     options = []
     if self.opt_ext:
         options.append('ext')
     if self.opt_bip39:
         options.append('bip39')
     if self.opt_bip39_145:
         options.append('bip39_145')
     title = _('Enter Seed')
     message = _('Please enter your seed phrase in order to restore your wallet.')
     return self.seed_input(title, message, test, options)
예제 #12
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)
     self.seed_warning = WWLabel('')
     if msg:
         self.seed_warning.setText(seed_warning_msg(seed))
     self.addWidget(self.seed_warning)
예제 #13
0
 def __init__(self, parent, seed, passphrase):
     WindowModalDialog.__init__(self, parent,
                                ('Bitcoin Nano - ' + _('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)))
예제 #14
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)
예제 #15
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 bitcoins 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)
예제 #16
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:
         tx_dict = self.tx.as_dict()
         input_values = [x['value'] for x in self.tx.inputs()]
         tx_dict['input_values'] = input_values
         with open(fileName, "w+") as f:
             f.write(json.dumps(tx_dict, indent=4) + '\n')
         self.show_message(_("Transaction saved successfully"))
         self.saved = True
예제 #17
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)
예제 #18
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
예제 #19
0
    def __init__(self,
                 data,
                 parent=None,
                 title="Bitcoin Nano",
                 show_text=False):
        WindowModalDialog.__init__(self, parent, title)

        vbox = QVBoxLayout()
        qrw = QRCodeWidget(data)
        qscreen = QApplication.primaryScreen()
        vbox.addWidget(qrw, 1)
        if show_text:
            text = QTextEdit()
            text.setText(data)
            text.setReadOnly(True)
            vbox.addWidget(text)
        hbox = QHBoxLayout()
        hbox.addStretch(1)

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

            def print_qr():
                p = qscreen.grabWindow(qrw.winId())
                p.save(filename, 'png')
                self.show_message(_("QR code saved to file") + " " + filename)

            def copy_to_clipboard():
                p = qscreen.grabWindow(qrw.winId())
                p.save(filename, 'png')
                QApplication.clipboard().setImage(QImage(filename))
                self.show_message(_("QR code copied to clipboard"))

            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(self.accept)
        b.setDefault(True)

        vbox.addLayout(hbox)
        self.setLayout(vbox)
예제 #20
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))
예제 #21
0
 def show_network_dialog(self, parent):
     if not self.daemon.network:
         parent.show_warning(_(
             'You are using Bitcoin Nano in offline mode; restart Bitcoin Nano 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()
예제 #22
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)
예제 #23
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))
예제 #24
0
 def on_update(self):
     self.wallet = self.parent.wallet
     item = self.currentItem()
     current_address = str(item.data(0, Qt.UserRole)) 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.setBackground(0, QColor('lightblue'))
                 if self.wallet.is_beyond_limit(address, is_change):
                     address_item.setBackground(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)
예제 #25
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
예제 #26
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 Bitcoin Nano"), self.close)
     self.tray.setContextMenu(m)
예제 #27
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)
예제 #28
0
    def receive_menu(self, menu, addrs, wallet):
        if type(wallet) is not Standard_Wallet:
            return

        keystore = wallet.get_keystore()
        if type(keystore) is not self.keystore_class:
            return

        if not self.is_mobile_paired():
            return

        if not keystore.is_p2pkh():
            return

        if len(addrs) == 1:

            def show_address():
                change, index = wallet.get_address_index(addrs[0])
                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)

            menu.addAction(_("Show on %s") % self.device, show_address)
예제 #29
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
예제 #30
0
    def __init__(self, win):
        QWidget.__init__(self)
        self.win = win
        self.setWindowTitle('Bitcoin Nano - ' + _('Payment Request'))
        self.setMinimumSize(800, 250)
        self.address = ''
        self.label = ''
        self.amount = 0
        self.setFocusPolicy(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)