Automated Action ab87d3c506 Implement comprehensive cryptocurrency exchange platform
- Built complete CEX platform with FastAPI and Python
- JWT-based authentication system with secure password hashing
- Multi-currency crypto wallet support (BTC, ETH, USDT)
- Fiat account management (USD, EUR, GBP)
- Local transaction signing without external APIs
- Comprehensive transaction handling (send/receive/deposit/withdraw)
- SQLAlchemy models with Alembic migrations
- Security middleware (rate limiting, headers, logging)
- Input validation and sanitization
- Encrypted private key storage with PBKDF2
- Standardized codebase architecture with service layer pattern
- Complete API documentation with health endpoints
- Comprehensive README with setup instructions

Features:
- User registration and authentication
- Crypto wallet creation and management
- Secure transaction signing using local private keys
- Fiat deposit/withdrawal system
- Transaction history and tracking
- Rate limiting and security headers
- Input validation for all endpoints
- Error handling and logging
2025-06-20 23:08:04 +00:00

39 lines
1.8 KiB
Python

from sqlalchemy import Column, Integer, String, Float, Boolean, DateTime, ForeignKey
from sqlalchemy.sql import func
from sqlalchemy.orm import relationship
from app.db.base import Base
class Wallet(Base):
__tablename__ = "wallets"
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
currency = Column(String, nullable=False) # BTC, ETH, USDT
address = Column(String, unique=True, nullable=False)
private_key_encrypted = Column(String, nullable=False)
balance = Column(Float, default=0.0)
is_active = Column(Boolean, default=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
# Relationships
owner = relationship("User", back_populates="wallets")
transactions_sent = relationship("Transaction", foreign_keys="Transaction.from_wallet_id", back_populates="from_wallet")
transactions_received = relationship("Transaction", foreign_keys="Transaction.to_wallet_id", back_populates="to_wallet")
class FiatAccount(Base):
__tablename__ = "fiat_accounts"
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
currency = Column(String, nullable=False) # USD, EUR, GBP
balance = Column(Float, default=0.0)
is_active = Column(Boolean, default=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
# Relationships
owner = relationship("User", back_populates="fiat_accounts")
deposits = relationship("FiatTransaction", foreign_keys="FiatTransaction.account_id", back_populates="account")