Skip to content

Commit 559f8db

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 fbe7626 commit 559f8db

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
@@ -8044,7 +8044,48 @@ where
80448044
htlc_failure_reason,
80458045
);
80468046
},
8047-
HTLCSource::TrampolineForward { .. } => todo!(),
8047+
// TODO: This branch should be tested when Trampoline Forwarding is implemented.
8048+
HTLCSource::TrampolineForward {
8049+
previous_hop_data,
8050+
incoming_trampoline_shared_secret,
8051+
..
8052+
} => {
8053+
// TODO: what do we want to do with this given we do not wish to propagate it directly?
8054+
let _decoded_onion_failure =
8055+
onion_error.decode_onion_failure(&self.secp_ctx, &self.logger, &source);
8056+
let incoming_trampoline_shared_secret = Some(*incoming_trampoline_shared_secret);
8057+
for current_hop_data in previous_hop_data {
8058+
let incoming_packet_shared_secret =
8059+
&current_hop_data.incoming_packet_shared_secret;
8060+
let channel_id = &current_hop_data.channel_id;
8061+
let short_channel_id = &current_hop_data.short_channel_id;
8062+
let htlc_id = &current_hop_data.htlc_id;
8063+
let blinded_failure = &current_hop_data.blinded_failure;
8064+
log_trace!(
8065+
WithContext::from(&self.logger, None, Some(*channel_id), Some(*payment_hash)),
8066+
"Failing {}HTLC with payment_hash {} backwards from us following Trampoline forwarding failure: {:?}",
8067+
if blinded_failure.is_some() { "blinded " } else { "" }, &payment_hash, onion_error
8068+
);
8069+
let onion_error = HTLCFailReason::reason(
8070+
LocalHTLCFailureReason::TemporaryTrampolineFailure,
8071+
Vec::new(),
8072+
);
8073+
let htlc_failure_reason = self.get_htlc_failure_from_blinded_failure_forward(
8074+
blinded_failure,
8075+
&onion_error,
8076+
incoming_packet_shared_secret,
8077+
&incoming_trampoline_shared_secret,
8078+
htlc_id,
8079+
);
8080+
self.fail_htlc_backwards_from_forward(
8081+
&onion_error,
8082+
failure_type.clone(),
8083+
short_channel_id,
8084+
channel_id,
8085+
htlc_failure_reason,
8086+
);
8087+
}
8088+
},
80488089
}
80498090
}
80508091

0 commit comments

Comments
 (0)