-
Notifications
You must be signed in to change notification settings - Fork 160
Fix BOLT11 DuplicatePayment triggering on-chain fallback in unified payment #1038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -287,9 +287,22 @@ impl UnifiedPayment { | |
|
|
||
| let payment_result = if let Ok(hrn) = HumanReadableName::from_encoded(uri_str) { | ||
| let hrn = maybe_wrap(hrn.clone()); | ||
| self.bolt12_payment.send_using_amount_inner(&offer, amount_msat.unwrap_or(0), None, None, route_parameters, Some(hrn)) | ||
| self.bolt12_payment.send_using_amount_inner( | ||
| &offer, | ||
| amount_msat.unwrap_or(0), | ||
| None, | ||
| None, | ||
| route_parameters, | ||
| Some(hrn), | ||
| ) | ||
| } else if let Some(amount_msat) = amount_msat { | ||
| self.bolt12_payment.send_using_amount(&offer, amount_msat, None, None, route_parameters) | ||
| self.bolt12_payment.send_using_amount( | ||
| &offer, | ||
| amount_msat, | ||
| None, | ||
| None, | ||
| route_parameters, | ||
| ) | ||
| } else { | ||
| self.bolt12_payment.send(&offer, None, None, route_parameters) | ||
| } | ||
|
|
@@ -304,14 +317,19 @@ impl UnifiedPayment { | |
| }, | ||
| PaymentMethod::LightningBolt11(invoice) => { | ||
| let invoice = maybe_wrap(invoice.clone()); | ||
| let payment_result = self.bolt11_invoice.send(&invoice, route_parameters) | ||
| .map_err(|e| { | ||
| let payment_result = self.bolt11_invoice.send(&invoice, route_parameters); | ||
|
|
||
| match payment_result { | ||
| Ok(payment_id) => { | ||
| return Ok(UnifiedPaymentResult::Bolt11 { payment_id }); | ||
| }, | ||
| Err(Error::DuplicatePayment) => { | ||
| log_error!(self.logger, "Failed to send BOLT11 invoice: DuplicatePayment. This is part of a unified payment. Aborting to avoid duplicate payment."); | ||
| return Err(Error::DuplicatePayment); | ||
| }, | ||
| Err(e) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this error can be just a persistence error happening in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, persistence failures return a separate |
||
| log_error!(self.logger, "Failed to send BOLT11 invoice: {:?}. This is part of a unified payment. Falling back to the on-chain transaction.", e); | ||
| e | ||
| }); | ||
|
|
||
| if let Ok(payment_id) = payment_result { | ||
| return Ok(UnifiedPaymentResult::Bolt11 { payment_id }); | ||
| }, | ||
| } | ||
| }, | ||
| PaymentMethod::OnChain(address) => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.