Skip to content

fix(lsps4): trigger channel open at peer_connected even during reestablish#9

Merged
martinsaposnic merged 1 commit intolsp-0.2.0from
fix/lsps4-peer-connected-channel-open
Mar 20, 2026
Merged

fix(lsps4): trigger channel open at peer_connected even during reestablish#9
martinsaposnic merged 1 commit intolsp-0.2.0from
fix/lsps4-peer-connected-channel-open

Conversation

@martinsaposnic
Copy link

Summary

  • When an HTLC arrives for an offline peer, htlc_intercepted stores it and sends a webhook. The peer reconnects, but peer_connected deferred all processing because channels 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 one. The HTLC would loop until expiry (45s) and fail.
  • Fix: call process_htlcs_for_peer even when channels aren't usable. calculate_htlc_actions skips non-usable channels, so it correctly returns new_channel_needed_msat and emits OpenChannel. No premature forwarding occurs since the forwards list is empty (no usable channels). Actual HTLC forwards happen via channel_ready once the new channel is established.

Test plan

  • Tested locally on regtest: payment that previously got stuck in the retry loop now opens a new zero-conf channel and forwards the HTLC successfully
  • Verify no duplicate channel opens when existing capacity IS sufficient (the existing channel just needs reestablish)
  • Verify behavior when peer has no channels at all (should be unchanged - already worked)

…blish

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.
@martinsaposnic martinsaposnic force-pushed the fix/lsps4-peer-connected-channel-open branch from d7b97a7 to 2252def Compare March 20, 2026 13:00
@amackillop amackillop self-requested a review March 20, 2026 14:05
@martinsaposnic martinsaposnic merged commit 55f7619 into lsp-0.2.0 Mar 20, 2026
12 of 43 checks passed
martinsaposnic added a commit to moneydevkit/ldk-node that referenced this pull request Mar 20, 2026
…en fix

Updates rust-lightning rev to include moneydevkit/rust-lightning#9:
trigger OpenChannel at peer_connected even during reestablish, fixing
stuck HTLC loop when existing channel capacity is insufficient.
amackillop pushed a commit to moneydevkit/ldk-node that referenced this pull request Mar 20, 2026
…en fix (#13)

Updates rust-lightning rev to include moneydevkit/rust-lightning#9:
trigger OpenChannel at peer_connected even during reestablish, fixing
stuck HTLC loop when existing channel capacity is insufficient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants