Skip to content

Commit 9b1e056

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 bf1d03b commit 9b1e056

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
@@ -63,7 +63,7 @@ use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutb
6363
use crate::ln::wire::Encode;
6464
use crate::offers::invoice::{BlindedPayInfo, Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, ExplicitSigningPubkey, InvoiceBuilder, UnsignedBolt12Invoice};
6565
use crate::offers::invoice_error::InvoiceError;
66-
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequestBuilder};
66+
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequest, InvoiceRequestBuilder};
6767
use crate::offers::nonce::Nonce;
6868
use crate::offers::offer::{Offer, OfferBuilder};
6969
use crate::offers::parse::Bolt12SemanticError;
@@ -9030,11 +9030,19 @@ where
90309030
)
90319031
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
90329032

9033+
self.enqueue_invoice_request(invoice_request, reply_paths)
9034+
}
9035+
9036+
fn enqueue_invoice_request(
9037+
&self,
9038+
invoice_request: InvoiceRequest,
9039+
reply_paths: Vec<BlindedPath>,
9040+
) -> Result<(), Bolt12SemanticError> {
90339041
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
9034-
if !offer.paths().is_empty() {
9042+
if !invoice_request.paths().is_empty() {
90359043
reply_paths
90369044
.iter()
9037-
.flat_map(|reply_path| offer.paths().iter().map(move |path| (path, reply_path)))
9045+
.flat_map(|reply_path| invoice_request.paths().iter().map(move |path| (path, reply_path)))
90389046
.take(OFFERS_MESSAGE_REQUEST_LIMIT)
90399047
.for_each(|(path, reply_path)| {
90409048
let message = new_pending_onion_message(
@@ -9044,7 +9052,7 @@ where
90449052
);
90459053
pending_offers_messages.push(message);
90469054
});
9047-
} else if let Some(signing_pubkey) = offer.signing_pubkey() {
9055+
} else if let Some(signing_pubkey) = invoice_request.signing_pubkey() {
90489056
for reply_path in reply_paths {
90499057
let message = new_pending_onion_message(
90509058
OffersMessage::InvoiceRequest(invoice_request.clone()),

0 commit comments

Comments
 (0)