Skip to content

Commit 7fb16ea

Browse files
Pass full message context into ChanMan blinded path util.
Allows us to repurpose this util to create blinded paths in an async payments message context while maintaining support for the offers context.
1 parent c3ed4a2 commit 7fb16ea

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9131,7 +9131,9 @@ where
91319131
let invoice_request = builder.build_and_sign()?;
91329132

91339133
let hmac = payment_id.hmac_for_offer_payment(nonce, expanded_key);
9134-
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) };
9134+
let context = MessageContext::Offers(
9135+
OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }
9136+
);
91359137
let reply_paths = self.create_blinded_paths(context)
91369138
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
91379139

@@ -9251,9 +9253,9 @@ where
92519253

92529254
let nonce = Nonce::from_entropy_source(entropy);
92539255
let hmac = payment_hash.hmac_for_offer_payment(nonce, expanded_key);
9254-
let context = OffersContext::InboundPayment {
9256+
let context = MessageContext::Offers(OffersContext::InboundPayment {
92559257
payment_hash: invoice.payment_hash(), nonce, hmac
9256-
};
9258+
});
92579259
let reply_paths = self.create_blinded_paths(context)
92589260
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
92599261

@@ -9401,7 +9403,7 @@ where
94019403
if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
94029404
self.create_compact_blinded_paths(context)
94039405
} else {
9404-
self.create_blinded_paths(context)
9406+
self.create_blinded_paths(MessageContext::Offers(context))
94059407
}
94069408
}
94079409

@@ -9422,7 +9424,7 @@ where
94229424
/// [`MessageRouter::create_blinded_paths`].
94239425
///
94249426
/// Errors if the `MessageRouter` errors.
9425-
fn create_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
9427+
fn create_blinded_paths(&self, context: MessageContext) -> Result<Vec<BlindedMessagePath>, ()> {
94269428
let recipient = self.get_our_node_id();
94279429
let secp_ctx = &self.secp_ctx;
94289430

@@ -9435,7 +9437,7 @@ where
94359437
.collect::<Vec<_>>();
94369438

94379439
self.router
9438-
.create_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
9440+
.create_blinded_paths(recipient, context, peers, secp_ctx)
94399441
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
94409442
}
94419443

@@ -10839,11 +10841,11 @@ where
1083910841
{
1084010842
let RetryableInvoiceRequest { invoice_request, nonce } = retryable_invoice_request;
1084110843
let hmac = payment_id.hmac_for_offer_payment(nonce, &self.inbound_payment_key);
10842-
let context = OffersContext::OutboundPayment {
10844+
let context = MessageContext::Offers(OffersContext::OutboundPayment {
1084310845
payment_id,
1084410846
nonce,
1084510847
hmac: Some(hmac)
10846-
};
10848+
});
1084710849
match self.create_blinded_paths(context) {
1084810850
Ok(reply_paths) => match self.enqueue_invoice_request(invoice_request, reply_paths) {
1084910851
Ok(_) => {}

0 commit comments

Comments
 (0)