tfix exchange_rate plugin behavior when typing amounts - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit bc3013caf0d3d6a35290e9cc9e51125b7d03d14c DIR parent 89ba1d7b0e63e78ba34013017f3ff9a4fe74fabb HTML Author: ThomasV <thomasv@gitorious> Date: Fri, 27 Feb 2015 21:13:17 +0100 fix exchange_rate plugin behavior when typing amounts Diffstat: M gui/qt/main_window.py | 46 ++++++++++++++++---------------- M plugins/exchange_rate.py | 3 ++- 2 files changed, 25 insertions(+), 24 deletions(-) --- DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py t@@ -1008,29 +1008,9 @@ class ElectrumWindow(QMainWindow): self.amount_e.shortcut.connect(on_shortcut) - def text_edited(is_fee): - outputs = self.payto_e.get_outputs() - amount = self.amount_e.get_amount() - fee = self.fee_e.get_amount() if is_fee else None - if amount is None: - self.fee_e.setAmount(None) - self.not_enough_funds = False - else: - if not outputs: - addr = self.payto_e.payto_address if self.payto_e.payto_address else self.dummy_address - outputs = [('address', addr, amount)] - try: - tx = self.wallet.make_unsigned_transaction(outputs, fee, coins = self.get_coins()) - self.not_enough_funds = False - except NotEnoughFunds: - self.not_enough_funds = True - if not is_fee: - fee = None if self.not_enough_funds else self.wallet.get_tx_fee(tx) - self.fee_e.setAmount(fee) - - self.payto_e.textChanged.connect(lambda:text_edited(False)) - self.amount_e.textEdited.connect(lambda:text_edited(False)) - self.fee_e.textEdited.connect(lambda:text_edited(True)) + self.payto_e.textChanged.connect(lambda: self.update_fee(False)) + self.amount_e.textEdited.connect(lambda: self.update_fee(False)) + self.fee_e.textEdited.connect(lambda: self.update_fee(True)) def entry_changed(): if not self.not_enough_funds: t@@ -1053,6 +1033,26 @@ class ElectrumWindow(QMainWindow): run_hook('create_send_tab', grid) return w + def update_fee(self, is_fee): + outputs = self.payto_e.get_outputs() + amount = self.amount_e.get_amount() + fee = self.fee_e.get_amount() if is_fee else None + if amount is None: + self.fee_e.setAmount(None) + self.not_enough_funds = False + else: + if not outputs: + addr = self.payto_e.payto_address if self.payto_e.payto_address else self.dummy_address + outputs = [('address', addr, amount)] + try: + tx = self.wallet.make_unsigned_transaction(outputs, fee, coins = self.get_coins()) + self.not_enough_funds = False + except NotEnoughFunds: + self.not_enough_funds = True + if not is_fee: + fee = None if self.not_enough_funds else self.wallet.get_tx_fee(tx) + self.fee_e.setAmount(fee) + def update_fee_edit(self): b = self.config.get('can_edit_fees', False) self.fee_e.setVisible(b) DIR diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py t@@ -742,12 +742,13 @@ class Plugin(BasePlugin): fiat_amount = Decimal(str(self.fiat_e.text())) except: self.btc_e.setText("") + self.win.fee_e.setText("") return exchange_rate = self.exchanger.exchange(Decimal("1.0"), self.fiat_unit()) if exchange_rate is not None: btc_amount = fiat_amount/exchange_rate self.btc_e.setAmount(int(btc_amount*Decimal(100000000))) - self.btc_e.textEdited.emit("") + self.win.update_fee(False) self.fiat_e.textEdited.connect(fiat_changed) def btc_changed(): btc_amount = self.btc_e.get_amount()