def get_tx_height(self, txid):
     # because we use a current timestamp, and history is empty,
     # FxThread.history_rate will use spot prices
     return TxMinedInfo(height=10,
                        conf=10,
                        timestamp=int(time.time()),
                        header_hash='def')
Example #2
0
 def get_card(self, tx_item): #tx_hash, tx_mined_status, value, balance):
     is_lightning = tx_item.get('lightning', False)
     timestamp = tx_item['timestamp']
     key = tx_item.get('txid') or tx_item['payment_hash']
     if is_lightning:
         status = 0
         txpos = tx_item['txpos']
         status_str = 'unconfirmed' if timestamp is None else format_time(int(timestamp))
         icon = "atlas://electrum/gui/kivy/theming/light/lightning"
         message = tx_item['label']
     else:
         tx_hash = tx_item['txid']
         conf = tx_item['confirmations']
         txpos = tx_item['txpos_in_block'] or 0
         height = tx_item['height']
         tx_mined_info = TxMinedInfo(height=tx_item['height'],
                                     conf=tx_item['confirmations'],
                                     timestamp=tx_item['timestamp'])
         status, status_str = self.app.wallet.get_tx_status(tx_hash, tx_mined_info)
         icon = "atlas://electrum/gui/kivy/theming/light/" + TX_ICONS[status]
         message = tx_item['label'] or tx_hash
     ri = {}
     ri['screen'] = self
     ri['key'] = key
     ri['icon'] = icon
     ri['date'] = status_str
     ri['message'] = message
     value = tx_item['value'].value
     if value is not None:
         ri['is_mine'] = value < 0
         ri['amount'] = self.app.format_amount(value, is_diff = True)
         if 'fiat_value' in tx_item:
             ri['quote_text'] = str(tx_item['fiat_value'])
     return ri
Example #3
0
 def get_card(self, tx_item):  #tx_hash, tx_mined_status, value, balance):
     is_lightning = tx_item.get('lightning', False)
     timestamp = tx_item['timestamp']
     key = tx_item.get('txid') or tx_item['payment_hash']
     if is_lightning:
         status = 0
         status_str = 'unconfirmed' if timestamp is None else format_time(
             int(timestamp))
         icon = f'atlas://{KIVY_GUI_PATH}/theming/atlas/light/lightning'
         message = tx_item['label']
         fee_msat = tx_item['fee_msat']
         fee = int(fee_msat / 1000) if fee_msat else None
         fee_text = '' if fee is None else 'fee: %d sat' % fee
     else:
         tx_hash = tx_item['txid']
         conf = tx_item['confirmations']
         tx_mined_info = TxMinedInfo(height=tx_item['height'],
                                     conf=tx_item['confirmations'],
                                     timestamp=tx_item['timestamp'])
         status, status_str = self.app.wallet.get_tx_status(
             tx_hash, tx_mined_info)
         icon = f'atlas://{KIVY_GUI_PATH}/theming/atlas/light/' + TX_ICONS[
             status]
         message = tx_item['label'] or tx_hash
         fee = tx_item['fee_sat']
         fee_text = '' if fee is None else 'fee: %d sat' % fee
     ri = {}
     ri['screen'] = self
     ri['key'] = key
     ri['icon'] = icon
     ri['date'] = status_str
     ri['message'] = message
     ri['fee_text'] = fee_text
     value = tx_item['value'].value
     if value is not None:
         ri['is_mine'] = value <= 0
         ri['amount'] = self.app.format_amount(value, is_diff=True)
         if 'fiat_value' in tx_item:
             ri['quote_text'] = str(tx_item['fiat_value'])
     return ri
Example #4
0
 def insert_tx(self, tx_item):
     fx = self.parent.fx
     tx_hash = tx_item['txid']
     height = tx_item['height']
     conf = tx_item['confirmations']
     timestamp = tx_item['timestamp']
     value = tx_item['value'].value
     balance = tx_item['balance'].value
     label = tx_item['label']
     tx_mined_status = TxMinedInfo(height=height,
                                   conf=conf,
                                   timestamp=timestamp)
     status, status_str = self.wallet.get_tx_status(tx_hash,
                                                    tx_mined_status)
     has_invoice = self.wallet.invoices.paid.get(tx_hash)
     v_str = self.parent.format_amount(value,
                                       is_diff=True,
                                       whitespaces=True)
     balance_str = self.parent.format_amount(balance, whitespaces=True)
     entry = ['', status_str, label, v_str, balance_str]
     item = [QStandardItem(e) for e in entry]
     item[3].setData(value, self.SORT_ROLE)
     item[4].setData(balance, self.SORT_ROLE)
     if has_invoice:
         item[2].setIcon(self.icon_cache.get(":icons/seal"))
     for i in range(len(entry)):
         self.set_item_properties(item[i], i, tx_hash)
     if value and value < 0:
         item[2].setForeground(self.red_brush)
         item[3].setForeground(self.red_brush)
     self.txid_to_items[tx_hash] = item
     self.update_item(tx_hash, self.wallet.get_tx_height(tx_hash))
     source_row_idx = self.std_model.rowCount()
     self.std_model.insertRow(source_row_idx, item)
     new_idx = self.std_model.index(source_row_idx, 0)
     history = fx.show_history()
     if history:
         self.update_fiat(tx_hash, tx_item)
     self.hide_row(self.proxy.mapFromSource(new_idx).row())
Example #5
0
 def tx_mined_info_from_tx_item(tx_item):
     tx_mined_info = TxMinedInfo(height=tx_item['height'],
                                 conf=tx_item['confirmations'],
                                 timestamp=tx_item['timestamp'])
     return tx_mined_info