fix(nwc): decode bolt11 before NWC call to prevent payment record loss - #4037
Open
dadofsambonzuki wants to merge 2 commits into
Open
fix(nwc): decode bolt11 before NWC call to prevent payment record loss#4037dadofsambonzuki wants to merge 2 commits into
dadofsambonzuki wants to merge 2 commits into
Conversation
Contributor
Author
motorina0
approved these changes
Jul 13, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #4037 +/- ##
==========================================
+ Coverage 56.50% 64.29% +7.78%
==========================================
Files 123 129 +6
Lines 16914 18979 +2065
==========================================
+ Hits 9557 12202 +2645
+ Misses 7357 6777 -580 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
motorina0
force-pushed
the
fix/nwc-pay-invoice-checking-id
branch
from
July 13, 2026 12:13
ef8d0a9 to
9bcfe50
Compare
dni
approved these changes
Jul 13, 2026
dni
reviewed
Jul 13, 2026
| return StatusResponse(str(e), 0) | ||
|
|
||
| async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse: | ||
| invoice_data = bolt11_decode(bolt11) |
Member
There was a problem hiding this comment.
you should put this in its own try / catch bolt11 decoding can throw an Bolt11Exception. return a failed paytment_repsonse then.
dni
requested changes
Jul 13, 2026
When pay_invoice raises an exception before bolt11_decode runs, payment_hash is never set, so PaymentResponse is returned with checking_id=None. LNbits core then marks the payment as failed and the database transaction is rolled back, losing the record entirely even though the NWC provider processed the payment. Move bolt11_decode before the try block so payment_hash is always available. The outer except block now returns a pending response with checking_id set, letting the core commit the payment record and settle it later via get_payment_status.
dni
force-pushed
the
fix/nwc-pay-invoice-checking-id
branch
from
July 13, 2026 13:39
307ad9b to
24d04a5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some NWC transactions were being silently dropped from the DB despite being paid as the transaction is being rolled back at the database level.
The flow: