@@ -31,7 +31,7 @@ use bitcoin::secp256k1::{SecretKey,PublicKey};
31
31
use bitcoin::secp256k1::Secp256k1;
32
32
use bitcoin::{secp256k1, Sequence};
33
33
34
- use crate::blinded_path::message::OffersContext;
34
+ use crate::blinded_path::message::{MessageContext, OffersContext} ;
35
35
use crate::blinded_path::{BlindedPath, NodeIdLookUp};
36
36
use crate::blinded_path::message::ForwardNode;
37
37
use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, PaymentConstraints, PaymentContext, ReceiveTlvs};
@@ -8377,7 +8377,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
8377
8377
let entropy = &*$self.entropy_source;
8378
8378
let secp_ctx = &$self.secp_ctx;
8379
8379
8380
- let path = $self.create_blinded_path_using_absolute_expiry(absolute_expiry)
8380
+ let path = $self.create_blinded_path_using_absolute_expiry(OffersContext::Unknown {}, absolute_expiry)
8381
8381
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8382
8382
let builder = OfferBuilder::deriving_signing_pubkey(
8383
8383
node_id, expanded_key, entropy, secp_ctx
@@ -8449,7 +8449,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
8449
8449
let entropy = &*$self.entropy_source;
8450
8450
let secp_ctx = &$self.secp_ctx;
8451
8451
8452
- let path = $self.create_blinded_path_using_absolute_expiry(Some(absolute_expiry))
8452
+ let context = OffersContext::OutboundPayment { payment_id };
8453
+ let path = $self.create_blinded_path_using_absolute_expiry(context, Some(absolute_expiry))
8453
8454
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8454
8455
let builder = RefundBuilder::deriving_payer_id(
8455
8456
node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
@@ -8572,7 +8573,9 @@ where
8572
8573
Some(payer_note) => builder.payer_note(payer_note),
8573
8574
};
8574
8575
let invoice_request = builder.build_and_sign()?;
8575
- let reply_path = self.create_blinded_path().map_err(|_| Bolt12SemanticError::MissingPaths)?;
8576
+
8577
+ let context = OffersContext::OutboundPayment { payment_id };
8578
+ let reply_path = self.create_blinded_path(context).map_err(|_| Bolt12SemanticError::MissingPaths)?;
8576
8579
8577
8580
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
8578
8581
@@ -8672,7 +8675,7 @@ where
8672
8675
)?;
8673
8676
let builder: InvoiceBuilder<DerivedSigningPubkey> = builder.into();
8674
8677
let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
8675
- let reply_path = self.create_blinded_path()
8678
+ let reply_path = self.create_blinded_path(OffersContext::Unknown {} )
8676
8679
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8677
8680
8678
8681
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
@@ -8805,15 +8808,15 @@ where
8805
8808
/// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
8806
8809
/// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
8807
8810
fn create_blinded_path_using_absolute_expiry(
8808
- &self, absolute_expiry: Option<Duration>
8811
+ &self, context: OffersContext, absolute_expiry: Option<Duration>,
8809
8812
) -> Result<BlindedPath, ()> {
8810
8813
let now = self.duration_since_epoch();
8811
8814
let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
8812
8815
8813
8816
if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
8814
- self.create_compact_blinded_path()
8817
+ self.create_compact_blinded_path(context )
8815
8818
} else {
8816
- self.create_blinded_path()
8819
+ self.create_blinded_path(context )
8817
8820
}
8818
8821
}
8819
8822
@@ -8833,7 +8836,7 @@ where
8833
8836
/// Creates a blinded path by delegating to [`MessageRouter::create_blinded_paths`].
8834
8837
///
8835
8838
/// Errors if the `MessageRouter` errors or returns an empty `Vec`.
8836
- fn create_blinded_path(&self) -> Result<BlindedPath, ()> {
8839
+ fn create_blinded_path(&self, context: OffersContext ) -> Result<BlindedPath, ()> {
8837
8840
let recipient = self.get_our_node_id();
8838
8841
let secp_ctx = &self.secp_ctx;
8839
8842
@@ -8846,14 +8849,14 @@ where
8846
8849
.collect::<Vec<_>>();
8847
8850
8848
8851
self.router
8849
- .create_blinded_paths(recipient, peers, secp_ctx)
8852
+ .create_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
8850
8853
.and_then(|paths| paths.into_iter().next().ok_or(()))
8851
8854
}
8852
8855
8853
8856
/// Creates a blinded path by delegating to [`MessageRouter::create_compact_blinded_paths`].
8854
8857
///
8855
8858
/// Errors if the `MessageRouter` errors or returns an empty `Vec`.
8856
- fn create_compact_blinded_path(&self) -> Result<BlindedPath, ()> {
8859
+ fn create_compact_blinded_path(&self, context: OffersContext ) -> Result<BlindedPath, ()> {
8857
8860
let recipient = self.get_our_node_id();
8858
8861
let secp_ctx = &self.secp_ctx;
8859
8862
@@ -8873,7 +8876,7 @@ where
8873
8876
.collect::<Vec<_>>();
8874
8877
8875
8878
self.router
8876
- .create_compact_blinded_paths(recipient, peers, secp_ctx)
8879
+ .create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
8877
8880
.and_then(|paths| paths.into_iter().next().ok_or(()))
8878
8881
}
8879
8882
0 commit comments