Update create_exchange endpoint to accept and validate bitcoin_transfer_method
This commit is contained in:
parent
d82829ab40
commit
28e8ba218f
2 changed files with 80 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ from database import get_db
|
|||
from date_validation import validate_date_in_range
|
||||
from models import (
|
||||
Availability,
|
||||
BitcoinTransferMethod,
|
||||
Exchange,
|
||||
ExchangeStatus,
|
||||
Permission,
|
||||
|
|
@ -385,6 +386,18 @@ async def create_exchange(
|
|||
detail=f"Invalid direction: {request.direction}. Must be 'buy' or 'sell'.",
|
||||
) from None
|
||||
|
||||
# Validate bitcoin transfer method
|
||||
try:
|
||||
bitcoin_transfer_method = BitcoinTransferMethod(request.bitcoin_transfer_method)
|
||||
except ValueError:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=(
|
||||
f"Invalid bitcoin_transfer_method: {request.bitcoin_transfer_method}. "
|
||||
"Must be 'onchain' or 'lightning'."
|
||||
),
|
||||
) from None
|
||||
|
||||
# Validate EUR amount
|
||||
if request.eur_amount < EUR_TRADE_MIN * 100:
|
||||
raise HTTPException(
|
||||
|
|
@ -468,6 +481,7 @@ async def create_exchange(
|
|||
slot_start=request.slot_start,
|
||||
slot_end=slot_end_dt,
|
||||
direction=direction,
|
||||
bitcoin_transfer_method=bitcoin_transfer_method,
|
||||
eur_amount=request.eur_amount,
|
||||
sats_amount=sats_amount,
|
||||
market_price_eur=market_price,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue