Skip to content

Commit c7d4361

Browse files
f take node id in forward_intercept
1 parent 8103b33 commit c7d4361

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,12 +3168,14 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
31683168
/// LDK to generate an [`HTLCIntercepted`] event when it receives the forwarded HTLC.
31693169
///
31703170
/// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
3171-
pub fn forward_intercepted_htlc(&self, intercept_id: InterceptId, short_channel_id: u64, amt_to_forward_msat: u64) -> Result<(), APIError> {
3171+
// TODO: when we move to deciding the best outbound channel at forward time, only take
3172+
// `next_node_id` and not `next_hop_scid`
3173+
pub fn forward_intercepted_htlc(&self, intercept_id: InterceptId, next_hop_scid: u64, _next_node_id: PublicKey, amt_to_forward_msat: u64) -> Result<(), APIError> {
31723174
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
31733175

3174-
if self.short_to_chan_info.read().unwrap().get(&short_channel_id).is_none() {
3176+
if self.short_to_chan_info.read().unwrap().get(&next_hop_scid).is_none() {
31753177
return Err(APIError::APIMisuseError {
3176-
err: format!("Channel with short channel id {:?} not found", short_channel_id)
3178+
err: format!("Channel with short channel id {:?} not found", next_hop_scid)
31773179
})
31783180
}
31793181

@@ -3184,7 +3186,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
31843186

31853187
let routing = match payment.forward_info.routing {
31863188
PendingHTLCRouting::Forward { onion_packet, .. } => {
3187-
PendingHTLCRouting::Forward { onion_packet, short_channel_id }
3189+
PendingHTLCRouting::Forward { onion_packet, short_channel_id: next_hop_scid }
31883190
},
31893191
_ => unreachable!()
31903192
};

lightning/src/ln/payment_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,19 +1458,19 @@ fn forward_intercepted_payment() {
14581458
};
14591459

14601460
// Check for unknown scid error.
1461-
let unknown_scid_err = nodes[1].node.forward_intercepted_htlc(intercept_id, 4242, expected_outbound_amount_msat).unwrap_err();
1461+
let unknown_scid_err = nodes[1].node.forward_intercepted_htlc(intercept_id, 4242, nodes[2].node.get_our_node_id(), expected_outbound_amount_msat).unwrap_err();
14621462
assert_eq!(unknown_scid_err, APIError::APIMisuseError { err: "Channel with short channel id 4242 not found".to_string() });
14631463

14641464
// Open the just-in-time channel so the payment can then be forwarded.
14651465
let scid = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
14661466

14671467
// Check for unknown intercept id error.
14681468
let unknown_intercept_id = InterceptId([42; 32]);
1469-
let unknown_intercept_id_err = nodes[1].node.forward_intercepted_htlc(unknown_intercept_id, scid, expected_outbound_amount_msat).unwrap_err();
1469+
let unknown_intercept_id_err = nodes[1].node.forward_intercepted_htlc(unknown_intercept_id, scid, nodes[2].node.get_our_node_id(), expected_outbound_amount_msat).unwrap_err();
14701470
assert_eq!(unknown_intercept_id_err , APIError::APIMisuseError { err: format!("Payment with intercept id {:?} not found", unknown_intercept_id.0) });
14711471

14721472
// Finally, forward the intercepted payment through and claim it.
1473-
nodes[1].node.forward_intercepted_htlc(intercept_id, scid, expected_outbound_amount_msat).unwrap();
1473+
nodes[1].node.forward_intercepted_htlc(intercept_id, scid, nodes[2].node.get_our_node_id(), expected_outbound_amount_msat).unwrap();
14741474
expect_pending_htlcs_forwardable!(nodes[1]);
14751475

14761476
let payment_event = {

0 commit comments

Comments
 (0)