@@ -10257,7 +10257,7 @@ where
10257
10257
R::Target: Router,
10258
10258
L::Target: Logger,
10259
10259
{
10260
- fn handle_message(&self, message: OffersMessage, responder: Option<Responder>) -> ResponseInstruction<OffersMessage> {
10260
+ fn handle_message(&self, message: OffersMessage, context: OffersContext, responder: Option<Responder>) -> ResponseInstruction<OffersMessage> {
10261
10261
let secp_ctx = &self.secp_ctx;
10262
10262
let expanded_key = &self.inbound_payment_key;
10263
10263
@@ -10267,17 +10267,31 @@ where
10267
10267
Some(responder) => responder,
10268
10268
None => return ResponseInstruction::NoResponse,
10269
10269
};
10270
+
10271
+ let nonce = match context {
10272
+ OffersContext::Unknown {} if invoice_request.metadata().is_some() => None,
10273
+ OffersContext::InvoiceRequest { nonce } => Some(nonce),
10274
+ _ => return ResponseInstruction::NoResponse,
10275
+ };
10276
+
10270
10277
let amount_msats = match InvoiceBuilder::<DerivedSigningPubkey>::amount_msats(
10271
10278
&invoice_request
10272
10279
) {
10273
10280
Ok(amount_msats) => amount_msats,
10274
10281
Err(error) => return responder.respond(OffersMessage::InvoiceError(error.into())),
10275
10282
};
10276
- let invoice_request = match invoice_request.verify(expanded_key, secp_ctx) {
10277
- Ok(invoice_request) => invoice_request,
10278
- Err(()) => {
10279
- let error = Bolt12SemanticError::InvalidMetadata;
10280
- return responder.respond(OffersMessage::InvoiceError(error.into()));
10283
+
10284
+ let invoice_request = match nonce {
10285
+ Some(nonce) => match invoice_request.verify_using_nonce(nonce, expanded_key, secp_ctx) {
10286
+ Ok(invoice_request) => invoice_request,
10287
+ Err(()) => return ResponseInstruction::NoResponse,
10288
+ },
10289
+ None => match invoice_request.verify(expanded_key, secp_ctx) {
10290
+ Ok(invoice_request) => invoice_request,
10291
+ Err(()) => {
10292
+ let error = Bolt12SemanticError::InvalidMetadata;
10293
+ return responder.respond(OffersMessage::InvoiceError(error.into()));
10294
+ },
10281
10295
},
10282
10296
};
10283
10297
0 commit comments