From: Jeffrey Czyz Date: Wed, 10 Jul 2024 21:03:31 +0000 (-0500) Subject: Add Bolt12PaymentError::SendingFailed variant X-Git-Tag: v0.0.124-beta~33^2~3 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=aa55366b376b1f064c3975cbe46a6b78e1e1c8eb;p=rust-lightning Add Bolt12PaymentError::SendingFailed variant Instead of returning Ok when path finding fails, allow returning a RetryableSendFailure from send_payment_for_bolt12_invoice. Follow up commits will return such failures. --- diff --git a/lightning/src/ln/max_payment_path_len_tests.rs b/lightning/src/ln/max_payment_path_len_tests.rs index 096bcf963..fd027ea62 100644 --- a/lightning/src/ln/max_payment_path_len_tests.rs +++ b/lightning/src/ln/max_payment_path_len_tests.rs @@ -388,7 +388,7 @@ fn bolt12_invoice_too_large_blinded_paths() { let invoice_om = nodes[1].onion_messenger.next_onion_message_for_peer(nodes[0].node.get_our_node_id()).unwrap(); nodes[0].onion_messenger.handle_onion_message(&nodes[1].node.get_our_node_id(), &invoice_om); // TODO: assert on the invoice error once we support replying to invoice OMs with failure info - nodes[0].logger.assert_log_contains("lightning::ln::channelmanager", "Failed paying invoice: OnionPacketSizeExceeded", 1); + nodes[0].logger.assert_log_contains("lightning::ln::channelmanager", "Failed paying invoice: SendingFailed(OnionPacketSizeExceeded)", 1); let events = nodes[0].node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index 443a7b2c3..42c100cde 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -510,11 +510,8 @@ pub enum Bolt12PaymentError { UnexpectedInvoice, /// Payment for an invoice with the corresponding [`PaymentId`] was already initiated. DuplicateInvoice, - /// The [`BlindedPath`]s provided are too large and caused us to exceed the maximum onion hop data - /// size of 1300 bytes. - /// - /// [`BlindedPath`]: crate::blinded_path::BlindedPath - OnionPacketSizeExceeded, + /// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed. + SendingFailed(RetryableSendFailure), } /// Indicates that we failed to send a payment probe. Further errors may be surfaced later via @@ -848,7 +845,7 @@ impl OutboundPayments { .map_err(|()| { log_error!(logger, "Can't construct an onion packet without exceeding 1300-byte onion \ hop_data length for payment with id {} and hash {}", payment_id, payment_hash); - Bolt12PaymentError::OnionPacketSizeExceeded + Bolt12PaymentError::SendingFailed(RetryableSendFailure::OnionPacketSizeExceeded) })?; if let Some(max_fee_msat) = max_total_routing_fee_msat {