예제 #1
0
 def on_vote_successful(result):
     errmsg, res = result
     if res:
         QMessageBox.information(self, _('Success'), _('Successfully voted'))
     else:
         QMessageBox.critical(self, _('Error Voting'), _(errmsg))
     self.proposals_widget.editor.vote_button.setEnabled(True)
예제 #2
0
    def cast_vote(self, proposal_name, vote_yes):
        """Vote for a proposal. This is called by ProposalsWidget."""
        vote_choice = 'yes' if vote_yes else 'no'
        mn = self.selected_masternode()
        if not mn.announced:
            return QMessageBox.critical(self, _('Cannot Vote'), _('Masternode has not been activated.'))
        # Check that we can vote before asking for a password.
        try:
            self.manager.check_can_vote(mn.alias, proposal_name)
        except Exception as e:
            return QMessageBox.critical(self, _('Cannot Vote'), _(str(e)))

        self.proposals_widget.editor.vote_button.setEnabled(False)

        def vote_thread():
            return self.manager.vote(mn.alias, proposal_name, vote_choice)

        # Show the result.
        def on_vote_successful(result):
            errmsg, res = result
            if res:
                QMessageBox.information(self, _('Success'), _('Successfully voted'))
            else:
                QMessageBox.critical(self, _('Error Voting'), _(errmsg))
            self.proposals_widget.editor.vote_button.setEnabled(True)

        def on_vote_failed(err):
            self.print_error('Error sending vote:')
            # Print traceback information to error log.
            self.print_error(''.join(traceback.format_tb(err[2])))
            self.print_error(''.join(traceback.format_exception_only(err[0], err[1])))
            self.proposals_widget.editor.vote_button.setEnabled(True)

        util.WaitingDialog(self, _('Voting...'), vote_thread, on_vote_successful, on_vote_failed)
예제 #3
0
    def create_menu(self, position):
        self.selectedIndexes()
        item = self.currentItem()
        if not item:
            return
        column = self.currentColumn()
        tx_hash = item.data(0, Qt.UserRole)
        if not tx_hash:
            return
        if column is 0:
            column_title = "ID"
            column_data = tx_hash
        else:
            column_title = self.headerItem().text(column)
            column_data = item.text(column)

        tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
        height, conf, timestamp = self.wallet.get_tx_height(tx_hash)
        tx = self.wallet.transactions.get(tx_hash)
        is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
        is_unconfirmed = height <= 0
        pr_key = self.wallet.invoices.paid.get(tx_hash)

        menu = QMenu()

        menu.addAction(_("Copy %s")%column_title, lambda: self.parent.app.clipboard().setText(column_data))
        if column in self.editable_columns:
            menu.addAction(_("Edit %s")%column_title, lambda: self.editItem(item, column))

        menu.addAction(_("Details"), lambda: self.parent.show_transaction(tx))
        if pr_key:
            menu.addAction(QIcon(":icons/seal"), _("View invoice"), lambda: self.parent.show_invoice(pr_key))
        if tx_URL:
            menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
        menu.exec_(self.viewport().mapToGlobal(position))
예제 #4
0
    def save_current_masternode(self, as_new=False):
        """Save the masternode that is being viewed.

        If as_new is True, a new masternode will be created.
        """
        delegate_privkey = str(self.masternode_editor.delegate_key_edit.text())
        if not delegate_privkey:
            QMessageBox.warning(self, _('Warning'), _('Delegate private key is empty.'))
            return

        try:
            delegate_pubkey = self.manager.import_masternode_delegate(delegate_privkey)
        except Exception:
            # Show an error if the private key is invalid and not an empty string.
            if delegate_privkey:
                QMessageBox.warning(self, _('Warning'), _('Ignoring invalid delegate private key.'))
            delegate_pubkey = ''

        alias = str(self.masternode_editor.alias_edit.text())
        # Construct a new masternode.
        if as_new:
            kwargs = self.masternode_editor.get_masternode_args()
            kwargs['delegate_key'] = delegate_pubkey
            del kwargs['vin']
            self.mapper.revert()
            self.masternodes_widget.add_masternode(MasternodeAnnounce(**kwargs))
        else:
            self.mapper.submit()
        self.manager.save()
        self.masternodes_widget.select_masternode(alias)
예제 #5
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)
예제 #6
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)
예제 #7
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()
예제 #8
0
    def sign_announce(self, alias):
        """Sign an announce for alias. This is called by SignAnnounceWidget."""
        pw = None
        if self.manager.wallet.has_password():
            pw = self.gui.password_dialog(msg=_('Please enter your password to activate masternode "%s".' % alias))
            if pw is None:
                return

        self.sign_announce_widget.sign_button.setEnabled(False)

        def sign_thread():
            return self.manager.sign_announce(alias, pw)

        def on_sign_successful(mn):
            self.print_msg('Successfully signed Masternode Announce.')
            self.send_announce(alias)
        # Proceed to broadcasting the announcement, or re-enable the button.
        def on_sign_error(err):
            self.print_error('Error signing MasternodeAnnounce:')
            # Print traceback information to error log.
            self.print_error(''.join(traceback.format_tb(err[2])))
            self.print_error(''.join(traceback.format_exception_only(err[0], err[1])))
            self.sign_announce_widget.sign_button.setEnabled(True)

        util.WaitingDialog(self, _('Signing Masternode Announce...'), sign_thread, on_sign_successful, on_sign_error)
예제 #9
0
 def refresh_headers(self):
     headers = [_('Address'), _('Label'), _('Balance')]
     fx = self.parent.fx
     if fx and fx.get_fiat_address_config():
         headers.extend([_(fx.get_currency() + ' Balance')])
     headers.extend([_('Tx')])
     self.update_headers(headers)
예제 #10
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.png"
     self.addButton(icon, self.qr_input, _("Read QR code"))
     run_hook('scan_text_edit', self)
예제 #11
0
 def delete_current_masternode(self):
     """Delete the masternode that is being viewed."""
     mn = self.selected_masternode()
     if QMessageBox.question(self, _('Delete'), _('Do you want to remove the masternode configuration for') + ' %s?'%mn.alias,
                 QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes:
         self.masternodes_widget.remove_masternode(mn.alias)
         self.masternodes_widget.view.selectRow(0)
예제 #12
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)
예제 #13
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)
예제 #14
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)
예제 #15
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 Xgox coins in it!")
         if not self.question(msg, title=title,
                              icon=QMessageBox.Critical):
             return
     invoke_client('wipe_device', unpair_after=True)
예제 #16
0
 def restore_seed_dialog(self, run_next, test):
     options = []
     if self.opt_ext:
         options.append('ext')
     if self.opt_bip39:
         options.append('bip39')
     title = _('Enter Seed')
     message = _(
         'Please enter your seed phrase in order to restore your wallet.')
     return self.seed_input(title, message, test, options)
예제 #17
0
 def save(self):
     name = 'signed_%s.txn' % (
         self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn'
     fileName = self.main_window.getSaveFileName(
         _("Select where to save your signed transaction"), name, "*.txn")
     if fileName:
         with open(fileName, "w+") as f:
             f.write(json.dumps(self.tx.as_dict(), indent=4) + '\n')
         self.show_message(_("Transaction saved successfully"))
         self.saved = True
예제 #18
0
 def 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
예제 #19
0
 def on_send_successful(result):
     errmsg, was_announced = result
     if was_announced:
         self.print_msg('Successfully broadcasted MasternodeAnnounce for "%s"' % alias)
         QMessageBox.information(self, _('Success'), _('Masternode activated successfully.'))
     else:
         self.print_error('Failed to broadcast MasternodeAnnounce: %s' % errmsg)
         QMessageBox.critical(self, _('Error Sending'), _(errmsg))
     self.masternodes_widget.refresh_items()
     self.masternodes_widget.select_masternode(alias)
예제 #20
0
    def import_masternode_conf(self, filename):
        """Import a masternode.conf file."""
        pw = None
        if self.manager.wallet.has_password():
            pw = self.gui.password_dialog(msg=_('Please enter your password to import Masternode information.'))
            if pw is None:
                return

        if not os.path.exists(filename):
            QMessageBox.critical(self, _('Error'), _('File does not exist'))
            return
        with open(filename, 'r') as f:
            lines = f.readlines()

        # Show an error if the conf file is malformed.
        try:
            conf_lines = parse_masternode_conf(lines)
        except Exception as e:
            QMessageBox.critical(self, _('Error'), _(str(e)))
            return

        num = self.masternodes_widget.import_masternode_conf_lines(conf_lines, pw)
        if not num:
            return QMessageBox.warning(self, _('Failed to Import'), _('Could not import any masternode configurations. Please ensure that they are not already imported.'))
        # Grammar is important.
        configurations = 'configuration' if num == 1 else 'configurations'
        adjective = 'this' if num == 1 else 'these'
        noun = 'masternode' if num == 1 else 'masternodes'
        words = {'adjective': adjective, 'configurations': configurations, 'noun': noun, 'num': num,}
        msg = '{num} {noun} {configurations} imported.\n\nPlease wait for transactions involving {adjective} {configurations} to be retrieved before activating {adjective} {noun}.'.format(**words)
        QMessageBox.information(self, _('Success'), _(msg))
예제 #21
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, Qt.SmoothTransformation))
         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)
예제 #22
0
    def __init__(self, parent=None):
        super(MasternodeEditor, self).__init__(parent)

        self.alias_edit = QLineEdit()
        self.alias_edit.setPlaceholderText(_('Enter a name for this masternode'))

        self.vin_edit = PrevOutWidget()

        self.addr_edit = NetworkAddressWidget()
        self.delegate_key_edit = QLineEdit()
        self.delegate_key_edit.setFont(QFont(util.MONOSPACE_FONT))
        self.delegate_key_edit.setPlaceholderText(_('Your masternode\'s private key'))
        self.protocol_version_edit = QLineEdit()
        self.protocol_version_edit.setText('70201')

        self.status_edit = QLineEdit()
        self.status_edit.setPlaceholderText(_('Masternode status'))
        self.status_edit.setReadOnly(True)

        form = QFormLayout()
        form.addRow(_('Alias:'), self.alias_edit)
        form.addRow(_('Status:'), self.status_edit)
        form.addRow(_('Collateral XGOX Output:'), self.vin_edit)
        form.addRow(_('Masternode Private Key:'), self.delegate_key_edit)
        form.addRow(_('Address:'), self.addr_edit)
        form.addRow(_('Protocol Version:'), self.protocol_version_edit)

        self.setLayout(form)
예제 #23
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)
예제 #24
0
 def confirm_seed_dialog(self, run_next, test):
     self.app.clipboard().clear()
     title = _('Confirm Seed')
     message = ' '.join([
         _('Your seed is important!'),
         _('If you lose your seed, your money will be permanently lost.'),
         _('To make sure that you have properly saved your seed, please retype it here.'
           )
     ])
     seed, is_bip39, is_ext = self.seed_input(title, message, test, None)
     return seed
예제 #25
0
 def __init__(self, parent, seed, passphrase):
     WindowModalDialog.__init__(self, parent,
                                ('Electrum-XGOX - ' + _('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)))
예제 #26
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)
예제 #27
0
 def get_tooltip(self, pos, fee_rate):
     from electrum_xgox.util import fee_levels
     rate_str = self.window.format_fee_rate(fee_rate) if fee_rate else _(
         'unknown')
     if self.dyn:
         tooltip = fee_levels[pos] + '\n' + rate_str
     else:
         tooltip = 'Fixed rate: ' + rate_str
         if self.config.has_fee_estimates():
             i = self.config.reverse_dynfee(fee_rate)
             tooltip += '\n' + (_('Low fee')
                                if i < 0 else 'Within %d blocks' % i)
     return tooltip
예제 #28
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 Xgox coins 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)
예제 #29
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)
예제 #30
0
    def __init__(self, parent=None):
        super(NetworkAddressWidget, self).__init__(parent)
        self.ip_edit = QLineEdit()
        self.port_edit = QSpinBox()
        self.port_edit.setRange(0, 99999)

        hbox = QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.addWidget(QLabel(_('IP:')))
        hbox.addWidget(self.ip_edit, stretch=1)
        hbox.addWidget(QLabel(_('Port:')))
        hbox.addWidget(self.port_edit, stretch=1)
        self.setLayout(hbox)