-
Notifications
You must be signed in to change notification settings - Fork 491
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
Add payment metadata to payment request (feature 48) #912
Conversation
819c657
to
ac88cce
Compare
Interestingly, this will come for free with route blinding: #765 |
ac88cce
to
a8e5fab
Compare
a8e5fab
to
7e73756
Compare
So, @joostjager pointed out that you could just use "beer" and mix with an internal secret; the metadata doesn't need to be a UUID. In general, however, this is not robust: you would not know if you have issued two such invoices simultaneously (if you did it serially, it's OK, since presumably you remember successfully-paid invoices, and could check for clashes). And, if it serves as a UUID, it also serves as a payment secret? |
I suggested to indeed use "beer" but also append the payment address before mixing with the internal secret. So this should keep invoices apart. |
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.
ACK once the pending comments are fixed.
I think we can (should?) integrate sender-side support ASAP, because it's trivial (just grab a field in the invoice, put it in the onion). Then after XXX months (when we see that senders have actually added support) we'll be able to leverage it on the recipient side.
7e73756
to
cdd3cbc
Compare
Agreed. It takes time for this change to actually land in wallet software. |
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.
Agreed, lets get payer-side support for this sooner rather than later.
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 have a draft PR ready on the eclair side if you want to do cross-compatibility tests: ACINQ/eclair#2063
04-onion-routing.md
Outdated
@@ -263,6 +263,9 @@ It is formatted according to the Type-Length-Value format defined in [BOLT #1](0 | |||
2. data: | |||
* [`32*byte`:`payment_secret`] | |||
* [`tu64`:`total_msat`] | |||
1. type: 10 (`payment_metadata`) |
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.
Route blinding already uses types 10 and 12, would it be possible to update this PR to use type 14 for payment_metadata
?
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.
Updated
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.
Actually, it looks like AMP is using 14 already. Shall we move to 16 then?
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.
What about AMP updating to another field? It's not documented that they use 14, not even in #658 AFAICT...
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.
Haha, that is not a q for me to answer 🍿
To be consequent, I think we should use 10 then?
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.
To be consequent, I think we should use 10 then?
Not quite, route blinding has documented that it uses 10 and 12 (for 6+ months) and already has two implementations' ACKs and cross-compatibility successfully tested (even before payment_metadata
, so it does take precedence). AMP has no spec and only one implementation...
Your call, you can either update to 16 here or ask lnd folks. In all cases using 14 for AMP without specifying it anywhere is reckless, it just creates a big risk that another feature will ship across multiple implementations and use 14 for something else which will be a huge pain to update. Until specified, AMP should use a TLV in the high range to avoid running into this kind of compatibility problems.
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.
Let's update to 16 so that we are unblocked.
Tagging @Roasbeef here for comment on AMP.
8e9f89b
to
41962a7
Compare
@@ -235,6 +238,9 @@ by which the description is served is as-yet unspecified and will | |||
probably be transport dependent. The `h` format could change in the future, | |||
by changing the length, so readers ignore it if it's not 256 bits. | |||
|
|||
The `m` field allows metadata to be attached to the payment. This supports | |||
applications where the recipient doesn't keep any context for the 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.
This is more a rationale for how this field could be used, but i can see other use cases as well (split PoS and recipient, ...). I'd personally prefer having these separate from the prescriptive text.
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.
But this part is already inside the rationale section, isn't it? So it should be ok? Or do you mean that you don't want something as concrete here, and would rather have a separate doc (a spark?) explain how the payment_metadata
field can be used for invoices not stored in a local DB?
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.
ACK 41962a7
@@ -216,7 +218,8 @@ A reader: | |||
- MUST use that as [`payment_secret`](04-onion-routing.md#tlv_payload-payload-format) | |||
- if the `c` field (`min_final_cltv_expiry`) is not provided: | |||
- MUST use an expiry delta of at least 18 when making the payment | |||
|
|||
- if an `m` field is provided: | |||
- MUST use that as [`payment_metadata`](04-onion-routing.md#tlv_payload-payload-format) |
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.
nit: please add an empty line between this and ### Rationale
42dc90b
to
2ab3a9f
Compare
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.
ACK 2ab3a9f
Ack 2ab3a9f |
Carried out interop test lnd->eclair, that works too. |
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.
ack 2ab3a9f
with latency, sorry :)
* Filter init, node and invoice features We should explicitly filter features based on where they can be included (`init`, `node_announcement` or `invoice`) as specified in Bolt 9. * Add support for sending `payment_metadata` Whenever we find a payment metadata field in an invoice, we send it in the onion payload for the final recipient. * Include `payment_metadata` in all invoices We include a payment metadata in every invoice we generate. This lets us see whether our payers support it or not, which is important data to have before we make it mandatory and use it for storage-less invoices. See lightning/bolts#912 for reference.
Add support for lightning/bolts#912 Whenever we find a payment metadata field in an invoice, we send it in the onion payload for the final recipient. We include a payment metadata in every invoice we generate. This lets us see whether our payers support it or not, which is important data to have before we make it mandatory and use it for storage-less invoices.
* Filter init, node and invoice features We should explicitly filter features based on where they can be included (`init`, `node_announcement` or `invoice`) as specified in Bolt 9. We also introduce the option_payment_metadata feature which helps our test cases since it's only allowed in invoices. * Refactor onion to dedicated namespace This commit doesn't contain any logic, it simply prefixes some classes to make it obvious that they are payment-related, rename files and moves some classes. We will update the payment onion, so it was a good time to do this small refactoring which will also be necessary for onion messages. * Add support for option_payment_metadata Add support for lightning/bolts#912 Whenever we find a payment metadata field in an invoice, we send it in the onion payload for the final recipient. We include a payment metadata in every invoice we generate. This lets us see whether our payers support it or not, which is important data to have before we make it mandatory and use it for storage-less invoices.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Protocol: `pay` (and decode, etc) supports bolt11 payment_metadata a-la lightning/bolts#912
@t-bast I vaguely remember that you planned to add marker metadata to all invoices generated in your systems, to be able to gauge the uptake of the payment metadata feature. Did you do that in the end, and if yes, can you share how it is going? |
This was added in eclair and phoenix, but it doesn't give us a very easy way of measuring support. Only the phoenix recipient knows whether the sender included the payment metadata and this information isn't shared with our node. Our node doesn't issue invoices so we don't have any data about that. This would be more interesting to measure at big hubs that acts as receiver nodes: Wallet of Satoshi, Muun and the likes. Those nodes are generating a lot of invoices and receiving payments and can better measure what percentage of senders do include the metadata. |
This PR adds a new field to bolt11 invoices for payment metadata. Senders are supposed to carry over this data to a tlv field to provide context for stateless invoice applications.
More background on stateless invoices: https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-September/003236.html
Please attach comments to the most appropriate line of the diff, so that discussions remain threaded and can eventually be resolved. We all know what PRs look like with too many top level comments.