Skip to content

Flag peers that leave liquidity fees unpaid - #3416

Merged
pm47 merged 3 commits into
masterfrom
otf-flag-unpaid-liquidity-fees
Oct 27, 2026
Merged

pm47 merged 3 commits into
masterfrom
otf-flag-unpaid-liquidity-fees

Conversation

@pm47

@pm47 pm47 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

When a peer buys liquidity using from_future_htlc, we take the risk of not being paid, and rely on our suspicious peers mechanism (max-suspicious-peers) to bound that risk. But a peer could withdraw the payments that should pay the fees before the purchase is signed (with will_fail_htlc, by letting the proposal time out, or by disconnecting): we then signed the funding transaction without recording any fee debt, and the peer was never flagged, so it could repeat this indefinitely.

This PR:

  • flags the peer when signing a from_future_htlc purchase leaves some of its fees unpaid
  • tracks those underpaid purchases by funding txid, so that they cannot be cleared by fulfilling an unrelated payment with the same payment hash (partial withdrawal of a multi-part payment, or payment hash reuse); they're only cleared by the operator (enableFromFutureHtlc) or on restart
  • forgets an underpaid purchase if it is aborted before being published (e.g. when our peer disconnects before sending their signatures), since we didn't lose anything in that case, and fails the corresponding upstream HTLCs, which was previously skipped

Reported-by: @erickcestari

pm47 and others added 3 commits October 22, 2026 11:29
When signing a liquidity purchase paid with from_future_htlc, we now
flag our peer as suspicious if some of its fees cannot be collected from
its pending payments, as we already do when funded HTLCs are failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Underpaid liquidity purchases are now tracked by funding txid instead
of payment hash, and are only cleared by the node operator (using
enableFromFutureHtlc) or when restarting. Failed relays are still keyed
by payment hash. Both count towards max-suspicious-peers, and each is
reported in its own metric.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
When a liquidity purchase is aborted before its funding transaction is
published, we haven't lost any fees: we now remove the corresponding
underpaid entry, and fail the upstream HTLCs of its funded payments.
We handle this event regardless of our connection state, since it is
sent asynchronously by the channel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@pm47
pm47 requested a review from sstone October 27, 2026 10:29
@pm47
pm47 merged commit c5b9afc into master Oct 27, 2026
1 check passed
@pm47
pm47 deleted the otf-flag-unpaid-liquidity-fees branch October 27, 2026 13:11
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