Skip to content

Commit 6157ac5

Browse files
ben-kaufmanclaude
andcommitted
fix: deduplicate healing payments by counterparty
When multiple channels exist with the same peer, the router may pick the same channel for both payments — leaving the other unhealed. Fix: send one payment per unique counterparty (not per channel) and dedup in the retry loop. Each retry may route through a different channel as outbound capacity shifts from previous attempts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 81cd590 commit 6157ac5

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,14 @@ impl Node {
728728
)
729729
};
730730

731+
// Deduplicate by counterparty — one payment per peer is enough to trigger
732+
// a commitment round-trip. If a peer has multiple channels, each retry
733+
// attempt may route through a different channel as outbound capacity shifts.
734+
let mut seen_peers = std::collections::HashSet::new();
731735
for (_, counterparty_node_id, _) in &initial_update_ids {
736+
if !seen_peers.insert(*counterparty_node_id) {
737+
continue;
738+
}
732739
match send_heal_payment(*counterparty_node_id) {
733740
Ok(_) => {
734741
log_info!(
@@ -800,16 +807,18 @@ impl Node {
800807
break;
801808
}
802809

803-
// Retry healing payments for unhealed channels.
810+
// Retry healing payments for peers that still have unhealed channels.
811+
// Dedup by peer — the router may pick a different channel on each retry.
804812
if last_retry_time.elapsed() >= retry_interval {
805813
last_retry_time = tokio::time::Instant::now();
814+
let mut retried_peers = std::collections::HashSet::new();
806815
for (ch_id, counterparty_node_id, initial_id) in &initial_update_ids {
807816
let healed = chain_monitor
808817
.get_monitor(*ch_id)
809818
.ok()
810819
.map(|m| m.get_latest_update_id() > *initial_id)
811820
.unwrap_or(true);
812-
if healed {
821+
if healed || !retried_peers.insert(*counterparty_node_id) {
813822
continue;
814823
}
815824

0 commit comments

Comments
 (0)