Skip to content

Custom tlvs#223

Open
Billa05 wants to merge 1 commit into
lightningdevkit:mainfrom
Billa05:custom-tlvs
Open

Custom tlvs#223
Billa05 wants to merge 1 commit into
lightningdevkit:mainfrom
Billa05:custom-tlvs

Conversation

@Billa05
Copy link
Copy Markdown

@Billa05 Billa05 commented May 28, 2026

Closes #217.

Exposes CustomTlvRecord through the gRPC API (LDK Node already supports it under the hood):

  • New types.CustomTlvRecord { uint64 type_num; bytes value; }
  • repeated custom_tlvs field on SpontaneousSendRequest
  • repeated custom_records field on PaymentReceived and PaymentClaimable
  • --custom-tlv <type_num>:<hex_value> flag (repeatable) on ldk-server-cli spontaneous-send

Strictly wire-additive, no new dependencies. Unit tests cover the proto <-> ldk-node conversions and the PaymentClaimable proto build, e2e-tests::test_cli_spontaneous_send_with_custom_tlvs drives the full CLI round-trip.

Note: the receive path round-trips odd-type TLVs only. LDK Node's spontaneous-receive uses claim_funds(preimage) rather than claim_funds_with_known_custom_tlvs, so BOLT 4 rejects even-type TLVs at the receiver. Inherited from the pinned ldk-node revision, this surface will support even types automatically once upstream changes that.

@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented May 28, 2026

👋 Thanks for assigning @benthecarman as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Comment thread ldk-server/src/api/custom_tlvs.rs Outdated
use ldk_node::CustomTlvRecord as NodeCustomTlvRecord;
use ldk_server_grpc::types::CustomTlvRecord as ProtoCustomTlvRecord;

pub(crate) fn proto_to_node_custom_tlv(proto: &ProtoCustomTlvRecord) -> NodeCustomTlvRecord {
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.

can we just put these in mod.rs, we have other converters already

Comment thread ldk-server/src/api/custom_tlvs.rs Outdated
}

#[test]
fn empty_value_round_trips() {
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.

can we have a round trip with non empty too

Comment thread ldk-server/src/main.rs Outdated
}

#[cfg(test)]
mod payment_claimable_proto_tests {
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.

we already have a test module, don't need a separate one here

Comment thread ldk-server-cli/src/main.rs Outdated
command: Commands,
}

fn parse_custom_tlv(s: &str) -> Result<(u64, Vec<u8>), String> {
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.

can we put this next to parse_page_token, also add tests

Comment thread e2e-tests/tests/e2e.rs Outdated
panic!("expected PaymentReceived");
};
assert_eq!(pr.custom_records.len(), 2);
let by_type: std::collections::HashMap<u64, Vec<u8>> = pr
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.

can we import this instead of giant def

Comment thread ldk-server/src/main.rs Outdated
payment_ref: &Payment, custom_records: &[ldk_node::CustomTlvRecord],
) -> events::PaymentClaimable {
let proto_custom_records: Vec<_> =
custom_records.iter().map(crate::api::custom_tlvs::node_to_proto_custom_tlv).collect();
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.

same here

Comment thread ldk-server/src/main.rs Outdated
}),
let proto_custom_records: Vec<_> = custom_records
.iter()
.map(crate::api::custom_tlvs::node_to_proto_custom_tlv)
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.

same here

@Billa05
Copy link
Copy Markdown
Author

Billa05 commented May 29, 2026

Addressed all the comments, rebased on latest main and squashed into one commit. Lmk if anything else is needed!

@Billa05 Billa05 requested a review from benthecarman May 29, 2026 18:15
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.

gRPC API: expose custom_tlvs on SpontaneousSend and custom_records on PaymentReceived / PaymentClaimable events

3 participants