mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-26 23:13:25 +00:00
wallet: get_full_history should populate acq_price/cap_gains if enabled
fixes #6370 qt history tab is calling get_full_history; so this is needed to populate cap_gains columns
This commit is contained in:
parent
928e43fc53
commit
c64da9448f
1 changed files with 16 additions and 8 deletions
|
@ -873,7 +873,12 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||
item['value'] = Satoshis(value)
|
||||
balance += value
|
||||
item['balance'] = Satoshis(balance)
|
||||
if fx:
|
||||
if fx and fx.is_enabled() and fx.get_history_config():
|
||||
txid = item.get('txid')
|
||||
if not item.get('lightning') and txid:
|
||||
fiat_fields = self.get_tx_item_fiat(txid, value, fx, item['fee_sat'])
|
||||
item.update(fiat_fields)
|
||||
else:
|
||||
timestamp = item['timestamp'] or now
|
||||
fiat_value = value / Decimal(bitcoin.COIN) * fx.timestamp_rate(timestamp)
|
||||
item['fiat_value'] = Fiat(fiat_value, fx.ccy)
|
||||
|
@ -1973,11 +1978,14 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||
lp = sum([coin.value_sats() for coin in coins]) * p / Decimal(COIN)
|
||||
return lp - ap
|
||||
|
||||
def average_price(self, txid, price_func, ccy):
|
||||
def average_price(self, txid, price_func, ccy) -> Decimal:
|
||||
""" Average acquisition price of the inputs of a transaction """
|
||||
input_value = 0
|
||||
total_price = 0
|
||||
for addr in self.db.get_txi_addresses(txid):
|
||||
txi_addresses = self.db.get_txi_addresses(txid)
|
||||
if not txi_addresses:
|
||||
return Decimal('NaN')
|
||||
for addr in txi_addresses:
|
||||
d = self.db.get_txi_addr(txid, addr)
|
||||
for ser, v in d:
|
||||
input_value += v
|
||||
|
@ -1987,7 +1995,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||
def clear_coin_price_cache(self):
|
||||
self._coin_price_cache = {}
|
||||
|
||||
def coin_price(self, txid, price_func, ccy, txin_value):
|
||||
def coin_price(self, txid, price_func, ccy, txin_value) -> Decimal:
|
||||
"""
|
||||
Acquisition price of a coin.
|
||||
This assumes that either all inputs are mine, or no input is mine.
|
||||
|
|
Loading…
Add table
Reference in a new issue