electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 86c36550809fa330b21edf30a9b65816890a7c5e
parent 3062a62cf99ee907d2239cde3af7ae852463a14f
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 21 Oct 2016 12:59:55 +0200

improve bump_fee (fix #1985)

Diffstat:
Mlib/wallet.py | 26++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/wallet.py b/lib/wallet.py @@ -1015,16 +1015,26 @@ class Abstract_Wallet(PrintError): for txin in inputs: txin['signatures'] = [None] * len(txin['signatures']) self.add_input_info(txin) - for i, o in enumerate(outputs): + # use own outputs + s = filter(lambda x: self.is_mine(x[1]), outputs) + # ... unless there is none + if not s: + s = outputs + # prioritize low value outputs, to get rid of dust + s = sorted(s, key=lambda x: x[2]) + for o in s: + i = outputs.index(o) otype, address, value = o - if self.is_mine(address) and value >= delta: - if value - delta >= self.dust_threshold(): - outputs[i] = otype, address, value - delta - else: - del outputs[i] + if value - delta >= self.dust_threshold(): + outputs[i] = otype, address, value - delta break - else: - raise BaseException(_("Cannot bump fee: could not find a change output")) + else: + del outputs[i] + delta -= value + if delta > 0: + continue + if delta > 0: + raise BaseException(_('Cannot bump fee: cound not find suitable outputs')) return Transaction.from_io(inputs, outputs) def add_input_info(self, txin):