Skip to content

Introduce Event Model for Offers Flow #3833

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
18 changes: 18 additions & 0 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12683,6 +12683,15 @@ where
Err(_) => return None,
};

let invoice_request = match self.flow.determine_invoice_request_handling(invoice_request) {
Ok(Some(ir)) => ir,
Ok(None) => return None,
Err(_) => {
log_trace!(self.logger, "Failed to handle invoice request");
return None;
}
};
Comment on lines +12728 to +12735
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... so the user may want to handle this asynchronously because they just need to verify that an amount (or supply that is) is sufficient for the offer's currency denomination. In that case, we should really have some function that continues the code below (i.e. creating a payment hash / secret, building the invoice, and enqueuing it to be sent).

Another reason is they want to supply their own payment hash. Similarly, they would need to build the invoice and enqueue it for sending. They may be even want to customize the invoice in some other ways using the builder.

I'm not quite sure how we want to do this. For the first case, it seems we should make it easy for them, which means they would need to call something on ChannelManager to continue the flow. Whereas, the second case is more about calling methods on OffersMessageFlow. But it would be weird for the former since the events' docs would need to reference ChannelManager.


let amount_msats = match InvoiceBuilder::<DerivedSigningPubkey>::amount_msats(
&invoice_request.inner, None
) {
Expand Down Expand Up @@ -12762,6 +12771,15 @@ where
&self.logger, None, None, Some(invoice.payment_hash()),
);

let invoice = match self.flow.determine_invoice_handling(invoice, payment_id) {
Ok(Some(invoice)) => invoice,
Ok(None) => return None,
Err(_) => {
log_trace!(logger, "Failed to handle invoice");
return None
},
};

if self.default_configuration.manually_handle_bolt12_invoices {
// Update the corresponding entry in `PendingOutboundPayment` for this invoice.
// This ensures that event generation remains idempotent in case we receive
Expand Down