1
0

wallet: rm wallet.txin_value

This commit is contained in:
SomberNight
2020-10-16 21:25:11 +02:00
parent 8b2eb83238
commit e71fa4924f
2 changed files with 3 additions and 15 deletions

View File

@@ -149,6 +149,8 @@ class AddressSynchronizer(Logger):
return txin.value_sats() return txin.value_sats()
prevout_hash = txin.prevout.txid.hex() prevout_hash = txin.prevout.txid.hex()
prevout_n = txin.prevout.out_idx prevout_n = txin.prevout.out_idx
if address is None:
address = self.get_txin_address(txin)
if address: if address:
d = self.db.get_txo_addr(prevout_hash, address) d = self.db.get_txo_addr(prevout_hash, address)
for n, v, cb in d: for n, v, cb in d:

View File

@@ -2049,20 +2049,6 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
def pubkeys_to_address(self, pubkeys: Sequence[str]) -> Optional[str]: def pubkeys_to_address(self, pubkeys: Sequence[str]) -> Optional[str]:
pass pass
def txin_value(self, txin: TxInput) -> Optional[int]:
if isinstance(txin, PartialTxInput):
v = txin.value_sats()
if v: return v
txid = txin.prevout.txid.hex()
prev_n = txin.prevout.out_idx
for addr in self.db.get_txo_addresses(txid):
d = self.db.get_txo_addr(txid, addr)
for n, v, cb in d:
if n == prev_n:
return v
# may occur if wallet is not synchronized
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.""" """Returns fiat price of bitcoin at the time tx got confirmed."""
timestamp = self.get_tx_height(txid).timestamp timestamp = self.get_tx_height(txid).timestamp
@@ -2072,7 +2058,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
coins = self.get_utxos(domain) coins = self.get_utxos(domain)
now = time.time() now = time.time()
p = price_func(now) p = price_func(now)
ap = sum(self.coin_price(coin.prevout.txid.hex(), price_func, ccy, self.txin_value(coin)) for coin in coins) ap = sum(self.coin_price(coin.prevout.txid.hex(), price_func, ccy, self.get_txin_value(coin)) for coin in coins)
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