From 0d4805f6fdffa93f74c794bb55ff3e3b66cfb52d Mon Sep 17 00:00:00 2001 From: Darin Stanchfield Date: Sun, 30 Aug 2015 09:24:31 -0700 Subject: [PATCH 1/2] added cancel button to transactional dialogs --- plugins/keepkey.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/keepkey.py b/plugins/keepkey.py index 0121d2ba..c6a408cc 100644 --- a/plugins/keepkey.py +++ b/plugins/keepkey.py @@ -235,12 +235,12 @@ class Plugin(BasePlugin): client = self.get_client() inputs = self.tx_inputs(tx, True) outputs = self.tx_outputs(tx) - #try: - signed_tx = client.sign_tx('Bitcoin', inputs, outputs)[1] - #except Exception, e: - # give_error(e) - #finally: - self.handler.stop() + try: + signed_tx = client.sign_tx('Bitcoin', inputs, outputs)[1] + except Exception, e: + give_error(e) + finally: + self.handler.stop() raw = signed_tx.encode('hex') tx.update_signatures(raw) @@ -526,7 +526,7 @@ class KeepKeyGuiMixin(object): message = "Confirm address on KeepKey device to continue" else: message = "Check KeepKey device to continue" - self.handler.show_message(message) + self.handler.show_message(msg.code, message, self) return proto.ButtonAck() def callback_PinMatrixRequest(self, msg): @@ -591,8 +591,10 @@ class KeepKeyQtHandler: def stop(self): self.win.emit(SIGNAL('keepkey_done')) - def show_message(self, msg): + def show_message(self, msg_code, msg, client): + self.messsage_code = msg_code self.message = msg + self.client = client self.win.emit(SIGNAL('message_dialog')) def get_pin(self, msg): @@ -651,6 +653,11 @@ class KeepKeyQtHandler: l = QLabel(self.message) vbox = QVBoxLayout(self.d) vbox.addWidget(l) + + if self.messsage_code in (3, 8): + vbox.addLayout(Buttons(CancelButton(self.d))) + self.d.connect(self.d, SIGNAL('rejected()'), self.client.cancel) + self.d.show() def dialog_stop(self): From c73ea700e1718d8694cf4e5b0dd401a2992a196b Mon Sep 17 00:00:00 2001 From: Darin Stanchfield Date: Sun, 30 Aug 2015 09:36:13 -0700 Subject: [PATCH 2/2] cleanup on error handling when a transaction is cancelled --- plugins/keepkey.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/keepkey.py b/plugins/keepkey.py index c6a408cc..d0849c01 100644 --- a/plugins/keepkey.py +++ b/plugins/keepkey.py @@ -238,9 +238,10 @@ class Plugin(BasePlugin): try: signed_tx = client.sign_tx('Bitcoin', inputs, outputs)[1] except Exception, e: - give_error(e) - finally: self.handler.stop() + give_error(e) + + self.handler.stop() raw = signed_tx.encode('hex') tx.update_signatures(raw)