From 01ad103c37ce53e4dc4126dcae6a9cd3f6a8d060 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 8 Sep 2014 09:29:25 +0200 Subject: [PATCH] don't change fee if it is fixed by user --- lib/wallet.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/wallet.py b/lib/wallet.py index 2558b12f..5920274a 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -759,12 +759,16 @@ class Abstract_Wallet(object): # if change is above dust threshold, add a change output. change_amount = total - ( amount + fee ) - if change_amount > DUST_THRESHOLD: + if fixed_fee is not None: + # Insert the change output at a random position in the outputs + posn = random.randint(0, len(tx.outputs)) + tx.outputs[posn:posn] = [( 'address', change_addr, change_amount)] + elif change_amount > DUST_THRESHOLD: # Insert the change output at a random position in the outputs posn = random.randint(0, len(tx.outputs)) tx.outputs[posn:posn] = [( 'address', change_addr, change_amount)] # recompute fee including change output - fee = fixed_fee if fixed_fee is not None else self.estimated_fee(tx) + fee = self.estimated_fee(tx) # remove change output tx.outputs.pop(posn) # if change is still above dust threshold, re-add change output.