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,11 +873,16 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
item['value'] = Satoshis(value)
|
item['value'] = Satoshis(value)
|
||||||
balance += value
|
balance += value
|
||||||
item['balance'] = Satoshis(balance)
|
item['balance'] = Satoshis(balance)
|
||||||
if fx:
|
if fx and fx.is_enabled() and fx.get_history_config():
|
||||||
timestamp = item['timestamp'] or now
|
txid = item.get('txid')
|
||||||
fiat_value = value / Decimal(bitcoin.COIN) * fx.timestamp_rate(timestamp)
|
if not item.get('lightning') and txid:
|
||||||
item['fiat_value'] = Fiat(fiat_value, fx.ccy)
|
fiat_fields = self.get_tx_item_fiat(txid, value, fx, item['fee_sat'])
|
||||||
item['fiat_default'] = True
|
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)
|
||||||
|
item['fiat_default'] = True
|
||||||
return transactions
|
return transactions
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
|
@ -1973,11 +1978,14 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
lp = sum([coin.value_sats() for coin in coins]) * p / Decimal(COIN)
|
lp = sum([coin.value_sats() for coin in coins]) * p / Decimal(COIN)
|
||||||
return lp - ap
|
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 """
|
""" Average acquisition price of the inputs of a transaction """
|
||||||
input_value = 0
|
input_value = 0
|
||||||
total_price = 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)
|
d = self.db.get_txi_addr(txid, addr)
|
||||||
for ser, v in d:
|
for ser, v in d:
|
||||||
input_value += v
|
input_value += v
|
||||||
|
@ -1987,7 +1995,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
def clear_coin_price_cache(self):
|
def clear_coin_price_cache(self):
|
||||||
self._coin_price_cache = {}
|
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.
|
Acquisition price of a coin.
|
||||||
This assumes that either all inputs are mine, or no input is mine.
|
This assumes that either all inputs are mine, or no input is mine.
|
||||||
|
|
Loading…
Add table
Reference in a new issue