diff --git a/bitcoinlib/config/config.py b/bitcoinlib/config/config.py
index 1fe927fe..6d902254 100644
--- a/bitcoinlib/config/config.py
+++ b/bitcoinlib/config/config.py
@@ -2,7 +2,7 @@
#
# BitcoinLib - Python Cryptocurrency Library
# CONFIG - Configuration settings
-# © 2022 - 2023 May - 1200 Web Development
+# © 2022 - 2024 Dec - 1200 Web Development
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -34,7 +34,6 @@
# File locations
-BCL_CONFIG_FILE = ''
BCL_INSTALL_DIR = Path(__file__).parents[1]
BCL_DATA_DIR = ''
BCL_DATABASE_DIR = ''
@@ -261,27 +260,18 @@ def config_get(section, var, fallback, is_boolean=False):
except Exception:
return fallback
- global BCL_INSTALL_DIR, BCL_DATABASE_DIR, DEFAULT_DATABASE, BCL_DATA_DIR, BCL_CONFIG_FILE
+ global BCL_INSTALL_DIR, BCL_DATABASE_DIR, DEFAULT_DATABASE, BCL_DATA_DIR
global ALLOW_DATABASE_THREADS, DEFAULT_DATABASE_CACHE
global BCL_LOG_FILE, LOGLEVEL, ENABLE_BITCOINLIB_LOGGING
global TIMEOUT_REQUESTS, DEFAULT_LANGUAGE, DEFAULT_NETWORK, DEFAULT_WITNESS_TYPE
global SERVICE_CACHING_ENABLED, DATABASE_ENCRYPTION_ENABLED, DB_FIELD_ENCRYPTION_KEY, DB_FIELD_ENCRYPTION_PASSWORD
global SERVICE_MAX_ERRORS, BLOCK_COUNT_CACHE_TIME, MAX_TRANSACTIONS
- # Read settings from Configuration file provided in OS environment~/.bitcoinlib/ directory
- config_file_name = os.environ.get('BCL_CONFIG_FILE')
- if not config_file_name:
- BCL_CONFIG_FILE = Path('~/.bitcoinlib/config.ini').expanduser()
- else:
- BCL_CONFIG_FILE = Path(config_file_name)
- if not BCL_CONFIG_FILE.is_absolute():
- BCL_CONFIG_FILE = Path(Path.home(), '.bitcoinlib', BCL_CONFIG_FILE)
- if not BCL_CONFIG_FILE.exists():
- BCL_CONFIG_FILE = Path(BCL_INSTALL_DIR, 'data', config_file_name)
- if not BCL_CONFIG_FILE.exists():
- raise IOError('Bitcoinlib configuration file not found: %s' % str(BCL_CONFIG_FILE))
- data = config.read(str(BCL_CONFIG_FILE))
- BCL_DATA_DIR = Path(config_get('locations', 'data_dir', fallback='~/.bitcoinlib')).expanduser()
+ # Get Bitcoinlib data directory, default is at ~/.bitcoinlib
+ env_data_dir = os.environ.get('BCL_DATA_DIR')
+ BCL_DATA_DIR = Path('~/.bitcoinlib').expanduser() if not env_data_dir else Path(env_data_dir).expanduser()
+ config_file = Path(BCL_DATA_DIR, 'config.ini')
+ data = config.read(str(config_file))
# Database settings
BCL_DATABASE_DIR = Path(BCL_DATA_DIR, config_get('locations', 'database_dir', 'database'))
diff --git a/bitcoinlib/data/config.ini b/bitcoinlib/data/config.ini
index 39610d9d..1e9e251f 100644
--- a/bitcoinlib/data/config.ini
+++ b/bitcoinlib/data/config.ini
@@ -1,6 +1,6 @@
#
# BITCOINLIB - Configuration file
-# © 2020 March - 1200 Web Development
+# © 2024 December - 1200 Web Development
#
# Paths to data, logs and configuration files, all paths are relative to bitcoinlib source directory if no
# absolute path is provided.
@@ -10,10 +10,8 @@
#
[locations]
-# Location of BitcoinLib data, configuration and log files. Relative paths will be based in installation directory
-;data_dir=~/.bitcoinlib
-
-# Default directory for database files. Relative paths will be based in user or bitcoinlib installation directory. Only used for sqlite files.
+# Default directory for database files. Relative paths will be based in user or bitcoinlib installation directory.
+# Only used for sqlite files. Default installation directory is in /.bitcoinlib
;database_dir=database
# Default database file for wallets, keys and transactions. Relative paths for sqlite will be based in 'database_dir'.
diff --git a/bitcoinlib/main.py b/bitcoinlib/main.py
index d1172929..2fd761b5 100644
--- a/bitcoinlib/main.py
+++ b/bitcoinlib/main.py
@@ -43,7 +43,6 @@
logger.info('WELCOME TO BITCOINLIB - CRYPTOCURRENCY LIBRARY')
logger.info('Version: %s' % BITCOINLIB_VERSION)
logger.info('Logger name: %s' % logging.__name__)
- logger.info('Read config from: %s' % BCL_CONFIG_FILE)
logger.info('Directory databases: %s' % BCL_DATABASE_DIR)
logger.info('Default database: %s' % DEFAULT_DATABASE)
logger.info('Logging to: %s' % BCL_LOG_FILE)