electrum

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

commit f00c4ed547bf7384c756f669a4e46ac183ecd8ef
parent c226b29ff42afe83744944a270cfdd5819ded399
Author: ThomasV <thomasv@gitorious>
Date:   Thu, 23 Oct 2014 16:32:27 +0200

simplify error handling during transaction signing

Diffstat:
Mgui/qt/main_window.py | 19+++----------------
Mgui/qt/util.py | 15++++++++-------
2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1081,8 +1081,6 @@ class ElectrumWindow(QMainWindow): tx = self.wallet.make_unsigned_transaction(outputs, fee, None, coins = coins) if not tx: raise BaseException(_("Insufficient funds")) - else: - tx.error = None except Exception as e: traceback.print_exc(file=sys.stdout) self.show_message(str(e)) @@ -1116,32 +1114,21 @@ class ElectrumWindow(QMainWindow): if self.wallet.is_watching_only(): return tx keypairs = {} - try: - self.wallet.add_keypairs(tx, keypairs, password) - self.wallet.sign_transaction(tx, keypairs, password) - except Exception as e: - traceback.print_exc(file=sys.stdout) - tx.error = str(e) + self.wallet.add_keypairs(tx, keypairs, password) + self.wallet.sign_transaction(tx, keypairs, password) return tx def sign_done(tx): - if tx.error: - self.show_message(tx.error) - self.send_button.setDisabled(False) - return if label: self.wallet.set_label(tx.hash(), label) - if not tx.is_complete() or self.config.get('show_before_broadcast'): self.show_transaction(tx) self.do_clear() - self.send_button.setDisabled(False) return - self.broadcast_transaction(tx) # keep a reference to WaitingDialog or the gui might crash - self.waiting_dialog = WaitingDialog(self, 'Signing..', sign_thread, sign_done) + self.waiting_dialog = WaitingDialog(self, 'Signing..', sign_thread, sign_done, lambda: self.send_button.setDisabled(False)) self.waiting_dialog.start() diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -17,7 +17,7 @@ else: class WaitingDialog(QThread): - def __init__(self, parent, message, run_task, on_complete=None): + def __init__(self, parent, message, run_task, on_success=None, on_complete=None): QThread.__init__(self) self.parent = parent self.d = QDialog(parent) @@ -26,6 +26,7 @@ class WaitingDialog(QThread): vbox = QVBoxLayout(self.d) vbox.addWidget(l) self.run_task = run_task + self.on_success = on_success self.on_complete = on_complete self.d.connect(self.d, SIGNAL('done'), self.close) self.d.show() @@ -43,14 +44,14 @@ class WaitingDialog(QThread): self.d.accept() if self.error: QMessageBox.warning(self.parent, _('Error'), self.error, _('OK')) - return + else: + if self.on_success: + if type(self.result) is not tuple: + self.result = (self.result,) + self.on_success(*self.result) if self.on_complete: - if type(self.result) is tuple: - self.on_complete(*self.result) - else: - self.on_complete(self.result) - + self.on_complete() class Timer(QThread):