wallet: dust limit calculation should round up (not down)

related to prev commit

closes #6035
This commit is contained in:
SomberNight 2020-03-15 17:42:02 +01:00
parent a500db371d
commit 510399d3d2
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -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
@ -311,8 +312,11 @@ def relayfee(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: