@@ -10623,36 +10623,41 @@ where
10623
10623
}
10624
10624
},
10625
10625
OffersMessage::Invoice(invoice) => {
10626
- let expected_payment_id = match context {
10626
+ let payer_data = match context {
10627
10627
OffersContext::Unknown {} if invoice.is_for_refund_without_paths() => None,
10628
- OffersContext::OutboundPayment { payment_id, .. } => Some(payment_id),
10628
+ OffersContext::OutboundPayment { payment_id, nonce } => Some(( payment_id, nonce) ),
10629
10629
_ => return ResponseInstruction::NoResponse,
10630
10630
};
10631
10631
10632
- let result = match invoice.verify(expanded_key, secp_ctx) {
10633
- Ok(payment_id) => {
10634
- if let Some(expected_payment_id) = expected_payment_id {
10635
- if payment_id != expected_payment_id {
10636
- return ResponseInstruction::NoResponse;
10637
- }
10638
- }
10639
-
10640
- let features = self.bolt12_invoice_features();
10641
- if invoice.invoice_features().requires_unknown_bits_from(&features) {
10642
- Err(InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures))
10643
- } else if self.default_configuration.manually_handle_bolt12_invoices {
10644
- let event = Event::InvoiceReceived { payment_id, invoice, responder };
10645
- self.pending_events.lock().unwrap().push_back((event, None));
10646
- return ResponseInstruction::NoResponse;
10632
+ let (invoice, payment_id) = match payer_data {
10633
+ Some((payment_id, nonce)) => {
10634
+ if invoice.verify_using_payer_data(payment_id, nonce, expanded_key, secp_ctx) {
10635
+ (invoice, payment_id)
10647
10636
} else {
10648
- self.send_payment_for_verified_bolt12_invoice(&invoice, payment_id)
10649
- .map_err(|e| {
10650
- log_trace!(self.logger, "Failed paying invoice: {:?}", e);
10651
- InvoiceError::from_string(format!("{:?}", e))
10652
- })
10637
+ return ResponseInstruction::NoResponse;
10653
10638
}
10654
10639
},
10655
- Err(()) => return ResponseInstruction::NoResponse,
10640
+ None => match invoice.verify(expanded_key, secp_ctx) {
10641
+ Ok(payment_id) => (invoice, payment_id),
10642
+ Err(()) => return ResponseInstruction::NoResponse,
10643
+ },
10644
+ };
10645
+
10646
+ let result = {
10647
+ let features = self.bolt12_invoice_features();
10648
+ if invoice.invoice_features().requires_unknown_bits_from(&features) {
10649
+ Err(InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures))
10650
+ } else if self.default_configuration.manually_handle_bolt12_invoices {
10651
+ let event = Event::InvoiceReceived { payment_id, invoice, responder };
10652
+ self.pending_events.lock().unwrap().push_back((event, None));
10653
+ return ResponseInstruction::NoResponse;
10654
+ } else {
10655
+ self.send_payment_for_verified_bolt12_invoice(&invoice, payment_id)
10656
+ .map_err(|e| {
10657
+ log_trace!(self.logger, "Failed paying invoice: {:?}", e);
10658
+ InvoiceError::from_string(format!("{:?}", e))
10659
+ })
10660
+ }
10656
10661
};
10657
10662
10658
10663
match result {
0 commit comments