Skip to content

Commit e0b0d25

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 35a0eb5 commit e0b0d25

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
@@ -1668,6 +1668,13 @@ pub enum LocalHTLCFailureReason {
16681668
HTLCMaximum,
16691669
/// The HTLC was failed because our remote peer is offline.
16701670
PeerOffline,
1671+
/// We have been unable to forward a payment to the next Trampoline node but may be able to
1672+
/// do it later.
1673+
TemporaryTrampolineFailure,
1674+
/// The amount or CLTV expiry were insufficient to route the payment to the next Trampoline.
1675+
TrampolineFeeOrExpiryInsufficient,
1676+
/// The specified next Trampoline node cannot be reached from our node.
1677+
UnknownNextTrampoline,
16711678
}
16721679

16731680
impl LocalHTLCFailureReason {
@@ -1708,6 +1715,9 @@ impl LocalHTLCFailureReason {
17081715
Self::InvalidOnionPayload | Self::InvalidTrampolinePayload => PERM | 22,
17091716
Self::MPPTimeout => 23,
17101717
Self::InvalidOnionBlinding => BADONION | PERM | 24,
1718+
Self::TemporaryTrampolineFailure => NODE | 25,
1719+
Self::TrampolineFeeOrExpiryInsufficient => NODE | 26,
1720+
Self::UnknownNextTrampoline => PERM | 27,
17111721
Self::UnknownFailureCode { code } => *code,
17121722
}
17131723
}
@@ -1842,6 +1852,9 @@ impl_writeable_tlv_based_enum!(LocalHTLCFailureReason,
18421852
(79, HTLCMinimum) => {},
18431853
(81, HTLCMaximum) => {},
18441854
(83, PeerOffline) => {},
1855+
(85, TemporaryTrampolineFailure) => {},
1856+
(87, TrampolineFeeOrExpiryInsufficient) => {},
1857+
(89, UnknownNextTrampoline) => {},
18451858
);
18461859

18471860
impl From<&HTLCFailReason> for HTLCHandlingFailureReason {
@@ -2008,6 +2021,11 @@ impl HTLCFailReason {
20082021
debug_assert!(false, "Unknown failure code: {}", code)
20092022
}
20102023
},
2024+
LocalHTLCFailureReason::TemporaryTrampolineFailure => debug_assert!(data.is_empty()),
2025+
LocalHTLCFailureReason::TrampolineFeeOrExpiryInsufficient => {
2026+
debug_assert_eq!(data.len(), 10)
2027+
},
2028+
LocalHTLCFailureReason::UnknownNextTrampoline => debug_assert!(data.is_empty()),
20112029
}
20122030

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

0 commit comments

Comments
 (0)