1
0

Merge pull request #3643 from SomberNight/fee_ui_feerounding

fee ui: rounding
This commit is contained in:
ThomasV
2018-01-15 14:18:58 +01:00
committed by GitHub
7 changed files with 96 additions and 18 deletions

View File

@@ -273,6 +273,8 @@ class CoinChooserRandom(CoinChooserBase):
candidates.add(tuple(sorted(permutation[:count + 1])))
break
else:
# FIXME this assumes that the effective value of any bkt is >= 0
# we should make sure not to choose buckets with <= 0 eff. val.
raise NotEnoughFunds()
candidates = [[buckets[n] for n in c] for c in candidates]

View File

@@ -5,7 +5,8 @@ import os
import stat
from copy import deepcopy
from .util import user_dir, print_error, print_stderr, PrintError
from .util import (user_dir, print_error, print_stderr, PrintError,
NoDynamicFeeEstimates)
from .bitcoin import MAX_FEE_RATE, FEE_TARGETS
@@ -245,6 +246,9 @@ class SimpleConfig(PrintError):
return self.get('dynamic_fees', True)
def fee_per_kb(self):
"""Returns sat/kvB fee to pay for a txn.
Note: might return None.
"""
dyn = self.is_dynfee()
if dyn:
fee_rate = self.dynfee(self.get('fee_level', 2))
@@ -252,8 +256,18 @@ class SimpleConfig(PrintError):
fee_rate = self.get('fee_per_kb', self.max_fee_rate()/2)
return fee_rate
def fee_per_byte(self):
"""Returns sat/vB fee to pay for a txn.
Note: might return None.
"""
fee_per_kb = self.fee_per_kb()
return fee_per_kb / 1000 if fee_per_kb is not None else None
def estimate_fee(self, size):
return self.estimate_fee_for_feerate(self.fee_per_kb(), size)
fee_per_kb = self.fee_per_kb()
if fee_per_kb is None:
raise NoDynamicFeeEstimates()
return self.estimate_fee_for_feerate(fee_per_kb, size)
@classmethod
def estimate_fee_for_feerate(cls, fee_per_kb, size):

View File

@@ -923,6 +923,7 @@ class Abstract_Wallet(PrintError):
tx = coin_chooser.make_tx(inputs, outputs, change_addrs[:max_change],
fee_estimator, self.dust_threshold())
else:
# FIXME?? this might spend inputs with negative effective value...
sendable = sum(map(lambda x:x['value'], inputs))
_type, data, value = outputs[i_max]
outputs[i_max] = (_type, data, 0)