Skip to content

Support async payments in BOLT 12 - #1149

Open
valentinewallace wants to merge 5 commits into
lightning:masterfrom
valentinewallace:2024-02-async-payments
Open

valentinewallace wants to merge 5 commits into
lightning:masterfrom
valentinewallace:2024-02-async-payments

Conversation

@valentinewallace

@valentinewallace valentinewallace commented Mar 19, 2024 •

Copy link
Copy Markdown
Contributor

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 #798 and #989.

@valentinewallace

Copy link
Copy Markdown
Contributor Author

Changed up the feature bits, required single-chain offers, and disallowed setting invoice_amount_msat for static invoices. Also moved away from the "keysend" language for clarity. These changes were based on implementing this in LDK in lightningdevkit/rust-lightning#3082, will take this out of draft once the design solidifies a bit more in that PR.

@t-bast t-bast mentioned this pull request Jun 17, 2024
9 of 22 tasks
@valentinewallace

Copy link
Copy Markdown
Contributor Author

Added a fixup requiring the invreq to be included in the payment onion per spec meeting discussion a week ago!

@t-bast t-bast mentioned this pull request Jun 26, 2024
16 of 23 tasks
@valentinewallace
valentinewallace force-pushed the 2024-02-async-payments branch from 5a36154 to 5b5fd7f Compare June 26, 2024 18:13
@t-bast t-bast mentioned this pull request Jul 12, 2024
13 of 22 tasks
@t-bast t-bast mentioned this pull request Jul 23, 2024
11 of 23 tasks
@t-bast t-bast mentioned this pull request Aug 9, 2024
14 of 21 tasks
@t-bast t-bast mentioned this pull request Aug 23, 2024
14 of 20 tasks
@t-bast t-bast mentioned this pull request Sep 6, 2024
8 of 20 tasks
valentinewallace added a commit to valentinewallace/rust-lightning that referenced this pull request Sep 18, 2024
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.
valentinewallace added a commit to valentinewallace/rust-lightning that referenced this pull request Sep 18, 2024
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.
valentinewallace added a commit to valentinewallace/rust-lightning that referenced this pull request Sep 18, 2024
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.
valentinewallace added a commit to valentinewallace/rust-lightning that referenced this pull request Sep 18, 2024
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.
valentinewallace added a commit to valentinewallace/rust-lightning that referenced this pull request Sep 18, 2024
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.
@t-bast t-bast mentioned this pull request Nov 19, 2025
8 of 24 tasks
@t-bast t-bast mentioned this pull request Jan 2, 2026
15 of 26 tasks
@t-bast t-bast mentioned this pull request Jan 26, 2026
11 of 25 tasks
@t-bast t-bast mentioned this pull request Feb 27, 2026
12 of 22 tasks
@t-bast t-bast mentioned this pull request Mar 23, 2026
9 of 20 tasks
@t-bast t-bast mentioned this pull request Apr 20, 2026
10 of 23 tasks
rustyrussell added a commit to rustyrussell/bolts that referenced this pull request May 28, 2026
@t-bast t-bast mentioned this pull request Jun 1, 2026
11 of 19 tasks
@t-bast t-bast mentioned this pull request Jul 16, 2026
12 of 19 tasks
@t-bast t-bast mentioned this pull request Aug 12, 2026
5 of 18 tasks
@t-bast t-bast mentioned this pull request Aug 27, 2026
15 of 22 tasks
@Roasbeef Roasbeef mentioned this pull request Oct 19, 2026
14 of 25 tasks
TheBlueMatt and others added 5 commits November 18, 2026 11:29
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]>
ldk-reviews-bot pushed a commit to lightningdevkit/rust-lightning that referenced this pull request Nov 23, 2026
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]>
ldk-reviews-bot pushed a commit to lightningdevkit/rust-lightning that referenced this pull request Nov 23, 2026
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]>
TheBlueMatt pushed a commit to TheBlueMatt/rust-lightning that referenced this pull request Nov 23, 2026
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
TheBlueMatt pushed a commit to TheBlueMatt/rust-lightning that referenced this pull request Nov 23, 2026
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
@ZZiigguurraatt

Copy link
Copy Markdown

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
https://github.com/ZZiigguurraatt/blips/blob/out_of_band_payloads/blip-0074.md

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.

4 participants