Skip to content

Commit 6b6ac93

Browse files
committed
Add trampoline LocalHTLCFailureReason variants per spec
This commit adds three new local htlc failure error reasons: `TemporaryTrampolineFailure`, `TrampolineFeeOrExpiryInsufficient`, and `UnknownNextTrampoline` for trampoline payment forwarding failures.
1 parent 381416a commit 6b6ac93

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,13 @@ pub enum LocalHTLCFailureReason {
16781678
HTLCMaximum,
16791679
/// The HTLC was failed because our remote peer is offline.
16801680
PeerOffline,
1681+
/// We have been unable to forward a payment to the next Trampoline node but may be able to
1682+
/// do it later.
1683+
TemporaryTrampolineFailure,
1684+
/// The amount or CLTV expiry were insufficient to route the payment to the next Trampoline.
1685+
TrampolineFeeOrExpiryInsufficient,
1686+
/// The specified next Trampoline node cannot be reached from our node.
1687+
UnknownNextTrampoline,
16811688
}
16821689

16831690
impl LocalHTLCFailureReason {
@@ -1718,6 +1725,9 @@ impl LocalHTLCFailureReason {
17181725
Self::InvalidOnionPayload | Self::InvalidTrampolinePayload => PERM | 22,
17191726
Self::MPPTimeout => 23,
17201727
Self::InvalidOnionBlinding => BADONION | PERM | 24,
1728+
Self::TemporaryTrampolineFailure => NODE | 25,
1729+
Self::TrampolineFeeOrExpiryInsufficient => NODE | 26,
1730+
Self::UnknownNextTrampoline => PERM | 27,
17211731
Self::UnknownFailureCode { code } => *code,
17221732
}
17231733
}
@@ -1852,6 +1862,9 @@ impl_writeable_tlv_based_enum!(LocalHTLCFailureReason,
18521862
(79, HTLCMinimum) => {},
18531863
(81, HTLCMaximum) => {},
18541864
(83, PeerOffline) => {},
1865+
(85, TemporaryTrampolineFailure) => {},
1866+
(87, TrampolineFeeOrExpiryInsufficient) => {},
1867+
(89, UnknownNextTrampoline) => {},
18551868
);
18561869

18571870
impl From<&HTLCFailReason> for HTLCHandlingFailureReason {
@@ -2018,6 +2031,11 @@ impl HTLCFailReason {
20182031
debug_assert!(false, "Unknown failure code: {}", code)
20192032
}
20202033
},
2034+
LocalHTLCFailureReason::TemporaryTrampolineFailure => debug_assert!(data.is_empty()),
2035+
LocalHTLCFailureReason::TrampolineFeeOrExpiryInsufficient => {
2036+
debug_assert_eq!(data.len(), 10)
2037+
},
2038+
LocalHTLCFailureReason::UnknownNextTrampoline => debug_assert!(data.is_empty()),
20212039
}
20222040

20232041
Self(HTLCFailReasonRepr::Reason { data, failure_reason })

0 commit comments

Comments
 (0)