Browse Source

Merge pull request #3370 from benma/devices

digitalbitbox: correctly handle user aborts
3.0.x
ThomasV 7 years ago
committed by GitHub
parent
commit
24af618164
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      lib/plugins.py
  2. 7
      plugins/digitalbitbox/digitalbitbox.py

2
lib/plugins.py

@ -472,7 +472,7 @@ class DeviceMgr(ThreadJob, PrintError):
infos = self.unpaired_device_infos(handler, plugin, devices) infos = self.unpaired_device_infos(handler, plugin, devices)
if infos: if infos:
break break
msg = _('Could not connect to your %s. Verify the cable is ' msg = _('Please insert your %s. Verify the cable is '
'connected and that no other application is using it.\n\n' 'connected and that no other application is using it.\n\n'
'Try to connect again?') % plugin.device 'Try to connect again?') % plugin.device
if not handler.yes_no_question(msg): if not handler.yes_no_question(msg):

7
plugins/digitalbitbox/digitalbitbox.py

@ -11,7 +11,7 @@ try:
from electrum.i18n import _ from electrum.i18n import _
from electrum.keystore import Hardware_KeyStore from electrum.keystore import Hardware_KeyStore
from ..hw_wallet import HW_PluginBase 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 time
import hid import hid
@ -588,6 +588,9 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
self.handler.finished() self.handler.finished()
if 'error' in reply: 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']) raise Exception(reply['error']['message'])
if 'sign' not in reply: if 'sign' not in reply:
@ -623,6 +626,8 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
sig = sigencode_der(sig_r, sig_s, generator_secp256k1.order()) sig = sigencode_der(sig_r, sig_s, generator_secp256k1.order())
txin['signatures'][ii] = to_hexstr(sig) + '01' txin['signatures'][ii] = to_hexstr(sig) + '01'
tx._inputs[i] = txin tx._inputs[i] = txin
except UserCancelled:
raise
except BaseException as e: except BaseException as e:
self.give_error(e, True) self.give_error(e, True)
else: else:

Loading…
Cancel
Save