Skip to content

Commit 2252def

Browse files
fix(lsps4): trigger channel open at peer_connected even during reestablish
When an HTLC arrives for an offline peer, htlc_intercepted stores it and sends a webhook. When the peer reconnects, peer_connected deferred all processing if channels existed but weren't usable yet (reestablish in progress). Later, process_pending_htlcs found insufficient capacity but assumed a channel open was already in flight - nobody ever opened the channel. Fix: call process_htlcs_for_peer even when channels aren't usable. calculate_htlc_actions skips non-usable channels, so if existing capacity is insufficient it returns new_channel_needed_msat and execute_htlc_actions emits OpenChannel. No premature forwarding occurs since the forwards list is empty (no usable channels). The actual HTLC forwards happen via channel_ready once the new channel is established.
1 parent eecf53e commit 2252def

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

lightning-liquidity/src/lsps4/service.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,22 @@ where
390390
// at all (process_htlcs_for_peer will trigger OpenChannel for JIT).
391391
self.process_htlcs_for_peer(counterparty_node_id.clone(), htlcs);
392392
} else {
393-
// Channels exist but none usable: reestablish still in progress.
394-
// Defer until process_pending_htlcs picks them up on the timer.
393+
// Channels exist but none usable yet (reestablish in progress).
394+
// We still call process_htlcs_for_peer because calculate_htlc_actions
395+
// skips non-usable channels. If existing capacity is insufficient, this
396+
// will emit OpenChannel now rather than deferring to process_pending_htlcs
397+
// (which would never open a channel). Forwards through existing channels
398+
// will be empty since none are usable, so no premature forwarding occurs.
399+
// The actual forwards happen later via channel_ready or process_pending_htlcs
400+
// once reestablish completes.
395401
log_info!(
396402
self.logger,
397-
"[LSPS4] peer_connected: {counterparty_node_id} has {} pending HTLCs but channels \
398-
not yet usable (reestablish in progress), deferring",
403+
"[LSPS4] peer_connected: {} has {} pending HTLCs, channels not yet usable \
404+
(reestablish in progress) - checking if new channel needed",
405+
counterparty_node_id,
399406
htlcs.len()
400407
);
408+
self.process_htlcs_for_peer(counterparty_node_id.clone(), htlcs);
401409
}
402410

403411
log_info!(

0 commit comments

Comments
 (0)