Commit daa9d60
committed
Prevent spurious splice on reconnect
When the LSP intercepts an HTLC for an offline peer, the peer
reconnects and peer_connected fires before channel_reestablish
completes. All channels report is_usable=false at this point.
calculate_htlc_actions_for_peer builds its capacity map from
is_usable channels (empty set), finds zero capacity, then falls
through to the splice candidate filter. That filter used
is_channel_ready, which matches mid-reestablish channels, so it
emits a splice. Once reestablish finishes,
the HTLC gets forwarded through the existing
channel. The splice was wasted, and the 30s liquidity cooldown
it sets blocks all subsequent liquidity actions for that peer.
Two fixes in calculate_htlc_actions_for_peer:
1. Early return when channels exist but none are usable. The
capacity map is empty so any decision would be wrong. The
HTLC stays in the store (persisted by the prior commit) and
the 1Hz timer retries once channels become usable.
2. Splice candidate filter changed from is_channel_ready to
is_usable. A mid-reestablish channel maye already have sufficient
capacity but it's just not visible yet. Splicing into it adds
unnecessary on-chain cost and a 30s cooldown for capacity
that was never actually insufficient. splice_channel() would
also fail if the channel does become usable in time.1 parent 19fb094 commit daa9d60
1 file changed
Lines changed: 25 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
709 | 728 | | |
710 | 729 | | |
711 | 730 | | |
| |||
783 | 802 | | |
784 | 803 | | |
785 | 804 | | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
790 | 810 | | |
791 | | - | |
| 811 | + | |
792 | 812 | | |
793 | 813 | | |
794 | 814 | | |
| |||
0 commit comments