From e864fa50882db90df50e6e0240f55197b28097ed Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 20 Jun 2019 17:47:43 +0200 Subject: [PATCH] coinchooser: tweak heuristic scoring. transactions without any change now get better scores. transactions with really small change get worse scores. --- electrum/coinchooser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/electrum/coinchooser.py b/electrum/coinchooser.py index c8604afb2..9c6a7b88f 100644 --- a/electrum/coinchooser.py +++ b/electrum/coinchooser.py @@ -413,8 +413,13 @@ class CoinChooserPrivacy(CoinChooserRandom): tx, change_outputs = tx_from_buckets(buckets) change = sum(o.value for o in change_outputs) # Penalize change not roughly in output range - if change < min_change: + if change == 0: + pass # no change is great! + elif change < min_change: badness += (min_change - change) / (min_change + 10000) + # Penalize really small change; under 1 mBTC ~= using 1 more input + if change < COIN / 1000: + badness += 1 elif change > max_change: badness += (change - max_change) / (max_change + 10000) # Penalize large change; 5 BTC excess ~= using 1 more input