From: Jeffrey Czyz Date: Fri, 19 Jul 2024 16:17:51 +0000 (-0500) Subject: Rename Bolt12Invoice::verify X-Git-Tag: v0.0.124-beta~37^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=718bc4766496c2f7b8fad8c6b9337a1c8f28fb4b;p=rust-lightning Rename Bolt12Invoice::verify --- diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index a5fe80a3a..3e4ac872e 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -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 diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 5ea2c2e60..e1f301382 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -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( + pub fn verify_using_metadata( &self, key: &ExpandedKey, secp_ctx: &Secp256k1 ) -> Result { let metadata = match &self.contents { diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index 8111e9958..4ad996450 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -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 diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index b5e9154d5..29220125f 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -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, diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index a98c606ab..9cfa3147c 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -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