Add wallet key encryption service

This commit is contained in:
Alexa Amundson
2025-11-16 01:47:22 -06:00
parent b2f933762a
commit 1aa9329491
7 changed files with 149 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ from app.config import settings
from app.database import async_engine, Base
from app.redis_client import close_redis
from app.routers import auth, email, social, video, files, blockchain, ai_chat, devices, miner
from app.services.crypto import rotate_plaintext_wallet_keys
@asynccontextmanager
@@ -26,6 +27,13 @@ async def lifespan(app: FastAPI):
print("Database tables created successfully")
print(f"Server running on {settings.ENVIRONMENT} mode")
# Re-encrypt any legacy plaintext wallet keys before serving requests
updated_users, updated_wallets = await rotate_plaintext_wallet_keys()
if updated_users or updated_wallets:
print(
f"Re-encrypted {updated_users} user keys and {updated_wallets} wallet keys"
)
yield
# Shutdown