Exemplo n.º 1
0
 def qr_input(self):
     from chainkey import qrscanner
     try:
         data = qrscanner.scan_qr(self.win.config)
     except BaseException, e:
         QMessageBox.warning(self, _('Error'), _(e), _('OK'))
         return ""
Exemplo n.º 2
0
 def build_tray_menu(self):
     m = QMenu()
     m.addAction(_("Show/Hide"), self.show_or_hide)
     m.addAction(_("Dark/Light"), self.toggle_tray_icon)
     m.addSeparator()
     m.addAction(_("Exit Encompass"), self.close)
     self.tray.setContextMenu(m)
Exemplo n.º 3
0
    def mouseReleaseEvent(self, event):
        dialog = QDialog(self)
        dialog.setWindowTitle(_('Encompass update'))
        dialog.setModal(1)

        main_layout = QGridLayout()
        main_layout.addWidget(QLabel(_("A new version of Encompass is available:")+" " + self.latest_version), 0,0,1,3)

        ignore_version = QPushButton(_("Ignore this version"))
        ignore_version.clicked.connect(self.ignore_this_version)

        ignore_all_versions = QPushButton(_("Ignore all versions"))
        ignore_all_versions.clicked.connect(self.ignore_all_version)

        open_website = QPushButton(_("Goto download page"))
        open_website.clicked.connect(self.open_website)

        main_layout.addWidget(ignore_version, 1, 0)
        main_layout.addWidget(ignore_all_versions, 1, 1)
        main_layout.addWidget(open_website, 1, 2)

        dialog.setLayout(main_layout)

        self.dialog = dialog

        if not dialog.exec_(): return
Exemplo n.º 4
0
    def before_send(self):
        '''
        Change URL to address before making a send.
        IMPORTANT:
            return False to continue execution of the send
            return True to stop execution of the send
        '''

        if self.win.payto_e.is_multiline():  # only supports single line entries atm
            return False
        if self.win.payto_e.is_pr:
            return
        payto_e = str(self.win.payto_e.toPlainText())
        regex = re.compile(r'^([^\s]+) <([A-Za-z0-9]+)>')  # only do that for converted addresses
        try:
            (url, address) = regex.search(payto_e).groups()
        except AttributeError:
            return False

        if not self.validated:
            msgBox = QMessageBox()
            msgBox.setText(_('WARNING: the address ' + address + ' could not be validated via an additional security check, DNSSEC, and thus may not be correct.'))
            msgBox.setInformativeText(_('Do you wish to continue?'))
            msgBox.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok)
            msgBox.setDefaultButton(QMessageBox.Cancel)
            reply = msgBox.exec_()
            if reply != QMessageBox.Ok:
                return True

        return False
Exemplo n.º 5
0
    def add_io(self, form):

        if self.tx.locktime > 0:
            form.addRow(QLabel("LockTime:"), QLabel(self.tx.locktime))

        def format_input(x):
            if x.get('is_coinbase'):
                return 'coinbase'
            else:
                _hash = x.get('prevout_hash')
                return _hash[0:8] + '...' + _hash[-8:] + ":%d"%x.get('prevout_n') + u'\t' + "%s"%x.get('address')
        lines = map(format_input, self.tx.inputs )
        i_text = QTextEdit()
        i_text.setFont(QFont(MONOSPACE_FONT))
        i_text.setText('\n'.join(lines))
        i_text.setReadOnly(True)
        i_text.setMaximumHeight(100)
        inputs_layout = QVBoxLayout()
        inputs_layout.addWidget(QLabel(_("Inputs:")))
        inputs_layout.addWidget(i_text)
        form.addRow(inputs_layout)

        lines = map(lambda x: x[0] + u'\t\t' + self.parent.format_amount(x[1]) if x[1] else x[0], self.tx.get_outputs())
        o_text = QTextEdit()
        o_text.setFont(QFont(MONOSPACE_FONT))
        o_text.setText('\n'.join(lines))
        o_text.setReadOnly(True)
        o_text.setMaximumHeight(100)
        outputs_layout = QVBoxLayout()
        outputs_layout.addWidget(QLabel(_("Outputs:")))
        outputs_layout.addWidget(o_text)
        form.addRow(outputs_layout)
Exemplo n.º 6
0
    def context_menu(self):
        view_menu = QMenu()
        themes_menu = view_menu.addMenu(_("&Themes"))
        selected_theme = self.actuator.selected_theme()
        theme_group = QActionGroup(self)
        for theme_name in self.actuator.theme_names():
            theme_action = themes_menu.addAction(theme_name)
            theme_action.setCheckable(True)
            if selected_theme == theme_name:
                theme_action.setChecked(True)
            class SelectThemeFunctor:
                def __init__(self, theme_name, toggle_theme):
                    self.theme_name = theme_name
                    self.toggle_theme = toggle_theme
                def __call__(self, checked):
                    if checked:
                        self.toggle_theme(self.theme_name)
            delegate = SelectThemeFunctor(theme_name, self.toggle_theme)
            theme_action.toggled.connect(delegate)
            theme_group.addAction(theme_action)
        view_menu.addSeparator()

        show_receiving = view_menu.addAction(_("Show Receiving addresses"))
        show_receiving.setCheckable(True)
        show_receiving.toggled.connect(self.toggle_receiving_layout)
        show_receiving.setChecked(self.config.get("gui_show_receiving",False))

        show_history = view_menu.addAction(_("Show History"))
        show_history.setCheckable(True)
        show_history.toggled.connect(self.show_history)
        show_history.setChecked(self.config.get("gui_show_history",False))

        return view_menu
Exemplo n.º 7
0
 def callback_PassphraseRequest(self, req):
     msg = _("Please enter your Trezor passphrase.")
     passphrase = trezor_passphrase_dialog(msg)
     if passphrase is None:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return proto.Cancel()
     return proto.PassphraseAck(passphrase=passphrase)
Exemplo n.º 8
0
 def save(self):
     name = 'signed_%s.txn' % (self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn'
     fileName = self.parent.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"))
Exemplo n.º 9
0
    def __init__(self, parent):
        CurrenciesCheckboxDialog.__init__(self, parent)
        self.setWindowTitle(_('Hide Coins'))
        self.hide_chains = self.parent.config.get_above_chain('hide_chains', [])

        # sanity checking
        active_chain_code = self.parent.active_chain.code
        if active_chain_code in self.hide_chains:
            self.hide_chains.remove(active_chain_code)

        self.main_layout = vbox = QVBoxLayout()
        hide_label = QLabel(_('You can select chains here that will be hidden from view in the currency selection dialog.'))
        vbox.addWidget(hide_label)

        for cbox in self.coin_checkboxes:
            code = str(cbox.text()).split()[0]
            if code == active_chain_code:
                cbox.setChecked(False)
                cbox.setEnabled(False)
                continue
            cbox.setChecked(code in self.hide_chains)
        vbox.addLayout(self.scroll_layout)

        vbox.addLayout(close_button(self))
        self.finished.connect(self.save_hide_chains)
        self.setLayout(vbox)
Exemplo n.º 10
0
    def __init__(self, parent):
        super(SendEdit, self).__init__(parent)
        self.parent = parent
        # list of 2-tuples: (widget, PayToEdit)
        self.payto_widgets = []

        self.shortcut_paytoedit = None
        self.shortcut_addr = ''

        self.payto_help = HelpButton(_('Recipient of the funds.') + '\n\n' + _('You may enter a coin address, a label from your list of contacts (a list of completions will be proposed), or an alias (email-like address that forwards to a coin address)'))

        self.amount_help = HelpButton(_('Amount to be sent.') + '\n\n' \
                                      + _('The amount will be displayed in red if you do not have enough funds in your wallet. Note that if you have frozen some of your addresses, the available funds will be lower than your total balance.') \
                                      + '\n\n' + _('Keyboard shortcut: type "!" to send all your coins.'))

        self.scroller = QScrollArea()
        self.scroller.setEnabled(True)
        self.scroller.setWidgetResizable(True)
        self.scroller.setMinimumSize(100, 125)
        self.scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll_widget = QWidget()
        self.scroll_widget.setProperty("scrollArea", True)
        self.vbox = QVBoxLayout()
        self.scrolling_layout = QVBoxLayout()

        self.num_paytoedits = 10

        # scroll area
        self.scroll_widget.setLayout(self.vbox)
        self.scroller.setWidget(self.scroll_widget)
        self.scrolling_layout.addWidget(self.scroller)

        self.create_paytoedits()
        self.active_paytoedit = self.payto_widgets[0][1]
        self.vbox.addStretch(1)
Exemplo n.º 11
0
    def __init__(self, transaction_id, parent):
        super(TransactionWindow, self).__init__()

        self.tx_id = str(transaction_id)
        self.parent = parent

        self.setModal(True)
        self.resize(200,100)
        self.setWindowTitle(_("Transaction successfully sent"))

        self.layout = QGridLayout(self)
        history_label = "%s\n%s" % (_("Your transaction has been sent."), _("Please enter a label for this transaction for future reference."))
        self.layout.addWidget(QLabel(history_label))

        self.label_edit = QLineEdit()
        self.label_edit.setPlaceholderText(_("Transaction label"))
        self.label_edit.setObjectName("lite_label_input")
        self.label_edit.setAttribute(Qt.WA_MacShowFocusRect, 0)
        self.label_edit.setFocusPolicy(Qt.ClickFocus)
        self.layout.addWidget(self.label_edit)

        self.save_button = QPushButton(_("Save"))
        self.layout.addWidget(self.save_button)
        self.save_button.clicked.connect(self.set_label)

        self.exec_()
Exemplo n.º 12
0
    def __init__(self):
        QDialog.__init__(self)
        self.setMinimumSize(200, 100)
        self.setWindowTitle('M-of-N Wallet')
        self.main_layout = vb = QVBoxLayout(self)
        mofn_explanation = QLabel(_("Select M (minimum number of cosigner signatures) and N (total cosigners)"))
        vb.addWidget(mofn_explanation)

        # choices
        self.m_list = map(lambda x: QString(str(x)), [1,2,3,4])
        self.n_list = []
        mnbox = QHBoxLayout()
        self.combobox_m = cb_m = QComboBox()
        self.combobox_n = cb_n = QComboBox()
        cb_m.addItems(self.m_list)
        cb_n.setEnabled(False)
        # add choices to layout
        mnbox.addWidget(cb_m)
        mnbox.addWidget(QLabel(_("of")))
        mnbox.addWidget(cb_n)
        vb.addLayout(mnbox)
        # connect choice combo box
        cb_m.currentIndexChanged.connect(self.on_m_changed)
        cb_n.currentIndexChanged.connect(self.on_n_changed)

        # ok and cancel buttons
        self.ok_cancel, self.accept_button = okc, accept_b = ok_cancel_buttons2(self)
        accept_b.setEnabled(False)

        vb.addLayout(okc)
Exemplo n.º 13
0
 def verify_seed(self, seed, sid, func=None):
     r = self.enter_seed_dialog(MSG_VERIFY_SEED, sid, func)
     if not r:
         return
     if prepare_seed(r) != prepare_seed(seed):
         QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK'))
         return False
     else:
         return True
Exemplo n.º 14
0
 def give_error(self, message, clear_client = False):
     if not self.signing:
         QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK'))
     else:
         self.signing = False
     if clear_client and self.client is not None:
         self.client.bad = True
         self.device_checked = False
     raise Exception(message)                
Exemplo n.º 15
0
def ok_cancel_buttons(dialog):
    row_layout = QHBoxLayout()
    row_layout.addStretch(1)
    ok_button = QPushButton(_("OK"))
    row_layout.addWidget(ok_button)
    ok_button.clicked.connect(dialog.accept)
    cancel_button = QPushButton(_("Cancel"))
    row_layout.addWidget(cancel_button)
    cancel_button.clicked.connect(dialog.reject)
    return row_layout
Exemplo n.º 16
0
    def export_history_dialog(self, d,hbox):
        history = self.wallet.get_tx_history()

        if len(history) > 0:
            b = QPushButton(_("Preview plot"))
            hbox.addWidget(b)
            b.clicked.connect(lambda: self.do_plot(self.wallet, history))
        else:
            b = QPushButton(_("No history to plot"))
            hbox.addWidget(b)
Exemplo n.º 17
0
 def __init__(self, parent, seed, imported_keys):
     QDialog.__init__(self, parent)
     self.setModal(1)
     self.setMinimumWidth(400)
     self.setWindowTitle('Encompass' + ' - ' + _('Seed'))
     vbox = show_seed_box(seed)
     if imported_keys:
         vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>"))
     vbox.addLayout(close_button(self))
     self.setLayout(vbox)
Exemplo n.º 18
0
 def on_change_hist(checked):
     if checked:
         self.config.set_key('history_rates', 'checked')
         self.request_history_rates()
     else:
         self.config.set_key('history_rates', 'unchecked')
         self.win.history_list.setHeaderLabels( [ '', _('Date'), _('Description') , _('Amount'), _('Balance')] )
         self.win.history_list.setColumnCount(5)
         for i,width in enumerate(self.win.column_widths['history']):
             self.win.history_list.setColumnWidth(i, width)
Exemplo n.º 19
0
 def installwizard_restore(self, wizard, storage):
     if storage.get('wallet_type') != 'btchip':
         return
     wallet = BTChipWallet(storage)
     try:
         wallet.create_main_account(None)
     except BaseException as e:
         QMessageBox.information(None, _('Error'), str(e), _('OK'))
         return
     return wallet
Exemplo n.º 20
0
    def history_tab_update(self):
        if self.config.get('history_rates') != "checked":
            return
        if not self.resp_hist:
            return

        self.win.is_edit = True
        self.win.history_list.setColumnCount(6)
        self.win.history_list.setHeaderLabels( [ '', _('Date'), _('Description') , _('Amount'), _('Balance'), _('Fiat Amount')] )
        root = self.win.history_list.invisibleRootItem()
        childcount = root.childCount()
        for i in range(childcount):
            item = root.child(i)
            try:
                tx_info = self.tx_list[str(item.data(0, Qt.UserRole).toPyObject())]
            except Exception:
                newtx = self.wallet.get_tx_history()
                v = newtx[[x[0] for x in newtx].index(str(item.data(0, Qt.UserRole).toPyObject()))][3]
                tx_info = {'timestamp':int(time.time()), 'value': v }
                pass
            tx_time = int(tx_info['timestamp'])
            if self.cur_exchange == "CoinDesk":
                tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d')
                try:
                    tx_fiat_val = "%.2f %s" % (Decimal(str(tx_info['value'])) / 100000000 * Decimal(self.resp_hist['bpi'][tx_time_str]), "USD")
                except KeyError:
                    tx_fiat_val = "%.2f %s" % (self.btc_rate * Decimal(str(tx_info['value']))/100000000 , "USD")
            elif self.cur_exchange == "Winkdex":
                tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d') + "T16:00:00-04:00"
                try:
                    tx_rate = self.resp_hist[[x['timestamp'] for x in self.resp_hist].index(tx_time_str)]['price']
                    tx_fiat_val = "%.2f %s" % (Decimal(tx_info['value']) / 100000000 * Decimal(tx_rate)/Decimal("100.0"), "USD")
                except ValueError:
                    tx_fiat_val = "%.2f %s" % (self.btc_rate * Decimal(tx_info['value'])/100000000 , "USD")
                except KeyError:
                    tx_fiat_val = _("No data")
            elif self.cur_exchange == "BitcoinVenezuela":
                tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d')
                try:
                    num = self.resp_hist[tx_time_str].replace(',','')
                    tx_fiat_val = "%.2f %s" % (Decimal(str(tx_info['value'])) / 100000000 * Decimal(num), cur_currency)
                except KeyError:
                    tx_fiat_val = _("No data")

            tx_fiat_val = " "*(12-len(tx_fiat_val)) + tx_fiat_val
            item.setText(5, tx_fiat_val)
            item.setFont(5, QFont(MONOSPACE_FONT))
            if Decimal(str(tx_info['value'])) < 0:
                item.setForeground(5, QBrush(QColor("#BC1E1E")))

        for i, width in enumerate(self.win.column_widths['history']):
            self.win.history_list.setColumnWidth(i, width)
        self.win.history_list.setColumnWidth(4, 140)
        self.win.history_list.setColumnWidth(5, 120)
        self.win.is_edit = False
Exemplo n.º 21
0
    def restore_or_create(self):
        vbox = QVBoxLayout()
        main_label = QLabel(_("Encompass could not find an existing wallet."))
        vbox.addWidget(main_label)
        grid = QGridLayout()
        grid.setSpacing(5)
        gb1 = QGroupBox(_("What do you want to do?"))
        vbox.addWidget(gb1)
        b1 = QRadioButton(gb1)
        b1.setText(_("Create new wallet"))
        b1.setChecked(True)
        b2 = QRadioButton(gb1)
        b2.setText(_("Restore an existing wallet"))
        group1 = QButtonGroup()
        group1.addButton(b1)
        group1.addButton(b2)
        vbox.addWidget(b1)
        vbox.addWidget(b2)

        gb2 = QGroupBox(_("Wallet type:"))
        vbox.addWidget(gb2)
        group2 = QButtonGroup()

        self.wallet_types = [
            ('standard',  _("Standard wallet")),
            ('twofactor', _("Wallet with two-factor authentication")),
            ('multisig',  _("Multi-signature wallet")),
            ('hardware',  _("Hardware wallet")),
        ]

        for i, (wtype,name) in enumerate(self.wallet_types):
            if not filter(lambda x:x[0]==wtype, chainkey.wallet.wallet_types):
                continue
            button = QRadioButton(gb2)
            button.setText(name)
            vbox.addWidget(button)
            group2.addButton(button)
            group2.setId(button, i)
            if i==0:
                button.setChecked(True)

        vbox.addStretch(1)
        hbox, button = ok_cancel_buttons2(self, _('Next'))
        vbox.addLayout(hbox)
        self.set_layout(vbox)
        self.show()
        self.raise_()
        button.setDefault(True)

        if not self.exec_():
            return None, None

        action = 'create' if b1.isChecked() else 'restore'
        wallet_type = self.wallet_types[group2.checkedId()][0]
        return action, wallet_type
Exemplo n.º 22
0
 def append(self, address, amount, date):
     if address is None:
         address = _("Unknown")
     if amount is None:
         amount = _("Unknown")
     if date is None:
         date = _("Unknown")
     item = QTreeWidgetItem([amount, address, date])
     if float(amount) < 0:
         item.setForeground(0, QBrush(QColor("#BC1E1E")))
     self.insertTopLevelItem(0, item)
Exemplo n.º 23
0
def ok_cancel_buttons2(dialog, ok_label=None, cancel_label=None):
    hbox = QHBoxLayout()
    hbox.addStretch(1)
    b = QPushButton(cancel_label or _('Cancel'))
    hbox.addWidget(b)
    b.clicked.connect(dialog.reject)
    b = QPushButton(ok_label or _("OK"))
    hbox.addWidget(b)
    b.clicked.connect(dialog.accept)
    b.setDefault(True)
    return hbox, b
Exemplo n.º 24
0
    def __init__(self, owner=None):
        self.owner = owner
        self.editing = False

        QTreeWidget.__init__(self, owner)
        self.setColumnCount(3)
        self.setHeaderLabels([_("Address"), _("Label"), _("Used")])
        self.setIndentation(0)

        self.hide_used = True
        self.setColumnHidden(2, True)
Exemplo n.º 25
0
    def close(self):
        self.d.accept()
        if self.error:
            QMessageBox.warning(self.parent, _('Error'), self.error, _('OK'))
        else:
            if self.on_success:
                if type(self.result) is not tuple:
                    self.result = (self.result,)
                self.on_success(*self.result)

        if self.on_complete:
            self.on_complete()
Exemplo n.º 26
0
    def settings_dialog(self):
        def check_for_api_key(api_key):
            if api_key and len(api_key) > 12:
              self.config.set_key("plugin_label_api_key", str(self.auth_token_edit.text()))
              self.upload.setEnabled(True)
              self.download.setEnabled(True)
              self.accept.setEnabled(True)
            else:
              self.upload.setEnabled(False)
              self.download.setEnabled(False)
              self.accept.setEnabled(False)

        d = QDialog()
        layout = QGridLayout(d)
        layout.addWidget(QLabel("API Key: "),0,0)

        self.auth_token_edit = QLineEdit(self.auth_token())
        self.auth_token_edit.textChanged.connect(check_for_api_key)

        layout.addWidget(QLabel("Label sync options: "),2,0)
        layout.addWidget(self.auth_token_edit, 0,1,1,2)

        decrypt_key_text =  QLineEdit(self.encode_password)
        decrypt_key_text.setReadOnly(True)
        layout.addWidget(decrypt_key_text, 1,1)
        layout.addWidget(QLabel("Decryption key: "),1,0)
        layout.addWidget(HelpButton("This key can be used on the LabElectrum website to decrypt your data in case you want to review it online."),1,2)

        self.upload = QPushButton("Force upload")
        self.upload.clicked.connect(self.full_push)
        layout.addWidget(self.upload, 2,1)

        self.download = QPushButton("Force download")
        self.download.clicked.connect(self.full_pull)
        layout.addWidget(self.download, 2,2)

        c = QPushButton(_("Cancel"))
        c.clicked.connect(d.reject)

        self.accept = QPushButton(_("Done"))
        self.accept.clicked.connect(d.accept)

        layout.addWidget(c,3,1)
        layout.addWidget(self.accept,3,2)

        check_for_api_key(self.auth_token())

        self.window.labelsChanged.connect(self.done_processing)

        if d.exec_():
          return True
        else:
          return False
Exemplo n.º 27
0
    def setup(self, address):
        label = QLabel(_("Copied your coin address to the clipboard!"))
        address_display = QLineEdit(address)
        address_display.setReadOnly(True)
        resize_line_edit_width(address_display, address)

        main_layout = QVBoxLayout(self)
        main_layout.addWidget(label)
        main_layout.addWidget(address_display)

        self.setMouseTracking(True)
        self.setWindowTitle("Encompass - " + _("Receive coin payment"))
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.MSWindowsFixedSizeDialogHint)
        self.layout().setSizeConstraint(QLayout.SetFixedSize)
Exemplo n.º 28
0
 def passphrase_dialog(self):
     from chainkey_gui.qt.password_dialog import make_password_dialog, run_password_dialog
     d = QDialog()
     d.setModal(1)
     d.setLayout(make_password_dialog(d, None, self.message, False))
     confirmed, p, passphrase = run_password_dialog(d, None, None)
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _('Password request canceled'), _('OK'))
         self.passphrase = None
     else:
         if passphrase is None:
             passphrase = '' # Even blank string is valid Trezor passphrase
         self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase))
     self.done.set()
Exemplo n.º 29
0
 def question(self, msg, yes_label=_('OK'), no_label=_('Cancel'), icon=None):
     vbox = QVBoxLayout()
     self.set_layout(vbox)
     if icon:
         logo = QLabel()
         logo.setPixmap(icon)
         vbox.addWidget(logo)
     label = QLabel(msg)
     label.setWordWrap(True)
     vbox.addWidget(label)
     vbox.addStretch(1)
     vbox.addLayout(ok_cancel_buttons(self, yes_label, no_label))
     if not self.exec_():
         return None
     return True
Exemplo n.º 30
0
    def do_full_pull(self, force = False):
        connection = httplib.HTTPConnection(self.target_host)
        connection.request("GET", ("/api/wallets/%s/labels.json?auth_token=%s" % (self.wallet_id, self.auth_token())),"", {'Content-Type': 'application/json'})
        response = connection.getresponse()
        if response.status != 200:
            print_error("Cannot retrieve labels:", response.status, response.reason)
            return
        response = json.loads(response.read())
        if "error" in response:
            raise BaseException(_("Could not sync labels: %s" % response["error"]))

        for label in response:
            try:
                key = self.decode(label["external_id"])
            except:
                continue
            try:
                value = self.decode(label["text"])
            except:
                continue
            try:
                json.dumps(key)
                json.dumps(value)
            except:
                print_error('error: no json', key)
                continue
            if force or not self.wallet.labels.get(key):
                self.wallet.labels[key] = value
        self.wallet.storage.put('labels', self.wallet.labels)
        print_error("received %d labels"%len(response))
        self.window.labelsChanged.emit()
Exemplo n.º 31
0
 def passphrase_dialog(self):
     from chainkey_gui.qt.password_dialog import make_password_dialog, run_password_dialog
     d = QDialog()
     d.setModal(1)
     d.setLayout(make_password_dialog(d, None, self.message, False))
     confirmed, p, passphrase = run_password_dialog(d, None, None)
     if not confirmed:
         QMessageBox.critical(None, _('Error'),
                              _('Password request canceled'), _('OK'))
         self.passphrase = None
     else:
         if passphrase is None:
             passphrase = ''  # Even blank string is valid Trezor passphrase
         self.passphrase = unicodedata.normalize('NFKD',
                                                 unicode(passphrase))
     self.done.set()
Exemplo n.º 32
0
def show_seed_box(seed, sid=None):

    save_msg = _("Please save these %d words on paper (order is important)."
                 ) % len(seed.split()) + " "
    qr_msg = _(
        "Your seed is also displayed as QR code, in case you want to transfer it to a mobile phone."
    ) + "<p>"
    warning_msg = "<b>" + _("WARNING") + ":</b> " + _(
        "Never disclose your seed. Never type it on a website.") + "</b><p>"

    if sid is None:
        msg = _("Your wallet generation seed is")
        msg2 = save_msg + " " \
               + _("This seed will allow you to recover your wallet in case of computer failure.") + "<br/>" \
               + warning_msg

    elif sid == 'cold':
        msg = _("Your cold storage seed is")
        msg2 = save_msg + " " \
               + _("This seed will be permanently deleted from your wallet file. Make sure you have saved it before you press 'next'") + " " \

    elif sid == 'hot':
        msg = _("Your hot seed is")
        msg2 = save_msg + " " \
               + _("If you ever need to recover your wallet from seed, you will need both this seed and your cold seed.") + " " \

    label1 = QLabel(msg + ":")
    seed_text = ShowQRTextEdit(text=seed)
    seed_text.setMaximumHeight(130)

    label2 = QLabel(msg2)
    label2.setWordWrap(True)

    logo = QLabel()
    logo.setPixmap(QPixmap(icon_filename(sid)).scaledToWidth(56))
    logo.setMaximumWidth(60)

    grid = QGridLayout()
    grid.addWidget(logo, 0, 0)
    grid.addWidget(label1, 0, 1)
    grid.addWidget(seed_text, 1, 0, 1, 2)
    vbox = QVBoxLayout()
    vbox.addLayout(grid)
    vbox.addWidget(label2)
    vbox.addStretch(1)

    return vbox
Exemplo n.º 33
0
def filename_field(parent, config, defaultname, select_msg, csv_default=True):

    vbox = QVBoxLayout()
    vbox.addWidget(QLabel(_("Format")))
    gb = QGroupBox("format", parent)
    b1 = QRadioButton(gb)
    b1.setText(_("CSV"))
    b1.setChecked(csv_default)
    b2 = QRadioButton(gb)
    b2.setText(_("json"))
    b2.setChecked(False if csv_default else True)
    vbox.addWidget(b1)
    vbox.addWidget(b2)

    hbox = QHBoxLayout()

    directory = config.get_above_chain('io_dir',
                                       unicode(os.path.expanduser('~')))
    path = os.path.join(directory, defaultname)
    filename_e = QLineEdit()
    filename_e.setText(path)

    def func():
        text = unicode(filename_e.text())
        _filter = "*.csv" if text.endswith(
            ".csv") else "*.json" if text.endswith(".json") else None
        p = unicode(
            QFileDialog.getSaveFileName(None, select_msg, text, _filter))
        if p:
            filename_e.setText(p)

    button = QPushButton(_('File'))
    button.clicked.connect(func)
    hbox.addWidget(button)
    hbox.addWidget(filename_e)
    vbox.addLayout(hbox)

    def set_csv(v):
        text = unicode(filename_e.text())
        text = text.replace(".json", ".csv") if v else text.replace(
            ".csv", ".json")
        filename_e.setText(text)

    b1.clicked.connect(lambda: set_csv(True))
    b2.clicked.connect(lambda: set_csv(False))

    return vbox, filename_e, b1
Exemplo n.º 34
0
def close_button(dialog, label=None):
    hbox = QHBoxLayout()
    hbox.addStretch(1)
    b = QPushButton(label or _("Close"))
    hbox.addWidget(b)
    b.clicked.connect(dialog.close)
    b.setDefault(True)
    return hbox
Exemplo n.º 35
0
 def __init__(self, config, name):
     BasePlugin.__init__(self, config, name)
     self._is_available = self._init()
     self._requires_settings = True
     self.wallet = None
     self.window = None
     if self._is_available:
         chainkey.wallet.wallet_types.append(
             ('hardware', 'trezor', _("Trezor wallet"), TrezorWallet))
Exemplo n.º 36
0
    def do_verify(self, tx):
        # 1. get the password and sign the verification request
        password = None
        if self.wallet.use_encryption:
            msg = _(
                'GreenAddress requires your signature to verify that transaction is instant.\n'
                'Please enter your password to sign a verification request.')
            password = self.win.password_dialog(msg)
            if not password:
                return
        try:
            self.verify_button.setText(_('Verifying...'))
            QApplication.processEvents()  # update the button label

            addr = self.get_my_addr(tx)
            message = "Please verify if %s is GreenAddress instant confirmed" % tx.hash(
            )
            sig = self.wallet.sign_message(addr, message, password)

            # 2. send the request
            connection = httplib.HTTPSConnection('greenaddress.it')
            connection.request("GET", ("/verify/?signature=%s&txhash=%s" %
                                       (urllib.quote(sig), tx.hash())), None,
                               {'User-Agent': 'Electrum'})
            response = connection.getresponse()
            response = json.loads(response.read())

            # 3. display the result
            if response.get('verified'):
                QMessageBox.information(
                    None, _('Verification successful!'),
                    _('%s is covered by GreenAddress instant confirmation') %
                    (tx.hash()), _('OK'))
            else:
                QMessageBox.critical(
                    None, _('Verification failed!'),
                    _('%s is not covered by GreenAddress instant confirmation')
                    % (tx.hash()), _('OK'))
        except BaseException as e:
            import traceback
            traceback.print_exc(file=sys.stdout)
            QMessageBox.information(None, _('Error'), str(e), _('OK'))
        finally:
            self.verify_button.setText(self.button_label)
Exemplo n.º 37
0
    def network_dialog(self):
        # skip this if config already exists
        if self.config.get('server') is not None:
            return

        grid = QGridLayout()
        grid.setSpacing(5)

        label = QLabel(_("Encompass communicates with remote servers to get information about your transactions and addresses. The servers all fulfil the same purpose only differing in hardware. In most cases you simply want to let Encompass pick one at random if you have a preference though feel free to select a server manually.") + "\n\n" \
                      + _("How do you want to connect to a server:")+" ")
        label.setWordWrap(True)
        grid.addWidget(label, 0, 0)

        gb = QGroupBox()

        b1 = QRadioButton(gb)
        b1.setText(_("Auto connect"))
        b1.setChecked(True)

        b2 = QRadioButton(gb)
        b2.setText(_("Select server manually"))

        #b3 = QRadioButton(gb)
        #b3.setText(_("Stay offline"))

        grid.addWidget(b1,1,0)
        grid.addWidget(b2,2,0)
        #grid.addWidget(b3,3,0)

        vbox = QVBoxLayout()
        vbox.addLayout(grid)

        vbox.addStretch(1)
        vbox.addLayout(ok_cancel_buttons(self, _('Next')))

        self.set_layout(vbox)
        if not self.exec_():
            return

        if b2.isChecked():
            return NetworkDialog(self.network, self.config, None).do_exec()
        else:
            self.config.set_key('auto_cycle', True, True)
            return
Exemplo n.º 38
0
    def __init__(self, data, parent=None, title = "", show_text=False):
        QDialog.__init__(self, parent)

        d = self
        d.setWindowTitle(title)
        vbox = QVBoxLayout()
        qrw = QRCodeWidget(data)
        vbox.addWidget(qrw, 1)
        if show_text:
            text = QTextEdit()
            text.setText(data)
            text.setReadOnly(True)
            vbox.addWidget(text)
        hbox = QHBoxLayout()
        hbox.addStretch(1)

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

            def print_qr():
                bmp.save_qrcode(qrw.qr, filename)
                QMessageBox.information(None, _('Message'), _("QR code saved to file") + " " + filename, _('OK'))

            def copy_to_clipboard():
                bmp.save_qrcode(qrw.qr, filename)
                QApplication.clipboard().setImage(QImage(filename))
                QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK'))

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

        vbox.addLayout(hbox)
        d.setLayout(vbox)
Exemplo n.º 39
0
    def __init__(self, parent):
        super(SettingsDialog, self).__init__(parent)
        self.gui = gui = parent
        self.config = gui.config
        self.actuator = gui.actuator
        self.active_chain = gui.active_chain

        self.setWindowTitle(_('Encompass Settings'))
        self.setModal(1)
        self.setMinimumWidth(500)
        # There are tabs for each category of settings.
        self.pages_tabs = QTabWidget()

        # Global options
        global_rows = self.create_global_options()
        global_options_grid = QGridLayout()
        for r in global_rows:
            r.add_to_layout(global_options_grid)

        global_description = _("These settings are not limited to any coin.")
        global_widget = self.create_page_widget(global_description, global_options_grid)
        self.pages_tabs.addTab(global_widget, _('Global'))

        # Per-chain options
        chain_rows = self.create_chain_options()
        chain_options_grid = QGridLayout()
        for r in chain_rows:
            r.add_to_layout(chain_options_grid)

        chain_description = _("These settings only affect") + " {}.".format(self.active_chain.coin_name)
        chain_widget = self.create_page_widget(chain_description, chain_options_grid)
        self.pages_tabs.addTab(chain_widget, self.actuator.get_coin_icon(self.active_chain.code), self.active_chain.coin_name)

        pages_explanation = QLabel(_('Select a category of settings below:'))
        pages_explanation.setWordWrap(True)

        vbox = QVBoxLayout()
        vbox.addWidget(pages_explanation)
        vbox.addWidget(self.pages_tabs, stretch=1)
        vbox.addLayout(close_button(self))

        self.setLayout(vbox)
Exemplo n.º 40
0
    def __init__(self, parent):
        super(QDialog, self).__init__(parent)

        self.setModal(True)

        self.password_input = QLineEdit()
        self.password_input.setEchoMode(QLineEdit.Password)

        main_layout = QVBoxLayout(self)
        message = _('Please enter your password')
        main_layout.addWidget(QLabel(message))

        grid = QGridLayout()
        grid.setSpacing(8)
        grid.addWidget(QLabel(_('Password')), 1, 0)
        grid.addWidget(self.password_input, 1, 1)
        main_layout.addLayout(grid)

        main_layout.addLayout(ok_cancel_buttons(self))
        self.setLayout(main_layout)
Exemplo n.º 41
0
def do_buy(credentials, amount):
    conn = httplib.HTTPSConnection('coinbase.com')
    credentials.authorize(conn)
    params = {
        'qty': float(amount) / SATOSHIS_PER_BTC,
        'agree_btc_amount_varies': False
    }
    resp = conn.auth_request('POST', '/api/v1/buys', urlencode(params), None)

    if resp.status != 200:
        message(_('Error, could not buy bitcoin'))
        return
    content = json.loads(resp.read())
    if content['success']:
        message(_('Success!\n') + content['transfer']['description'])
    else:
        if content['errors']:
            message(_('Error: ') + string.join(content['errors'], '\n'))
        else:
            message(_('Error, could not buy bitcoin'))
Exemplo n.º 42
0
 def password_dialog(self, msg=None):
     if not msg:
         msg = _("Do not enter your device PIN here !\r\n\r\n" \
                 "Your BTChip wants to talk to you and tell you a unique second factor code.\r\n" \
                 "For this to work, please open a text editor (on a different computer / device if you believe this computer is compromised) and put your cursor into it, unplug your BTChip and plug it back in.\r\n" \
                 "It should show itself to your computer as a keyboard and output the second factor along with a summary of the transaction it is signing into the text-editor.\r\n\r\n" \
                 "Check that summary and then enter the second factor code here.\r\n" \
                 "Before clicking OK, re-plug the device once more (unplug it and plug it again if you read the second factor code on the same computer)")
     d = QDialog()
     d.setModal(1)
     d.setLayout(make_password_dialog(d, None, msg, False))
     return run_password_dialog(d, None, None)
Exemplo n.º 43
0
 def show_message(self, msg, icon=None):
     vbox = QVBoxLayout()
     self.set_layout(vbox)
     if icon:
         logo = QLabel()
         logo.setPixmap(icon)
         vbox.addWidget(logo)
     vbox.addWidget(QLabel(msg))
     vbox.addStretch(1)
     vbox.addLayout(close_button(self, _('Next')))
     if not self.exec_():
         return None
Exemplo n.º 44
0
    def waiting_dialog(self, task, msg= _("Encompass is generating your addresses, please wait.")):
        def target():
            task()
            self.emit(QtCore.SIGNAL('accept'))

        vbox = QVBoxLayout()
        self.waiting_label = QLabel(msg)
        vbox.addWidget(self.waiting_label)
        self.set_layout(vbox)
        t = threading.Thread(target = target)
        t.start()
        self.exec_()
Exemplo n.º 45
0
    def add_paytoedit(self):
        w = QWidget()
        grid = QGridLayout()
        grid.setSpacing(8)
        grid.setColumnMinimumWidth(1, 300)
        grid.setColumnStretch(1, 2)

        pay_edit = PayToEdit(self.parent,
                             BTCAmountEdit(self.parent.get_decimal_point))

        self.payto_widgets.append((w, pay_edit))
        current_widget_index = len(self.payto_widgets) - 1

        completer = QCompleter()
        completer.setCaseSensitivity(False)
        pay_edit.setCompleter(completer)
        completer.setModel(self.parent.completions)

        if current_widget_index == 0:
            grid.addWidget(QLabel(_('Pay to')), 0, 0, 1, 1)
            grid.addWidget(QLabel(_('Amount')), 0, 3, 1, 1)

            grid.addWidget(self.payto_help, 0, 1)
            grid.addWidget(self.amount_help, 0, 4)

        grid.addWidget(pay_edit, 1, 0, 1, 3)

        grid.addWidget(pay_edit.amount_edit, 1, 3, 1, 3)

        w.setLayout(grid)
        self.vbox.addWidget(w)

        pay_edit.amount_edit.shortcut.connect(
            functools.partial(self.on_shortcut, current_widget_index))
        pay_edit.textChanged.connect(
            functools.partial(self.on_textChanged, current_widget_index))
        pay_edit.amount_edit.textEdited.connect(
            functools.partial(self.on_textChanged, current_widget_index))

        return w
Exemplo n.º 46
0
 def installwizard_restore(self, wizard, storage):
     if storage.get_above_chain('wallet_type') != 'trezor':
         return
     seed = wizard.enter_seed_dialog("Enter your Trezor seed",
                                     None,
                                     func=lambda x: True)
     if not seed:
         return
     wallet = TrezorWallet(storage)
     self.wallet = wallet
     passphrase = self.handler.get_passphrase(
         _("Please enter your Trezor passphrase.") + '\n' +
         _("Press OK if you do not use one."))
     if passphrase is None:
         return
     password = wizard.password_dialog()
     wallet.add_seed(seed, password)
     wallet.add_cosigner_seed(seed, 'x/', password, passphrase)
     wallet.create_main_account(password)
     # disable trezor plugin
     self.set_enabled(False)
     return wallet
Exemplo n.º 47
0
def propose_rebuy_qt(amount):
    web = QWebView()
    box = QMessageBox()
    box.setFixedSize(200, 200)

    credentials = read_local_oauth_credentials()
    questionText = _('Rebuy ') + format_satoshis(amount) + _(' BTC?')
    if credentials:
        credentials.refresh()
    if credentials and not credentials.invalid:
        credentials.store_locally()
        totalPrice = get_coinbase_total_price(credentials, amount)
        questionText += _('\n(Price: ') + totalPrice + _(')')

    if not question(box, questionText):
        return

    if credentials:
        do_buy(credentials, amount)
    else:
        do_oauth_flow(web, amount)
    return web
Exemplo n.º 48
0
 def enter_seed_dialog(self, msg, sid, func=None):
     if func is None:
         func = self.is_any
     vbox, seed_e = seed_dialog.enter_seed_box(msg, self, sid)
     vbox.addStretch(1)
     hbox, button = ok_cancel_buttons2(self, _('Next'))
     vbox.addLayout(hbox)
     button.setEnabled(False)
     seed_e.textChanged.connect(lambda: button.setEnabled(func(self.get_seed_text(seed_e))))
     self.set_layout(vbox)
     if not self.exec_():
         return
     return self.get_seed_text(seed_e)
Exemplo n.º 49
0
    def __init__(self, parent):
        super(SendEdit, self).__init__(parent)
        self.parent = parent
        # list of 2-tuples: (widget, PayToEdit)
        self.payto_widgets = []

        self.shortcut_paytoedit = None
        self.shortcut_addr = ''

        self.payto_help = HelpButton(
            _('Recipient of the funds.') + '\n\n' +
            _('You may enter a coin address, a label from your list of contacts (a list of completions will be proposed), or an alias (email-like address that forwards to a coin address)'
              ))

        self.amount_help = HelpButton(_('Amount to be sent.') + '\n\n' \
                                      + _('The amount will be displayed in red if you do not have enough funds in your wallet. Note that if you have frozen some of your addresses, the available funds will be lower than your total balance.') \
                                      + '\n\n' + _('Keyboard shortcut: type "!" to send all your coins.'))

        self.scroller = QScrollArea()
        self.scroller.setEnabled(True)
        self.scroller.setWidgetResizable(True)
        self.scroller.setMinimumSize(100, 125)
        self.scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll_widget = QWidget()
        self.scroll_widget.setProperty("scrollArea", True)
        self.vbox = QVBoxLayout()
        self.scrolling_layout = QVBoxLayout()

        self.num_paytoedits = 10

        # scroll area
        self.scroll_widget.setLayout(self.vbox)
        self.scroller.setWidget(self.scroll_widget)
        self.scrolling_layout.addWidget(self.scroller)

        self.create_paytoedits()
        self.active_paytoedit = self.payto_widgets[0][1]
        self.vbox.addStretch(1)
Exemplo n.º 50
0
def address_field(addresses):
    hbox = QHBoxLayout()
    address_e = QLineEdit()
    if addresses:
        address_e.setText(addresses[0])
    def func():
        i = addresses.index(str(address_e.text())) + 1
        i = i % len(addresses)
        address_e.setText(addresses[i])
    button = QPushButton(_('Address'))
    button.clicked.connect(func)
    hbox.addWidget(button)
    hbox.addWidget(address_e)
    return hbox, address_e
Exemplo n.º 51
0
 def transaction_dialog(self, d):
     clamspeech = getattr(d.tx, 'clamspeech', None)
     if not clamspeech:
         return
     form = d.layout()
     vbox = QVBoxLayout()
     vbox.addWidget(QLabel(_("ClamSpeech:")))
     speech_text = QTextEdit()
     speech_text.setReadOnly(True)
     speech_text.setMaximumHeight(100)
     speech_text.setText(clamspeech)
     speech_text.setFixedHeight(50)
     vbox.addWidget(speech_text)
     form.insertRow(form.rowCount() - 1, vbox)
Exemplo n.º 52
0
 def load_wallet(self, wallet):
     if self.trezor_is_connected():
         if not wallet.is_supported_coin():
             QMessageBox.information(
                 self.window, _('Error'),
                 _("Wallet firmware does not support the active currency.\nContinuing in watching-only mode."
                   ), _('OK'))
             self.wallet.force_watching_only = True
         if not self.wallet.check_proper_device():
             QMessageBox.information(
                 self.window, _('Error'),
                 _("This wallet does not match your Trezor device"),
                 _('OK'))
             self.wallet.force_watching_only = True
     else:
         QMessageBox.information(
             self.window, _('Error'),
             _("Trezor device not detected.\nContinuing in watching-only mode."
               ), _('OK'))
         self.wallet.force_watching_only = True
Exemplo n.º 53
0
    def pin_dialog(self, msg):
        d = QDialog(None)
        d.setModal(1)
        d.setWindowTitle(_("Enter PIN"))
        d.setWindowFlags(d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
        matrix = PinMatrixWidget()

        vbox = QVBoxLayout()
        vbox.addWidget(QLabel(msg))
        vbox.addWidget(matrix)
        vbox.addLayout(ok_cancel_buttons(d))
        d.setLayout(vbox)

        if not d.exec_(): return
        return str(matrix.get_value())
Exemplo n.º 54
0
    def add_io(self, form):

        if self.tx.locktime > 0:
            form.addRow(QLabel("LockTime:"), QLabel(self.tx.locktime))

        def format_input(x):
            if x.get('is_coinbase'):
                return 'coinbase'
            else:
                _hash = x.get('prevout_hash')
                return _hash[0:8] + '...' + _hash[-8:] + ":%d" % x.get(
                    'prevout_n') + u'\t' + "%s" % x.get('address')

        lines = map(format_input, self.tx.inputs)
        i_text = QTextEdit()
        i_text.setFont(QFont(MONOSPACE_FONT))
        i_text.setText('\n'.join(lines))
        i_text.setReadOnly(True)
        i_text.setMaximumHeight(100)
        inputs_layout = QVBoxLayout()
        inputs_layout.addWidget(QLabel(_("Inputs:")))
        inputs_layout.addWidget(i_text)
        form.addRow(inputs_layout)

        lines = map(
            lambda x: x[0] + u'\t\t' + self.parent.format_amount(x[1])
            if x[1] else x[0], self.tx.get_outputs())
        o_text = QTextEdit()
        o_text.setFont(QFont(MONOSPACE_FONT))
        o_text.setText('\n'.join(lines))
        o_text.setReadOnly(True)
        o_text.setMaximumHeight(100)
        outputs_layout = QVBoxLayout()
        outputs_layout.addWidget(QLabel(_("Outputs:")))
        outputs_layout.addWidget(o_text)
        form.addRow(outputs_layout)
Exemplo n.º 55
0
    def context_menu(self):
        view_menu = QMenu()
        themes_menu = view_menu.addMenu(_("&Themes"))
        selected_theme = self.actuator.selected_theme()
        theme_group = QActionGroup(self)
        for theme_name in self.actuator.theme_names():
            theme_action = themes_menu.addAction(theme_name)
            theme_action.setCheckable(True)
            if selected_theme == theme_name:
                theme_action.setChecked(True)

            class SelectThemeFunctor:
                def __init__(self, theme_name, toggle_theme):
                    self.theme_name = theme_name
                    self.toggle_theme = toggle_theme

                def __call__(self, checked):
                    if checked:
                        self.toggle_theme(self.theme_name)

            delegate = SelectThemeFunctor(theme_name, self.toggle_theme)
            theme_action.toggled.connect(delegate)
            theme_group.addAction(theme_action)
        view_menu.addSeparator()

        show_receiving = view_menu.addAction(_("Show Receiving addresses"))
        show_receiving.setCheckable(True)
        show_receiving.toggled.connect(self.toggle_receiving_layout)
        show_receiving.setChecked(self.config.get("gui_show_receiving", False))

        show_history = view_menu.addAction(_("Show History"))
        show_history.setCheckable(True)
        show_history.toggled.connect(self.show_history)
        show_history.setChecked(self.config.get("gui_show_history", False))

        return view_menu
Exemplo n.º 56
0
    def add_chain_dialog(self):
        d = QDialog(self)
        d.setModal(1)
        d.setWindowTitle(_("Add Currency To Wallet"))

        pw = QLineEdit()
        pw.setEchoMode(2)

        vbox = QVBoxLayout()
        msg = _('Please enter your password to start using this currency')
        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(ok_cancel_buttons(d))
        d.setLayout(vbox)

        always_hook('password_dialog', pw, grid, 1)
        if not d.exec_(): return
        return unicode(pw.text())
Exemplo n.º 57
0
    def __init__(self, parent, verbose_view=False):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.verbose_view = verbose_view
        self.setWindowTitle(_('Change Currency'))

        self.main_layout = main_layout = QVBoxLayout()

        self.create_chains_info()
        self.create_chains_view()
        self.refresh_chains()

        main_layout.addWidget(self.chains_view)

        main_layout.addLayout(ok_cancel_buttons(self))

        self.setLayout(main_layout)
Exemplo n.º 58
0
 def waiting_dialog(self, f):
     s = Timer()
     s.start()
     w = QDialog()
     w.resize(200, 70)
     w.setWindowTitle('Encompass')
     l = QLabel(_('Sending transaction, please wait.'))
     vbox = QVBoxLayout()
     vbox.addWidget(l)
     w.setLayout(vbox)
     w.show()
     def ff():
         s = f()
         if s: l.setText(s)
         else: w.close()
     w.connect(s, QtCore.SIGNAL('timersignal'), ff)
     w.exec_()
     w.destroy()
Exemplo n.º 59
0
    def resolve(self, url):
        '''Resolve OpenAlias address using url.'''
        print_error('[OA] Attempting to resolve OpenAlias data for ' + url)

        url = url.replace(
            '@', '.')  # support email-style addresses, per the OA standard
        prefix = chainparams.get_active_chain().code.lower()
        retries = 3
        err = None
        for i in range(0, retries):
            try:
                resolver = dns.resolver.Resolver()
                resolver.timeout = 2.0
                resolver.lifetime = 4.0
                records = resolver.query(url, dns.rdatatype.TXT)
                for record in records:
                    string = record.strings[0]
                    if string.startswith('oa1:' + prefix):
                        address = self.find_regex(
                            string, r'recipient_address=([A-Za-z0-9]+)')
                        name = self.find_regex(string,
                                               r'recipient_name=([^;]+)')
                        if not name:
                            name = address
                        if not address:
                            continue
                        return (address, name)
                QMessageBox.warning(self.win, _('Error'),
                                    _('No OpenAlias record found.'), _('OK'))
                return 0
            except dns.resolver.NXDOMAIN:
                err = _('No such domain.')
                continue
            except dns.resolver.Timeout:
                err = _('Timed out while resolving.')
                continue
            except DNSException:
                err = _('Unhandled exception.')
                continue
            except Exception, e:
                err = _('Unexpected error: ' + str(e))
                continue
            break
Exemplo n.º 60
0
 def choice(self, title, msg, choices):
     vbox = QVBoxLayout()
     self.set_layout(vbox)
     vbox.addWidget(QLabel(title))
     gb2 = QGroupBox(msg)
     vbox.addWidget(gb2)
     group2 = QButtonGroup()
     for i,c in enumerate(choices):
         button = QRadioButton(gb2)
         button.setText(c[1])
         vbox.addWidget(button)
         group2.addButton(button)
         group2.setId(button, i)
         if i==0:
             button.setChecked(True)
     vbox.addStretch(1)
     vbox.addLayout(ok_cancel_buttons(self, _("Next")))
     if not self.exec_():
         return
     wallet_type = choices[group2.checkedId()][0]
     return wallet_type