Exemplo n.º 1
0
 def get_card(self, tx_hash, height, conf, timestamp, value, balance):
     status, status_str = self.app.wallet.get_tx_status(
         tx_hash, height, conf, timestamp)
     icon = "atlas://gui/kivy/theming/light/" + TX_ICONS[status]
     label = self.app.wallet.get_label(tx_hash) if tx_hash else _(
         'Pruned transaction outputs')
     date = timestamp_to_datetime(timestamp)
     ri = self.cards.get(tx_hash)
     if ri is None:
         ri = Factory.HistoryItem()
         ri.screen = self
         ri.tx_hash = tx_hash
         self.cards[tx_hash] = ri
     ri.icon = icon
     ri.date = status_str
     ri.message = label
     ri.value = value or 0
     ri.amount = self.app.format_amount(value,
                                        True) if value is not None else '--'
     ri.confirmations = conf
     if self.app.fiat_unit and date:
         rate = self.app.fx.history_rate(date)
         if rate:
             s = self.app.fx.value_str(value, rate)
             ri.quote_text = '' if s is None else s + ' ' + self.app.fiat_unit
     return ri
Exemplo n.º 2
0
 def update_tx_mined_status(self, tx_hash: str, tx_mined_info: TxMinedInfo):
     try:
         row = self.transactions.pos_from_key(tx_hash)
         tx_item = self.transactions[tx_hash]
     except KeyError:
         return
     self.tx_status_cache[tx_hash] = self.parent.wallet.get_tx_status(tx_hash, tx_mined_info)
     tx_item.update({
         'confirmations':  tx_mined_info.conf,
         'timestamp':      tx_mined_info.timestamp,
         'txpos_in_block': tx_mined_info.txpos,
         'date':           timestamp_to_datetime(tx_mined_info.timestamp),
     })
     topLeft = self.createIndex(row, 0)
     bottomRight = self.createIndex(row, len(HistoryColumns) - 1)
     self.dataChanged.emit(topLeft, bottomRight)
Exemplo n.º 3
0
 def update_tx_mined_status(self, tx_hash: str, tx_mined_info: TxMinedInfo):
     idx = self.index_from_txid(tx_hash)
     if not idx.isValid():
         return
     tx_item = idx.internalPointer()
     if not tx_item:
         return
     islock = tx_item['islock']
     self.tx_status_cache[tx_hash] = \
         self.parent.wallet.get_tx_status(tx_hash, tx_mined_info, islock)
     tx_item.update({
         'confirmations':  tx_mined_info.conf,
         'timestamp':      tx_mined_info.timestamp,
         'txpos_in_block': tx_mined_info.txpos,
         'date':           timestamp_to_datetime(tx_mined_info.timestamp),
     })
     idx_last = idx.sibling(idx.row(), HistoryColumns.TXID)
     self.dataChanged.emit(idx, idx_last)
Exemplo n.º 4
0
 def on_update(self):
     self.wallet = self.parent.wallet
     h = self.wallet.get_history(self.get_domain())
     item = self.currentItem()
     current_tx = item.data(0, Qt.UserRole) if item else None
     self.clear()
     fx = self.parent.fx
     if fx: fx.history_used_spot = False
     for h_item in h:
         tx_hash, height, conf, timestamp, value, balance = h_item
         status, status_str = self.wallet.get_tx_status(
             tx_hash, height, conf, timestamp)
         has_invoice = self.wallet.invoices.paid.get(tx_hash)
         icon = QIcon(":icons/" + TX_ICONS[status])
         v_str = self.parent.format_amount(value, True, whitespaces=True)
         balance_str = self.parent.format_amount(balance, whitespaces=True)
         label = self.wallet.get_label(tx_hash)
         entry = ['', tx_hash, status_str, label, v_str, balance_str]
         if fx and fx.show_history():
             date = timestamp_to_datetime(
                 time.time() if conf <= 0 else timestamp)
             for amount in [value, balance]:
                 text = fx.historical_value_str(amount, date)
                 entry.append(text)
         item = QTreeWidgetItem(entry)
         item.setIcon(0, icon)
         item.setToolTip(
             0,
             str(conf) + " confirmation" + ("s" if conf != 1 else ""))
         if has_invoice:
             item.setIcon(3, QIcon(":icons/seal"))
         for i in range(len(entry)):
             if i > 3:
                 item.setTextAlignment(i, Qt.AlignRight)
             item.setFont(i, QFont(MONOSPACE_FONT))
         if value and value < 0:
             item.setForeground(3, QBrush(QColor("#BC1E1E")))
             item.setForeground(4, QBrush(QColor("#BC1E1E")))
         if tx_hash:
             item.setData(0, Qt.UserRole, tx_hash)
         self.insertTopLevelItem(0, item)
         if current_tx == tx_hash:
             self.setCurrentItem(item)
Exemplo n.º 5
0
 def timestamp_rate(self, timestamp):
     from electrum_dash.util import timestamp_to_datetime
     date = timestamp_to_datetime(timestamp)
     return self.history_rate(date)