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:
parent
230beccc37
commit
fe38e08d4e
4 changed files with 272 additions and 17 deletions
|
|
@ -560,6 +560,44 @@ class LamassuTransactionProcessor:
|
|||
logger.error(f"Error executing SSH query: {e}")
|
||||
return []
|
||||
|
||||
async def fetch_transaction_by_id(self, db_config: Dict[str, Any], transaction_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Fetch a specific transaction by ID from Lamassu database, bypassing all status filters"""
|
||||
try:
|
||||
logger.info(f"Fetching transaction {transaction_id} from Lamassu database (bypass all filters)")
|
||||
|
||||
# Query for specific transaction ID without any status/dispense filters
|
||||
lamassu_query = f"""
|
||||
SELECT
|
||||
co.id as transaction_id,
|
||||
co.fiat as fiat_amount,
|
||||
co.crypto_atoms as crypto_amount,
|
||||
co.confirmed_at as transaction_time,
|
||||
co.device_id,
|
||||
co.status,
|
||||
co.commission_percentage,
|
||||
co.discount,
|
||||
co.crypto_code,
|
||||
co.fiat_code,
|
||||
co.dispense,
|
||||
co.dispense_confirmed
|
||||
FROM cash_out_txs co
|
||||
WHERE co.id = '{transaction_id}'
|
||||
"""
|
||||
|
||||
results = await self.execute_ssh_query(db_config, lamassu_query)
|
||||
|
||||
if not results:
|
||||
logger.warning(f"Transaction {transaction_id} not found in Lamassu database")
|
||||
return None
|
||||
|
||||
transaction = results[0]
|
||||
logger.info(f"Found transaction {transaction_id}: status={transaction.get('status')}, dispense={transaction.get('dispense')}, dispense_confirmed={transaction.get('dispense_confirmed')}")
|
||||
return transaction
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching transaction {transaction_id} from Lamassu database: {e}")
|
||||
return None
|
||||
|
||||
async def fetch_new_transactions(self, db_config: Dict[str, Any]) -> List[Dict[str, Any]]:
|
||||
"""Fetch new successful transactions from Lamassu database since last poll"""
|
||||
try:
|
||||
|
|
@ -573,13 +611,13 @@ class LamassuTransactionProcessor:
|
|||
# Fallback to last 24 hours for first run or if no previous poll
|
||||
time_threshold = datetime.now(timezone.utc) - timedelta(hours=24)
|
||||
logger.info(f"No previous poll found, checking last 24 hours since: {time_threshold}")
|
||||
|
||||
|
||||
# Convert to UTC if not already timezone-aware
|
||||
if time_threshold.tzinfo is None:
|
||||
time_threshold = time_threshold.replace(tzinfo=timezone.utc)
|
||||
elif time_threshold.tzinfo != timezone.utc:
|
||||
time_threshold = time_threshold.astimezone(timezone.utc)
|
||||
|
||||
|
||||
# Format as UTC for database query
|
||||
time_threshold_str = time_threshold.strftime('%Y-%m-%d %H:%M:%S UTC')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue