Example #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
Example #2
0
	def getDataArray(self, tip):
		return [
			#tip.getID(),
			format_time(tip.chaintip_message_created_utc), 
			#tip.acceptance_status,
			#tip.chaintip_confirmation_status if hasattr(tip, "chaintip_confirmation_status") else "",
			'linked' if tip.acceptance_status == 'received' else 'not yet linked' if tip.acceptance_status == 'funded' else tip.acceptance_status,
			#tip.chaintip_confirmation_status if hasattr(tip, "chaintip_confirmation_status") else "",
			tip.chaintip_confirmation_status if (hasattr(tip, "chaintip_confirmation_status") and tip.chaintip_confirmation_status == "<stealth>") else "",
			tip.payment_status,
			"{0:.8f}".format(tip.amount_received_bch) if isinstance(tip.amount_received_bch, Decimal) else "",
			#tip.chaintip_message_author_name,
			#tip.chaintip_message_subject,
			tip.subreddit_str if hasattr(tip, "subreddit_str") else "",
			tip.username,
			#tip.direction,
			tip.tip_amount_text,
			"{0:.8f}".format(tip.amount_bch) if isinstance(tip.amount_bch, Decimal) else "",
			"{0:.2f}".format(tip.amount_fiat) if hasattr(tip, "amount_fiat") and tip.amount_fiat else "",
			#tip.fiat_currency if hasattr(tip, "fiat_currency") else "",
			#tip.recipient_address.to_ui_string() if tip.recipient_address else None,
			#str(tip.tip_quantity),
			#tip.tip_unit,
			#tip.tipping_comment_id,
			#tip.tippee_content_link,
			#tip.tippee_post_id,
			#tip.tippee_comment_id,
			#tip.tipping_comment.body.partition('\n')[0] if hasattr(tip, "tipping_comment") else "",
			#tip.claim_return_txid if hasattr(tip, "claim_return_txid") and tip.claim_return_txid else ""
		]
Example #3
0
    def on_update(self):
        self.chkVisible()

        # update the receive address if necessary
        current_address_string = self.parent.receive_address_e.text().strip()
        current_address = Address.from_string(current_address_string) if len(
            current_address_string) else None
        domain = self.wallet.get_receiving_addresses()
        addr = self.wallet.get_unused_address()
        if current_address not in domain and addr:
            self.parent.set_receive_address(addr)

        # clear the list and fill it again
        item = self.currentItem()
        prev_sel = item.data(0, Qt.UserRole) if item else None
        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', '')
            token_id = req.get('token_id', None)
            if token_id:
                amount_str = str(amount) if amount else ""
                item = QTreeWidgetItem([
                    date,
                    address.to_ui_string(), '', message, amount_str,
                    _(pr_tooltips.get(status, ''))
                ])
            else:
                amount_str = self.parent.format_amount(
                    amount) if amount else ""
                item = QTreeWidgetItem([
                    date,
                    address.to_ui_string(), '', message, amount_str,
                    _(pr_tooltips.get(status, ''))
                ])
            item.setData(0, Qt.UserRole, address)
            if signature is not None:
                item.setIcon(2, QIcon(":icons/seal.svg"))
                item.setToolTip(2, 'signed by ' + requestor)
            if status is not PR_UNKNOWN:
                item.setIcon(6, QIcon(pr_icons.get(status)))
            self.addTopLevelItem(item)
            if prev_sel == address:
                self.setCurrentItem(item)
Example #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_string = self.parent.receive_address_e.text().strip()
        current_address = Address.from_string(current_address_string) if len(
            current_address_string) else None
        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.to_ui_string(), '', message, amount_str,
                pr_tooltips.get(status, '')
            ])
            item.setData(0, Qt.UserRole, address)
            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)
Example #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))
Example #6
0
 def show_pr_details(self, req, status, is_invoice):
     from electroncash.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()
Example #7
0
 def importRecentTipsFromReddit(self):
     dates = []
     for tip in self.tiplist.tips.values():
         if hasattr(tip, "chaintip_message_created_utc"):
             dates.append(int(tip.chaintip_message_created_utc))
     if len(dates) > 0:
         dates = sorted(dates)
         self.print_error(
             f"importRecentTipsFromReddit(): latest tip date: {dates[-1]} = {format_time(dates[-1])}, importing..."
         )
         # import...
         try:
             dialog = WaitingDialog(
                 self.window,
                 _("importing from Reddit (starting {d})...").format(
                     d=format_time(dates[-1])),
                 lambda: self.reddit.doImport(-3, dates[-1]),
                 auto_exec=True,
                 on_error=self.importError)
         except Exception as e:
             traceback.print_exc()
             traceback.print_stack()
Example #8
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
Example #9
0
    def doReloadForKey(self, ignored):
        t0 = time.time()
        wallet = parent().wallet
        daemon = parent().daemon
        if not wallet:
            return list(
            )  # wallet not open for whatever reason (can happen due to app backgrounding)

        domain = wallet.get_addresses()

        reqs = list()
        for req in wallet.get_sorted_requests(parent().config):
            address = req['address']
            if address not in domain:
                print("addr '%s' not in domain!" % str(address))
                continue
            timestamp = req.get('time', 0)
            amount = req.get('amount', None)
            expiration = req.get('exp', None)
            expirationStr = format_time(expiration) if expiration else ''
            message = req.get('memo', '')
            date = format_time(timestamp)
            status = req.get('status')
            signature = req.get('sig')
            requestor = req.get('name', '')
            amount_str = parent().format_amount(amount) if amount else ""
            signedBy = ''
            iconSign = ''
            iconStatus = ''
            fiatStr = ''
            fiat = None
            #item.setData(0, Qt.UserRole, address)
            if signature is not None:
                #item.setIcon(2, QIcon(":icons/seal.png"))
                #item.setToolTip(2, 'signed by '+ requestor)
                signedBy = 'signed by ' + requestor
                iconSign = "seal.png"
            if status is not PR_UNKNOWN:
                #item.setIcon(6, QIcon(pr_icons.get(status)))
                iconStatus = pr_icons.get(status, '')
            try:
                if daemon and daemon.fx.is_enabled() and amount:
                    fiatStr = daemon.fx.format_amount_and_units(amount)
                    try:
                        fiat = float(fiatStr.split()[0])
                    except:
                        pass
            except:
                utils.NSLog("ReqMgr: could not get fiat amount")
                fiatStr = ''
            #ReqItem = namedtuple("ReqItem", "dateStr addrStr signedBy message amountStr statusStr addr iconSign iconStatus fiatStr, timestamp expiration expirationStr amount fiat")
            item = ReqItem(date, address.to_ui_string(),
                           signedBy, message, amount_str,
                           pr_tooltips.get(status, ''), address, iconSign,
                           iconStatus, fiatStr, timestamp, expiration,
                           expirationStr, amount, fiat)
            #print ("addr,amount,expiration = ",item.addrStr, item.amountStr, item.expiration, item.expirationStr)
            #self.addTopLevelItem(item)
            reqs.append(item)
            #print(item)
        reqs = sorted(reqs, key=lambda x: -x.timestamp)
        utils.NSLog("ReqMgr: fetched %d extant payment requests in %f ms",
                    len(reqs), (time.time() - t0) * 1e3)
        return reqs