]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename InvoiceRequest::verify
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 19 Jul 2024 14:56:11 +0000 (09:56 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Mon, 22 Jul 2024 16:34:03 +0000 (11:34 -0500)
lightning/src/ln/channelmanager.rs
lightning/src/offers/invoice.rs
lightning/src/offers/invoice_request.rs
lightning/src/offers/offer.rs

index 80faffc0d7d41a3420224822b0707a98074014f8..b5356a85347f42335aba3d23f89d3bb9294647f9 100644 (file)
@@ -10717,7 +10717,7 @@ where
                                                Ok(invoice_request) => invoice_request,
                                                Err(()) => return ResponseInstruction::NoResponse,
                                        },
-                                       None => match invoice_request.verify(expanded_key, secp_ctx) {
+                                       None => match invoice_request.verify_using_metadata(expanded_key, secp_ctx) {
                                                Ok(invoice_request) => invoice_request,
                                                Err(()) => {
                                                        let error = Bolt12SemanticError::InvalidMetadata;
index 6100f02ca828765fd1a7a220bc8e52b4f150cf37..2d34b1c0977cf9da6497e30051740811f8d0851b 100644 (file)
@@ -1797,7 +1797,7 @@ mod tests {
                        .sign(payer_sign).unwrap();
 
                match invoice_request
-                       .verify(&expanded_key, &secp_ctx).unwrap()
+                       .verify_using_metadata(&expanded_key, &secp_ctx).unwrap()
                        .respond_using_derived_keys_no_std(payment_paths(), payment_hash(), now())
                {
                        Ok(_) => panic!("expected error"),
index 0fee4683c5079501da953a816b60ea0a9e364ac6..39eb157d76f09b532d612e086bc15aa4ee6dd241 100644 (file)
@@ -605,7 +605,7 @@ pub struct InvoiceRequest {
        signature: Signature,
 }
 
-/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] or
+/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify_using_metadata`] or
 /// [`InvoiceRequest::verify_using_recipient_data`] and exposes different ways to respond depending
 /// on whether the signing keys were derived.
 #[derive(Clone, Debug)]
@@ -738,8 +738,9 @@ macro_rules! invoice_request_respond_with_explicit_signing_pubkey_methods { (
        /// # Note
        ///
        /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
-       /// then first use [`InvoiceRequest::verify`] or [`InvoiceRequest::verify_using_recipient_data`]
-       /// and then [`VerifiedInvoiceRequest`] methods instead.
+       /// then first use [`InvoiceRequest::verify_using_metadata`] or
+       /// [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods
+       /// instead.
        ///
        /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
        /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
@@ -783,7 +784,7 @@ macro_rules! invoice_request_verify_method { ($self: ident, $self_type: ty) => {
        /// [`Bolt12Invoice`] for the request if they could be extracted from the metadata.
        ///
        /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
-       pub fn verify<
+       pub fn verify_using_metadata<
                #[cfg(not(c_bindings))]
                T: secp256k1::Signing
        >(
@@ -793,7 +794,8 @@ macro_rules! invoice_request_verify_method { ($self: ident, $self_type: ty) => {
                #[cfg(c_bindings)]
                secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<VerifiedInvoiceRequest, ()> {
-               let (offer_id, keys) = $self.contents.inner.offer.verify(&$self.bytes, key, secp_ctx)?;
+               let (offer_id, keys) =
+                       $self.contents.inner.offer.verify_using_metadata(&$self.bytes, key, secp_ctx)?;
                Ok(VerifiedInvoiceRequest {
                        offer_id,
                        #[cfg(not(c_bindings))]
@@ -2326,7 +2328,7 @@ mod tests {
                        .payer_note("0".repeat(PAYER_NOTE_LIMIT * 2))
                        .build().unwrap()
                        .sign(payer_sign).unwrap();
-               match invoice_request.verify(&expanded_key, &secp_ctx) {
+               match invoice_request.verify_using_metadata(&expanded_key, &secp_ctx) {
                        Ok(invoice_request) => {
                                let fields = invoice_request.fields();
                                assert_eq!(invoice_request.offer_id, offer.id());
index 1911940eb044f2a36b6531167fb5c7d4bc05eb02..94d5175a5b62aadac22fa69524133b4644f1cadb 100644 (file)
@@ -248,12 +248,12 @@ macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => {
        /// `node_id` is used for the signing pubkey.
        ///
        /// Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by
-       /// [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an
-       /// [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the metadata will not be
-       /// set and must be included in each [`BlindedPath`] instead. In this case, use
-       /// [`InvoiceRequest::verify_using_recipient_data`].
+       /// [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the
+       /// offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the
+       /// metadata will not be set and must be included in each [`BlindedPath`] instead. In this case,
+       /// use [`InvoiceRequest::verify_using_recipient_data`].
        ///
-       /// [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify
+       /// [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata
        /// [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data
        /// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
        pub fn deriving_signing_pubkey(
@@ -922,20 +922,20 @@ impl OfferContents {
                self.signing_pubkey
        }
 
-       pub(super) fn verify<T: secp256k1::Signing>(
+       pub(super) fn verify_using_metadata<T: secp256k1::Signing>(
                &self, bytes: &[u8], key: &ExpandedKey, secp_ctx: &Secp256k1<T>
        ) -> Result<(OfferId, Option<Keypair>), ()> {
-               self.verify_using_metadata(bytes, self.metadata.as_ref(), key, secp_ctx)
+               self.verify(bytes, self.metadata.as_ref(), key, secp_ctx)
        }
 
        pub(super) fn verify_using_recipient_data<T: secp256k1::Signing>(
                &self, bytes: &[u8], nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
        ) -> Result<(OfferId, Option<Keypair>), ()> {
-               self.verify_using_metadata(bytes, Some(&Metadata::RecipientData(nonce)), key, secp_ctx)
+               self.verify(bytes, Some(&Metadata::RecipientData(nonce)), key, secp_ctx)
        }
 
        /// Verifies that the offer metadata was produced from the offer in the TLV stream.
-       fn verify_using_metadata<T: secp256k1::Signing>(
+       fn verify<T: secp256k1::Signing>(
                &self, bytes: &[u8], metadata: Option<&Metadata>, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
        ) -> Result<(OfferId, Option<Keypair>), ()> {
                match metadata {
@@ -1311,7 +1311,7 @@ mod tests {
                let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
                        .build().unwrap()
                        .sign(payer_sign).unwrap();
-               match invoice_request.verify(&expanded_key, &secp_ctx) {
+               match invoice_request.verify_using_metadata(&expanded_key, &secp_ctx) {
                        Ok(invoice_request) => assert_eq!(invoice_request.offer_id, offer.id()),
                        Err(_) => panic!("unexpected error"),
                }
@@ -1335,7 +1335,7 @@ mod tests {
                        .request_invoice(vec![1; 32], payer_pubkey()).unwrap()
                        .build().unwrap()
                        .sign(payer_sign).unwrap();
-               assert!(invoice_request.verify(&expanded_key, &secp_ctx).is_err());
+               assert!(invoice_request.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
 
                // Fails verification with altered metadata
                let mut tlv_stream = offer.as_tlv_stream();
@@ -1349,7 +1349,7 @@ mod tests {
                        .request_invoice(vec![1; 32], payer_pubkey()).unwrap()
                        .build().unwrap()
                        .sign(payer_sign).unwrap();
-               assert!(invoice_request.verify(&expanded_key, &secp_ctx).is_err());
+               assert!(invoice_request.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
        }
 
        #[test]
@@ -1390,7 +1390,7 @@ mod tests {
                let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
                        .build().unwrap()
                        .sign(payer_sign).unwrap();
-               assert!(invoice_request.verify(&expanded_key, &secp_ctx).is_err());
+               assert!(invoice_request.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
 
                // Fails verification with altered offer field
                let mut tlv_stream = offer.as_tlv_stream();