Skip to content

Commit 1881f35

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 17d80f9 commit 1881f35

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
@@ -65,7 +65,7 @@ use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutb
6565
use crate::ln::wire::Encode;
6666
use crate::offers::invoice::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, ExplicitSigningPubkey, InvoiceBuilder, UnsignedBolt12Invoice};
6767
use crate::offers::invoice_error::InvoiceError;
68-
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequestBuilder};
68+
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequest, InvoiceRequestBuilder};
6969
use crate::offers::nonce::Nonce;
7070
use crate::offers::offer::{Offer, OfferBuilder};
7171
use crate::offers::parse::Bolt12SemanticError;
@@ -9142,11 +9142,19 @@ where
91429142
)
91439143
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
91449144

9145+
self.enqueue_invoice_request(invoice_request, reply_paths)
9146+
}
9147+
9148+
fn enqueue_invoice_request(
9149+
&self,
9150+
invoice_request: InvoiceRequest,
9151+
reply_paths: Vec<BlindedMessagePath>,
9152+
) -> Result<(), Bolt12SemanticError> {
91459153
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
9146-
if !offer.paths().is_empty() {
9154+
if !invoice_request.paths().is_empty() {
91479155
reply_paths
91489156
.iter()
9149-
.flat_map(|reply_path| offer.paths().iter().map(move |path| (path, reply_path)))
9157+
.flat_map(|reply_path| invoice_request.paths().iter().map(move |path| (path, reply_path)))
91509158
.take(OFFERS_MESSAGE_REQUEST_LIMIT)
91519159
.for_each(|(path, reply_path)| {
91529160
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
@@ -9156,7 +9164,7 @@ where
91569164
let message = OffersMessage::InvoiceRequest(invoice_request.clone());
91579165
pending_offers_messages.push((message, instructions));
91589166
});
9159-
} else if let Some(signing_pubkey) = offer.signing_pubkey() {
9167+
} else if let Some(signing_pubkey) = invoice_request.signing_pubkey() {
91609168
for reply_path in reply_paths {
91619169
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
91629170
destination: Destination::Node(signing_pubkey),

0 commit comments

Comments
 (0)