Compare commits

..

2 Commits

Author SHA1 Message Date
shroominic
eaffd59c6a Merge branch 'main' into old-keys-refund-bugfix 2025-11-21 17:21:03 -08:00
redshift
d1fda4137d Fixed the old keys refund failure bug
refund was failing for old keys without refund_currency set. Fixed it by just moving the logic around.
2025-10-04 12:40:18 +00:00
3 changed files with 19 additions and 5 deletions

View File

@@ -154,6 +154,11 @@ async def refund_wallet_endpoint(
key: ApiKey = await validate_bearer_key(bearer_value, session)
remaining_balance_msats: int = key.balance
refund_currency = key.refund_currency or "sat"
if refund_currency == "sat":
remaining_balance = remaining_balance_msats // 1000
else:
remaining_balance = remaining_balance_msats
if key.refund_currency == "sat":
remaining_balance = remaining_balance_msats // 1000
@@ -172,7 +177,7 @@ async def refund_wallet_endpoint(
await send_to_lnurl(
remaining_balance,
key.refund_currency or "sat",
refund_currency,
key.refund_mint_url or global_settings.primary_mint,
key.refund_address,
)
@@ -183,11 +188,11 @@ async def refund_wallet_endpoint(
remaining_balance, refund_currency, key.refund_mint_url
)
result = {"token": token}
if key.refund_currency == "sat":
result["sats"] = str(remaining_balance_msats // 1000)
if refund_currency == "sat":
result["sats"] = str(remaining_balance)
else:
result["msats"] = str(remaining_balance_msats)
result["msats"] = str(remaining_balance)
except HTTPException:
# Re-raise HTTP exceptions (like 400 for balance too small)
@@ -203,6 +208,13 @@ async def refund_wallet_endpoint(
):
raise HTTPException(status_code=503, detail="Mint service unavailable")
else:
from .core.logging import get_logger
logger = get_logger(__name__)
logger.error(
"Refund failed",
extra={"error": error_msg},
)
raise HTTPException(status_code=500, detail="Refund failed")
await _refund_cache_set(bearer_value, result)

1
vendor/cdk vendored Submodule

Submodule vendor/cdk added at 52d796e9fe

1
vendor/cdk-python vendored Submodule

Submodule vendor/cdk-python added at 915c6966b0