From f3092a8b500bc41cafe2083ef65583a0ec0e1904 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Fri, 24 Nov 2017 10:09:59 +0100 Subject: [PATCH] digitalbitbox: correctly handle user aborts 1. When the pairing is being forced and the user clicks 'No', the tx was cancelled completely because the UserCancelled exception was accidentally converted to an Exception. 2. Same with user aborting the signing process with a short touch on the device (or a timeout). --- plugins/digitalbitbox/digitalbitbox.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/digitalbitbox/digitalbitbox.py b/plugins/digitalbitbox/digitalbitbox.py index ba0f7265..a96e18ef 100644 --- a/plugins/digitalbitbox/digitalbitbox.py +++ b/plugins/digitalbitbox/digitalbitbox.py @@ -11,7 +11,7 @@ try: from electrum.i18n import _ from electrum.keystore import Hardware_KeyStore from ..hw_wallet import HW_PluginBase - from electrum.util import print_error, to_string + from electrum.util import print_error, to_string, UserCancelled import time import hid @@ -588,6 +588,9 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore): self.handler.finished() if 'error' in reply: + if reply["error"].get('code') in (600, 601): + # aborted via LED short touch or timeout + raise UserCancelled() raise Exception(reply['error']['message']) if 'sign' not in reply: @@ -623,6 +626,8 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore): sig = sigencode_der(sig_r, sig_s, generator_secp256k1.order()) txin['signatures'][ii] = to_hexstr(sig) + '01' tx._inputs[i] = txin + except UserCancelled: + raise except BaseException as e: self.give_error(e, True) else: