Browse Source

TxOutput usage: trivial clean-up

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
parent
commit
5effaaf428
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/transaction.py
  2. 6
      electrum/wallet.py

2
electrum/transaction.py

@ -1043,7 +1043,7 @@ class Transaction:
return sum(x['value'] for x in self.inputs())
def output_value(self):
return sum(val for tp, addr, val in self.outputs())
return sum(o.value for o in self.outputs())
def get_fee(self):
return self.input_value() - self.output_value()

6
electrum/wallet.py

@ -869,17 +869,17 @@ class Abstract_Wallet(AddressSynchronizer):
inputs = tx.inputs()
outputs = tx.outputs()
# use own outputs
s = list(filter(lambda x: self.is_mine(x[1]), outputs))
s = list(filter(lambda o: self.is_mine(o.address), outputs))
# ... unless there is none
if not s:
s = outputs
x_fee = run_hook('get_tx_extra_fee', self, tx)
if x_fee:
x_fee_address, x_fee_amount = x_fee
s = filter(lambda x: x[1]!=x_fee_address, s)
s = filter(lambda o: o.address != x_fee_address, s)
# prioritize low value outputs, to get rid of dust
s = sorted(s, key=lambda x: x[2])
s = sorted(s, key=lambda o: o.value)
for o in s:
i = outputs.index(o)
if o.value - delta >= self.dust_threshold():

Loading…
Cancel
Save