tfix #1666 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 2a507b91c138f6cf8310b22ff0d4f774a29f5d3b DIR parent 3ee61c4c6ea23133395663da27b8bbe9a93d74bb HTML Author: ThomasV <thomasv@electrum.org> Date: Wed, 3 Feb 2016 10:29:31 +0100 fix #1666 Diffstat: M gui/qt/main_window.py | 10 +++++++--- M lib/wallet.py | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) --- DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py t@@ -1011,7 +1011,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): def on_shortcut(): inputs = self.get_coins() fee = self.fee_e.get_amount() if self.fee_e.isModified() else None - amount, fee = self.wallet.get_max_amount(self.config, inputs, fee) + addr = self.get_payto_or_dummy() + amount, fee = self.wallet.get_max_amount(self.config, inputs, addr, fee) if not self.fee_e.isModified(): self.fee_e.setAmount(fee) self.amount_e.setAmount(max(0, amount)) t@@ -1078,13 +1079,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): def update_fee(self): self.require_fee_update = True + def get_payto_or_dummy(self): + return self.payto_e.payto_address if self.payto_e.payto_address else self.wallet.dummy_address() + def do_update_fee(self): '''Recalculate the fee. If the fee was manually input, retain it, but still build the TX to see if there are enough funds. ''' freeze_fee = (self.fee_e.isModified() and (self.fee_e.text() or self.fee_e.hasFocus())) - outputs = self.payto_e.get_outputs() amount = self.amount_e.get_amount() if amount is None: if not freeze_fee: t@@ -1092,8 +1095,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.not_enough_funds = False else: fee = self.fee_e.get_amount() if freeze_fee else None + outputs = self.payto_e.get_outputs() if not outputs: - addr = self.payto_e.payto_address if self.payto_e.payto_address else self.wallet.dummy_address() + addr = self.get_payto_or_dummy() outputs = [(TYPE_ADDRESS, addr, amount)] try: tx = self.wallet.make_unsigned_transaction(self.get_coins(), outputs, self.config, fee) DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -657,12 +657,12 @@ class Abstract_Wallet(PrintError): def dummy_address(self): return self.addresses(False)[0] - def get_max_amount(self, config, inputs, fee): + def get_max_amount(self, config, inputs, recipient, fee): sendable = sum(map(lambda x:x['value'], inputs)) for i in inputs: self.add_input_info(i) - output = (TYPE_ADDRESS, self.dummy_address(), sendable) - dummy_tx = Transaction.from_io(inputs, [output]) + outputs = [(TYPE_ADDRESS, recipient, sendable)] + dummy_tx = Transaction.from_io(inputs, outputs) if fee is None: fee = self.estimate_fee(config, dummy_tx.estimated_size()) amount = max(0, sendable - fee)