]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add Bolt12PaymentError::SendingFailed variant
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 10 Jul 2024 21:03:31 +0000 (16:03 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 11 Jul 2024 23:01:20 +0000 (18:01 -0500)
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.

lightning/src/ln/max_payment_path_len_tests.rs
lightning/src/ln/outbound_payment.rs

index 096bcf9633c64e45238714b8cafa4a54ec63f3f6..fd027ea62b6abeab8c9a462178b19408300dccbc 100644 (file)
@@ -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);
index 443a7b2c3a285098f849f2b01756182fdf363043..42c100cde2813262b471d04bc9b70d56c4a8b8bf 100644 (file)
@@ -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 {