alternative pk load

This commit is contained in:
Dobromir Popov
2024-10-08 00:45:48 +03:00
parent d5812fed03
commit 29fb14b8e6
2 changed files with 13 additions and 0 deletions

View File

@ -41,6 +41,18 @@ load_dotenv()
# Load secret environment variables
load_dotenv('.env.secret')
pk = os.getenv("PK")
if not pk:
try:
with open('./secret.pk', 'r') as f:
pk = f.read().strip()
if pk:
logging.info("Private key loaded successfully from file.")
else:
logging.warning("Private key file is empty.")
except FileNotFoundError:
logging.warning("Private key file not found.")
except Exception as e:
logging.error(f"Error reading private key file: {str(e)}")
if not pk
logging.error("Private key not found in environment variables. Will not be able to sign transactions.")