diff --git a/src/cryptoadvance/specter/managers/device_manager.py b/src/cryptoadvance/specter/managers/device_manager.py index a4919a047f..16b3b303fb 100644 --- a/src/cryptoadvance/specter/managers/device_manager.py +++ b/src/cryptoadvance/specter/managers/device_manager.py @@ -4,12 +4,12 @@ import pathlib from flask_babel import lazy_gettext as _ -from cryptoadvance.specter.devices.bitcoin_core import BitcoinCoreWatchOnly +from cryptoadvance.specter.devices.bitcoin_core import BitcoinCore, BitcoinCoreWatchOnly from ..helpers import alias, load_jsons from ..rpc import get_default_datadir -from ..devices import __all__ as device_classes +from ..devices import __all__ as all_device_classes from ..devices.generic import GenericDevice # default device type from ..persistence import write_device, delete_file, delete_folder @@ -18,7 +18,7 @@ def get_device_class(device_type): """Look up device class by its type""" - for cls in device_classes: + for cls in all_device_classes: if device_type == cls.device_type: return cls return GenericDevice @@ -100,33 +100,40 @@ def remove_device( @property def supported_devices(self): - return device_classes + return all_device_classes def supported_devices_for_chain(self, specter): """Devices which you can create via the UI. BitcoinCoreWatchonly is not among them and if we have no node, hot-wallets neither. Liquid support is limited as well. """ if not specter.chain: - devices = [ + device_classes = [ device_class - for device_class in device_classes + for device_class in all_device_classes if device_class.device_type not in ["bitcoincore", "elementscore"] ] elif specter.is_liquid: - devices = [ + device_classes = [ device_class - for device_class in device_classes + for device_class in all_device_classes if device_class.liquid_support ] else: - devices = [ + device_classes = [ device_class - for device_class in device_classes + for device_class in all_device_classes if device_class.bitcoin_core_support ] - if BitcoinCoreWatchOnly in devices: - devices.remove(BitcoinCoreWatchOnly) - return devices + if BitcoinCoreWatchOnly in device_classes: + device_classes.remove(BitcoinCoreWatchOnly) + + # The node might not like to have certain devices + new_device_classes = [] + for device_class in device_classes: + if specter.node.is_device_supported(device_class): + new_device_classes.append(device_class) + device_classes = new_device_classes + return device_classes def delete(self, specter): """Deletes all the devices""" diff --git a/src/cryptoadvance/specter/managers/node_manager.py b/src/cryptoadvance/specter/managers/node_manager.py index 68598e8423..718cadb5dc 100644 --- a/src/cryptoadvance/specter/managers/node_manager.py +++ b/src/cryptoadvance/specter/managers/node_manager.py @@ -65,8 +65,6 @@ def load_from_disk(self, data_folder=None): default_alias=nodes_files[node_alias]["alias"], default_fullpath=calc_fullpath(self.data_folder, node_alias), ) - print("---------------------------------------") - print(node.__class__.__module__.split(".")) if ( node.__class__.__module__.split(".")[1] == "specterext" ): # e.g. cryptoadvance.specterext.spectrum diff --git a/src/cryptoadvance/specter/node.py b/src/cryptoadvance/specter/node.py index a9030d6e9e..c35ca8e22a 100644 --- a/src/cryptoadvance/specter/node.py +++ b/src/cryptoadvance/specter/node.py @@ -3,12 +3,16 @@ import os from os import path import shutil +from typing import Type from embit.liquid.networks import get_network from flask import render_template from flask_babel import lazy_gettext as _ from requests.exceptions import ConnectionError +from cryptoadvance.specter.devices.bitcoin_core import BitcoinCore, BitcoinCoreWatchOnly +from cryptoadvance.specter.devices.elements_core import ElementsCore + from .helpers import deep_update, is_liquid, is_testnet from .liquid.rpc import LiquidRPC from .persistence import PersistentObject, write_node @@ -19,6 +23,7 @@ get_default_datadir, ) from .specter_error import SpecterError, BrokenCoreConnectionException +from .device import Device logger = logging.getLogger(__name__) @@ -132,6 +137,21 @@ def check_blockheight(self): "A Node Implementation need to implement the check_blockheight method" ) + def is_device_supported(self, device_class_or_device_instance): + """Lets the node deactivate specific devices. The parameter could be a device or a device_type + You have to check yourself if overriding this method. + e.g. + if device_instance_or_device_class.__class__ == type: + device_class = device_instance_or_device_class + else: + device_class = device_instance_or_device_class.__class__ + # example: + # if BitcoinCore == device_class: + # return False + return True + """ + return True + def node_info_template(self): """This should return the path to a Info template as string""" return "node/components/bitcoin_core_info.jinja" diff --git a/src/cryptoadvance/specter/templates/wallet/new_wallet/new_wallet.jinja b/src/cryptoadvance/specter/templates/wallet/new_wallet/new_wallet.jinja index 9699de8022..dd58dbada8 100644 --- a/src/cryptoadvance/specter/templates/wallet/new_wallet/new_wallet.jinja +++ b/src/cryptoadvance/specter/templates/wallet/new_wallet/new_wallet.jinja @@ -11,7 +11,7 @@ {% for device_name in specter.device_manager.devices_names %} {% set device = specter.device_manager.devices[device_name] %}