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()
Beispiel #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()
 def show_pr_details(self, req, status, is_invoice):
     from electrum_exos.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/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()