Skip to content

Commit 9d46340

Browse files
committed
Rename InvoiceRequest::verify
1 parent bf42847 commit 9d46340

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10717,7 +10717,7 @@ where
1071710717
Ok(invoice_request) => invoice_request,
1071810718
Err(()) => return ResponseInstruction::NoResponse,
1071910719
},
10720-
None => match invoice_request.verify(expanded_key, secp_ctx) {
10720+
None => match invoice_request.verify_using_metadata(expanded_key, secp_ctx) {
1072110721
Ok(invoice_request) => invoice_request,
1072210722
Err(()) => {
1072310723
let error = Bolt12SemanticError::InvalidMetadata;

lightning/src/offers/invoice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ mod tests {
17971797
.sign(payer_sign).unwrap();
17981798

17991799
match invoice_request
1800-
.verify(&expanded_key, &secp_ctx).unwrap()
1800+
.verify_using_metadata(&expanded_key, &secp_ctx).unwrap()
18011801
.respond_using_derived_keys_no_std(payment_paths(), payment_hash(), now())
18021802
{
18031803
Ok(_) => panic!("expected error"),

lightning/src/offers/invoice_request.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ pub struct InvoiceRequest {
605605
signature: Signature,
606606
}
607607

608-
/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] or
608+
/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify_using_metadata`] or
609609
/// [`InvoiceRequest::verify_using_recipient_data`] and exposes different ways to respond depending
610610
/// on whether the signing keys were derived.
611611
#[derive(Clone, Debug)]
@@ -738,8 +738,9 @@ macro_rules! invoice_request_respond_with_explicit_signing_pubkey_methods { (
738738
/// # Note
739739
///
740740
/// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
741-
/// then first use [`InvoiceRequest::verify`] or [`InvoiceRequest::verify_using_recipient_data`]
742-
/// and then [`VerifiedInvoiceRequest`] methods instead.
741+
/// then first use [`InvoiceRequest::verify_using_metadata`] or
742+
/// [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods
743+
/// instead.
743744
///
744745
/// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
745746
/// [`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) => {
783784
/// [`Bolt12Invoice`] for the request if they could be extracted from the metadata.
784785
///
785786
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
786-
pub fn verify<
787+
pub fn verify_using_metadata<
787788
#[cfg(not(c_bindings))]
788789
T: secp256k1::Signing
789790
>(
@@ -793,7 +794,8 @@ macro_rules! invoice_request_verify_method { ($self: ident, $self_type: ty) => {
793794
#[cfg(c_bindings)]
794795
secp_ctx: &Secp256k1<secp256k1::All>,
795796
) -> Result<VerifiedInvoiceRequest, ()> {
796-
let (offer_id, keys) = $self.contents.inner.offer.verify(&$self.bytes, key, secp_ctx)?;
797+
let (offer_id, keys) =
798+
$self.contents.inner.offer.verify_using_metadata(&$self.bytes, key, secp_ctx)?;
797799
Ok(VerifiedInvoiceRequest {
798800
offer_id,
799801
#[cfg(not(c_bindings))]
@@ -2326,7 +2328,7 @@ mod tests {
23262328
.payer_note("0".repeat(PAYER_NOTE_LIMIT * 2))
23272329
.build().unwrap()
23282330
.sign(payer_sign).unwrap();
2329-
match invoice_request.verify(&expanded_key, &secp_ctx) {
2331+
match invoice_request.verify_using_metadata(&expanded_key, &secp_ctx) {
23302332
Ok(invoice_request) => {
23312333
let fields = invoice_request.fields();
23322334
assert_eq!(invoice_request.offer_id, offer.id());

lightning/src/offers/offer.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => {
248248
/// `node_id` is used for the signing pubkey.
249249
///
250250
/// Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by
251-
/// [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an
252-
/// [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the metadata will not be
253-
/// set and must be included in each [`BlindedPath`] instead. In this case, use
254-
/// [`InvoiceRequest::verify_using_recipient_data`].
251+
/// [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the
252+
/// offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the
253+
/// metadata will not be set and must be included in each [`BlindedPath`] instead. In this case,
254+
/// use [`InvoiceRequest::verify_using_recipient_data`].
255255
///
256-
/// [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify
256+
/// [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata
257257
/// [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data
258258
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
259259
pub fn deriving_signing_pubkey(
@@ -922,20 +922,20 @@ impl OfferContents {
922922
self.signing_pubkey
923923
}
924924

925-
pub(super) fn verify<T: secp256k1::Signing>(
925+
pub(super) fn verify_using_metadata<T: secp256k1::Signing>(
926926
&self, bytes: &[u8], key: &ExpandedKey, secp_ctx: &Secp256k1<T>
927927
) -> Result<(OfferId, Option<Keypair>), ()> {
928-
self.verify_using_metadata(bytes, self.metadata.as_ref(), key, secp_ctx)
928+
self.verify(bytes, self.metadata.as_ref(), key, secp_ctx)
929929
}
930930

931931
pub(super) fn verify_using_recipient_data<T: secp256k1::Signing>(
932932
&self, bytes: &[u8], nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
933933
) -> Result<(OfferId, Option<Keypair>), ()> {
934-
self.verify_using_metadata(bytes, Some(&Metadata::RecipientData(nonce)), key, secp_ctx)
934+
self.verify(bytes, Some(&Metadata::RecipientData(nonce)), key, secp_ctx)
935935
}
936936

937937
/// Verifies that the offer metadata was produced from the offer in the TLV stream.
938-
fn verify_using_metadata<T: secp256k1::Signing>(
938+
fn verify<T: secp256k1::Signing>(
939939
&self, bytes: &[u8], metadata: Option<&Metadata>, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
940940
) -> Result<(OfferId, Option<Keypair>), ()> {
941941
match metadata {
@@ -1311,7 +1311,7 @@ mod tests {
13111311
let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
13121312
.build().unwrap()
13131313
.sign(payer_sign).unwrap();
1314-
match invoice_request.verify(&expanded_key, &secp_ctx) {
1314+
match invoice_request.verify_using_metadata(&expanded_key, &secp_ctx) {
13151315
Ok(invoice_request) => assert_eq!(invoice_request.offer_id, offer.id()),
13161316
Err(_) => panic!("unexpected error"),
13171317
}
@@ -1335,7 +1335,7 @@ mod tests {
13351335
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
13361336
.build().unwrap()
13371337
.sign(payer_sign).unwrap();
1338-
assert!(invoice_request.verify(&expanded_key, &secp_ctx).is_err());
1338+
assert!(invoice_request.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
13391339

13401340
// Fails verification with altered metadata
13411341
let mut tlv_stream = offer.as_tlv_stream();
@@ -1349,7 +1349,7 @@ mod tests {
13491349
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
13501350
.build().unwrap()
13511351
.sign(payer_sign).unwrap();
1352-
assert!(invoice_request.verify(&expanded_key, &secp_ctx).is_err());
1352+
assert!(invoice_request.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
13531353
}
13541354

13551355
#[test]
@@ -1390,7 +1390,7 @@ mod tests {
13901390
let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
13911391
.build().unwrap()
13921392
.sign(payer_sign).unwrap();
1393-
assert!(invoice_request.verify(&expanded_key, &secp_ctx).is_err());
1393+
assert!(invoice_request.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
13941394

13951395
// Fails verification with altered offer field
13961396
let mut tlv_stream = offer.as_tlv_stream();

0 commit comments

Comments
 (0)