|
@ -1549,7 +1549,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): |
|
|
tx.add_info_from_wallet(self) |
|
|
tx.add_info_from_wallet(self) |
|
|
assert tx.get_fee() is not None |
|
|
assert tx.get_fee() is not None |
|
|
inputs = tx.inputs() |
|
|
inputs = tx.inputs() |
|
|
outputs = list(tx.outputs()) |
|
|
outputs = tx._outputs # note: we will mutate this directly |
|
|
|
|
|
|
|
|
# use own outputs |
|
|
# use own outputs |
|
|
s = list(filter(lambda o: self.is_mine(o.address), outputs)) |
|
|
s = list(filter(lambda o: self.is_mine(o.address), outputs)) |
|
@ -1559,14 +1559,14 @@ class Abstract_Wallet(AddressSynchronizer, ABC): |
|
|
x_fee = run_hook('get_tx_extra_fee', self, tx) |
|
|
x_fee = run_hook('get_tx_extra_fee', self, tx) |
|
|
if x_fee: |
|
|
if x_fee: |
|
|
x_fee_address, x_fee_amount = x_fee |
|
|
x_fee_address, x_fee_amount = x_fee |
|
|
s = filter(lambda o: o.address != x_fee_address, s) |
|
|
s = list(filter(lambda o: o.address != x_fee_address, s)) |
|
|
if not s: |
|
|
if not s: |
|
|
raise CannotBumpFee('No outputs at all??') |
|
|
raise CannotBumpFee('No outputs at all??') |
|
|
|
|
|
|
|
|
# prioritize low value outputs, to get rid of dust |
|
|
# prioritize low value outputs, to get rid of dust |
|
|
s = sorted(s, key=lambda o: o.value) |
|
|
s = sorted(s, key=lambda o: o.value) |
|
|
for o in s: |
|
|
for o in s: |
|
|
target_fee = int(round(tx.estimated_size() * new_fee_rate)) |
|
|
target_fee = int(math.ceil(tx.estimated_size() * new_fee_rate)) |
|
|
delta = target_fee - tx.get_fee() |
|
|
delta = target_fee - tx.get_fee() |
|
|
i = outputs.index(o) |
|
|
i = outputs.index(o) |
|
|
if o.value - delta >= self.dust_threshold(): |
|
|
if o.value - delta >= self.dust_threshold(): |
|
@ -1577,9 +1577,8 @@ class Abstract_Wallet(AddressSynchronizer, ABC): |
|
|
break |
|
|
break |
|
|
else: |
|
|
else: |
|
|
del outputs[i] |
|
|
del outputs[i] |
|
|
delta -= o.value |
|
|
# note: we mutated the outputs of tx, which will affect |
|
|
# note: delta might be negative now, in which case |
|
|
# tx.estimated_size() in the next iteration |
|
|
# the value of the next output will be increased |
|
|
|
|
|
if delta > 0: |
|
|
if delta > 0: |
|
|
raise CannotBumpFee(_('Could not find suitable outputs')) |
|
|
raise CannotBumpFee(_('Could not find suitable outputs')) |
|
|
|
|
|
|
|
|