Skip to content

Commit 457a504

Browse files
fix(lsps4): use is_channel_ready for splice candidate selection
Use is_channel_ready instead of is_usable when selecting splice candidates. This ensures we prefer splice over new channel even during channel_reestablish (~1s window). splice_channel() will fail with "pending open/close" if the channel isn't usable yet, and the timer retries once reestablishment completes.
1 parent afe7b5b commit 457a504

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lightning-liquidity/src/lsps4/service.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,12 @@ where
783783
.fold(required_amount, |acc, h| acc.saturating_add(h.amount_to_forward_msat));
784784

785785
// Prefer splicing into the largest usable channel over opening a new one.
786-
let splice_candidate = channels
786+
// Use is_channel_ready (not is_usable) so we prefer splice even during
787+
// channel_reestablish. splice_channel() will fail if the channel isn't
788+
// usable yet, and the timer will retry once reestablishment completes.
789+
let splice_candidate = channels
787790
.iter()
788-
.filter(|c| c.is_usable)
791+
.filter(|c| c.is_channel_ready)
789792
.max_by_key(|c| c.channel_value_satoshis);
790793

791794
if let Some(candidate) = splice_candidate {

0 commit comments

Comments
 (0)