commit 510399d3d258fef76a390786ad447bba40a2871b parent a500db371db414e4235e0609d6c328aa99eb135f Author: SomberNight <somber.night@protonmail.com> Date: Sun, 15 Mar 2020 17:42:02 +0100 wallet: dust limit calculation should round up (not down) related to prev commit closes #6035 Diffstat:
M | electrum/bitcoin.py | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/electrum/bitcoin.py b/electrum/bitcoin.py @@ -299,6 +299,7 @@ def add_number_to_script(i: int) -> bytes: def relayfee(network: 'Network' = None) -> int: + """Returns feerate in sat/kbyte.""" from .simple_config import FEERATE_DEFAULT_RELAY, FEERATE_MAX_RELAY if network and network.relay_fee is not None: fee = network.relay_fee @@ -310,9 +311,12 @@ def relayfee(network: 'Network' = None) -> int: return fee -def dust_threshold(network: 'Network'=None) -> int: +def dust_threshold(network: 'Network' = None) -> int: + """Returns the dust limit in satoshis.""" # Change <= dust threshold is added to the tx fee - return 182 * 3 * relayfee(network) // 1000 + dust_lim = 182 * 3 * relayfee(network) # in msat + # convert to sat, but round up: + return (dust_lim // 1000) + (dust_lim % 1000 > 0) def hash_encode(x: bytes) -> str: