Skip to content

Commit 7218ae2

Browse files
committed
Introduce enqueue_invoice_request Function
1. Separate the logic of forming `invoice_request` messages from `invoice_request` and `reply_paths` and enqueueing them into a separate function. 2. This logic will be reused in the following commit when reforming `invoice_request` messages for retrying.
1 parent bf7a0d6 commit 7218ae2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutb
6464
use crate::ln::wire::Encode;
6565
use crate::offers::invoice::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, ExplicitSigningPubkey, InvoiceBuilder, UnsignedBolt12Invoice};
6666
use crate::offers::invoice_error::InvoiceError;
67-
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequestBuilder};
67+
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequest, InvoiceRequestBuilder};
6868
use crate::offers::nonce::Nonce;
6969
use crate::offers::offer::{Offer, OfferBuilder};
7070
use crate::offers::parse::Bolt12SemanticError;
@@ -9066,11 +9066,19 @@ where
90669066
)
90679067
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
90689068

9069+
self.enqueue_invoice_request(invoice_request, reply_paths)
9070+
}
9071+
9072+
fn enqueue_invoice_request(
9073+
&self,
9074+
invoice_request: InvoiceRequest,
9075+
reply_paths: Vec<BlindedMessagePath>,
9076+
) -> Result<(), Bolt12SemanticError> {
90699077
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
9070-
if !offer.paths().is_empty() {
9078+
if !invoice_request.paths().is_empty() {
90719079
reply_paths
90729080
.iter()
9073-
.flat_map(|reply_path| offer.paths().iter().map(move |path| (path, reply_path)))
9081+
.flat_map(|reply_path| invoice_request.paths().iter().map(move |path| (path, reply_path)))
90749082
.take(OFFERS_MESSAGE_REQUEST_LIMIT)
90759083
.for_each(|(path, reply_path)| {
90769084
let message = new_pending_onion_message(
@@ -9080,7 +9088,7 @@ where
90809088
);
90819089
pending_offers_messages.push(message);
90829090
});
9083-
} else if let Some(signing_pubkey) = offer.signing_pubkey() {
9091+
} else if let Some(signing_pubkey) = invoice_request.signing_pubkey() {
90849092
for reply_path in reply_paths {
90859093
let message = new_pending_onion_message(
90869094
OffersMessage::InvoiceRequest(invoice_request.clone()),

0 commit comments

Comments
 (0)