Browse Source

Don't use is_available() for HW wallets

is_available() is only used from generic code for non-hardware
wallets.  Having a local function of the same name is confusing.
master
Neil Booth 10 years ago
parent
commit
56497c1ae2
  1. 17
      plugins/ledger/ledger.py
  2. 15
      plugins/trezor/plugin.py

17
plugins/ledger/ledger.py

@ -421,31 +421,22 @@ class LedgerPlugin(BasePlugin):
def __init__(self, parent, config, name): def __init__(self, parent, config, name):
BasePlugin.__init__(self, parent, config, name) BasePlugin.__init__(self, parent, config, name)
self._is_available = self._init()
self.wallet = None self.wallet = None
self.handler = None self.handler = None
def constructor(self, s): def constructor(self, s):
return BTChipWallet(s) return BTChipWallet(s)
def _init(self): def set_enabled(self, enabled):
return BTCHIP self.wallet.storage.put('use_' + self.name, enabled)
def is_available(self): def is_enabled(self):
if not self._is_available: if not BTCHIP:
return False return False
if not self.wallet: if not self.wallet:
return False return False
if self.wallet.storage.get('wallet_type') != 'btchip': if self.wallet.storage.get('wallet_type') != 'btchip':
return False return False
return True
def set_enabled(self, enabled):
self.wallet.storage.put('use_' + self.name, enabled)
def is_enabled(self):
if not self.is_available():
return False
if self.wallet.has_seed(): if self.wallet.has_seed():
return False return False
return True return True

15
plugins/trezor/plugin.py

@ -165,19 +165,16 @@ class TrezorCompatiblePlugin(BasePlugin):
self.print_error(message) self.print_error(message)
raise Exception(message) raise Exception(message)
def is_available(self):
if not self.libraries_available:
return False
if not self.wallet:
return False
wallet_type = self.wallet.storage.get('wallet_type')
return wallet_type == self.wallet_class.wallet_type
def set_enabled(self, enabled): def set_enabled(self, enabled):
self.wallet.storage.put('use_' + self.name, enabled) self.wallet.storage.put('use_' + self.name, enabled)
def is_enabled(self): def is_enabled(self):
if not self.is_available(): if not self.libraries_available:
return False
if not self.wallet:
return False
wallet_type = self.wallet_class.wallet_type
if self.wallet.storage.get('wallet_type') != wallet_type:
return False return False
if self.wallet.has_seed(): if self.wallet.has_seed():
return False return False

Loading…
Cancel
Save