Skip to content

Set custom tlvs to update_add_htlc via the htlc_accepted_hook #8433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nepet
Copy link
Collaborator

@nepet nepet commented Jul 30, 2025

Important

25.09 FREEZE July 28TH: Non-bugfix PRs not ready by this date will wait for 25.12.

RC1 is scheduled on August 11th

The final release is scheduled for September 1st.

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.

This PR allows plugins that registered to th htlc_accepted_hook to get and replace the TLV-stream update_add_htlc_tlvs attached to incomming update_add_htlc messages, adding a new HTLC.

If a plugin want's to replace the TLV-stream with custom TLVS, it needs to return

{
    "result": "continue",
    "extra_tlvs": [hex-encoded string]
}

Specifying extra_tlvs will replace the TLV-stream attached to the HTLC (also the blinding path-key) and will be - in case of a forward - forwarded as the update_add_htlc_tlvs to the peer.

This PR is a necessary precondition to implement the LSPS2 protocol and Resolves #6663

@nepet nepet force-pushed the 2519-extra-tlv-on-htlc_accepted-hook branch 6 times, most recently from 83eb85c to a9bd415 Compare July 31, 2025 15:34
nepet added 8 commits July 31, 2025 21:06
We currently only consider known tlv types in the internal
representation of a htlc. This commit adds the remaining unknown tlv
fields to the htlc as well. This is in prepareation to forward these to
the htlc_accepted_hook.

Signed-off-by: Peter Neuroth <[email protected]>
This appends the extra_tlvs to the internal wire htlcs "added" and
"existing" for the extra tlvs to be handed to lightningd.

Signed-off-by: Peter Neuroth <[email protected]>
This appends the extra_tlvs to the internal channeld_offer_htlc wire
msg. We also recombine the extra_tlvs with the blinded path key for
forwarding htlcs.

Signed-off-by: Peter Neuroth <[email protected]>
Add serializing and deserializing of the extra tlvs to to the
htlc_accepted_hook to allow plugin users to replace the tlv stream that
is attached to the update_add_htlc message on forwards.

Signed-off-by: Peter Neuroth <[email protected]>
Adds some testcases for custom tlvs, set by a htlc_accepted_hook. We
check that the custom tlvs replace the update_add_htlc_tlvs and get
forwarded to the peer. We also check that a malformed tlv will result in
a **BROKEN** behaviour.

Signed-off-by: Peter Neuroth <[email protected]>
Changelog-Added: The `htlc_accepted_hook` now gets the TLV-stream
attached to the HTLC passed through as `extra_tlvs` and can replace it.

Signed-off-by: Peter Neuroth <[email protected]>
There was a problem with a ‘highlight’ that was misunderstood as a
spelling mistake in lib-wally. Since ‘hightlight’ is already filtered
out, we simply instruct grep to ignore upper/lower case when filtering.

Signed-off-by: Peter Neuroth <[email protected]>
The rare case happened where a lockfile sha-sum contained a "Ctlv" which
spell-check complained about. Stupid lockfiles that don't know it is
actually "cltv"!

Signed-off-by: Peter Neuroth <[email protected]>
@nepet nepet force-pushed the 2519-extra-tlv-on-htlc_accepted-hook branch from a9bd415 to b0c1c55 Compare July 31, 2025 19:07
@madelinevibes madelinevibes added this to the v25.09 milestone Aug 7, 2025
@madelinevibes
Copy link
Collaborator

this PR is necessary for LSPS2 - doesn't conclude LSPS2.

@madelinevibes madelinevibes requested review from cdecker and rustyrussell and removed request for cdecker August 7, 2025 09:12
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.

Ability to add custom TLV to update_add_htlc message
2 participants