Skip to content

Commit 84d7f02

Browse files
martinsaposnicFernando Ledesma
authored andcommitted
add a bunch of logs
1 parent 6777b98 commit 84d7f02

File tree

2 files changed

+84
-31
lines changed

2 files changed

+84
-31
lines changed

lightning-liquidity/src/lsps4/service.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,21 @@ where
145145
&self, intercept_scid: u64, intercept_id: InterceptId, expected_outbound_amount_msat: u64,
146146
payment_hash: PaymentHash,
147147
) -> Result<(), APIError> {
148+
log_debug!(
149+
self.logger,
150+
"[htlc_intercepted] HTLC intercepted with scid {}, id {:?}, expected_outbound_amount_msat {}, payment_hash {}",
151+
intercept_scid,
152+
intercept_id,
153+
expected_outbound_amount_msat,
154+
payment_hash
155+
);
148156
if let Some(counterparty_node_id) = self.scid_store.get_peer(intercept_scid) {
157+
log_debug!(
158+
self.logger,
159+
"[htlc_intercepted] Intercept SCID {} matches peer {}, processing HTLC",
160+
intercept_scid,
161+
counterparty_node_id
162+
);
149163
let htlc = InterceptedHtlc::new(
150164
intercept_id,
151165
intercept_scid,
@@ -155,21 +169,51 @@ where
155169
);
156170

157171
if !self.is_peer_connected(&counterparty_node_id) {
172+
log_debug!(
173+
self.logger,
174+
"[htlc_intercepted] Peer {} not connected, storing HTLC and sending webhook",
175+
counterparty_node_id
176+
);
158177
self.htlc_store.insert(htlc).unwrap(); // TODO: handle persistence failures
159178
let mut event_queue_notifier = self.pending_events.notifier();
160179
event_queue_notifier.enqueue(crate::events::LiquidityEvent::LSPS4Service(LSPS4ServiceEvent::SendWebhook {
161180
counterparty_node_id: counterparty_node_id.clone(),
162181
}));
163182
} else {
164-
let actions = self.calculate_htlc_actions_for_peer(counterparty_node_id,vec![htlc.clone()]);
183+
log_debug!(
184+
self.logger,
185+
"[htlc_intercepted] Peer {} connected, processing HTLC immediately",
186+
counterparty_node_id
187+
);
188+
let actions =
189+
self.calculate_htlc_actions_for_peer(counterparty_node_id, vec![htlc.clone()]);
165190

166191
if actions.new_channel_needed_msat.is_some() {
167192
self.htlc_store.insert(htlc).unwrap(); // TODO: handle persistence failures
168193
}
169194

195+
log_debug!(
196+
self.logger,
197+
"[htlc_intercepted] Calculated actions for peer {}: {:?}",
198+
counterparty_node_id,
199+
actions
200+
);
201+
170202
self.execute_htlc_actions(actions, counterparty_node_id.clone());
171203
}
204+
} else {
205+
log_debug!(
206+
self.logger,
207+
"[htlc_intercepted] Intercept SCID {} not present in scid_store; ignoring HTLC id {:?}",
208+
intercept_scid,
209+
intercept_id
210+
);
172211
}
212+
log_debug!(
213+
self.logger,
214+
"[htlc_intercepted] Finalizing htlc_intercepted for intercept_scid {}",
215+
intercept_scid
216+
);
173217

174218
Ok(())
175219
}

lightning/src/ln/channelmanager.rs

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6712,6 +6712,9 @@ where
67126712
&self, intercept_id: InterceptId, next_hop_channel_id: &ChannelId, next_node_id: PublicKey,
67136713
amt_to_forward_msat: u64,
67146714
) -> Result<(), APIError> {
6715+
let entry_logger = WithContext::from(&self.logger, Some(next_node_id), Some(*next_hop_channel_id), None);
6716+
log_info!(entry_logger, "forward_intercepted_htlc called: intercept_id {:?} next_hop_channel_id {} next_node_id {} amt_to_forward_msat {}",
6717+
intercept_id, next_hop_channel_id, next_node_id, amt_to_forward_msat);
67156718
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
67166719

67176720
let outbound_scid_alias = {
@@ -11265,38 +11268,43 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1126511268
// Pull this now to avoid introducing a lock order with `forward_htlcs`.
1126611269
let is_our_scid = self.short_to_chan_info.read().unwrap().contains_key(&scid);
1126711270

11268-
let payment_hash = forward_info.payment_hash;
11269-
let logger = WithContext::from(
11270-
&self.logger,
11271-
None,
11272-
Some(prev_channel_id),
11273-
Some(payment_hash),
11271+
11272+
let payment_hash = forward_info.payment_hash;
11273+
let is_intercept = fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, scid, &self.chain_hash);
11274+
let is_phantom = fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, scid, &self.chain_hash);
11275+
let logger = WithContext::from(
11276+
&self.logger,
11277+
None,
11278+
Some(prev_channel_id),
11279+
Some(payment_hash),
11280+
);
11281+
log_debug!(logger, "Forward HTLC decision: scid {} is_our_scid={} is_intercept={} is_phantom={} incoming_amt_msat={:?} outgoing_amt_msat={} prev_short_channel_id={} prev_channel_id={}",
11282+
scid, is_our_scid, is_intercept, is_phantom, forward_info.incoming_amt_msat, forward_info.outgoing_amt_msat, prev_outbound_scid_alias, prev_channel_id);
11283+
let pending_add = PendingAddHTLCInfo {
11284+
prev_outbound_scid_alias,
11285+
prev_counterparty_node_id,
11286+
prev_funding_outpoint,
11287+
prev_channel_id,
11288+
prev_htlc_id,
11289+
prev_user_channel_id,
11290+
forward_info,
11291+
};
11292+
let mut fail_intercepted_htlc = |pending_add: PendingAddHTLCInfo| {
11293+
let htlc_source =
11294+
HTLCSource::PreviousHopData(pending_add.htlc_previous_hop_data());
11295+
let reason = HTLCFailReason::from_failure_code(
11296+
LocalHTLCFailureReason::UnknownNextPeer,
1127411297
);
11275-
let pending_add = PendingAddHTLCInfo {
11276-
prev_outbound_scid_alias,
11277-
prev_counterparty_node_id,
11278-
prev_funding_outpoint,
11279-
prev_channel_id,
11280-
prev_htlc_id,
11281-
prev_user_channel_id,
11282-
forward_info,
11283-
};
11284-
let mut fail_intercepted_htlc = |pending_add: PendingAddHTLCInfo| {
11285-
let htlc_source =
11286-
HTLCSource::PreviousHopData(pending_add.htlc_previous_hop_data());
11287-
let reason = HTLCFailReason::from_failure_code(
11288-
LocalHTLCFailureReason::UnknownNextPeer,
11289-
);
11290-
let failure_type = HTLCHandlingFailureType::InvalidForward {
11291-
requested_forward_scid: scid,
11292-
};
11293-
failed_intercept_forwards.push((
11294-
htlc_source,
11295-
payment_hash,
11296-
reason,
11297-
failure_type,
11298-
));
11298+
let failure_type = HTLCHandlingFailureType::InvalidForward {
11299+
requested_forward_scid: scid,
1129911300
};
11301+
failed_intercept_forwards.push((
11302+
htlc_source,
11303+
payment_hash,
11304+
reason,
11305+
failure_type,
11306+
));
11307+
};
1130011308

1130111309
// In the case that we have an HTLC that we're supposed to hold onto until the
1130211310
// recipient comes online *and* the outbound scid is encoded as
@@ -11391,6 +11399,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1139111399
}
1139211400

1139311401
if !new_intercept_events.is_empty() {
11402+
log_info!(WithContext::from(&self.logger, None, None, None), "Queueing {} HTLCIntercepted event(s)", new_intercept_events.len());
1139411403
let mut events = self.pending_events.lock().unwrap();
1139511404
events.append(&mut new_intercept_events);
1139611405
}

0 commit comments

Comments
 (0)