Skip to content

Commit a05f2d2

Browse files
a-mpchcarlaKC
authored andcommitted
ln: 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 77ea9c7 commit a05f2d2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,13 @@ pub enum LocalHTLCFailureReason {
16631663
PeerOffline,
16641664
/// The HTLC was failed because the channel balance was overdrawn.
16651665
ChannelBalanceOverdrawn,
1666+
/// We have been unable to forward a payment to the next Trampoline node but may be able to
1667+
/// do it later.
1668+
TemporaryTrampolineFailure,
1669+
/// The amount or CLTV expiry were insufficient to route the payment to the next Trampoline.
1670+
TrampolineFeeOrExpiryInsufficient,
1671+
/// The specified next Trampoline node cannot be reached from our node.
1672+
UnknownNextTrampoline,
16661673
}
16671674

16681675
impl LocalHTLCFailureReason {
@@ -1704,6 +1711,9 @@ impl LocalHTLCFailureReason {
17041711
Self::InvalidOnionPayload | Self::InvalidTrampolinePayload => PERM | 22,
17051712
Self::MPPTimeout => 23,
17061713
Self::InvalidOnionBlinding => BADONION | PERM | 24,
1714+
Self::TemporaryTrampolineFailure => NODE | 25,
1715+
Self::TrampolineFeeOrExpiryInsufficient => NODE | 26,
1716+
Self::UnknownNextTrampoline => PERM | 27,
17071717
Self::UnknownFailureCode { code } => *code,
17081718
}
17091719
}
@@ -1863,7 +1873,10 @@ ser_failure_reasons!(
18631873
(39, HTLCMinimum),
18641874
(40, HTLCMaximum),
18651875
(41, PeerOffline),
1866-
(42, ChannelBalanceOverdrawn)
1876+
(42, ChannelBalanceOverdrawn),
1877+
(43, TemporaryTrampolineFailure),
1878+
(44, TrampolineFeeOrExpiryInsufficient),
1879+
(45, UnknownNextTrampoline)
18671880
);
18681881

18691882
impl From<&HTLCFailReason> for HTLCHandlingFailureReason {
@@ -2031,6 +2044,11 @@ impl HTLCFailReason {
20312044
debug_assert!(false, "Unknown failure code: {}", code)
20322045
}
20332046
},
2047+
LocalHTLCFailureReason::TemporaryTrampolineFailure => debug_assert!(data.is_empty()),
2048+
LocalHTLCFailureReason::TrampolineFeeOrExpiryInsufficient => {
2049+
debug_assert_eq!(data.len(), 10)
2050+
},
2051+
LocalHTLCFailureReason::UnknownNextTrampoline => debug_assert!(data.is_empty()),
20342052
}
20352053

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

0 commit comments

Comments
 (0)