]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename Bolt12Invoice::verify
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 19 Jul 2024 16:17:51 +0000 (11:17 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Mon, 22 Jul 2024 16:38:39 +0000 (11:38 -0500)
lightning/src/ln/channelmanager.rs
lightning/src/offers/invoice.rs
lightning/src/offers/invoice_request.rs
lightning/src/offers/offer.rs
lightning/src/offers/refund.rs

index a5fe80a3a7033ebe714cfe299bb23bd434908262..3e4ac872e1b26ce33de6fd883228616b400e272d 100644 (file)
@@ -4220,7 +4220,7 @@ where
 
                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
index 5ea2c2e6041545f0ca191219f26f2c647b32085b..e1f30138212b7c9bbdf12c976a5b8ecf3b5b5307 100644 (file)
@@ -775,7 +775,7 @@ impl Bolt12Invoice {
        /// 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 {
index 8111e995813b00f6d9d124426c750474fb6a6324..4ad99645002271797d2a403eddcf31c3c5d4bcaf 100644 (file)
@@ -1413,7 +1413,7 @@ mod tests {
                        .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"),
                }
@@ -1440,7 +1440,7 @@ mod tests {
                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 (
@@ -1463,7 +1463,7 @@ mod tests {
                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]
@@ -1487,7 +1487,7 @@ mod tests {
                        .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
index b5e9154d53aba912b2783135ff09a471ddf7abb9..29220125f66f948c3f3b4a55c209f67c3b596da9 100644 (file)
@@ -685,8 +685,9 @@ macro_rules! request_invoice_derived_payer_id { ($self: ident, $builder: ty) =>
        /// - 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.
        ///
@@ -694,7 +695,7 @@ macro_rules! request_invoice_derived_payer_id { ($self: ident, $builder: ty) =>
        ///
        /// [`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,
index a98c606abd2a720be4255ad90623716f5ed9efdc..9cfa3147c63d698879a8f4cd72765b2c6a7f7c23 100644 (file)
@@ -190,15 +190,15 @@ macro_rules! refund_builder_methods { (
        /// 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(
@@ -1045,7 +1045,7 @@ mod tests {
                        .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"),
                }
@@ -1062,7 +1062,7 @@ mod tests {
                        .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();
@@ -1077,7 +1077,7 @@ mod tests {
                        .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]
@@ -1110,7 +1110,7 @@ mod tests {
                        .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