def update(self):
     inv_list = self.parent.invoices.unpaid_invoices()
     self.model().clear()
     self.update_headers(self.__class__.headers)
     self.header().setSectionResizeMode(self.Columns.REQUESTOR,
                                        QHeaderView.Interactive)
     for idx, pr in enumerate(inv_list):
         key = pr.get_id()
         status = self.parent.invoices.get_status(key)
         if status is None:
             continue
         requestor = pr.get_requestor()
         exp = pr.get_expiration_date()
         date_str = format_time(exp) if exp else _('Never')
         labels = [
             date_str, requestor, pr.memo,
             self.parent.format_amount(pr.get_amount(), whitespaces=True),
             pr_tooltips.get(status, '')
         ]
         items = [QStandardItem(e) for e in labels]
         self.set_editability(items)
         items[self.Columns.STATUS].setIcon(read_QIcon(
             pr_icons.get(status)))
         items[self.Columns.DATE].setData(key, role=Qt.UserRole)
         items[self.Columns.REQUESTOR].setFont(QFont(MONOSPACE_FONT))
         items[self.Columns.AMOUNT].setFont(QFont(MONOSPACE_FONT))
         self.model().insertRow(idx, items)
     self.selectionModel().select(self.model().index(0, 0),
                                  QItemSelectionModel.SelectCurrent)
     if self.parent.isVisible():
         b = len(inv_list) > 0
         self.setVisible(b)
         self.parent.invoices_label.setVisible(b)
     self.filter()
Exemple #2
0
    def update(self):
        self.wallet = self.parent.wallet
        # hide receive tab if no receive requests available
        if self.parent.isVisible():
            b = len(self.wallet.receive_requests) > 0
            self.setVisible(b)
            self.parent.receive_requests_label.setVisible(b)
            if not b:
                self.parent.expires_label.hide()
                self.parent.expires_combo.show()

        # update the receive address if necessary
        current_address = self.parent.receive_address_e.text()
        domain = self.wallet.get_receiving_addresses()
        try:
            addr = self.wallet.get_unused_address()
        except InternalAddressCorruption as e:
            self.parent.show_error(str(e))
            addr = ''
        if current_address not in domain and addr:
            self.parent.set_receive_address(addr)
        self.parent.new_request_button.setEnabled(addr != current_address)
        self.parent.update_receive_address_styling()

        self.model().clear()
        self.update_headers(self.__class__.headers)
        self.hideColumn(self.Columns.ADDRESS)
        for req in self.wallet.get_sorted_requests(self.config):
            address = req['address']
            if address not in domain:
                continue
            timestamp = req.get('time', 0)
            amount = req.get('amount')
            expiration = req.get('exp', None)
            message = req['memo']
            date = format_time(timestamp)
            status = req.get('status')
            signature = req.get('sig')
            requestor = req.get('name', '')
            amount_str = self.parent.format_amount(amount) if amount else ""
            labels = [date, address, '', message, amount_str, pr_tooltips.get(status,'')]
            items = [QStandardItem(e) for e in labels]
            self.set_editability(items)
            if signature is not None:
                items[self.Columns.SIGNATURE].setIcon(read_QIcon("seal.png"))
                items[self.Columns.SIGNATURE].setToolTip(f'signed by {requestor}')
            if status is not PR_UNKNOWN:
                items[self.Columns.STATUS].setIcon(read_QIcon(pr_icons.get(status)))
            items[self.Columns.DESCRIPTION].setData(address, Qt.UserRole)
            self.model().insertRow(self.model().rowCount(), items)
        self.filter()
Exemple #3
0
    def on_update(self):
        self.wallet = self.parent.wallet
        # hide receive tab if no receive requests available
        b = len(self.wallet.receive_requests) > 0
        self.setVisible(b)
        self.parent.receive_requests_label.setVisible(b)
        if not b:
            self.parent.expires_label.hide()
            self.parent.expires_combo.show()

        # update the receive address if necessary
        current_address = self.parent.receive_address_e.text()
        domain = self.wallet.get_receiving_addresses()
        addr = self.wallet.get_unused_address()
        if not current_address in domain and addr:
            self.parent.set_receive_address(addr)
        self.parent.new_request_button.setEnabled(addr != current_address)

        # clear the list and fill it again
        self.clear()
        for req in self.wallet.get_sorted_requests(self.config):
            address = req['address']
            if address not in domain:
                continue
            timestamp = req.get('time', 0)
            amount = req.get('amount')
            expiration = req.get('exp', None)
            message = req.get('memo', '')
            date = format_time(timestamp)
            status = req.get('status')
            signature = req.get('sig')
            requestor = req.get('name', '')
            amount_str = self.parent.format_amount(amount) if amount else ""
            item = QTreeWidgetItem([
                date, address, '', message, amount_str,
                pr_tooltips.get(status, '')
            ])
            if signature is not None:
                item.setIcon(2, QIcon(":icons/seal.png"))
                item.setToolTip(2, 'signed by ' + requestor)
            if status is not PR_UNKNOWN:
                item.setIcon(6, QIcon(pr_icons.get(status)))
            self.addTopLevelItem(item)
 def show_pr_details(self, req, status, is_invoice):
     from electrum_xzc.util import format_time
     requestor = req.get('requestor')
     exp = req.get('exp')
     memo = req.get('memo')
     amount = req.get('amount')
     fund = req.get('fund')
     popup = Builder.load_file('electrum_xzc/gui/kivy/uix/ui_screens/invoice.kv')
     popup.is_invoice = is_invoice
     popup.amount = amount
     popup.requestor = requestor if is_invoice else req.get('address')
     popup.exp = format_time(exp) if exp else ''
     popup.description = memo if memo else ''
     popup.signature = req.get('signature', '')
     popup.status = status
     popup.fund = fund if fund else 0
     txid = req.get('txid')
     popup.tx_hash = txid or ''
     popup.on_open = lambda: popup.ids.output_list.update(req.get('outputs', []))
     popup.export = self.export_private_keys
     popup.open()
Exemple #5
0
 def on_update(self):
     inv_list = self.parent.invoices.unpaid_invoices()
     self.clear()
     for pr in inv_list:
         key = pr.get_id()
         status = self.parent.invoices.get_status(key)
         requestor = pr.get_requestor()
         exp = pr.get_expiration_date()
         date_str = format_time(exp) if exp else _('Never')
         item = QTreeWidgetItem([
             date_str, requestor, pr.memo,
             self.parent.format_amount(pr.get_amount(), whitespaces=True),
             pr_tooltips.get(status, '')
         ])
         item.setIcon(4, QIcon(pr_icons.get(status)))
         item.setData(0, Qt.UserRole, key)
         item.setFont(1, QFont(MONOSPACE_FONT))
         item.setFont(3, QFont(MONOSPACE_FONT))
         self.addTopLevelItem(item)
     self.setCurrentItem(self.topLevelItem(0))
     self.setVisible(len(inv_list))
     self.parent.invoices_label.setVisible(len(inv_list))
Exemple #6
0
 def get_card(self, pr):
     key = pr.get_id()
     ci = self.cards.get(key)
     if ci is None:
         ci = Factory.InvoiceItem()
         ci.key = key
         ci.screen = self
         self.cards[key] = ci
     ci.requestor = pr.get_requestor()
     ci.memo = pr.get_memo()
     amount = pr.get_amount()
     if amount:
         ci.amount = self.app.format_amount_and_units(amount)
         status = self.app.wallet.invoices.get_status(ci.key)
         ci.status = invoice_text[status]
         ci.icon = pr_icon[status]
     else:
         ci.amount = _('No Amount')
         ci.status = ''
     exp = pr.get_expiration_date()
     ci.date = format_time(exp) if exp else _('Never')
     return ci