/// Sockets for connecting to the node.
addresses: Vec<msgs::SocketAddress>,
},
- /// Indicates a request for an invoice failed to yield a response in a reasonable amount of time
- /// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an
- /// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed.
- ///
- /// # Failure Behavior and Persistence
- /// This event will eventually be replayed after failures-to-handle (i.e., the event handler
- /// returning `Err(ReplayEvent ())`) and will be persisted across restarts.
- ///
- /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
- /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
- /// [`Offer`]: crate::offers::offer::Offer
- /// [`Refund`]: crate::offers::refund::Refund
- InvoiceRequestFailed {
- /// The `payment_id` to have been associated with payment for the requested invoice.
- payment_id: PaymentId,
- },
/// Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was
/// received.
///
/// [`Offer`]: crate::offers::offer::Offer
payment_hash: Option<PaymentHash>,
/// The reason the payment failed. This is only `None` for events generated or serialized
- /// by versions prior to 0.0.115.
+ /// by versions prior to 0.0.115 or when deserializing an `Event::InvoiceRequestFailed`,
+ /// which was removed in 0.0.124.
reason: Option<PaymentFailureReason>,
},
/// Indicates that a path for an outbound payment was successful.
(8, funding_txo, required),
});
},
- &Event::InvoiceRequestFailed { ref payment_id } => {
- 33u8.write(writer)?;
- write_tlv_fields!(writer, {
- (0, payment_id, required),
- })
- },
&Event::ConnectionNeeded { .. } => {
35u8.write(writer)?;
// Never write ConnectionNeeded events as buffered onion messages aren't serialized.
};
f()
},
+ // This was Event::InvoiceRequestFailed prior to version 0.0.124.
33u8 => {
let mut f = || {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, payment_id, required),
});
- Ok(Some(Event::InvoiceRequestFailed {
+ Ok(Some(Event::PaymentFailed {
payment_id: payment_id.0.unwrap(),
+ payment_hash: None,
+ reason: None,
}))
};
f()
/// ```
///
/// Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`]
-/// and pays the [`Bolt12Invoice`] response. In addition to success and failure events,
-/// [`ChannelManager`] may also generate an [`Event::InvoiceRequestFailed`].
+/// and pays the [`Bolt12Invoice`] response.
///
/// ```
/// # use lightning::events::{Event, EventsProvider};
/// match event {
/// Event::PaymentSent { payment_id: Some(payment_id), .. } => println!("Paid {}", payment_id),
/// Event::PaymentFailed { payment_id, .. } => println!("Failed paying {}", payment_id),
-/// Event::InvoiceRequestFailed { payment_id, .. } => println!("Failed paying {}", payment_id),
/// // ...
/// # _ => {},
/// }
/// # Requested Invoices
///
/// In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
- /// the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
- /// and prevent any attempts at paying it once received. The other events may only be generated
- /// once the invoice has been received.
+ /// the payment prior to receiving the invoice will result in an [`Event::PaymentFailed`] and
+ /// prevent any attempts at paying it once received.
///
/// # Restart Behavior
///
/// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
- /// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
- /// [`Event::InvoiceRequestFailed`].
+ /// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated.
///
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
pub fn abandon_payment(&self, payment_id: PaymentId) {
///
/// To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the
/// invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail
- /// with an [`Event::InvoiceRequestFailed`].
+ /// with an [`Event::PaymentFailed`].
///
/// If `max_total_routing_fee_msat` is not specified, The default from
/// [`RouteParameters::from_payment_params_and_value`] is applied.
///
/// To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the
/// invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the
- /// payment will fail with an [`Event::InvoiceRequestFailed`].
+ /// payment will fail with an [`Event::PaymentFailed`].
///
/// # Privacy
///
assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None);
david.node.abandon_payment(payment_id);
- get_event!(david, Event::InvoiceRequestFailed);
+ get_event!(david, Event::PaymentFailed);
// Send the invoice request to Alice using an invalid blinded path.
let payment_id = PaymentId([2; 32]);
david.node.pay_for_offer(&offer, None, None, None, payment_id, Retry::Attempts(0), None)
.unwrap();
david.node.abandon_payment(payment_id);
- get_event!(david, Event::InvoiceRequestFailed);
+ get_event!(david, Event::PaymentFailed);
// Don't send the invoice request, but grab its reply path to use with a different request.
let invalid_reply_path = {
expect_recent_payment!(david, RecentPaymentDetails::AwaitingInvoice, payment_id);
david.node.abandon_payment(payment_id);
- get_event!(david, Event::InvoiceRequestFailed);
+ get_event!(david, Event::PaymentFailed);
// Send the invoice to David using an invalid blinded path.
let invalid_path = refund.paths().first().unwrap().clone();
assert_eq!(invoice_error, InvoiceError::from(Bolt12SemanticError::MissingPaths));
// Confirm that david drops this failed payment from his pending outbound payments.
- match get_event!(david, Event::InvoiceRequestFailed) {
- Event::InvoiceRequestFailed { payment_id: pay_id } => {
- assert_eq!(pay_id, payment_id)
+ match get_event!(david, Event::PaymentFailed) {
+ Event::PaymentFailed { payment_id: actual_payment_id, .. } => {
+ assert_eq!(payment_id, actual_payment_id);
},
- _ => panic!("No Event::InvoiceRequestFailed"),
+ _ => panic!("No Event::PaymentFailed"),
}
}
},
};
if is_stale {
- pending_events.push_back(
- (events::Event::InvoiceRequestFailed { payment_id: *payment_id }, None)
- );
+ let event = events::Event::PaymentFailed {
+ payment_id: *payment_id,
+ payment_hash: None,
+ reason: None,
+ };
+ pending_events.push_back((event, None));
false
} else {
true
payment.remove();
}
} else if let PendingOutboundPayment::AwaitingInvoice { .. } = payment.get() {
- pending_events.lock().unwrap().push_back((events::Event::InvoiceRequestFailed {
+ pending_events.lock().unwrap().push_back((events::Event::PaymentFailed {
payment_id,
+ payment_hash: None,
+ reason: Some(reason),
}, None));
payment.remove();
}
assert!(!pending_events.lock().unwrap().is_empty());
assert_eq!(
pending_events.lock().unwrap().pop_front(),
- Some((Event::InvoiceRequestFailed { payment_id }, None)),
+ Some((Event::PaymentFailed { payment_id, payment_hash: None, reason: None }, None)),
);
assert!(pending_events.lock().unwrap().is_empty());
assert!(!pending_events.lock().unwrap().is_empty());
assert_eq!(
pending_events.lock().unwrap().pop_front(),
- Some((Event::InvoiceRequestFailed { payment_id }, None)),
+ Some((Event::PaymentFailed { payment_id, payment_hash: None, reason: None }, None)),
);
assert!(pending_events.lock().unwrap().is_empty());
assert!(!pending_events.lock().unwrap().is_empty());
assert_eq!(
pending_events.lock().unwrap().pop_front(),
- Some((Event::InvoiceRequestFailed { payment_id }, None)),
+ Some((Event::PaymentFailed {
+ payment_id, payment_hash: None, reason: Some(PaymentFailureReason::UserAbandoned),
+ }, None)),
);
assert!(pending_events.lock().unwrap().is_empty());
}