Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lightning/src/ln/onion_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,13 @@ pub enum LocalHTLCFailureReason {
PeerOffline,
/// The HTLC was failed because the channel balance was overdrawn.
ChannelBalanceOverdrawn,
/// We have been unable to forward a payment to the next Trampoline node but may be able to
/// do it later.
TemporaryTrampolineFailure,
/// The amount or CLTV expiry were insufficient to route the payment to the next Trampoline.
TrampolineFeeOrExpiryInsufficient,
/// The specified next Trampoline node cannot be reached from our node.
UnknownNextTrampoline,
}

impl LocalHTLCFailureReason {
Expand Down Expand Up @@ -1704,6 +1711,9 @@ impl LocalHTLCFailureReason {
Self::InvalidOnionPayload | Self::InvalidTrampolinePayload => PERM | 22,
Self::MPPTimeout => 23,
Self::InvalidOnionBlinding => BADONION | PERM | 24,
Self::TemporaryTrampolineFailure => NODE | 25,
Self::TrampolineFeeOrExpiryInsufficient => NODE | 26,
Self::UnknownNextTrampoline => PERM | 27,
Self::UnknownFailureCode { code } => *code,
}
}
Expand Down Expand Up @@ -1863,7 +1873,10 @@ ser_failure_reasons!(
(39, HTLCMinimum),
(40, HTLCMaximum),
(41, PeerOffline),
(42, ChannelBalanceOverdrawn)
(42, ChannelBalanceOverdrawn),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I just noticed this, on line 1778 we have a macro that says "Error codes that represent BOLT04 error codes must be included here", which looks like it should include these new errors

(43, TemporaryTrampolineFailure),
(44, TrampolineFeeOrExpiryInsufficient),
(45, UnknownNextTrampoline)
);

impl From<&HTLCFailReason> for HTLCHandlingFailureReason {
Expand Down Expand Up @@ -2031,6 +2044,11 @@ impl HTLCFailReason {
debug_assert!(false, "Unknown failure code: {}", code)
}
},
LocalHTLCFailureReason::TemporaryTrampolineFailure => debug_assert!(data.is_empty()),
LocalHTLCFailureReason::TrampolineFeeOrExpiryInsufficient => {
debug_assert_eq!(data.len(), 10)
},
LocalHTLCFailureReason::UnknownNextTrampoline => debug_assert!(data.is_empty()),
}

Self(HTLCFailReasonRepr::Reason { data, failure_reason })
Expand Down