match context {
OffersContext::Unknown {} if invoice.is_for_refund_without_paths() => {
- invoice.verify(expanded_key, secp_ctx)
+ invoice.verify_using_metadata(expanded_key, secp_ctx)
},
OffersContext::OutboundPayment { payment_id, nonce } => {
invoice
/// checking the payer metadata from the invoice request.
///
/// Returns the associated [`PaymentId`] to use when sending the payment.
- pub fn verify<T: secp256k1::Signing>(
+ pub fn verify_using_metadata<T: secp256k1::Signing>(
&self, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
) -> Result<PaymentId, ()> {
let metadata = match &self.contents {
.unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- match invoice.verify(&expanded_key, &secp_ctx) {
+ match invoice.verify_using_metadata(&expanded_key, &secp_ctx) {
Ok(payment_id) => assert_eq!(payment_id, PaymentId([1; 32])),
Err(()) => panic!("verification failed"),
}
signature_tlv_stream.write(&mut encoded_invoice).unwrap();
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
- assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
+ assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
// Fails verification with altered metadata
let (
signature_tlv_stream.write(&mut encoded_invoice).unwrap();
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
- assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
+ assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
}
#[test]
.unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
+ assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
assert!(invoice.verify_using_payer_data(payment_id, nonce, &expanded_key, &secp_ctx));
// Fails verification with altered fields
/// - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each
/// request,
/// - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called
- /// such that it can be used by [`Bolt12Invoice::verify`] to determine if the invoice was
- /// requested using a base [`ExpandedKey`] from which the payer id was derived, and
+ /// such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine if the
+ /// invoice was requested using a base [`ExpandedKey`] from which the payer id was derived,
+ /// and
/// - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can
/// be used when sending the payment for the requested invoice.
///
///
/// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id
/// [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata
- /// [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify
+ /// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
pub fn request_invoice_deriving_payer_id<
'a, 'b,
/// provided `node_id` is used for the payer id.
///
/// Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by
- /// [`Bolt12Invoice::verify`] to determine if the invoice was produced for the refund given an
- /// [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the metadata must be
- /// included in each [`BlindedPath`] instead. In this case, use
+ /// [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the
+ /// refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the
+ /// metadata must be included in each [`BlindedPath`] instead. In this case, use
/// [`Bolt12Invoice::verify_using_payer_data`].
///
/// The `payment_id` is encrypted in the metadata and should be unique. This ensures that only
/// one invoice will be paid for the refund and that payments can be uniquely identified.
///
- /// [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify
+ /// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
/// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
pub fn deriving_payer_id(
.unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- match invoice.verify(&expanded_key, &secp_ctx) {
+ match invoice.verify_using_metadata(&expanded_key, &secp_ctx) {
Ok(payment_id) => assert_eq!(payment_id, PaymentId([1; 32])),
Err(()) => panic!("verification failed"),
}
.unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
+ assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
// Fails verification with altered metadata
let mut tlv_stream = refund.as_tlv_stream();
.unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
+ assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
}
#[test]
.unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
+ assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
assert!(invoice.verify_using_payer_data(payment_id, nonce, &expanded_key, &secp_ctx));
// Fails verification with altered fields