Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Offer::signing_pubkey to Offer::issuer_id #3218

Merged
merged 7 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 12 additions & 12 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 @@ -9115,7 +9115,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
.and_then(|paths| paths.into_iter().next().ok_or(()))
.map_err(|_| Bolt12SemanticError::MissingPaths)?;

let builder = RefundBuilder::deriving_payer_id(
let builder = RefundBuilder::deriving_signing_pubkey(
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
)?
.chain_hash($self.chain_hash)
Expand Down Expand Up @@ -9197,7 +9197,7 @@ where
/// # Limitations
///
/// Requires a direct connection to an introduction node in [`Offer::paths`] or to
/// [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
/// [`Offer::issuer_signing_pubkey`], if empty. A similar restriction applies to the responding
/// [`Bolt12Invoice::payment_paths`].
///
/// # Errors
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 Expand Up @@ -9288,18 +9288,18 @@ where
let message = OffersMessage::InvoiceRequest(invoice_request.clone());
pending_offers_messages.push((message, instructions));
});
} else if let Some(signing_pubkey) = invoice_request.signing_pubkey() {
} else if let Some(node_id) = invoice_request.issuer_signing_pubkey() {
for reply_path in reply_paths {
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
destination: Destination::Node(signing_pubkey),
destination: Destination::Node(node_id),
reply_path,
};
let message = OffersMessage::InvoiceRequest(invoice_request.clone());
pending_offers_messages.push((message, instructions));
}
} else {
debug_assert!(false);
return Err(Bolt12SemanticError::MissingSigningPubkey);
return Err(Bolt12SemanticError::MissingIssuerSigningPubkey);
}

Ok(())
Expand All @@ -9315,9 +9315,9 @@ where
/// # Limitations
///
/// Requires a direct connection to an introduction node in [`Refund::paths`] or to
/// [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
/// node meeting the aforementioned criteria, but there's no guarantee that they will be
/// received and no retries will be made.
/// [`Refund::payer_signing_pubkey`], if empty. This request is best effort; an invoice will be
/// sent to each node meeting the aforementioned criteria, but there's no guarantee that they
/// will be received and no retries will be made.
///
/// # Errors
///
Expand Down Expand Up @@ -9378,7 +9378,7 @@ where
if refund.paths().is_empty() {
for reply_path in reply_paths {
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
destination: Destination::Node(refund.payer_id()),
destination: Destination::Node(refund.payer_signing_pubkey()),
reply_path,
};
let message = OffersMessage::Invoice(invoice.clone());
Expand Down
62 changes: 31 additions & 31 deletions lightning/src/ln/offers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn prefers_non_tor_nodes_in_blinded_paths() {
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(bob_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
let introduction_node_id = resolve_introduction_node(david, &path);
Expand All @@ -321,7 +321,7 @@ fn prefers_non_tor_nodes_in_blinded_paths() {
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(bob_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
let introduction_node_id = resolve_introduction_node(david, &path);
Expand Down Expand Up @@ -372,7 +372,7 @@ fn prefers_more_connected_nodes_in_blinded_paths() {
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(bob_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
let introduction_node_id = resolve_introduction_node(david, &path);
Expand Down Expand Up @@ -541,7 +541,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
.unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
Expand All @@ -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 @@ -651,7 +651,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
.build().unwrap();
assert_eq!(refund.amount_msats(), 10_000_000);
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
assert_ne!(refund.payer_id(), david_id);
assert_ne!(refund.payer_signing_pubkey(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
Expand Down Expand Up @@ -709,7 +709,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
Expand All @@ -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 @@ -779,7 +779,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
.build().unwrap();
assert_eq!(refund.amount_msats(), 10_000_000);
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
assert_ne!(refund.payer_id(), bob_id);
assert_ne!(refund.payer_signing_pubkey(), bob_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
Expand Down Expand Up @@ -832,7 +832,7 @@ fn pays_for_offer_without_blinded_paths() {
.clear_paths()
.amount_msats(10_000_000)
.build().unwrap();
assert_eq!(offer.signing_pubkey(), Some(alice_id));
assert_eq!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(offer.paths().is_empty());

let payment_id = PaymentId([1; 32]);
Expand All @@ -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 @@ -886,7 +886,7 @@ fn pays_for_refund_without_blinded_paths() {
.unwrap()
.clear_paths()
.build().unwrap();
assert_eq!(refund.payer_id(), bob_id);
assert_eq!(refund.payer_signing_pubkey(), bob_id);
assert!(refund.paths().is_empty());
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);

Expand Down Expand Up @@ -955,7 +955,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
.unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
Expand Down Expand Up @@ -1040,7 +1040,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
assert_ne!(refund.payer_id(), alice_id);
assert_ne!(refund.payer_signing_pubkey(), alice_id);
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
}
Expand Down Expand Up @@ -1090,7 +1090,7 @@ fn creates_and_pays_for_offer_with_retry() {
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
Expand All @@ -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 @@ -1248,7 +1248,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
Expand All @@ -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 @@ -1315,7 +1315,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
assert_ne!(refund.payer_id(), bob_id);
assert_ne!(refund.payer_signing_pubkey(), bob_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
Expand Down Expand Up @@ -1379,7 +1379,7 @@ fn fails_authentication_when_handling_invoice_request() {
.amount_msats(10_000_000)
.build().unwrap();
assert_eq!(offer.metadata(), None);
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
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 @@ -1490,7 +1490,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
.unwrap()
.amount_msats(10_000_000)
.build().unwrap();
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
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 Expand Up @@ -1598,7 +1598,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
assert_ne!(refund.payer_id(), david_id);
assert_ne!(refund.payer_signing_pubkey(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
Expand Down Expand Up @@ -1632,7 +1632,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
assert_ne!(refund.payer_id(), david_id);
assert_ne!(refund.payer_signing_pubkey(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
Expand Down
Loading
Loading