diff --git a/make_post_sell/lib/crypto_payment_rescue.py b/make_post_sell/lib/crypto_payment_rescue.py index ca1b40e..d37f51a 100644 --- a/make_post_sell/lib/crypto_payment_rescue.py +++ b/make_post_sell/lib/crypto_payment_rescue.py @@ -167,26 +167,38 @@ class PaymentRescue: logger = logging.getLogger(__name__) - refund_amount_xmr = refund_details["refund_amount"] - refund_amount_piconero = int(refund_amount_xmr * Decimal("1e12")) + refund_amount_coin = refund_details["refund_amount"] + + # Get coin type and atomic units for proper logging + coin_type = payment.coin_type if payment else "XMR" + from .crypto_watcher import get_coin_config + coin_config = get_coin_config(coin_type) + atomic_units = int(coin_config["atomic_units"]) + refund_amount_atomic = int(refund_amount_coin * atomic_units) + + atomic_unit_name = "piconero" if coin_type == "XMR" else "koinu" if coin_type == "DOGE" else "atomic units" logger.info(f"Attempting to refund payment {refund_details['payment_id']}") logger.info( - f"Refund amount: {refund_amount_xmr} XMR ({refund_amount_piconero} piconero)" + f"Refund amount: {refund_amount_coin} {coin_type} ({refund_amount_atomic} {atomic_unit_name})" ) logger.info(f"Refund address: {refund_details['refund_address']}") logger.info(f"Refund reason: {refund_details['reason']}") # Check if incoming payment has enough confirmations before allowing refund - if payment and payment.current_confirmations < 10: + from .crypto_watcher import get_coin_config + coin_config = get_coin_config(payment.coin_type if payment else "XMR") + required_confirmations = coin_config.get("confirmations_required", 10) + + if payment and payment.current_confirmations < required_confirmations: logger.info( - f"Refund delayed - incoming payment has {payment.current_confirmations}/10 confirmations" + f"Refund delayed - incoming payment has {payment.current_confirmations}/{required_confirmations} confirmations" ) return { "success": False, - "error": f"Incoming payment needs {10 - payment.current_confirmations} more confirmations before refund", + "error": f"Incoming payment needs {required_confirmations - payment.current_confirmations} more confirmations before refund", "refund_details": refund_details, - "confirmations_needed": 10 - payment.current_confirmations, + "confirmations_needed": required_confirmations - payment.current_confirmations, } # Check wallet balance for the specific account before attempting refund @@ -221,7 +233,7 @@ class PaymentRescue: "destinations": [ { "address": refund_details["refund_address"], - "amount": refund_amount_piconero, + "amount": refund_amount_atomic, } ], "account_index": account_index, # Specify the account that received the funds