@@ -2625,9 +2625,7 @@ const MAX_NO_CHANNEL_PEERS: usize = 250;
2625
2625
/// short-lived, while anything with a greater expiration is considered long-lived.
2626
2626
///
2627
2627
/// Using [`ChannelManager::create_offer_builder`] or [`ChannelManager::create_refund_builder`],
2628
- /// will included a [`BlindedMessagePath`] created using:
2629
- /// - [`MessageRouter::create_compact_blinded_paths`] when short-lived, and
2630
- /// - [`MessageRouter::create_blinded_paths`] when long-lived.
2628
+ /// will included a [`BlindedMessagePath`] created using [`MessageRouter::create_blinded_paths`].
2631
2629
///
2632
2630
/// Using compact [`BlindedMessagePath`]s may provide better privacy as the [`MessageRouter`] could select
2633
2631
/// more hops. However, since they use short channel ids instead of pubkeys, they are more likely to
@@ -4453,7 +4451,7 @@ where
4453
4451
let reply_paths = match self.create_blinded_paths(
4454
4452
MessageContext::AsyncPayments(
4455
4453
AsyncPaymentsContext::OutboundPayment { payment_id, nonce, hmac }
4456
- )
4454
+ ), BlindedPathType::Full
4457
4455
) {
4458
4456
Ok(paths) => paths,
4459
4457
Err(()) => {
@@ -9123,23 +9121,13 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
9123
9121
let secp_ctx = &$self.secp_ctx;
9124
9122
9125
9123
let nonce = Nonce::from_entropy_source(entropy);
9126
- let context = OffersContext::InvoiceRequest { nonce };
9124
+ let context = MessageContext::Offers (
9125
+ OffersContext::InvoiceRequest { nonce }
9126
+ );
9127
9127
let builder = match blinded_path {
9128
- Some(BlindedPathType::Compact) => {
9129
- let path = $self
9130
- .create_compact_blinded_paths(context)
9131
- .and_then(|paths| paths.into_iter().next().ok_or(()))
9132
- .map_err(|_| Bolt12SemanticError::MissingPaths)?;
9133
-
9134
- OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
9135
- .chain_hash($self.chain_hash)
9136
- .path(path)
9137
- }
9138
-
9139
- Some(BlindedPathType::Full) => {
9140
- let context = MessageContext::Offers(context);
9128
+ Some(blinded_path) => {
9141
9129
let path = $self
9142
- .create_blinded_paths(context)
9130
+ .create_blinded_paths(context, blinded_path )
9143
9131
.and_then(|paths| paths.into_iter().next().ok_or(()))
9144
9132
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
9145
9133
@@ -9212,28 +9200,14 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
9212
9200
let secp_ctx = &$self.secp_ctx;
9213
9201
9214
9202
let nonce = Nonce::from_entropy_source(entropy);
9215
- let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None };
9203
+ let context = MessageContext::Offers (
9204
+ OffersContext::OutboundPayment { payment_id, nonce, hmac: None }
9205
+ );
9216
9206
9217
9207
let builder = match blinded_path {
9218
- Some(BlindedPathType::Compact ) => {
9208
+ Some(blinded_path ) => {
9219
9209
let path = $self
9220
- .create_compact_blinded_paths(context)
9221
- .and_then(|paths| paths.into_iter().next().ok_or(()))
9222
- .map_err(|_| Bolt12SemanticError::MissingPaths)?;
9223
-
9224
- RefundBuilder::deriving_signing_pubkey(
9225
- node_id, expanded_key, nonce, secp_ctx,
9226
- amount_msats, payment_id,
9227
- )?
9228
- .chain_hash($self.chain_hash)
9229
- .absolute_expiry(absolute_expiry)
9230
- .path(path)
9231
- }
9232
-
9233
- Some(BlindedPathType::Full) => {
9234
- let context = MessageContext::Offers(context);
9235
- let path = $self
9236
- .create_blinded_paths(context)
9210
+ .create_blinded_paths(context, blinded_path)
9237
9211
.and_then(|paths| paths.into_iter().next().ok_or(()))
9238
9212
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
9239
9213
@@ -9383,7 +9357,7 @@ where
9383
9357
let context = MessageContext::Offers(
9384
9358
OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }
9385
9359
);
9386
- let reply_paths = self.create_blinded_paths(context)
9360
+ let reply_paths = self.create_blinded_paths(context, BlindedPathType::Full )
9387
9361
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
9388
9362
9389
9363
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
@@ -9505,7 +9479,7 @@ where
9505
9479
let context = MessageContext::Offers(OffersContext::InboundPayment {
9506
9480
payment_hash: invoice.payment_hash(), nonce, hmac
9507
9481
});
9508
- let reply_paths = self.create_blinded_paths(context)
9482
+ let reply_paths = self.create_blinded_paths(context, BlindedPathType::Full )
9509
9483
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
9510
9484
9511
9485
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
@@ -9655,7 +9629,7 @@ where
9655
9629
/// [`MessageRouter::create_blinded_paths`].
9656
9630
///
9657
9631
/// Errors if the `MessageRouter` errors.
9658
- fn create_blinded_paths(&self, context: MessageContext) -> Result<Vec<BlindedMessagePath>, ()> {
9632
+ fn create_blinded_paths(&self, context: MessageContext, blinded_path: BlindedPathType ) -> Result<Vec<BlindedMessagePath>, ()> {
9659
9633
let recipient = self.get_our_node_id();
9660
9634
let secp_ctx = &self.secp_ctx;
9661
9635
@@ -9664,44 +9638,30 @@ where
9664
9638
.map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
9665
9639
.filter(|(_, peer)| peer.is_connected)
9666
9640
.filter(|(_, peer)| peer.latest_features.supports_onion_messages())
9667
- .map(|(node_id, _)| {
9668
- MessageForwardNode {
9669
- node_id: *node_id,
9670
- short_channel_id: None,
9641
+ .map(|(node_id, peer)| {
9642
+ match blinded_path {
9643
+ BlindedPathType::Full => {
9644
+ MessageForwardNode {
9645
+ node_id: *node_id,
9646
+ short_channel_id: None,
9647
+ }
9648
+ }
9649
+ BlindedPathType::Compact => {
9650
+ MessageForwardNode {
9651
+ node_id: *node_id,
9652
+ short_channel_id: peer.channel_by_id
9653
+ .iter()
9654
+ .filter(|(_, channel)| channel.context().is_usable())
9655
+ .min_by_key(|(_, channel)| channel.context().channel_creation_height)
9656
+ .and_then(|(_, channel)| channel.context().get_short_channel_id()),
9657
+ }
9658
+ }
9671
9659
}
9672
9660
})
9673
9661
.collect::<Vec<_>>();
9674
9662
9675
9663
self.message_router
9676
- .create_blinded_paths(recipient, context, peers, secp_ctx)
9677
- .and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
9678
- }
9679
-
9680
- /// Creates a collection of blinded paths by delegating to
9681
- /// [`MessageRouter::create_compact_blinded_paths`].
9682
- ///
9683
- /// Errors if the `MessageRouter` errors.
9684
- fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
9685
- let recipient = self.get_our_node_id();
9686
- let secp_ctx = &self.secp_ctx;
9687
-
9688
- let peers = self.per_peer_state.read().unwrap()
9689
- .iter()
9690
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
9691
- .filter(|(_, peer)| peer.is_connected)
9692
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
9693
- .map(|(node_id, peer)| MessageForwardNode {
9694
- node_id: *node_id,
9695
- short_channel_id: peer.channel_by_id
9696
- .iter()
9697
- .filter(|(_, channel)| channel.context().is_usable())
9698
- .min_by_key(|(_, channel)| channel.context().channel_creation_height)
9699
- .and_then(|(_, channel)| channel.context().get_short_channel_id()),
9700
- })
9701
- .collect::<Vec<_>>();
9702
-
9703
- self.message_router
9704
- .create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
9664
+ .create_blinded_paths(recipient, context, blinded_path, peers, secp_ctx)
9705
9665
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
9706
9666
}
9707
9667
@@ -11088,7 +11048,7 @@ where
11088
11048
nonce,
11089
11049
hmac: Some(hmac)
11090
11050
});
11091
- match self.create_blinded_paths(context) {
11051
+ match self.create_blinded_paths(context, BlindedPathType::Full ) {
11092
11052
Ok(reply_paths) => match self.enqueue_invoice_request(invoice_request, reply_paths) {
11093
11053
Ok(_) => {}
11094
11054
Err(_) => {
0 commit comments