hw wallets: define SUPPORTED_XTYPES for each plugin
This commit is contained in:
@@ -96,7 +96,7 @@ class DigitalBitbox_Client():
|
||||
|
||||
|
||||
def get_xpub(self, bip32_path, xtype):
|
||||
assert xtype in ('standard', 'p2wpkh-p2sh', 'p2wpkh')
|
||||
assert xtype in self.plugin.SUPPORTED_XTYPES
|
||||
reply = self._get_xpub(bip32_path)
|
||||
if reply:
|
||||
xpub = reply['xpub']
|
||||
@@ -664,6 +664,7 @@ class DigitalBitboxPlugin(HW_PluginBase):
|
||||
DEVICE_IDS = [
|
||||
(0x03eb, 0x2402) # Digital Bitbox
|
||||
]
|
||||
SUPPORTED_XTYPES = ('standard', 'p2wpkh-p2sh', 'p2wpkh', 'p2wsh-p2sh', 'p2wsh')
|
||||
|
||||
def __init__(self, parent, config, name):
|
||||
HW_PluginBase.__init__(self, parent, config, name)
|
||||
@@ -723,8 +724,8 @@ class DigitalBitboxPlugin(HW_PluginBase):
|
||||
|
||||
|
||||
def get_xpub(self, device_id, derivation, xtype, wizard):
|
||||
if xtype not in ('standard', 'p2wpkh-p2sh', 'p2wpkh'):
|
||||
raise ScriptTypeNotSupported(_('This type of script is not supported with the Digital Bitbox.'))
|
||||
if xtype not in self.SUPPORTED_XTYPES:
|
||||
raise ScriptTypeNotSupported(_('This type of script is not supported with {}.').format(self.device))
|
||||
devmgr = self.device_manager()
|
||||
client = devmgr.client_by_id(device_id)
|
||||
client.handler = self.create_handler(wizard)
|
||||
|
||||
@@ -78,6 +78,7 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||
libraries_URL = 'https://github.com/keepkey/python-keepkey'
|
||||
minimum_firmware = (1, 0, 0)
|
||||
keystore_class = KeepKey_KeyStore
|
||||
SUPPORTED_XTYPES = ('standard', )
|
||||
|
||||
MAX_LABEL_LEN = 32
|
||||
|
||||
@@ -235,8 +236,8 @@ class KeepKeyPlugin(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.'))
|
||||
if xtype not in self.SUPPORTED_XTYPES:
|
||||
raise ScriptTypeNotSupported(_('This type of script is not supported with {}.').format(self.device))
|
||||
devmgr = self.device_manager()
|
||||
client = devmgr.client_by_id(device_id)
|
||||
client.handler = wizard
|
||||
|
||||
@@ -12,6 +12,7 @@ from electrum.transaction import Transaction
|
||||
from electrum.wallet import Standard_Wallet
|
||||
from ..hw_wallet import HW_PluginBase
|
||||
from electrum.util import print_error, is_verbose, bfh, bh2u, versiontuple
|
||||
from electrum.base_wizard import ScriptTypeNotSupported
|
||||
|
||||
try:
|
||||
import hid
|
||||
@@ -549,6 +550,7 @@ class LedgerPlugin(HW_PluginBase):
|
||||
(0x2c97, 0x0000), # Blue
|
||||
(0x2c97, 0x0001) # Nano-S
|
||||
]
|
||||
SUPPORTED_XTYPES = ('standard', 'p2wpkh-p2sh', 'p2wpkh', 'p2wsh-p2sh', 'p2wsh')
|
||||
|
||||
def __init__(self, parent, config, name):
|
||||
self.segwit = config.get("segwit")
|
||||
@@ -592,6 +594,8 @@ class LedgerPlugin(HW_PluginBase):
|
||||
client.get_xpub("m/44'/0'", 'standard') # TODO replace by direct derivation once Nano S > 1.1
|
||||
|
||||
def get_xpub(self, device_id, derivation, xtype, wizard):
|
||||
if xtype not in self.SUPPORTED_XTYPES:
|
||||
raise ScriptTypeNotSupported(_('This type of script is not supported with {}.').format(self.device))
|
||||
devmgr = self.device_manager()
|
||||
client = devmgr.client_by_id(device_id)
|
||||
client.handler = self.create_handler(wizard)
|
||||
|
||||
@@ -10,6 +10,7 @@ from electrum.i18n import _
|
||||
from electrum.plugins import BasePlugin, Device
|
||||
from electrum.transaction import deserialize, Transaction
|
||||
from electrum.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey, xtype_from_derivation
|
||||
from electrum.base_wizard import ScriptTypeNotSupported
|
||||
|
||||
from ..hw_wallet import HW_PluginBase
|
||||
|
||||
@@ -85,6 +86,7 @@ class TrezorPlugin(HW_PluginBase):
|
||||
minimum_firmware = (1, 5, 2)
|
||||
keystore_class = TrezorKeyStore
|
||||
minimum_library = (0, 9, 0)
|
||||
SUPPORTED_XTYPES = ('standard', 'p2wpkh-p2sh', 'p2wpkh', 'p2wsh-p2sh', 'p2wsh')
|
||||
|
||||
MAX_LABEL_LEN = 32
|
||||
|
||||
@@ -263,6 +265,8 @@ class TrezorPlugin(HW_PluginBase):
|
||||
client.used()
|
||||
|
||||
def get_xpub(self, device_id, derivation, xtype, wizard):
|
||||
if xtype not in self.SUPPORTED_XTYPES:
|
||||
raise ScriptTypeNotSupported(_('This type of script is not supported with {}.').format(self.device))
|
||||
devmgr = self.device_manager()
|
||||
client = devmgr.client_by_id(device_id)
|
||||
client.handler = wizard
|
||||
|
||||
Reference in New Issue
Block a user