Esempio n. 1
0
    def get_card(self, req):
        address = req['address']
        timestamp = req.get('time', 0)
        amount = req.get('amount')
        expiration = req.get('exp', None)
        status = req.get('status')
        signature = req.get('sig')

        ci = self.cards.get(address)
        if ci is None:
            ci = Factory.RequestItem()
            ci.screen = self
            ci.address = address
            self.cards[address] = ci

        ci.memo = self.app.wallet.get_label(address)
        if amount:
            status = req.get('status')
            ci.status = request_text[status]
        else:
            received = self.app.wallet.get_addr_received(address)
            ci.status = self.app.format_amount_and_units(amount)
        ci.icon = pr_icon[status]
        ci.amount = self.app.format_amount_and_units(amount) if amount else _('No Amount')
        ci.date = format_time(timestamp)
        return ci
Esempio n. 2
0
 def show_pr_details(self, req, status, is_invoice):
     from denariium.util import format_time
     requestor = req.get('requestor')
     exp = req.get('exp')
     memo = req.get('memo')
     amount = req.get('amount')
     popup = Builder.load_file('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
     txid = req.get('txid')
     popup.tx_hash = txid or ''
     popup.on_open = lambda: popup.ids.output_list.update(req.get('outputs', []))
     popup.open()
Esempio n. 3
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))
Esempio n. 4
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)
Esempio n. 5
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