Skip to content

Commit 718bc47

Browse files
committed
Rename Bolt12Invoice::verify
1 parent df5d7ea commit 718bc47

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

lightning/src/ln/channelmanager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4220,7 +4220,7 @@ where
42204220

42214221
match context {
42224222
OffersContext::Unknown {} if invoice.is_for_refund_without_paths() => {
4223-
invoice.verify(expanded_key, secp_ctx)
4223+
invoice.verify_using_metadata(expanded_key, secp_ctx)
42244224
},
42254225
OffersContext::OutboundPayment { payment_id, nonce } => {
42264226
invoice

lightning/src/offers/invoice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl Bolt12Invoice {
775775
/// checking the payer metadata from the invoice request.
776776
///
777777
/// Returns the associated [`PaymentId`] to use when sending the payment.
778-
pub fn verify<T: secp256k1::Signing>(
778+
pub fn verify_using_metadata<T: secp256k1::Signing>(
779779
&self, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
780780
) -> Result<PaymentId, ()> {
781781
let metadata = match &self.contents {

lightning/src/offers/invoice_request.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ mod tests {
14131413
.unwrap()
14141414
.build().unwrap()
14151415
.sign(recipient_sign).unwrap();
1416-
match invoice.verify(&expanded_key, &secp_ctx) {
1416+
match invoice.verify_using_metadata(&expanded_key, &secp_ctx) {
14171417
Ok(payment_id) => assert_eq!(payment_id, PaymentId([1; 32])),
14181418
Err(()) => panic!("verification failed"),
14191419
}
@@ -1440,7 +1440,7 @@ mod tests {
14401440
signature_tlv_stream.write(&mut encoded_invoice).unwrap();
14411441

14421442
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
1443-
assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
1443+
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
14441444

14451445
// Fails verification with altered metadata
14461446
let (
@@ -1463,7 +1463,7 @@ mod tests {
14631463
signature_tlv_stream.write(&mut encoded_invoice).unwrap();
14641464

14651465
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
1466-
assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
1466+
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
14671467
}
14681468

14691469
#[test]
@@ -1487,7 +1487,7 @@ mod tests {
14871487
.unwrap()
14881488
.build().unwrap()
14891489
.sign(recipient_sign).unwrap();
1490-
assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
1490+
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
14911491
assert!(invoice.verify_using_payer_data(payment_id, nonce, &expanded_key, &secp_ctx));
14921492

14931493
// Fails verification with altered fields

lightning/src/offers/offer.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -685,16 +685,17 @@ macro_rules! request_invoice_derived_payer_id { ($self: ident, $builder: ty) =>
685685
/// - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each
686686
/// request,
687687
/// - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called
688-
/// such that it can be used by [`Bolt12Invoice::verify`] to determine if the invoice was
689-
/// requested using a base [`ExpandedKey`] from which the payer id was derived, and
688+
/// such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine if the
689+
/// invoice was requested using a base [`ExpandedKey`] from which the payer id was derived,
690+
/// and
690691
/// - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can
691692
/// be used when sending the payment for the requested invoice.
692693
///
693694
/// Useful to protect the sender's privacy.
694695
///
695696
/// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id
696697
/// [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata
697-
/// [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify
698+
/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
698699
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
699700
pub fn request_invoice_deriving_payer_id<
700701
'a, 'b,

lightning/src/offers/refund.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ macro_rules! refund_builder_methods { (
190190
/// provided `node_id` is used for the payer id.
191191
///
192192
/// Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by
193-
/// [`Bolt12Invoice::verify`] to determine if the invoice was produced for the refund given an
194-
/// [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the metadata must be
195-
/// included in each [`BlindedPath`] instead. In this case, use
193+
/// [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the
194+
/// refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the
195+
/// metadata must be included in each [`BlindedPath`] instead. In this case, use
196196
/// [`Bolt12Invoice::verify_using_payer_data`].
197197
///
198198
/// The `payment_id` is encrypted in the metadata and should be unique. This ensures that only
199199
/// one invoice will be paid for the refund and that payments can be uniquely identified.
200200
///
201-
/// [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify
201+
/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
202202
/// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data
203203
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
204204
pub fn deriving_payer_id(
@@ -1045,7 +1045,7 @@ mod tests {
10451045
.unwrap()
10461046
.build().unwrap()
10471047
.sign(recipient_sign).unwrap();
1048-
match invoice.verify(&expanded_key, &secp_ctx) {
1048+
match invoice.verify_using_metadata(&expanded_key, &secp_ctx) {
10491049
Ok(payment_id) => assert_eq!(payment_id, PaymentId([1; 32])),
10501050
Err(()) => panic!("verification failed"),
10511051
}
@@ -1062,7 +1062,7 @@ mod tests {
10621062
.unwrap()
10631063
.build().unwrap()
10641064
.sign(recipient_sign).unwrap();
1065-
assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
1065+
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
10661066

10671067
// Fails verification with altered metadata
10681068
let mut tlv_stream = refund.as_tlv_stream();
@@ -1077,7 +1077,7 @@ mod tests {
10771077
.unwrap()
10781078
.build().unwrap()
10791079
.sign(recipient_sign).unwrap();
1080-
assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
1080+
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
10811081
}
10821082

10831083
#[test]
@@ -1110,7 +1110,7 @@ mod tests {
11101110
.unwrap()
11111111
.build().unwrap()
11121112
.sign(recipient_sign).unwrap();
1113-
assert!(invoice.verify(&expanded_key, &secp_ctx).is_err());
1113+
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
11141114
assert!(invoice.verify_using_payer_data(payment_id, nonce, &expanded_key, &secp_ctx));
11151115

11161116
// Fails verification with altered fields

0 commit comments

Comments
 (0)