Adds manual transaction processing feature

Implements functionality to manually process specific Lamassu transactions by ID, bypassing dispense checks.

This allows administrators to handle transactions that may have failed due to dispense issues or were settled manually outside of the automated process.

The feature includes a new UI dialog for entering the transaction ID and an API endpoint to fetch and process the transaction, crediting wallets and distributing funds according to the DCA configuration.
This commit is contained in:
padreug 2025-10-24 00:15:22 +02:00
parent 230beccc37
commit fe38e08d4e
4 changed files with 272 additions and 17 deletions

View file

@ -233,6 +233,73 @@ async def api_manual_poll(
)
@satmachineadmin_api_router.post("/api/v1/dca/process-transaction/{transaction_id}")
async def api_process_specific_transaction(
transaction_id: str,
user: User = Depends(check_super_user),
):
"""
Manually process a specific Lamassu transaction by ID, bypassing all status filters.
This endpoint is useful for processing transactions that were manually settled
or had dispense issues but need to be included in DCA distribution.
"""
try:
from .transaction_processor import transaction_processor
from .crud import get_payments_by_lamassu_transaction
# Get database configuration
db_config = await transaction_processor.connect_to_lamassu_db()
if not db_config:
raise HTTPException(
status_code=HTTPStatus.SERVICE_UNAVAILABLE,
detail="Could not get Lamassu database configuration",
)
# Check if transaction was already processed
existing_payments = await get_payments_by_lamassu_transaction(transaction_id)
if existing_payments:
return {
"success": False,
"already_processed": True,
"message": f"Transaction {transaction_id} was already processed with {len(existing_payments)} distributions",
"payment_count": len(existing_payments),
}
# Fetch the specific transaction from Lamassu (bypassing all filters)
transaction = await transaction_processor.fetch_transaction_by_id(db_config, transaction_id)
if not transaction:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail=f"Transaction {transaction_id} not found in Lamassu database",
)
# Process the transaction through normal DCA flow
await transaction_processor.process_transaction(transaction)
return {
"success": True,
"message": f"Transaction {transaction_id} processed successfully",
"transaction_details": {
"transaction_id": transaction_id,
"status": transaction.get("status"),
"dispense": transaction.get("dispense"),
"dispense_confirmed": transaction.get("dispense_confirmed"),
"crypto_amount": transaction.get("crypto_amount"),
"fiat_amount": transaction.get("fiat_amount"),
},
}
except HTTPException:
raise
except Exception as e:
raise HTTPException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
detail=f"Error processing transaction {transaction_id}: {str(e)}",
)
@satmachineadmin_api_router.post("/api/v1/dca/test-transaction")
async def api_test_transaction(
user: User = Depends(check_super_user),