Repository navigation
Support async payments in BOLT 12 - #1149
valentinewallace wants to merge 5 commits into
Conversation
10f0c5b to
dc6599f
Compare
|
Changed up the feature bits, required single-chain offers, and disallowed setting |
|
Added a fixup requiring the invreq to be included in the payment onion per spec meeting discussion a week ago! |
5a36154 to
5b5fd7f
Compare
Per <lightning/bolts#1149>, when paying a static invoice we need to include our original invoice request in the HTLC onion since the recipient wouldn't have received it previously. We use an experimental TLV type for this new onion payload field, since the spec is still not merged in the BOLTs.
Add a new invoice request parameter to onion_utils::build_onion_payloads. As of this commit it will always be passed in as None, to be updated in future commits. Per <lightning/bolts#1149>, when paying a static invoice we need to include our original invoice request in the HTLC onion since the recipient wouldn't have received it previously.
Add a new invoice request parameter to onion_utils::create_payment_onion. As of this commit it will always be passed in as None, to be updated in future commits. Per <lightning/bolts#1149>, when paying a static invoice we need to include our original invoice request in the HTLC onion since the recipient wouldn't have received it previously.
Add a new invoice request parameter to outbound_payments and channelmanager send-to-route internal utils. As of this commit the invreq will always be passed in as None, to be updated in future commits. Per <lightning/bolts#1149>, when paying a static invoice we need to include our original invoice request in the HTLC onion since the recipient wouldn't have received it previously.
When transitioning outbound payments from AwaitingInvoice to StaticInvoiceReceived, include the invreq in the new state's outbound payment storage for future inclusion in an async payment onion. Per <lightning/bolts#1149>, when paying a static invoice we need to include our original invoice request in the HTLC onion since the recipient wouldn't have received it previously.
70 is taken by lightning#1149 Signed-off-by: Rusty Russell <[email protected]>
This is an incredibly simple first start towards the protocol sketched out at [1]. It adds the ability to have a counteraprty hold an HTLC before forwarding it. Specifically, the HTLC sender sets a required TLV on the `update_add_htlc` message and sends an onion message to the final recipient. From there, the final recipient uses the included `reply_path` to notify the sender's counterparty that they're online and ready to receive the HTLC. In order to fully flesh out the protocol as sketched, we'll need to add an onion message mailbox service (which should be as simple as a new feature bit), add PTLCs, and extensions to BOLT 12 to allow signaling that the final recipient is often-offline. While we could add such signaling to BOLT 11, there's not a whole lot of reason to - if the recipient is able to provide an invoice, they're currently online! [1] https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-October/003307.html
This builds on prior commits by adding the ability to fetch an invoice from an always-online node on behalf of an often-offline recipient, e.g. a mobile node. The idea is that often-offline recipients will supply some always-online node such as their wallet vendor with a static (i.e. `payment_hash`-less) invoice to return on its behalf. The recipient will then publish an offer containing blinded paths that terminate at this always-online node, who payers can request the invoice from if the recipient is offline at the time. After receiving the static invoice, payers will commence the protocol outlined in [1] to send the HTLC asynchronously. [1]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-October/003307.html
This field may be useful for often-offline recipients who did not receive the invreq when it was originally sent, due to another node providing a static invoice on their behalf. Recipients may want to verify the invreq or be provided some other relevant data about the payment while remaining stateless until an HTLC is actually received.
An always-online node forwards invoice_requests it receives on behalf of an often-offline payee over a blinded path the payee provided. That path may lead back to one of the always-online node's own offer paths, in which case the invoice_request would be forwarded in an endless loop. Add an odd onionmsg_tlv field marking messages sent on behalf of another node, and have always-online nodes ignore marked invoice_requests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
42813d8 to
5829083
Compare
When we send an onion message with `MessageSendInstructions::ForwardedMessage` we are sending a payload field and reply path on behalf of another node, over a destination path chosen by that node and opaque to us. Per the new `forwarded_message` TLV in BOLT 4's `onionmsg_tlv`, mark the final hop's payload of such messages so that we can recognize them should the destination path lead back to us. The TLV is parsed into the received payload; in forwarding and dummy layers it keeps being rejected like any other control TLV below 64. @Val asked: > Understood. It's pretty trivial to fix anyway, I believe, though we'll > need to update the async payments spec with the marker. I updated the > spec PR > lightning/bolts#1149 > > @auto-pr-bot please open a PR to fix this issue. Use the linked spec > PR above, the latest commit, to guide the change. Requested-by: @Val Authored-By: matt/GLM-5.3-Flash-GGUF:Q4_K_XL <[email protected]>
A static invoice server forwards every invoice request it receives for an async recipient over a blinded path that the recipient chose when it registered its static invoice. That path is opaque to us, and a malicious recipient can register one that terminates at one of our own `StaticInvoiceRequested` offer paths (rewriting the short channel id-based introduction node to a node id, if need be): the forwarded request then arrives back at us looking like a fresh one, is served and forwarded again, and circulates until the offer paths expire or the link to the next hop goes down, all without further traffic from the attacker. Since the path cannot be validated when registered, break the loop where the forward returns: an offers message carrying the `forwarded_message` marker that arrives on one of our static invoice request paths is our own forward coming back, and is now ignored before any event is raised. Payers never set the marker, and requests arriving on a recipient's own `OffersContext::InvoiceRequest` paths are unaffected. The new regression test loops a forwarded invoice request back through the recipient, as the attacker would, and checks it is dropped while the static invoice still reaches the payer. @Val asked: > Understood. It's pretty trivial to fix anyway, I believe, though we'll > need to update the async payments spec with the marker. I updated the > spec PR > lightning/bolts#1149 > > @auto-pr-bot please open a PR to fix this issue. Use the linked spec > PR above, the latest commit, to guide the change. Requested-by: @Val Authored-By: matt/GLM-5.3-Flash-GGUF:Q4_K_XL <[email protected]>
When we send an onion message with `MessageSendInstructions::ForwardedMessage` we are sending a payload field and reply path on behalf of another node, over a destination path chosen by that node and opaque to us. Per the new `forwarded_message` TLV in BOLT 4's `onionmsg_tlv`, mark the final hop's payload of such messages so that we can recognize them should the destination path lead back to us. The TLV is parsed into the received payload; in forwarding and dummy layers it keeps being rejected like any other control TLV below 64. @Val asked: > Understood. It's pretty trivial to fix anyway, I believe, though we'll > need to update the async payments spec with the marker. I updated the > spec PR > lightning/bolts#1149 > > @auto-pr-bot please open a PR to fix this issue. Use the linked spec > PR above, the latest commit, to guide the change. Requested-by: @Val Authored-By: matt/GLM-5.3-Flash-GGUF:Q4_K_XL <[email protected]> Conflicts resolved in: * lightning/src/onion_message/messenger.rs * lightning/src/onion_message/packet.rs Backport of 68176d1
A static invoice server forwards every invoice request it receives for an async recipient over a blinded path that the recipient chose when it registered its static invoice. That path is opaque to us, and a malicious recipient can register one that terminates at one of our own `StaticInvoiceRequested` offer paths (rewriting the short channel id-based introduction node to a node id, if need be): the forwarded request then arrives back at us looking like a fresh one, is served and forwarded again, and circulates until the offer paths expire or the link to the next hop goes down, all without further traffic from the attacker. Since the path cannot be validated when registered, break the loop where the forward returns: an offers message carrying the `forwarded_message` marker that arrives on one of our static invoice request paths is our own forward coming back, and is now ignored before any event is raised. Payers never set the marker, and requests arriving on a recipient's own `OffersContext::InvoiceRequest` paths are unaffected. The new regression test loops a forwarded invoice request back through the recipient, as the attacker would, and checks it is dropped while the static invoice still reaches the payer. @Val asked: > Understood. It's pretty trivial to fix anyway, I believe, though we'll > need to update the async payments spec with the marker. I updated the > spec PR > lightning/bolts#1149 > > @auto-pr-bot please open a PR to fix this issue. Use the linked spec > PR above, the latest commit, to guide the change. Requested-by: @Val Authored-By: matt/GLM-5.3-Flash-GGUF:Q4_K_XL <[email protected]> Conflicts resolved in: * lightning/src/ln/async_payments_tests.rs Backport of a1c90f2
|
I've created a related proposal that I think you should check out. It requires no pre-payment invoice fetch, no changes to the final hop TLV allow list, and more... lightning/blips#76 |
This builds on #989 by adding the ability to fetch an invoice from an
always-online node on behalf of an often-offline recipient, e.g. a mobile node.
The idea is that often-offline recipients will supply some always-online node
such as their wallet vendor with a static keysend (i.e.
payment_hash-less)invoice to return on its behalf. The recipient will then publish an offer
containing blinded paths that terminate at this always-online node, who payers
can request the invoice from if the recipient is offline at the time. After
receiving the keysend invoice, payers will commence the protocol outlined in
1 to send the HTLC asynchronously.
Some context on the commit where we include the invoice request in the payment onion:
This definitely warrants discussion, but the idea is that this field may be useful for often-offline recipients who did not receive the invoice request when it was originally sent. Recipients may want to verify the invreq or be provided some other relevant data about the payment, while keeping the payment stateless until an HTLC is actually received. For example, future extensions have been proposed 2 that require the recipient to know a unique token for a payment, and this field would provide that to them.
Based on
#798and #989.