Closed chGoodchild closed 2 months ago
Based on the log and script you've provided, it seems the token redemption process is executing correctly up until the final step. The error "Connection rejected: Token redemption failed" is likely occurring after the script has finished running, possibly in the system that's calling this script.
Here are a few potential reasons for this error:
Token already spent: The token might have already been redeemed. The check_token function shows the token is valid, but it might have been spent in the time between checking and redeeming.
Network issues: There could be intermittent network problems causing the connection to be rejected.
Server-side issues: The mint server might be experiencing problems or rejecting the redemption for reasons not evident in the client-side script.
Mismatched amounts: The amount in the token might not match the amount in the payment request.
Timing issues: There might be a delay between generating the payment request and redeeming the token, causing the request to expire.
To troubleshoot this:
Add more verbose logging, especially around the redeem_token function. Log the full request being sent and the full response received.
Check if the token is still valid immediately before redemption.
Verify that the amounts match exactly between the token and the payment request.
Add a small delay between getting the payment request and redeeming the token to ensure all systems are in sync.
Check the server logs if you have access to them.
Try redeeming a smaller amount to see if it's an issue with the specific token or a general problem.
Verify that the mint's API hasn't changed and that all endpoints are still correct.
Check if there are any rate limiting or security measures on the server side that might be rejecting the request.
Without more information about the system calling this script and the server-side implementation, it's difficult to pinpoint the exact cause. However, these suggestions should help narrow down the problem.
{ "paid": true, "preimage": "", "change": [], "total_amount": 64 }
Amount paid:
Total amount msat: 0
Connection approved: Token redeemed successfully, sessiontime 0
METHOD: client_auth, MAC: 28:d2:44:64:f1:f7, USERNAME: 0, PASSWORD: 0
METHOD: client_auth, MAC: 28:d2:44:64:f1:f7, INGOING_BYTES: 0, OUTGOING_BYTES: 0
Fixed, the endpoint had changed the format of its response from .paid == true
to "paid": true
root@OpenWrt:/tmp# cat arguments_log.md
METHOD: auth_client, MAC: 28:d2:44:64:f1:f7, USERNAME: cashuAeyJ0b2tlbiI6W3sibWludCI6Imh0dHBzOi8vbWludC5taW5pYml0cy5jYXNoL0JpdGNvaW4iLCJwcm9vZnMiOlt7ImlkIjoiMDA1MDA1NTBmMDQ5NDE0NiIsImFtb3VudCI6NjQsInNlY3JldCI6ImVjZjkzODJmMDliZWU4MmJkMTVkMGUwYzRiZjhkZjMxY2YyNjQ4MmRjMjhiYmJlNTg2NDc2NDExYjgxZWI0NTEiLCJDIjoiMDIxZDBhODBiM2EyMjc0ZDI0ZGU3OTIxYjM5MjBmMDIxYTVhZmFkNGM1ZDFjYzc0NGFkNjcyYjZkNzVkOTFkZjk3In1dfV0sInVuaXQiOiJzYXQiLCJtZW1vIjoiU2VudCBmcm9tIE1pbmliaXRzIn0, PASSWORD:
Auth Client - ECASH: cashuAeyJ0b2tlbiI6W3sibWludCI6Imh0dHBzOi8vbWludC5taW5pYml0cy5jYXNoL0JpdGNvaW4iLCJwcm9vZnMiOlt7ImlkIjoiMDA1MDA1NTBmMDQ5NDE0NiIsImFtb3VudCI6NjQsInNlY3JldCI6ImVjZjkzODJmMDliZWU4MmJkMTVkMGUwYzRiZjhkZjMxY2YyNjQ4MmRjMjhiYmJlNTg2NDc2NDExYjgxZWI0NTEiLCJDIjoiMDIxZDBhODBiM2EyMjc0ZDI0ZGU3OTIxYjM5MjBmMDIxYTVhZmFkNGM1ZDFjYzc0NGFkNjcyYjZkNzVkOTFkZjk3In1dfV0sInVuaXQiOiJzYXQiLCJtZW1vIjoiU2VudCBmcm9tIE1pbmliaXRzIn0
Curl request - ECASH:
Redeem token response: {
"paid": true,
"preimage": "",
"change": [],
"total_amount": 64
}
Curl request - ECASH: cashuAeyJ0b2tlbiI6W3sibWludCI6Imh0dHBzOi8vbWludC5taW5pYml0cy5jYXNoL0JpdGNvaW4iLCJwcm9vZnMiOlt7ImlkIjoiMDA1MDA1NTBmMDQ5NDE0NiIsImFtb3VudCI6NjQsInNlY3JldCI6ImVjZjkzODJmMDliZWU4MmJkMTVkMGUwYzRiZjhkZjMxY2YyNjQ4MmRjMjhiYmJlNTg2NDc2NDExYjgxZWI0NTEiLCJDIjoiMDIxZDBhODBiM2EyMjc0ZDI0ZGU3OTIxYjM5MjBmMDIxYTVhZmFkNGM1ZDFjYzc0NGFkNjcyYjZkNzVkOTFkZjk3In1dfV0sInVuaXQiOiJzYXQiLCJtZW1vIjoiU2VudCBmcm9tIE1pbmliaXRzIn0, Exit Code: 0
Redeem response: { "paid": true, "preimage": "", "change": [], "total_amount": 64 }
Received response: { "paid": true, "preimage": "", "change": [], "total_amount": 64 }
Amount paid:
Total amount msat: 0
Connection approved: Token redeemed successfully, sessiontime 0
METHOD: client_auth, MAC: 28:d2:44:64:f1:f7, USERNAME: 0, PASSWORD: 0
METHOD: client_auth, MAC: 28:d2:44:64:f1:f7, INGOING_BYTES: 0, OUTGOING_BYTES: 0