Implement DOGE refund support in crypto payment rescue
- Add coin-specific refund logic (XMR uses transfer, DOGE uses sendtoaddress) - Fix confirmation threshold logging to use coin-specific requirements - Improve refund amount logging to show correct coin type and atomic units - DOGE refunds now use sendtoaddress RPC instead of failing with 404 Note: Crypto watcher needs restart to pick up changes
This commit is contained in:
parent
5df297eade
commit
35780e4245
1 changed files with 32 additions and 17 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue