tMerge pull request #3683 from SomberNight/wizard_scriptnotsupported - electrum - Electrum Bitcoin wallet
 (HTM) git clone https://git.parazyd.org/electrum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
       ---
 (DIR) commit d38303354c92919099780f44c62661a4c8d2e809
 (DIR) parent 1da020c4154b015ed640a451565be5f3d43a1578
 (HTM) Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 11 Jan 2018 16:45:55 +0100
       
       Merge pull request #3683 from SomberNight/wizard_scriptnotsupported
       
       wizard: allow to choose derivation again if script type is not supported
       Diffstat:
         M lib/base_wizard.py                  |      17 ++++++++++++++---
         M plugins/digitalbitbox/digitalbitbo… |       3 +++
         M plugins/keepkey/plugin.py           |       3 +++
       
       3 files changed, 20 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/lib/base_wizard.py b/lib/base_wizard.py
       t@@ -31,6 +31,9 @@ from .wallet import Imported_Wallet, Standard_Wallet, Multisig_Wallet, wallet_ty
        from .i18n import _
        
        
       +class ScriptTypeNotSupported(Exception): pass
       +
       +
        class BaseWizard(object):
        
            def __init__(self, config, storage):
       t@@ -242,9 +245,15 @@ class BaseWizard(object):
                    ('p2sh-segwit BIP49', bip44_derivation(0, bip43_purpose=49)),
                    ('native-segwit BIP84', bip44_derivation(0, bip43_purpose=84)),
                )
       -        self.line_dialog(run_next=f, title=_('Derivation'), message=message,
       -                         default=default, test=bitcoin.is_bip32_derivation,
       -                         presets=presets)
       +        while True:
       +            try:
       +                self.line_dialog(run_next=f, title=_('Derivation'), message=message,
       +                                 default=default, test=bitcoin.is_bip32_derivation,
       +                                 presets=presets)
       +                return
       +            except ScriptTypeNotSupported as e:
       +                self.show_error(e)
       +                # let the user choose again
        
            def on_hw_derivation(self, name, device_info, derivation):
                from .keystore import hardware_keystore
       t@@ -254,6 +263,8 @@ class BaseWizard(object):
                    return
                try:
                    xpub = self.plugin.get_xpub(device_info.device.id_, derivation, xtype, self)
       +        except ScriptTypeNotSupported:
       +            raise  # this is handled in derivation_dialog
                except BaseException as e:
                    self.show_error(e)
                    return
 (DIR) diff --git a/plugins/digitalbitbox/digitalbitbox.py b/plugins/digitalbitbox/digitalbitbox.py
       t@@ -12,6 +12,7 @@ try:
            from electrum.keystore import Hardware_KeyStore
            from ..hw_wallet import HW_PluginBase
            from electrum.util import print_error, to_string, UserCancelled
       +    from electrum.base_wizard import ScriptTypeNotSupported
        
            import time
            import hid
       t@@ -697,6 +698,8 @@ class DigitalBitboxPlugin(HW_PluginBase):
        
        
            def get_xpub(self, device_id, derivation, xtype, wizard):
       +        if xtype not in ('standard', 'p2wpkh-p2sh'):
       +            raise ScriptTypeNotSupported(_('This type of script is not supported with the Digital Bitbox.'))
                devmgr = self.device_manager()
                client = devmgr.client_by_id(device_id)
                client.handler = self.create_handler(wizard)
 (DIR) diff --git a/plugins/keepkey/plugin.py b/plugins/keepkey/plugin.py
       t@@ -10,6 +10,7 @@ from electrum.i18n import _
        from electrum.plugins import BasePlugin
        from electrum.transaction import deserialize
        from electrum.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey
       +from electrum.base_wizard import ScriptTypeNotSupported
        
        from ..hw_wallet import HW_PluginBase
        
       t@@ -208,6 +209,8 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
                client.used()
        
            def get_xpub(self, device_id, derivation, xtype, wizard):
       +        if xtype not in ('standard',):
       +            raise ScriptTypeNotSupported(_('This type of script is not supported with KeepKey.'))
                devmgr = self.device_manager()
                client = devmgr.client_by_id(device_id)
                client.handler = wizard