Skip to content

Commit 0383f8b

Browse files
committed
Add reason to Event::PaymentFailed
1 parent 1927a3e commit 0383f8b

File tree

7 files changed

+64
-31
lines changed

7 files changed

+64
-31
lines changed

lightning/src/events/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ pub enum Event {
463463
///
464464
/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
465465
payment_hash: PaymentHash,
466+
/// The reason the payment failed. This is only `None` for events generated or serialized
467+
/// by versions prior to 0.0.115.
468+
reason: Option<PaymentFailureReason>,
466469
},
467470
/// Indicates that a path for an outbound payment was successful.
468471
///
@@ -901,10 +904,11 @@ impl Writeable for Event {
901904
(4, *path, vec_type)
902905
})
903906
},
904-
&Event::PaymentFailed { ref payment_id, ref payment_hash } => {
907+
&Event::PaymentFailed { ref payment_id, ref payment_hash, ref reason } => {
905908
15u8.write(writer)?;
906909
write_tlv_fields!(writer, {
907910
(0, payment_id, required),
911+
(1, reason, option),
908912
(2, payment_hash, required),
909913
})
910914
},
@@ -1193,13 +1197,16 @@ impl MaybeReadable for Event {
11931197
let f = || {
11941198
let mut payment_hash = PaymentHash([0; 32]);
11951199
let mut payment_id = PaymentId([0; 32]);
1200+
let mut reason = None;
11961201
read_tlv_fields!(reader, {
11971202
(0, payment_id, required),
1203+
(1, reason, upgradable_option),
11981204
(2, payment_hash, required),
11991205
});
12001206
Ok(Some(Event::PaymentFailed {
12011207
payment_id,
12021208
payment_hash,
1209+
reason,
12031210
}))
12041211
};
12051212
f()

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, Fee
3636
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, HTLC_FAIL_BACK_BUFFER, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY, MonitorEvent, CLOSED_CHANNEL_UPDATE_ID};
3737
use crate::chain::transaction::{OutPoint, TransactionData};
3838
use crate::events;
39-
use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
39+
use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination, PaymentFailureReason};
4040
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
4141
// construct one themselves.
4242
use crate::ln::{inbound_payment, PaymentHash, PaymentPreimage, PaymentSecret};
@@ -2702,7 +2702,7 @@ where
27022702
/// [`Event::PaymentSent`]: events::Event::PaymentSent
27032703
pub fn abandon_payment(&self, payment_id: PaymentId) {
27042704
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
2705-
self.pending_outbound_payments.abandon_payment(payment_id, &self.pending_events);
2705+
self.pending_outbound_payments.abandon_payment(payment_id, PaymentFailureReason::UserAbandoned, &self.pending_events);
27062706
}
27072707

27082708
/// Send a spontaneous payment, which is a payment that does not require the recipient to have

lightning/src/ln/functional_test_utils.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch, keysinterface::EntropySource};
1414
use crate::chain::channelmonitor::ChannelMonitor;
1515
use crate::chain::transaction::OutPoint;
16-
use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose};
16+
use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, PaymentFailureReason};
1717
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
1818
use crate::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
1919
use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate};
@@ -1920,9 +1920,14 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>(
19201920
};
19211921
if !conditions.expected_mpp_parts_remain {
19221922
match &payment_failed_events[1] {
1923-
Event::PaymentFailed { ref payment_hash, ref payment_id } => {
1923+
Event::PaymentFailed { ref payment_hash, ref payment_id, ref reason } => {
19241924
assert_eq!(*payment_hash, expected_payment_hash, "unexpected second payment_hash");
19251925
assert_eq!(*payment_id, expected_payment_id);
1926+
assert_eq!(reason.unwrap(), if expected_payment_failed_permanently {
1927+
PaymentFailureReason::RecipientRejected
1928+
} else {
1929+
PaymentFailureReason::FailedAlongPath
1930+
});
19261931
}
19271932
_ => panic!("Unexpected second event"),
19281933
}
@@ -2216,10 +2221,10 @@ pub fn fail_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expe
22162221
let expected_destinations: Vec<HTLCDestination> = repeat(HTLCDestination::FailedPayment { payment_hash: our_payment_hash }).take(expected_paths.len()).collect();
22172222
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(expected_paths[0].last().unwrap(), expected_destinations);
22182223

2219-
pass_failed_payment_back(origin_node, expected_paths, skip_last, our_payment_hash);
2224+
pass_failed_payment_back(origin_node, expected_paths, skip_last, our_payment_hash, PaymentFailureReason::RecipientRejected);
22202225
}
22212226

2222-
pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths_slice: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_hash: PaymentHash) {
2227+
pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths_slice: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_hash: PaymentHash, expected_fail_reason: PaymentFailureReason) {
22232228
let mut expected_paths: Vec<_> = expected_paths_slice.iter().collect();
22242229
check_added_monitors!(expected_paths[0].last().unwrap(), expected_paths.len());
22252230

@@ -2305,9 +2310,10 @@ pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expe
23052310
};
23062311
if i == expected_paths.len() - 1 {
23072312
match events[1] {
2308-
Event::PaymentFailed { ref payment_hash, ref payment_id } => {
2313+
Event::PaymentFailed { ref payment_hash, ref payment_id, ref reason } => {
23092314
assert_eq!(*payment_hash, our_payment_hash, "unexpected second payment_hash");
23102315
assert_eq!(*payment_id, expected_payment_id);
2316+
assert_eq!(reason.unwrap(), expected_fail_reason);
23112317
}
23122318
_ => panic!("Unexpected second event"),
23132319
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::chain::channelmonitor;
1818
use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY};
1919
use crate::chain::transaction::OutPoint;
2020
use crate::chain::keysinterface::{ChannelSigner, EcdsaChannelSigner, EntropySource};
21-
use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, ClosureReason, HTLCDestination};
21+
use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, ClosureReason, HTLCDestination, PaymentFailureReason};
2222
use crate::ln::{PaymentPreimage, PaymentSecret, PaymentHash};
2323
use crate::ln::channel::{commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC, CONCURRENT_INBOUND_HTLC_FEE_BUFFER, FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE, MIN_AFFORDABLE_HTLC_COUNT};
2424
use crate::ln::channelmanager::{self, PaymentId, RAACommitmentOrder, PaymentSendFailure, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA};
@@ -9501,7 +9501,7 @@ fn test_double_partial_claim() {
95019501
];
95029502
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[3], failed_destinations);
95039503

9504-
pass_failed_payment_back(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_hash);
9504+
pass_failed_payment_back(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_hash, PaymentFailureReason::RecipientRejected);
95059505

95069506
// nodes[1] now retries one of the two paths...
95079507
nodes[0].node.send_payment(&route, payment_hash, &Some(payment_secret), PaymentId(payment_hash.0)).unwrap();

lightning/src/ln/onion_route_tests.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS};
1515
use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
16-
use crate::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure};
16+
use crate::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentFailureReason};
1717
use crate::ln::{PaymentHash, PaymentSecret};
1818
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
1919
use crate::ln::channelmanager::{HTLCForwardInfo, FailureCode, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingAddHTLCInfo, PendingHTLCInfo, PendingHTLCRouting, PaymentId};
@@ -212,9 +212,14 @@ fn run_onion_failure_test_with_fail_intercept<F1,F2,F3>(_name: &str, test_case:
212212
panic!("Unexpected event");
213213
}
214214
match events[1] {
215-
Event::PaymentFailed { payment_hash: ev_payment_hash, payment_id: ev_payment_id } => {
215+
Event::PaymentFailed { payment_hash: ev_payment_hash, payment_id: ev_payment_id, reason: ref ev_reason } => {
216216
assert_eq!(*payment_hash, ev_payment_hash);
217217
assert_eq!(payment_id, ev_payment_id);
218+
assert_eq!(if expected_retryable {
219+
PaymentFailureReason::FailedAlongPath
220+
} else {
221+
PaymentFailureReason::RecipientRejected
222+
}, ev_reason.unwrap());
218223
}
219224
_ => panic!("Unexpected second event"),
220225
}

lightning/src/ln/outbound_payment.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
1414
use bitcoin::secp256k1::{self, Secp256k1, SecretKey};
1515

1616
use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
17-
use crate::events;
17+
use crate::events::{self, PaymentFailureReason};
1818
use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
1919
use crate::ln::channelmanager::{ChannelDetails, HTLCSource, IDEMPOTENCY_TIMEOUT_TICKS, PaymentId};
2020
use crate::ln::onion_utils::HTLCFailReason;
@@ -550,6 +550,7 @@ impl OutboundPayments {
550550
pending_events.lock().unwrap().push(events::Event::PaymentFailed {
551551
payment_id: *pmt_id,
552552
payment_hash: pmt.payment_hash().expect("PendingOutboundPayments::Retryable always has a payment hash set"),
553+
reason: Some(events::PaymentFailureReason::ExhaustedRetryAttempts),
553554
});
554555
retain = false;
555556
}
@@ -629,7 +630,7 @@ impl OutboundPayments {
629630
#[cfg(feature = "std")] {
630631
if has_expired(&route_params) {
631632
log_error!(logger, "Payment params expired on retry, abandoning payment {}", log_bytes!(payment_id.0));
632-
self.abandon_payment(payment_id, pending_events);
633+
self.abandon_payment(payment_id, PaymentFailureReason::PaymentExpired, pending_events);
633634
return
634635
}
635636
}
@@ -642,14 +643,14 @@ impl OutboundPayments {
642643
Ok(route) => route,
643644
Err(e) => {
644645
log_error!(logger, "Failed to find a route on retry, abandoning payment {}: {:#?}", log_bytes!(payment_id.0), e);
645-
self.abandon_payment(payment_id, pending_events);
646+
self.abandon_payment(payment_id, PaymentFailureReason::FailedRoutingRetry, pending_events);
646647
return
647648
}
648649
};
649650
for path in route.paths.iter() {
650651
if path.len() == 0 {
651652
log_error!(logger, "length-0 path in route");
652-
self.abandon_payment(payment_id, pending_events);
653+
self.abandon_payment(payment_id, PaymentFailureReason::FailedRoutingRetry, pending_events);
653654
return
654655
}
655656
}
@@ -661,11 +662,12 @@ impl OutboundPayments {
661662
}
662663

663664
macro_rules! abandon_with_entry {
664-
($payment: expr) => {
665+
($payment: expr, $reason: expr) => {
665666
if $payment.get_mut().mark_abandoned().is_ok() && $payment.get().remaining_parts() == 0 {
666667
pending_events.lock().unwrap().push(events::Event::PaymentFailed {
667668
payment_id,
668669
payment_hash,
670+
reason: Some($reason),
669671
});
670672
$payment.remove();
671673
}
@@ -682,7 +684,7 @@ impl OutboundPayments {
682684
let retry_amt_msat: u64 = route.paths.iter().map(|path| path.last().unwrap().fee_msat).sum();
683685
if retry_amt_msat + *pending_amt_msat > *total_msat * (100 + RETRY_OVERFLOW_PERCENTAGE) / 100 {
684686
log_error!(logger, "retry_amt_msat of {} will put pending_amt_msat (currently: {}) more than 10% over total_payment_amt_msat of {}", retry_amt_msat, pending_amt_msat, total_msat);
685-
abandon_with_entry!(payment);
687+
abandon_with_entry!(payment, PaymentFailureReason::UnexpectedError);
686688
return
687689
}
688690
(*total_msat, *payment_secret, *keysend_preimage)
@@ -702,7 +704,7 @@ impl OutboundPayments {
702704
};
703705
if !payment.get().is_retryable_now() {
704706
log_error!(logger, "Retries exhausted for payment id {}", log_bytes!(payment_id.0));
705-
abandon_with_entry!(payment);
707+
abandon_with_entry!(payment, PaymentFailureReason::ExhaustedRetryAttempts);
706708
return
707709
}
708710
payment.get_mut().increment_attempts();
@@ -760,11 +762,11 @@ impl OutboundPayments {
760762
},
761763
PaymentSendFailure::PathParameterError(results) => {
762764
Self::push_path_failed_evs_and_scids(payment_id, payment_hash, &mut route_params, route.paths, results.into_iter(), pending_events);
763-
self.abandon_payment(payment_id, pending_events);
765+
self.abandon_payment(payment_id, PaymentFailureReason::UnexpectedError, pending_events);
764766
},
765767
PaymentSendFailure::ParameterError(e) => {
766768
log_error!(logger, "Failed to send to route due to parameter error: {:?}. Your router is buggy", e);
767-
self.abandon_payment(payment_id, pending_events);
769+
self.abandon_payment(payment_id, PaymentFailureReason::UnexpectedError, pending_events);
768770
},
769771
PaymentSendFailure::DuplicatePayment => debug_assert!(false), // unreachable
770772
}
@@ -1176,6 +1178,11 @@ impl OutboundPayments {
11761178
full_failure_ev = Some(events::Event::PaymentFailed {
11771179
payment_id: *payment_id,
11781180
payment_hash: payment.get().payment_hash().expect("PendingOutboundPayments::RetriesExceeded always has a payment hash set"),
1181+
reason: Some(if payment_retryable {
1182+
PaymentFailureReason::FailedAlongPath
1183+
} else {
1184+
PaymentFailureReason::RecipientRejected
1185+
}),
11791186
});
11801187
}
11811188
payment.remove();
@@ -1233,7 +1240,7 @@ impl OutboundPayments {
12331240
}
12341241

12351242
pub(super) fn abandon_payment(
1236-
&self, payment_id: PaymentId, pending_events: &Mutex<Vec<events::Event>>
1243+
&self, payment_id: PaymentId, reason: PaymentFailureReason, pending_events: &Mutex<Vec<events::Event>>
12371244
) {
12381245
let mut outbounds = self.pending_outbound_payments.lock().unwrap();
12391246
if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) {
@@ -1242,6 +1249,7 @@ impl OutboundPayments {
12421249
pending_events.lock().unwrap().push(events::Event::PaymentFailed {
12431250
payment_id,
12441251
payment_hash: payment.get().payment_hash().expect("PendingOutboundPayments::RetriesExceeded always has a payment hash set"),
1252+
reason: Some(reason),
12451253
});
12461254
payment.remove();
12471255
}
@@ -1312,7 +1320,7 @@ mod tests {
13121320
use bitcoin::network::constants::Network;
13131321
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
13141322

1315-
use crate::events::{Event, PathFailure};
1323+
use crate::events::{Event, PathFailure, PaymentFailureReason};
13161324
use crate::ln::PaymentHash;
13171325
use crate::ln::channelmanager::PaymentId;
13181326
use crate::ln::features::{ChannelFeatures, NodeFeatures};
@@ -1332,6 +1340,7 @@ mod tests {
13321340
}
13331341
#[cfg(feature = "std")]
13341342
fn do_fails_paying_after_expiration(on_retry: bool) {
1343+
13351344
let outbound_payments = OutboundPayments::new();
13361345
let logger = test_utils::TestLogger::new();
13371346
let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, &logger));
@@ -1360,7 +1369,9 @@ mod tests {
13601369
&pending_events, &|_, _, _, _, _, _, _, _| Ok(()));
13611370
let events = pending_events.lock().unwrap();
13621371
assert_eq!(events.len(), 1);
1363-
if let Event::PaymentFailed { .. } = events[0] { } else { panic!("Unexpected event"); }
1372+
if let Event::PaymentFailed { ref reason, .. } = events[0] {
1373+
assert_eq!(reason.unwrap(), PaymentFailureReason::PaymentExpired);
1374+
} else { panic!("Unexpected event"); }
13641375
} else {
13651376
let err = outbound_payments.send_payment(
13661377
PaymentHash([0; 32]), &None, PaymentId([0; 32]), Retry::Attempts(0), expired_route_params,

lightning/src/ln/payment_tests.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Listen, Watch};
1515
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS};
1616
use crate::chain::keysinterface::EntropySource;
1717
use crate::chain::transaction::OutPoint;
18-
use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure};
18+
use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentFailureReason};
1919
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
2020
use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS, RecentPaymentDetails};
2121
use crate::ln::features::InvoiceFeatures;
@@ -1169,7 +1169,7 @@ fn abandoned_send_payment_idempotent() {
11691169
}
11701170
check_send_rejected!();
11711171

1172-
pass_failed_payment_back(&nodes[0], &[&[&nodes[1]]], false, first_payment_hash);
1172+
pass_failed_payment_back(&nodes[0], &[&[&nodes[1]]], false, first_payment_hash, PaymentFailureReason::RecipientRejected);
11731173

11741174
// However, we can reuse the PaymentId immediately after we `abandon_payment` upon passing the
11751175
// failed payment back.
@@ -1702,9 +1702,10 @@ fn do_automatic_retries(test: AutoRetry) {
17021702
let mut events = nodes[0].node.get_and_clear_pending_events();
17031703
assert_eq!(events.len(), 1);
17041704
match events[0] {
1705-
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id } => {
1705+
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id, reason: ref ev_reason } => {
17061706
assert_eq!(payment_hash, *ev_payment_hash);
17071707
assert_eq!(PaymentId(payment_hash.0), *ev_payment_id);
1708+
assert_eq!(PaymentFailureReason::ExhaustedRetryAttempts, ev_reason.unwrap());
17081709
},
17091710
_ => panic!("Unexpected event"),
17101711
}
@@ -1737,9 +1738,10 @@ fn do_automatic_retries(test: AutoRetry) {
17371738
let mut events = nodes[0].node.get_and_clear_pending_events();
17381739
assert_eq!(events.len(), 1);
17391740
match events[0] {
1740-
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id } => {
1741+
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id, reason: ref ev_reason } => {
17411742
assert_eq!(payment_hash, *ev_payment_hash);
17421743
assert_eq!(PaymentId(payment_hash.0), *ev_payment_id);
1744+
assert_eq!(PaymentFailureReason::ExhaustedRetryAttempts, ev_reason.unwrap());
17431745
},
17441746
_ => panic!("Unexpected event"),
17451747
}
@@ -1756,9 +1758,10 @@ fn do_automatic_retries(test: AutoRetry) {
17561758
let mut events = nodes[0].node.get_and_clear_pending_events();
17571759
assert_eq!(events.len(), 1);
17581760
match events[0] {
1759-
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id } => {
1761+
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id, reason: ref ev_reason } => {
17601762
assert_eq!(payment_hash, *ev_payment_hash);
17611763
assert_eq!(PaymentId(payment_hash.0), *ev_payment_id);
1764+
assert_eq!(PaymentFailureReason::FailedRoutingRetry, ev_reason.unwrap());
17621765
},
17631766
_ => panic!("Unexpected event"),
17641767
}
@@ -2059,7 +2062,7 @@ fn fails_paying_after_rejected_by_payee() {
20592062

20602063
nodes[1].node.fail_htlc_backwards(&payment_hash);
20612064
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCDestination::FailedPayment { payment_hash }]);
2062-
pass_failed_payment_back(&nodes[0], &[&[&nodes[1]]], false, payment_hash);
2065+
pass_failed_payment_back(&nodes[0], &[&[&nodes[1]]], false, payment_hash, PaymentFailureReason::RecipientRejected);
20632066
}
20642067

20652068
#[test]
@@ -2432,9 +2435,10 @@ fn no_extra_retries_on_back_to_back_fail() {
24322435
_ => panic!("Unexpected event"),
24332436
}
24342437
match events[1] {
2435-
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id } => {
2438+
Event::PaymentFailed { payment_hash: ref ev_payment_hash, payment_id: ref ev_payment_id, reason: ref ev_reason } => {
24362439
assert_eq!(payment_hash, *ev_payment_hash);
24372440
assert_eq!(PaymentId(payment_hash.0), *ev_payment_id);
2441+
assert_eq!(PaymentFailureReason::FailedAlongPath, ev_reason.unwrap());
24382442
},
24392443
_ => panic!("Unexpected event"),
24402444
}

0 commit comments

Comments
 (0)