commit 8bdf863fcae0ee44846e61052582011611a83884
parent 986985c3988b34d09ddd3fbfb984f4445d308d77
Author: SomberNight <somber.night@protonmail.com>
Date: Thu, 12 Apr 2018 16:49:25 +0200
fix: android HistoryScreen was not displaying fiat value of unconfirmed txns
Diffstat:
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
@@ -17,7 +17,7 @@ from kivy.lang import Builder
from kivy.factory import Factory
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.util import timestamp_to_datetime
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)
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()
@@ -146,8 +145,11 @@ class HistoryScreen(CScreen):
ri.is_mine = value < 0
if value < 0: value = - value
ri.amount = self.app.format_amount_and_units(value)
- if self.app.fiat_unit and date:
- ri.quote_text = self.app.fx.historical_value_str(value, date) + ' ' + self.app.fx.ccy
+ if self.app.fiat_unit:
+ 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
def update(self, see_all=False):
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -1790,6 +1790,7 @@ class Abstract_Wallet(PrintError):
return None
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)
return price_func(timestamp if timestamp else time.time())