Custom tlvs#223
Conversation
|
👋 Thanks for assigning @benthecarman as a reviewer! |
| 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 { |
There was a problem hiding this comment.
can we just put these in mod.rs, we have other converters already
| } | ||
|
|
||
| #[test] | ||
| fn empty_value_round_trips() { |
There was a problem hiding this comment.
can we have a round trip with non empty too
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod payment_claimable_proto_tests { |
There was a problem hiding this comment.
we already have a test module, don't need a separate one here
| command: Commands, | ||
| } | ||
|
|
||
| fn parse_custom_tlv(s: &str) -> Result<(u64, Vec<u8>), String> { |
There was a problem hiding this comment.
can we put this next to parse_page_token, also add tests
| panic!("expected PaymentReceived"); | ||
| }; | ||
| assert_eq!(pr.custom_records.len(), 2); | ||
| let by_type: std::collections::HashMap<u64, Vec<u8>> = pr |
There was a problem hiding this comment.
can we import this instead of giant def
| 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(); |
| }), | ||
| let proto_custom_records: Vec<_> = custom_records | ||
| .iter() | ||
| .map(crate::api::custom_tlvs::node_to_proto_custom_tlv) |
|
Addressed all the comments, rebased on latest main and squashed into one commit. Lmk if anything else is needed! |
Closes #217.
Exposes
CustomTlvRecordthrough the gRPC API (LDK Node already supports it under the hood):types.CustomTlvRecord { uint64 type_num; bytes value; }repeated custom_tlvsfield onSpontaneousSendRequestrepeated custom_recordsfield onPaymentReceivedandPaymentClaimable--custom-tlv <type_num>:<hex_value>flag (repeatable) onldk-server-cli spontaneous-sendStrictly wire-additive, no new dependencies. Unit tests cover the proto <-> ldk-node conversions and the
PaymentClaimableproto build,e2e-tests::test_cli_spontaneous_send_with_custom_tlvsdrives 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 thanclaim_funds_with_known_custom_tlvs, so BOLT 4 rejects even-type TLVs at the receiver. Inherited from the pinnedldk-noderevision, this surface will support even types automatically once upstream changes that.