From 029e0b8b0d788463feb56cb34540d9dcc9f31e93 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 26 Jun 2014 10:40:33 +0200 Subject: [PATCH] estimate fee using number of outputs --- gui/qt/main_window.py | 19 ++++++++++++------- gui/qt/paytoedit.py | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 51a7c35..cc61f42 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -876,16 +876,21 @@ class ElectrumWindow(QMainWindow): amount = self.amount_e.get_amount() fee = self.fee_e.get_amount() + outputs = self.payto_e.get_outputs() + + if not is_fee: + fee = None - if not is_fee: fee = None if amount is None: self.fee_e.setAmount(None) - return - # assume that there will be 2 outputs (one for change) - inputs, total, fee = self.wallet.choose_tx_inputs(amount, fee, 2, coins = self.get_coins()) - if not is_fee: - self.fee_e.setAmount(fee) - if inputs: + not_enough_funds = False + else: + inputs, total, fee = self.wallet.choose_tx_inputs(amount, fee, len(outputs), coins = self.get_coins()) + not_enough_funds = len(inputs) == 0 + if not is_fee: + self.fee_e.setAmount(fee) + + if not not_enough_funds: palette = QPalette() palette.setColor(self.amount_e.foregroundRole(), QColor('black')) text = "" diff --git a/gui/qt/paytoedit.py b/gui/qt/paytoedit.py index 07deb94..ceb92fa 100644 --- a/gui/qt/paytoedit.py +++ b/gui/qt/paytoedit.py @@ -47,6 +47,7 @@ class PayToEdit(QRTextEdit): self.is_pr = False self.scan_f = self.win.pay_from_URI self.update_size() + self.payto_address = None def lock_amount(self): self.amount_edit.setFrozen(True) -- 1.7.1