Skip to content

Commit b167ce5

Browse files
committed
Add trampoline routing failure handling
Implement failure propagation for `HTLCSource::TrampolineForward` by iterating through previous hop data and failing each HTLC with `TemporaryTrampolineFailure`. Note that testing should be implemented when trampoline forward is completed.
1 parent b7de07c commit b167ce5

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7938,7 +7938,48 @@ where
79387938
htlc_failure_reason,
79397939
);
79407940
},
7941-
HTLCSource::TrampolineForward { .. } => todo!(),
7941+
// TODO: This branch should be tested when Trampoline Forwarding is implemented.
7942+
HTLCSource::TrampolineForward {
7943+
previous_hop_data,
7944+
incoming_trampoline_shared_secret,
7945+
..
7946+
} => {
7947+
// TODO: what do we want to do with this given we do not wish to propagate it directly?
7948+
let _decoded_onion_failure =
7949+
onion_error.decode_onion_failure(&self.secp_ctx, &self.logger, &source);
7950+
let incoming_trampoline_shared_secret = Some(*incoming_trampoline_shared_secret);
7951+
for current_hop_data in previous_hop_data {
7952+
let incoming_packet_shared_secret =
7953+
&current_hop_data.incoming_packet_shared_secret;
7954+
let channel_id = &current_hop_data.channel_id;
7955+
let short_channel_id = &current_hop_data.short_channel_id;
7956+
let htlc_id = &current_hop_data.htlc_id;
7957+
let blinded_failure = &current_hop_data.blinded_failure;
7958+
log_trace!(
7959+
WithContext::from(&self.logger, None, Some(*channel_id), Some(*payment_hash)),
7960+
"Failing {}HTLC with payment_hash {} backwards from us following Trampoline forwarding failure: {:?}",
7961+
if blinded_failure.is_some() { "blinded " } else { "" }, &payment_hash, onion_error
7962+
);
7963+
let onion_error = HTLCFailReason::reason(
7964+
LocalHTLCFailureReason::TemporaryTrampolineFailure,
7965+
Vec::new(),
7966+
);
7967+
let htlc_failure_reason = self.get_htlc_failure_from_blinded_failure_forward(
7968+
blinded_failure,
7969+
&onion_error,
7970+
incoming_packet_shared_secret,
7971+
&incoming_trampoline_shared_secret,
7972+
htlc_id,
7973+
);
7974+
self.fail_htlc_backwards_from_forward(
7975+
&onion_error,
7976+
failure_type.clone(),
7977+
short_channel_id,
7978+
channel_id,
7979+
htlc_failure_reason,
7980+
);
7981+
}
7982+
},
79427983
}
79437984
}
79447985

0 commit comments

Comments
 (0)