Add new PaymentFailureReason::BlindedPathCreationFailed

RouteNotFound did not fit here because that error is reserved for failing to
find a route for a payment, whereas here we are failing to create a blinded
path back to ourselves..
This commit is contained in:
Valentine Wallace 2024-09-11 13:53:39 -04:00
parent cdc0c3b581
commit 3945bf86f9
No known key found for this signature in database
GPG key ID: FD3E106A2CE099B4
2 changed files with 10 additions and 1 deletions

View file

@ -577,6 +577,12 @@ pub enum PaymentFailureReason {
/// ///
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
InvoiceRequestRejected, InvoiceRequestRejected,
/// Failed to create a blinded path back to ourselves.
/// We attempted to initiate payment to a static invoice but failed to create a reply path for our
/// [`HeldHtlcAvailable`] message.
///
/// [`HeldHtlcAvailable`]: crate::onion_message::async_payments::HeldHtlcAvailable
BlindedPathCreationFailed,
} }
impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason, impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
@ -587,6 +593,7 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
(4, RetriesExhausted) => {}, (4, RetriesExhausted) => {},
(5, InvoiceRequestRejected) => {}, (5, InvoiceRequestRejected) => {},
(6, PaymentExpired) => {}, (6, PaymentExpired) => {},
(7, BlindedPathCreationFailed) => {},
(8, RouteNotFound) => {}, (8, RouteNotFound) => {},
(10, UnexpectedError) => {}, (10, UnexpectedError) => {},
); );
@ -1651,6 +1658,8 @@ impl Writeable for Event {
&Some(PaymentFailureReason::RetriesExhausted), &Some(PaymentFailureReason::RetriesExhausted),
Some(PaymentFailureReason::InvoiceRequestRejected) => Some(PaymentFailureReason::InvoiceRequestRejected) =>
&Some(PaymentFailureReason::RecipientRejected), &Some(PaymentFailureReason::RecipientRejected),
Some(PaymentFailureReason::BlindedPathCreationFailed) =>
&Some(PaymentFailureReason::RouteNotFound)
}; };
write_tlv_fields!(writer, { write_tlv_fields!(writer, {
(0, payment_id, required), (0, payment_id, required),

View file

@ -4463,7 +4463,7 @@ where
) { ) {
Ok(paths) => paths, Ok(paths) => paths,
Err(()) => { Err(()) => {
self.abandon_payment_with_reason(payment_id, PaymentFailureReason::RouteNotFound); self.abandon_payment_with_reason(payment_id, PaymentFailureReason::BlindedPathCreationFailed);
res = Err(Bolt12PaymentError::BlindedPathCreationFailed); res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
return NotifyOption::DoPersist return NotifyOption::DoPersist
} }