Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions hdwallet/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,30 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit

try:
from .. import environment
except:
pass

import inspect
# Import the module containing cryptocurrency definitions
from bip38 import cryptocurrencies

BIP38_CRYPTOCURRENCIES = {
# The original 'try/except from .. import environment' block was removed.
# It was likely causing ImportError when run as a script and was not used
# later in the code, leading to an unnecessary silent error handler.

# Define a dictionary to map cryptocurrency class names to their classes.
# The variable name uses snake_case as it represents a module-level collection,
# not a globally immutable constant (though convention often leans toward ALL_CAPS
# for module-level variables like this if they are treated as immutable).
bip38_cryptocurrencies = {
# Iterate over all members of the 'cryptocurrencies' module
name: cls for name, cls in inspect.getmembers(cryptocurrencies, inspect.isclass)
if issubclass(cls, cryptocurrencies.ICryptocurrency)
}
# Filter to include only classes that inherit from ICryptocurrency
# and exclude the base interface class itself (ICryptocurrency).
if issubclass(cls, cryptocurrencies.ICryptocurrency) and cls is not cryptocurrencies.ICryptocurrency
}

# Example of how the dynamically loaded data is structured:
# print(bip38_cryptocurrencies)

# If the file needs to execute specific logic when run directly:
if __name__ == "__main__":
# Placeholder for execution logic if this file is run as a script.
print(f"Loaded {len(bip38_cryptocurrencies)} cryptocurrency handlers.")