@@ -8584,12 +8584,14 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
8584
8584
let entropy = &*$self.entropy_source;
8585
8585
let secp_ctx = &$self.secp_ctx;
8586
8586
8587
- let path = $self.create_blinded_path().map_err(|_| Bolt12SemanticError::MissingPaths)?;
8587
+ let paths = $self.create_blinded_path(5)
8588
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8589
+
8588
8590
let builder = OfferBuilder::deriving_signing_pubkey(
8589
8591
node_id, expanded_key, entropy, secp_ctx
8590
8592
)
8591
8593
.chain_hash($self.chain_hash)
8592
- .path(path );
8594
+ .path(paths );
8593
8595
8594
8596
Ok(builder.into())
8595
8597
}
@@ -8651,13 +8653,15 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
8651
8653
let entropy = &*$self.entropy_source;
8652
8654
let secp_ctx = &$self.secp_ctx;
8653
8655
8654
- let path = $self.create_blinded_path().map_err(|_| Bolt12SemanticError::MissingPaths)?;
8656
+ let paths = $self.create_blinded_path(5)
8657
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8658
+
8655
8659
let builder = RefundBuilder::deriving_payer_id(
8656
8660
node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
8657
8661
)?
8658
8662
.chain_hash($self.chain_hash)
8659
8663
.absolute_expiry(absolute_expiry)
8660
- .path(path );
8664
+ .path(paths );
8661
8665
8662
8666
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);
8663
8667
@@ -8774,7 +8778,8 @@ where
8774
8778
Some(payer_note) => builder.payer_note(payer_note),
8775
8779
};
8776
8780
let invoice_request = builder.build_and_sign()?;
8777
- let reply_path = self.create_blinded_path().map_err(|_| Bolt12SemanticError::MissingPaths)?;
8781
+ let reply_paths = self.create_blinded_path(5)
8782
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8778
8783
8779
8784
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
8780
8785
@@ -8792,20 +8797,24 @@ where
8792
8797
// one invoice for a given payment id will be paid, even if more than one is received.
8793
8798
const REQUEST_LIMIT: usize = 10;
8794
8799
for path in offer.paths().into_iter().take(REQUEST_LIMIT) {
8800
+ for reply_path in reply_paths.clone() {
8801
+ let message = new_pending_onion_message(
8802
+ OffersMessage::InvoiceRequest(invoice_request.clone()),
8803
+ Destination::BlindedPath(path.clone()),
8804
+ Some(reply_path.clone()),
8805
+ );
8806
+ pending_offers_messages.push(message);
8807
+ }
8808
+ }
8809
+ } else if let Some(signing_pubkey) = offer.signing_pubkey() {
8810
+ for reply_path in reply_paths {
8795
8811
let message = new_pending_onion_message(
8796
8812
OffersMessage::InvoiceRequest(invoice_request.clone()),
8797
- Destination::BlindedPath(path.clone() ),
8798
- Some(reply_path.clone() ),
8813
+ Destination::Node(signing_pubkey ),
8814
+ Some(reply_path),
8799
8815
);
8800
8816
pending_offers_messages.push(message);
8801
8817
}
8802
- } else if let Some(signing_pubkey) = offer.signing_pubkey() {
8803
- let message = new_pending_onion_message(
8804
- OffersMessage::InvoiceRequest(invoice_request),
8805
- Destination::Node(signing_pubkey),
8806
- Some(reply_path),
8807
- );
8808
- pending_offers_messages.push(message);
8809
8818
} else {
8810
8819
debug_assert!(false);
8811
8820
return Err(Bolt12SemanticError::MissingSigningPubkey);
@@ -8874,26 +8883,30 @@ where
8874
8883
)?;
8875
8884
let builder: InvoiceBuilder<DerivedSigningPubkey> = builder.into();
8876
8885
let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
8877
- let reply_path = self.create_blinded_path()
8886
+ let reply_paths = self.create_blinded_path(5 )
8878
8887
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8879
8888
8880
8889
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
8881
8890
if refund.paths().is_empty() {
8882
- let message = new_pending_onion_message(
8883
- OffersMessage::Invoice(invoice.clone()),
8884
- Destination::Node(refund.payer_id()),
8885
- Some(reply_path),
8886
- );
8887
- pending_offers_messages.push(message);
8888
- } else {
8889
- for path in refund.paths() {
8891
+ for reply_path in reply_paths {
8890
8892
let message = new_pending_onion_message(
8891
8893
OffersMessage::Invoice(invoice.clone()),
8892
- Destination::BlindedPath(path.clone ()),
8893
- Some(reply_path.clone() ),
8894
+ Destination::Node(refund.payer_id ()),
8895
+ Some(reply_path),
8894
8896
);
8895
8897
pending_offers_messages.push(message);
8896
8898
}
8899
+ } else {
8900
+ for path in refund.paths() {
8901
+ for reply_path in reply_paths.clone() {
8902
+ let message = new_pending_onion_message(
8903
+ OffersMessage::Invoice(invoice.clone()),
8904
+ Destination::BlindedPath(path.clone()),
8905
+ Some(reply_path.clone()),
8906
+ );
8907
+ pending_offers_messages.push(message);
8908
+ }
8909
+ }
8897
8910
}
8898
8911
8899
8912
Ok(invoice)
@@ -9003,7 +9016,7 @@ where
9003
9016
/// Creates a blinded path by delegating to [`MessageRouter::create_blinded_paths`].
9004
9017
///
9005
9018
/// Errors if the `MessageRouter` errors or returns an empty `Vec`.
9006
- fn create_blinded_path(&self) -> Result<BlindedPath, ()> {
9019
+ fn create_blinded_path(&self, count: usize ) -> Result<Vec< BlindedPath> , ()> {
9007
9020
let recipient = self.get_our_node_id();
9008
9021
let secp_ctx = &self.secp_ctx;
9009
9022
@@ -9022,8 +9035,7 @@ where
9022
9035
.collect::<Vec<_>>();
9023
9036
9024
9037
self.router
9025
- .create_blinded_paths(recipient, peers, secp_ctx)
9026
- .and_then(|paths| paths.into_iter().next().ok_or(()))
9038
+ .create_blinded_paths(recipient, peers, secp_ctx, count)
9027
9039
}
9028
9040
9029
9041
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
0 commit comments