Skip to content

Commit

Permalink
Rename InvoiceRequest::payer_id
Browse files Browse the repository at this point in the history
For consistency with Offer::issuer_signing_pubkey, rename
InvoiceRequest::payer_id to use "signing_pubkey" instead of "id".
  • Loading branch information
jkczyz committed Sep 16, 2024
1 parent de29295 commit dd8f744
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 162 deletions.
2 changes: 1 addition & 1 deletion fuzz/src/invoice_request_deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: OfferId([42; 32]),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: invoice_request.quantity(),
payer_note_truncated: invoice_request
.payer_note()
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutb
use crate::ln::wire::Encode;
use crate::offers::invoice::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, ExplicitSigningPubkey, InvoiceBuilder, UnsignedBolt12Invoice};
use crate::offers::invoice_error::InvoiceError;
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequest, InvoiceRequestBuilder};
use crate::offers::invoice_request::{DerivedPayerSigningPubkey, InvoiceRequest, InvoiceRequestBuilder};
use crate::offers::nonce::Nonce;
use crate::offers::offer::{Offer, OfferBuilder};
use crate::offers::parse::Bolt12SemanticError;
Expand Down Expand Up @@ -9226,8 +9226,8 @@ where
let secp_ctx = &self.secp_ctx;

let nonce = Nonce::from_entropy_source(entropy);
let builder: InvoiceRequestBuilder<DerivedPayerId, secp256k1::All> = offer
.request_invoice_deriving_payer_id(expanded_key, nonce, secp_ctx, payment_id)?
let builder: InvoiceRequestBuilder<DerivedPayerSigningPubkey, secp256k1::All> = offer
.request_invoice_deriving_signing_pubkey(expanded_key, nonce, secp_ctx, payment_id)?
.into();
let builder = builder.chain_hash(self.chain_hash)?;

Expand Down
26 changes: 13 additions & 13 deletions lightning/src/ln/offers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,13 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: offer.id(),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: None,
payer_note_truncated: None,
},
});
assert_eq!(invoice_request.amount_msats(), None);
assert_ne!(invoice_request.payer_id(), david_id);
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));

let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
Expand Down Expand Up @@ -726,13 +726,13 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: offer.id(),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: None,
payer_note_truncated: None,
},
});
assert_eq!(invoice_request.amount_msats(), None);
assert_ne!(invoice_request.payer_id(), bob_id);
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(bob_id));

let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
Expand Down Expand Up @@ -846,7 +846,7 @@ fn pays_for_offer_without_blinded_paths() {
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: offer.id(),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: None,
payer_note_truncated: None,
},
Expand Down Expand Up @@ -1112,13 +1112,13 @@ fn creates_and_pays_for_offer_with_retry() {
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: offer.id(),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: None,
payer_note_truncated: None,
},
});
assert_eq!(invoice_request.amount_msats(), None);
assert_ne!(invoice_request.payer_id(), bob_id);
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(bob_id));
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
Expand Down Expand Up @@ -1176,7 +1176,7 @@ fn pays_bolt12_invoice_asynchronously() {
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: offer.id(),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: None,
payer_note_truncated: None,
},
Expand Down Expand Up @@ -1265,12 +1265,12 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
offer_id: offer.id(),
invoice_request: InvoiceRequestFields {
payer_id: invoice_request.payer_id(),
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
quantity: None,
payer_note_truncated: None,
},
});
assert_ne!(invoice_request.payer_id(), bob_id);
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(alice_id));

let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
Expand Down Expand Up @@ -1411,7 +1411,7 @@ fn fails_authentication_when_handling_invoice_request() {

let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(invoice_request.amount_msats(), None);
assert_ne!(invoice_request.payer_id(), david_id);
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));

assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None);
Expand Down Expand Up @@ -1441,7 +1441,7 @@ fn fails_authentication_when_handling_invoice_request() {

let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(invoice_request.amount_msats(), None);
assert_ne!(invoice_request.payer_id(), david_id);
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));

assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None);
Expand Down Expand Up @@ -1543,7 +1543,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {

let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(invoice_request.amount_msats(), None);
assert_ne!(invoice_request.payer_id(), david_id);
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));

let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
Expand Down
18 changes: 9 additions & 9 deletions lightning/src/offers/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
/// refund in case there are no [`message_paths`].
///
/// [`message_paths`]: Self::message_paths
pub fn payer_id(&$self) -> PublicKey {
$contents.payer_id()
pub fn payer_signing_pubkey(&$self) -> PublicKey {
$contents.payer_signing_pubkey()
}

/// A payer-provided note reflected back in the invoice.
Expand Down Expand Up @@ -1017,10 +1017,10 @@ impl InvoiceContents {
}
}

fn payer_id(&self) -> PublicKey {
fn payer_signing_pubkey(&self) -> PublicKey {
match self {
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.payer_id(),
InvoiceContents::ForRefund { refund, .. } => refund.payer_id(),
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.payer_signing_pubkey(),
}
}

Expand Down Expand Up @@ -1099,9 +1099,9 @@ impl InvoiceContents {
});
let tlv_stream = offer_records.chain(invreq_records);

let payer_id = self.payer_id();
let signing_pubkey = self.payer_signing_pubkey();
signer::verify_payer_metadata(
metadata.as_ref(), key, iv_bytes, payer_id, tlv_stream, secp_ctx,
metadata.as_ref(), key, iv_bytes, signing_pubkey, tlv_stream, secp_ctx,
)
}

Expand Down Expand Up @@ -1526,7 +1526,7 @@ mod tests {
assert_eq!(unsigned_invoice.amount_msats(), 1000);
assert_eq!(unsigned_invoice.invoice_request_features(), &InvoiceRequestFeatures::empty());
assert_eq!(unsigned_invoice.quantity(), None);
assert_eq!(unsigned_invoice.payer_id(), payer_pubkey());
assert_eq!(unsigned_invoice.payer_signing_pubkey(), payer_pubkey());
assert_eq!(unsigned_invoice.payer_note(), None);
assert_eq!(unsigned_invoice.payment_paths(), payment_paths.as_slice());
assert_eq!(unsigned_invoice.created_at(), now);
Expand Down Expand Up @@ -1568,7 +1568,7 @@ mod tests {
assert_eq!(invoice.amount_msats(), 1000);
assert_eq!(invoice.invoice_request_features(), &InvoiceRequestFeatures::empty());
assert_eq!(invoice.quantity(), None);
assert_eq!(invoice.payer_id(), payer_pubkey());
assert_eq!(invoice.payer_signing_pubkey(), payer_pubkey());
assert_eq!(invoice.payer_note(), None);
assert_eq!(invoice.payment_paths(), payment_paths.as_slice());
assert_eq!(invoice.created_at(), now);
Expand Down Expand Up @@ -1666,7 +1666,7 @@ mod tests {
assert_eq!(invoice.amount_msats(), 1000);
assert_eq!(invoice.invoice_request_features(), &InvoiceRequestFeatures::empty());
assert_eq!(invoice.quantity(), None);
assert_eq!(invoice.payer_id(), payer_pubkey());
assert_eq!(invoice.payer_signing_pubkey(), payer_pubkey());
assert_eq!(invoice.payer_note(), None);
assert_eq!(invoice.payment_paths(), payment_paths.as_slice());
assert_eq!(invoice.created_at(), now);
Expand Down
Loading

0 comments on commit dd8f744

Please sign in to comment.