Skip to content

lsps-plugin: fail HTLC with TEMPORARY_CHANNEL_FAILURE on JIT channel errors - #9271

Open
Andezion wants to merge 1 commit into
ElementsProject:masterfrom
Andezion:fix-htlc-silent-fundchannel-error-clean
Open

Andezion wants to merge 1 commit into
ElementsProject:masterfrom
Andezion:fix-htlc-silent-fundchannel-error-clean

Conversation

@Andezion

@Andezion Andezion commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

In service.rs, handle_htlc_safe caught all errors from handle_htlc_inner and responded with "result": "continue" while only logging at debug! level. This silently swallowed failures during JIT channel opening - most critically, fundchannel failures caused by insufficient on-chain balance. The paying node received no failure signal and the operator had no actionable log output

Fix

Replace the catch-all continue with a typed dispatch on HtlcError:

  • HtlcError::FundChannel -> warn! (operator action required) + TEMPORARY_CHANNEL_FAILURE
  • HtlcError::ChannelReadyCheck -> warn! + TEMPORARY_CHANNEL_FAILURE
  • HtlcError::CapacityQuery -> error! + TEMPORARY_CHANNEL_FAILURE
    The outer handle_htlc_safe still catches truly unexpected errors (deserialization and stuff like that) and continues, which is the correct behaviour for unknown failures

Important

26.09 FREEZE August 5th: Non-bugfix PRs not ready by this date will wait for 26.12.

RC1 is scheduled on August 17th

The final release is scheduled for September 7th.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

@Andezion Andezion self-assigned this Jul 1, 2026
@madelinevibes madelinevibes added this to the v26.09 milestone Jul 1, 2026
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch 3 times, most recently from 3eb47a2 to 8cde735 Compare July 15, 2026 10:08
@daywalker90
daywalker90 requested a review from nepet July 21, 2026 08:50
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch from 8cde735 to 66480c3 Compare August 14, 2026 09:14
@Andezion Andezion added the Status::Ready for Review The work has been completed and is now awaiting evaluation or approval. label Aug 14, 2026
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch 4 times, most recently from 1f645d6 to d31e3b8 Compare August 26, 2026 09:35
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch from d31e3b8 to 612eaa0 Compare August 27, 2026 10:16
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch from 612eaa0 to 63a1b32 Compare October 12, 2026 20:42
@madelinevibes madelinevibes modified the milestones: v26.09, v26.12 Oct 14, 2026
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch from 63a1b32 to 290cf49 Compare October 26, 2026 15:15
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch 2 times, most recently from 579fa97 to f0bf882 Compare November 3, 2026 13:47

@nGoline nGoline left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues here before we merge, but there's a third one that can be fixed in this PR since you're fixing a constant:

  • proto/lsps2.rs:10 UNKNOWN_NEXT_PEER = "4010": unknown_next_peer is PERM|10 = 0x400a. Every RejectReason except OfferExpired (core/lsps2/htlc.rs:52) sends it.

error!("LSPS2: Capacity query failed: {:#}", cause);
}
}
json_fail(TEMPORARY_CHANNEL_FAILURE)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BOLT #4 (and wire/onion_wire.csv:56-58) define it as u16 len + channel_update, so the minimal valid message is "10070000". lightningd passes the hex through without validation and CLN payers only peek the type, but payers that parse the body see a malformed failure. Master's own mock (tests/plugins/lsps2_mock.py:44) already uses "10070000".

The failure also occurs in plugins/lsps-plugin/src/proto/lsps2.rs:9: TEMPORARY_CHANNEL_FAILURE = "1007"

warn!("LSPS2: Channel ready check failed: {:#}", cause);
}
HtlcError::CapacityQuery(ref cause) => {
error!("LSPS2: Capacity query failed: {:#}", cause);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logs CapacityQuery with error!, which common/status_levels.c maps to LOG_BROKEN. CapacityQuery is a failed RPC to the policy plugin, not an internal invariant failure, and BROKEN fails any pyln test that hits it. Should be warn!.

@nGoline nGoline left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, no test exercises the new failure path, while master now has a mock LSPS2 service that could.


fn handle_htlc_error(e: HtlcError) -> serde_json::Value {
match e {
HtlcError::FundChannel(ref cause) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FundChannel is not always transient. It also covers the client refusing the open (tests/test_cln_lsps.py test_lsps2_non_approved_zero_conf drives that path). master's mock, written against bLIP-52 (1ebc494), fails with temporary_channel_failure only when the client disconnects before funding_signed and with unknown_next_peer when the client rejects the open with an error. Mapping every FundChannel to temporary_channel_failure makes payers retry a payment that cannot succeed. Also, the old behaviour was not "no failure signal": continue makes lightningd fail the unresolvable JIT scid with unknown_next_peer. the PR body and Changelog should say what actually changes.

…errors

Changelog-Fixed: lsps-plugin: JIT channel HTLCs now fail with temporary_channel_failure instead of being silently continued when channel opening fails.
@Andezion
Andezion force-pushed the fix-htlc-silent-fundchannel-error-clean branch from f0bf882 to 1a47fe5 Compare November 23, 2026 19:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status::Ready for Review The work has been completed and is now awaiting evaluation or approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants