Skip to content

Fix bug with marking cashu send quote as pending#619

Merged
jbojcic1 merged 1 commit intomasterfrom
fix-bug-when-trying-to-pay-already-paid-ln-invoice
Sep 7, 2025
Merged

Fix bug with marking cashu send quote as pending#619
jbojcic1 merged 1 commit intomasterfrom
fix-bug-when-trying-to-pay-already-paid-ln-invoice

Conversation

@jbojcic1
Copy link
Collaborator

@jbojcic1 jbojcic1 commented Sep 7, 2025

No description provided.

@jbojcic1 jbojcic1 requested a review from gudnuf September 7, 2025 13:20
@jbojcic1 jbojcic1 self-assigned this Sep 7, 2025
@vercel
Copy link

vercel bot commented Sep 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
agicash Ready Ready Preview Comment Sep 7, 2025 1:21pm

@supabase
Copy link

supabase bot commented Sep 7, 2025

This pull request has been ignored for the connected project hrebgkfhjpkbxpztqqke because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

}
});

await cashuSendService.markSendQuoteAsPending(sendQuote);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the reason why the app would crash when you would try to pay already paid invoice. I don't remeber why I added this here but doesn't make sense because we also have regular onPending handler. It also doesn't make sense to mix it with initiate mutation because intiaite could pass and this fail and then you have retries of initiate too.
I played with sends and all still seems to be working fine so seems safe to remove

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might have been for when paying an invoice from the same mint. It seems to work with this change, but I notice after the send completes then after a couple seconds this error shows up... maybe after a retry or something

image

I noticed this was a problem when working on #622 because I tried to add polling for send quotes as well, but if the melt quote is updated to PAID before we poll the PENDING quote, then we get this error that the send-quote must be pending to complete because we never saw the pending state

Copy link
Collaborator Author

@jbojcic1 jbojcic1 Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested same mint payments after making this change. I also had in memory that those are the reason why we introduced this but then I saw they still work after this change. I noticed this exact thing and debugged it and I don't think it was caused by this but by the fact that mint sends two paid messages.

Was thinking that we will resolve that too with proper background task handling.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to be extra safe we can change our code to allow completing from unpaid state too. I think we should do that anyway because you could close the app after triggering the send before the pending message is received. then when you open it later you would get only paid message

@jbojcic1 jbojcic1 merged commit 457e322 into master Sep 7, 2025
5 checks passed
@jbojcic1 jbojcic1 deleted the fix-bug-when-trying-to-pay-already-paid-ln-invoice branch September 7, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants