fix: android HistoryScreen was not displaying fiat value of unconfirmed txns
This commit is contained in:
@@ -17,7 +17,7 @@ from kivy.lang import Builder
|
|||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform
|
||||||
|
|
||||||
from electrum.util import profiler, parse_URI, format_time, InvalidPassword, NotEnoughFunds
|
from electrum.util import profiler, parse_URI, format_time, InvalidPassword, NotEnoughFunds, Fiat
|
||||||
from electrum import bitcoin
|
from electrum import bitcoin
|
||||||
from electrum.util import timestamp_to_datetime
|
from electrum.util import timestamp_to_datetime
|
||||||
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
|
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
|
||||||
@@ -131,7 +131,6 @@ class HistoryScreen(CScreen):
|
|||||||
status, status_str = self.app.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
status, status_str = self.app.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
||||||
icon = "atlas://gui/kivy/theming/light/" + TX_ICONS[status]
|
icon = "atlas://gui/kivy/theming/light/" + TX_ICONS[status]
|
||||||
label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
|
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)
|
ri = self.cards.get(tx_hash)
|
||||||
if ri is None:
|
if ri is None:
|
||||||
ri = Factory.HistoryItem()
|
ri = Factory.HistoryItem()
|
||||||
@@ -146,8 +145,11 @@ class HistoryScreen(CScreen):
|
|||||||
ri.is_mine = value < 0
|
ri.is_mine = value < 0
|
||||||
if value < 0: value = - value
|
if value < 0: value = - value
|
||||||
ri.amount = self.app.format_amount_and_units(value)
|
ri.amount = self.app.format_amount_and_units(value)
|
||||||
if self.app.fiat_unit and date:
|
if self.app.fiat_unit:
|
||||||
ri.quote_text = self.app.fx.historical_value_str(value, date) + ' ' + self.app.fx.ccy
|
fx = self.app.fx
|
||||||
|
fiat_value = value / Decimal(bitcoin.COIN) * self.app.wallet.price_at_timestamp(tx_hash, fx.timestamp_rate)
|
||||||
|
fiat_value = Fiat(fiat_value, fx.ccy)
|
||||||
|
ri.quote_text = str(fiat_value)
|
||||||
return ri
|
return ri
|
||||||
|
|
||||||
def update(self, see_all=False):
|
def update(self, see_all=False):
|
||||||
|
|||||||
@@ -1790,6 +1790,7 @@ class Abstract_Wallet(PrintError):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def price_at_timestamp(self, txid, price_func):
|
def price_at_timestamp(self, txid, price_func):
|
||||||
|
"""Returns fiat price of bitcoin at the time tx got confirmed."""
|
||||||
height, conf, timestamp = self.get_tx_height(txid)
|
height, conf, timestamp = self.get_tx_height(txid)
|
||||||
return price_func(timestamp if timestamp else time.time())
|
return price_func(timestamp if timestamp else time.time())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user