"""
Lightning Enable MCP Tools

Tool implementations for L402 operations.
"""

import re

_CREDENTIAL_PATTERNS = [
    re.compile(r"Bearer\s+\S+", re.IGNORECASE),
    re.compile(r"shpat_\S+", re.IGNORECASE),
    re.compile(r"sk_live_\S+", re.IGNORECASE),
    re.compile(r"sk_test_\S+", re.IGNORECASE),
]


def sanitize_error(msg: str) -> str:
    """Remove potential credentials from error messages returned to users."""
    for pattern in _CREDENTIAL_PATTERNS:
        msg = pattern.sub("[REDACTED]", msg)
    return msg

from .access_resource import access_l402_resource
from .check_invoice_status import check_invoice_status
from .confirm_payment import confirm_payment
from .create_invoice import create_invoice
from .create_l402_challenge import create_l402_challenge
from .discover_api import discover_api
from .exchange_currency import exchange_currency
from .get_all_balances import get_all_balances
from .get_btc_price import get_btc_price
from .pay_challenge import pay_l402_challenge
from .pay_invoice import pay_invoice
from .send_onchain import send_onchain
from .verify_l402_payment import verify_l402_payment
from .wallet import check_wallet_balance
from .budget import configure_budget, get_payment_history
from .budget_status import get_budget_status

__all__ = [
    "access_l402_resource",
    "check_invoice_status",
    "confirm_payment",
    "create_invoice",
    "create_l402_challenge",
    "discover_api",
    "exchange_currency",
    "get_all_balances",
    "get_btc_price",
    "pay_l402_challenge",
    "pay_invoice",
    "send_onchain",
    "verify_l402_payment",
    "check_wallet_balance",
    "configure_budget",
    "get_payment_history",
    "get_budget_status",
]
