Skip to content

Commit f46a3ff

Browse files
committed
Forward invoice requests to async recipient
As a static invoice server, if we receive an invoice request on behalf of an often-offline recipient we will reply to the sender with the static invoice previously provided by the async recipient. Here, in addition to doing that we'll forward the invoice request received to the async recipient to give it a chance to reply with a fresh invoice in case it is online.
1 parent d810708 commit f46a3ff

File tree

5 files changed

+559
-65
lines changed

5 files changed

+559
-65
lines changed

lightning/src/events/mod.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub mod bump_transaction;
1818

1919
pub use bump_transaction::BumpTransactionEvent;
2020

21-
use crate::blinded_path::message::OffersContext;
21+
use crate::blinded_path::message::{BlindedMessagePath, OffersContext};
2222
use crate::blinded_path::payment::{
2323
Bolt12OfferContext, Bolt12RefundContext, PaymentContext, PaymentContextRef,
2424
};
@@ -28,6 +28,7 @@ use crate::ln::channelmanager::{InterceptId, PaymentId, RecipientOnionFields};
2828
use crate::ln::types::ChannelId;
2929
use crate::ln::{msgs, LocalHTLCFailureReason};
3030
use crate::offers::invoice::Bolt12Invoice;
31+
use crate::offers::invoice_request::InvoiceRequest;
3132
use crate::offers::static_invoice::StaticInvoice;
3233
use crate::onion_message::messenger::Responder;
3334
use crate::routing::gossip::NetworkUpdate;
@@ -1654,6 +1655,13 @@ pub enum Event {
16541655
/// The invoice that should be persisted and later provided to payers when handling a future
16551656
/// [`Event::StaticInvoiceRequested`].
16561657
invoice: StaticInvoice,
1658+
/// The path to where invoice requests will be forwarded. If we receive an invoice
1659+
/// request, we'll forward it to the async recipient over this path in case the
1660+
/// recipient is online to provide a new invoice. This path should be persisted and
1661+
/// later provided to [`ChannelManager::respond_to_static_invoice_request`].
1662+
///
1663+
/// [`ChannelManager::respond_to_static_invoice_request`]: crate::ln::channelmanager::ChannelManager::respond_to_static_invoice_request
1664+
invoice_request_path: BlindedMessagePath,
16571665
/// Useful for the recipient to replace a specific invoice stored by us as the static invoice
16581666
/// server.
16591667
///
@@ -1686,12 +1694,14 @@ pub enum Event {
16861694
///
16871695
/// If we previously persisted a [`StaticInvoice`] from an [`Event::PersistStaticInvoice`] that
16881696
/// matches the below `recipient_id` and `invoice_slot`, that invoice should be retrieved now
1689-
/// and forwarded to the payer via [`ChannelManager::send_static_invoice`].
1697+
/// and forwarded to the payer via [`ChannelManager::respond_to_static_invoice_request`].
1698+
/// The invoice request path previously persisted from [`Event::PersistStaticInvoice`] should
1699+
/// also be provided in [`ChannelManager::respond_to_static_invoice_request`].
16901700
///
16911701
/// [`ChannelManager::blinded_paths_for_async_recipient`]: crate::ln::channelmanager::ChannelManager::blinded_paths_for_async_recipient
16921702
/// [`ChannelManager::set_paths_to_static_invoice_server`]: crate::ln::channelmanager::ChannelManager::set_paths_to_static_invoice_server
16931703
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
1694-
/// [`ChannelManager::send_static_invoice`]: crate::ln::channelmanager::ChannelManager::send_static_invoice
1704+
/// [`ChannelManager::respond_to_static_invoice_request`]: crate::ln::channelmanager::ChannelManager::respond_to_static_invoice_request
16951705
StaticInvoiceRequested {
16961706
/// An identifier for the recipient previously surfaced in
16971707
/// [`Event::PersistStaticInvoice::recipient_id`]. Useful when paired with the `invoice_slot` to
@@ -1702,10 +1712,16 @@ pub enum Event {
17021712
/// retrieve the [`StaticInvoice`] requested by the payer.
17031713
invoice_slot: u16,
17041714
/// The path over which the [`StaticInvoice`] will be sent to the payer, which should be
1705-
/// provided to [`ChannelManager::send_static_invoice`] along with the invoice.
1715+
/// provided to [`ChannelManager::respond_to_static_invoice_request`] along with the invoice.
17061716
///
1707-
/// [`ChannelManager::send_static_invoice`]: crate::ln::channelmanager::ChannelManager::send_static_invoice
1717+
/// [`ChannelManager::respond_to_static_invoice_request`]: crate::ln::channelmanager::ChannelManager::respond_to_static_invoice_request
17081718
reply_path: Responder,
1719+
/// The invoice request that will be forwarded to the async recipient to give the
1720+
/// recipient a chance to provide an invoice in case it is online. It should be
1721+
/// provided to [`ChannelManager::respond_to_static_invoice_request`].
1722+
///
1723+
/// [`ChannelManager::respond_to_static_invoice_request`]: crate::ln::channelmanager::ChannelManager::respond_to_static_invoice_request
1724+
invoice_request: InvoiceRequest,
17091725
},
17101726
/// Indicates that a channel funding transaction constructed interactively is ready to be
17111727
/// signed. This event will only be triggered if at least one input was contributed.

0 commit comments

Comments
 (0)