-
Notifications
You must be signed in to change notification settings - Fork 64
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
Proposal: implement custom TLV records for spontaneous payments #273
base: main
Are you sure you want to change the base?
Conversation
@@ -456,3 +456,12 @@ impl Default for ChannelConfig { | |||
LdkChannelConfig::default().into() | |||
} | |||
} | |||
|
|||
/// Custom TLV entry. | |||
pub struct TlvEntry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the protocol the TLV entry is defined with a length
https://github.com/lightning/bolts/blob/master/01-messaging.md#type-length-value-format
Whats the reason of not including it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that LDK is expecting type and value to set the tlv. I guess then the length is set by ldk when sending the message.
Maybe add a bit more info on the type and value describing the restrictions or characterizes of the props:
for example, for type:
type identifiers below 2^16 are reserved for use in this specification. type identifiers greater than or equal to 2^16 are available for custom records.
(from the blip)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the protocol the TLV entry is defined with a length https://github.com/lightning/bolts/blob/master/01-messaging.md#type-length-value-format
Whats the reason of not including it here?
The length of the data buffer is used for that. I shall see if we can improve the representation, though
@@ -490,8 +490,11 @@ pub(crate) fn do_channel_full_cycle<K: KVStore + Sync + Send, E: ElectrumApi>( | |||
// Test spontaneous/keysend payments | |||
println!("\nA send_spontaneous_payment"); | |||
let keysend_amount_msat = 2500_000; | |||
let keysend_payment_hash = | |||
node_a.send_spontaneous_payment(keysend_amount_msat, node_b.node_id()).unwrap(); | |||
let tlv1 = TlvEntry { r#type: 131073, value: vec![0x00, 0x11, 0x22, 0x33] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this test validate that the counter-party node received the message?
@@ -1222,7 +1222,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> { | |||
|
|||
/// Send a spontaneous, aka. "keysend", payment | |||
pub fn send_spontaneous_payment( | |||
&self, amount_msat: u64, node_id: PublicKey, | |||
&self, amount_msat: u64, node_id: PublicKey, custom_tlvs: Vec<TlvEntry>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the custom_tlvs
required in order to send a spontaneous payment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really required but may be useful. But I see the point, we'll probably take tnull's suggestion to base this change off PR 270; probably once it's merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this! While adding custom TLV support is stretching our 'keep API minimal' guidelines, I see that it can be of value for certain usecases.
I however agree with @jbesraa's question above regarding the optionality of custom TLVs. Rather than just adding it to the API method, could you base this entire PR off #270 and add it as a new SpontaneousPayment::send_with_custom_tlvs
variant to and keep the default send
method untouched?
Is there a use for this people want in the immediate future aside from the messages thing? Is the podcast streaming sats thing using the messages field or are there other fields it uses? |
Yes, the main usecase is Podcasting 2.0: https://github.com/lightning/blips/blob/master/blip-0010.md |
Ah, damn, that uses a different TLV than other messages, okay, fair enough, hard to capture that in a single API that isn't full-blown custom TLVs 😭 |
should the |
A very simple implementation of custom TLV records for keysend requests.