Example #1
0
 def passphrase_dialog(self, msg, confirm):
     # If confirm is true, require the user to enter the passphrase twice
     parent = self.top_level_window()
     d = WindowModalDialog(parent, _("Enter Passphrase"))
     if confirm:
         OK_button = OkButton(d)
         playout = PasswordLayout(msg=msg,
                                  kind=PW_PASSPHRASE,
                                  OK_button=OK_button)
         vbox = QVBoxLayout()
         vbox.addLayout(playout.layout())
         vbox.addLayout(Buttons(CancelButton(d), OK_button))
         d.setLayout(vbox)
         passphrase = playout.new_password() if d.exec_() else None
     else:
         pw = QLineEdit()
         pw.setEchoMode(2)
         pw.setMinimumWidth(200)
         vbox = QVBoxLayout()
         vbox.addWidget(WWLabel(msg))
         vbox.addWidget(pw)
         vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
         d.setLayout(vbox)
         passphrase = pw.text() if d.exec_() else None
     self.passphrase = passphrase
     self.done.set()
Example #2
0
 def message_dialog(self, msg, on_cancel):
     # Called more than once during signing, to confirm output and fee
     self.clear_dialog()
     title = _('Please check your {} device').format(self.device)
     self.dialog = dialog = WindowModalDialog(self.top_level_window(), title)
     l = QLabel(msg)
     vbox = QVBoxLayout(dialog)
     vbox.addWidget(l)
     if on_cancel:
         dialog.rejected.connect(on_cancel)
         vbox.addLayout(Buttons(CancelButton(dialog)))
     dialog.show()
Example #3
0
 def pin_dialog(self, msg, show_strength):
     # Needed e.g. when resetting a device
     self.clear_dialog()
     dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN"))
     matrix = self.pin_matrix_widget_class(show_strength)
     vbox = QVBoxLayout()
     vbox.addWidget(QLabel(msg))
     vbox.addWidget(matrix)
     vbox.addLayout(Buttons(CancelButton(dialog), OkButton(dialog)))
     dialog.setLayout(vbox)
     dialog.exec_()
     self.response = str(matrix.get_value())
     self.done.set()
Example #4
0
    def pin_dialog(self, msg):
        # Needed e.g. when resetting a device
        from trezorlib.qt.pinmatrix import PinMatrixWidget

        self.clear_dialog()
        dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN"))
        matrix = PinMatrixWidget()
        vbox = QVBoxLayout()
        vbox.addWidget(QLabel(msg))
        vbox.addWidget(matrix)
        vbox.addLayout(Buttons(CancelButton(dialog), OkButton(dialog)))
        dialog.setLayout(vbox)
        dialog.exec_()
        self.response = str(matrix.get_value())
        self.done.set()
Example #5
0
 def auth_dialog(self, window):
     d = WindowModalDialog(window, _("Authorization"))
     vbox = QVBoxLayout(d)
     pw = AmountEdit(None, is_int = True)
     msg = _('Please enter your Google Authenticator code')
     vbox.addWidget(QLabel(msg))
     grid = QGridLayout()
     grid.setSpacing(8)
     grid.addWidget(QLabel(_('Code')), 1, 0)
     grid.addWidget(pw, 1, 1)
     vbox.addLayout(grid)
     msg = _('If you have lost your second factor, you need to restore your wallet from seed in order to request a new code.')
     label = QLabel(msg)
     label.setWordWrap(1)
     vbox.addWidget(label)
     vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
     if not d.exec_():
         return
     return pw.get_amount()
Example #6
0
    def __init__(self, *, window: 'ElectrumWindow', txs, password, is_sweep):

        WindowModalDialog.__init__(self, window,
                                   _('BitPost Transactions Preview'))
        self.setMinimumSize(800, 600)
        self.main_window = window
        self.txs = txs
        self.password_required = self.main_window.wallet.has_keystore_encryption(
        ) and not is_sweep
        self.is_send = False
        vbox = QVBoxLayout()
        self.setLayout(vbox)
        lbox = QListWidget()

        items = []
        for tx in txs:
            inputs = tx.inputs()
            outputs = tx.outputs()
            fee = tx.get_fee()
            fiat = False

            text = "fee: {}".format(fee)
            if self.main_window.fx and self.main_window.fx.is_enabled():
                fiat = Exchange(self.main_window.fx)
                text += fiat.str_exchange(fee)

            text += "\t\tvbyte: {}\n".format(tx.estimated_size())

            tmp = "fee/vbyte: {}".format(round(fee / tx.estimated_size(), 2))
            if fiat:
                tmp += fiat.str_exchange(fee / tx.estimated_size())
            text += tmp
            if len(tmp) > 22:
                tab = "\t"
            else:
                tab = "\t\t"

            text += "{}total size: {}\n".format(tab, tx.estimated_total_size())

            text += "INPUTS:\n"
            for i in inputs:
                text += "{}:{} = {}".format(i.prevout.txid.hex(),
                                            i.prevout.out_idx, i.value_sats())
                if fiat:
                    text += fiat.str_exchange(i.value_sats())
                text += "\n"
            text += "OUTPUTS:\n"
            for o in outputs:
                text += "{} = {}".format(o.address, o.value)
                if fiat:
                    text += fiat.str_exchange(o.value)
                text += "\n"

            items.append(text)

        lbox.addItems(items)
        vbox.addWidget(lbox)

        self.send_button = QPushButton(_('Send'))
        self.send_button.clicked.connect(self.on_send)
        self.send_button.setDefault(True)

        self.pw_label = QLabel(_('Password'))
        self.pw_label.setVisible(self.password_required)
        self.pw = PasswordLineEdit(password)
        self.pw.setVisible(self.password_required)

        vbox.addLayout(
            Buttons(CancelButton(self), self.pw_label, self.pw,
                    self.send_button))
Example #7
0
    def build_gui(self):
        vbox = QVBoxLayout()
        self.setLayout(vbox)
        grid = QGridLayout()
        vbox.addLayout(grid)
        self.amount_label = QLabel('')

        grid.addWidget(QLabel(_("Target for confirmation")), 0, 0)
        self.qtarget = QDateTimeEdit(QDateTime.currentDateTime().addSecs(
            int(self.main_window.config.get('bitpost_target_interval')) * 60))
        grid.addWidget(self.qtarget, 0, 1)

        self.asap_check = QCheckBox("ASAP")
        self.asap_check.clicked.connect(self.toggle_target)
        grid.addWidget(self.asap_check, 0, 2)

        grid.addWidget(QLabel(_("Maximum Fee")), 2, 0)
        self.max_fees = QLineEdit(
            str(self.main_window.config.get('bitpost_max_fee')))
        self.max_fees.textChanged.connect(self.change_max_fees)
        grid.addWidget(self.max_fees, 2, 1)
        self.fee_combo = QComboBox()
        fee_combo_values = get_fee_units(
            self.main_window,
            self.main_window.config.get('bitpost_max_fee_unit'))
        self.fee_combo.addItems(fee_combo_values)
        grid.addWidget(self.fee_combo, 2, 2)

        self.schedule_check = QCheckBox(_("Schedule transaction"))
        self.schedule_check.clicked.connect(self.toggle_delay)
        grid.addWidget(self.schedule_check, 3, 0, 1, -1)
        self.qdelay = QDateTimeEdit(QDateTime.currentDateTime())
        grid.addWidget(self.qdelay, 4, 0)
        sp_retain = QSizePolicy(self.qdelay.sizePolicy())
        sp_retain.setRetainSizeWhenHidden(True)
        self.qdelay.setSizePolicy(sp_retain)
        self.qdelay.setVisible(False)

        self.message_label = QLabel(self.default_message())
        grid.addWidget(self.message_label, 9, 0, 1, -1)
        self.pw_label = QLabel(_('Password'))
        self.pw_label.setVisible(self.password_required)
        self.pw = PasswordLineEdit()
        self.pw.setVisible(self.password_required)
        grid.addWidget(self.pw_label, 11, 0)
        grid.addWidget(self.pw, 11, 1, 1, -1)

        self.send_button = QPushButton(_('Send'))
        self.send_button.clicked.connect(self.on_send)
        self.send_button.setDefault(True)

        self.preview_button = QPushButton(_('Preview'))
        self.preview_button.clicked.connect(self.on_preview)
        self.preview_button.setDefault(True)

        vbox.addLayout(
            Buttons(CancelButton(self), self.preview_button, self.send_button))

        # set default to ASAP checked
        self.asap_check.setChecked(True)
        self.toggle_target()

        self.update()
        self.is_send = False