diff --git a/make_post_sell/lib/crypto_payment_rescue.py b/make_post_sell/lib/crypto_payment_rescue.py index d37f51a..fa7a708 100644 --- a/make_post_sell/lib/crypto_payment_rescue.py +++ b/make_post_sell/lib/crypto_payment_rescue.py @@ -228,23 +228,38 @@ class PaymentRescue: ) try: - # Create the refund transaction from the specific account that received the payment - transfer_params = { - "destinations": [ - { - "address": refund_details["refund_address"], - "amount": refund_amount_atomic, - } - ], - "account_index": account_index, # Specify the account that received the funds - "get_tx_key": True, - "do_not_relay": False, - "priority": 1, # Use low priority to reduce fees - } - - logger.info(f"Calling transfer with params: {transfer_params}") - tx_result = self.crypto_client._call("transfer", transfer_params) - logger.info(f"Transfer successful: {tx_result}") + # Create coin-specific refund transaction + if coin_type == "XMR": + # Monero uses the transfer RPC with atomic units (piconero) + transfer_params = { + "destinations": [ + { + "address": refund_details["refund_address"], + "amount": refund_amount_atomic, + } + ], + "account_index": account_index, + "get_tx_key": True, + "do_not_relay": False, + "priority": 1, + } + logger.info(f"Calling Monero transfer with params: {transfer_params}") + tx_result = self.crypto_client._call("transfer", transfer_params) + + elif coin_type == "DOGE": + # Dogecoin uses sendtoaddress RPC with coin amounts (not atomic units) + refund_amount_doge = float(refund_amount_coin) + logger.info(f"Calling Dogecoin sendtoaddress: {refund_amount_doge} DOGE to {refund_details['refund_address']}") + tx_hash = self.crypto_client.sendtoaddress( + refund_details["refund_address"], + refund_amount_doge + ) + tx_result = {"tx_hash": tx_hash} + + else: + raise ValueError(f"Refund not supported for coin type: {coin_type}") + + logger.info(f"Refund transaction successful: {tx_result}") return { "success": True,