Skip to content

Commit 429cbe1

Browse files
authored
Merge pull request #3218 from jkczyz/2024-07-offers-spec-update
Rename `Offer::signing_pubkey` to `Offer::issuer_id`
2 parents 6662c5c + e11025f commit 429cbe1

13 files changed

+422
-324
lines changed

fuzz/src/invoice_request_deser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
8585
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
8686
offer_id: OfferId([42; 32]),
8787
invoice_request: InvoiceRequestFields {
88-
payer_id: invoice_request.payer_id(),
88+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
8989
quantity: invoice_request.quantity(),
9090
payer_note_truncated: invoice_request
9191
.payer_note()

lightning/src/ln/channelmanager.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutb
6565
use crate::ln::wire::Encode;
6666
use crate::offers::invoice::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, ExplicitSigningPubkey, InvoiceBuilder, UnsignedBolt12Invoice};
6767
use crate::offers::invoice_error::InvoiceError;
68-
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequest, InvoiceRequestBuilder};
68+
use crate::offers::invoice_request::{DerivedPayerSigningPubkey, InvoiceRequest, InvoiceRequestBuilder};
6969
use crate::offers::nonce::Nonce;
7070
use crate::offers::offer::{Offer, OfferBuilder};
7171
use crate::offers::parse::Bolt12SemanticError;
@@ -9115,7 +9115,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
91159115
.and_then(|paths| paths.into_iter().next().ok_or(()))
91169116
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
91179117

9118-
let builder = RefundBuilder::deriving_payer_id(
9118+
let builder = RefundBuilder::deriving_signing_pubkey(
91199119
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
91209120
)?
91219121
.chain_hash($self.chain_hash)
@@ -9197,7 +9197,7 @@ where
91979197
/// # Limitations
91989198
///
91999199
/// Requires a direct connection to an introduction node in [`Offer::paths`] or to
9200-
/// [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
9200+
/// [`Offer::issuer_signing_pubkey`], if empty. A similar restriction applies to the responding
92019201
/// [`Bolt12Invoice::payment_paths`].
92029202
///
92039203
/// # Errors
@@ -9226,8 +9226,8 @@ where
92269226
let secp_ctx = &self.secp_ctx;
92279227

92289228
let nonce = Nonce::from_entropy_source(entropy);
9229-
let builder: InvoiceRequestBuilder<DerivedPayerId, secp256k1::All> = offer
9230-
.request_invoice_deriving_payer_id(expanded_key, nonce, secp_ctx, payment_id)?
9229+
let builder: InvoiceRequestBuilder<DerivedPayerSigningPubkey, secp256k1::All> = offer
9230+
.request_invoice_deriving_signing_pubkey(expanded_key, nonce, secp_ctx, payment_id)?
92319231
.into();
92329232
let builder = builder.chain_hash(self.chain_hash)?;
92339233

@@ -9288,18 +9288,18 @@ where
92889288
let message = OffersMessage::InvoiceRequest(invoice_request.clone());
92899289
pending_offers_messages.push((message, instructions));
92909290
});
9291-
} else if let Some(signing_pubkey) = invoice_request.signing_pubkey() {
9291+
} else if let Some(node_id) = invoice_request.issuer_signing_pubkey() {
92929292
for reply_path in reply_paths {
92939293
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
9294-
destination: Destination::Node(signing_pubkey),
9294+
destination: Destination::Node(node_id),
92959295
reply_path,
92969296
};
92979297
let message = OffersMessage::InvoiceRequest(invoice_request.clone());
92989298
pending_offers_messages.push((message, instructions));
92999299
}
93009300
} else {
93019301
debug_assert!(false);
9302-
return Err(Bolt12SemanticError::MissingSigningPubkey);
9302+
return Err(Bolt12SemanticError::MissingIssuerSigningPubkey);
93039303
}
93049304

93059305
Ok(())
@@ -9315,9 +9315,9 @@ where
93159315
/// # Limitations
93169316
///
93179317
/// Requires a direct connection to an introduction node in [`Refund::paths`] or to
9318-
/// [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
9319-
/// node meeting the aforementioned criteria, but there's no guarantee that they will be
9320-
/// received and no retries will be made.
9318+
/// [`Refund::payer_signing_pubkey`], if empty. This request is best effort; an invoice will be
9319+
/// sent to each node meeting the aforementioned criteria, but there's no guarantee that they
9320+
/// will be received and no retries will be made.
93219321
///
93229322
/// # Errors
93239323
///
@@ -9378,7 +9378,7 @@ where
93789378
if refund.paths().is_empty() {
93799379
for reply_path in reply_paths {
93809380
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
9381-
destination: Destination::Node(refund.payer_id()),
9381+
destination: Destination::Node(refund.payer_signing_pubkey()),
93829382
reply_path,
93839383
};
93849384
let message = OffersMessage::Invoice(invoice.clone());

lightning/src/ln/offers_tests.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn prefers_non_tor_nodes_in_blinded_paths() {
305305
.create_offer_builder(None).unwrap()
306306
.amount_msats(10_000_000)
307307
.build().unwrap();
308-
assert_ne!(offer.signing_pubkey(), Some(bob_id));
308+
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
309309
assert!(!offer.paths().is_empty());
310310
for path in offer.paths() {
311311
let introduction_node_id = resolve_introduction_node(david, &path);
@@ -321,7 +321,7 @@ fn prefers_non_tor_nodes_in_blinded_paths() {
321321
.create_offer_builder(None).unwrap()
322322
.amount_msats(10_000_000)
323323
.build().unwrap();
324-
assert_ne!(offer.signing_pubkey(), Some(bob_id));
324+
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
325325
assert!(!offer.paths().is_empty());
326326
for path in offer.paths() {
327327
let introduction_node_id = resolve_introduction_node(david, &path);
@@ -372,7 +372,7 @@ fn prefers_more_connected_nodes_in_blinded_paths() {
372372
.create_offer_builder(None).unwrap()
373373
.amount_msats(10_000_000)
374374
.build().unwrap();
375-
assert_ne!(offer.signing_pubkey(), Some(bob_id));
375+
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
376376
assert!(!offer.paths().is_empty());
377377
for path in offer.paths() {
378378
let introduction_node_id = resolve_introduction_node(david, &path);
@@ -541,7 +541,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
541541
.unwrap()
542542
.amount_msats(10_000_000)
543543
.build().unwrap();
544-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
544+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
545545
assert!(!offer.paths().is_empty());
546546
for path in offer.paths() {
547547
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -566,13 +566,13 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
566566
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
567567
offer_id: offer.id(),
568568
invoice_request: InvoiceRequestFields {
569-
payer_id: invoice_request.payer_id(),
569+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
570570
quantity: None,
571571
payer_note_truncated: None,
572572
},
573573
});
574574
assert_eq!(invoice_request.amount_msats(), None);
575-
assert_ne!(invoice_request.payer_id(), david_id);
575+
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
576576
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
577577

578578
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
@@ -651,7 +651,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
651651
.build().unwrap();
652652
assert_eq!(refund.amount_msats(), 10_000_000);
653653
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
654-
assert_ne!(refund.payer_id(), david_id);
654+
assert_ne!(refund.payer_signing_pubkey(), david_id);
655655
assert!(!refund.paths().is_empty());
656656
for path in refund.paths() {
657657
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
@@ -709,7 +709,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
709709
.create_offer_builder(None).unwrap()
710710
.amount_msats(10_000_000)
711711
.build().unwrap();
712-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
712+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
713713
assert!(!offer.paths().is_empty());
714714
for path in offer.paths() {
715715
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
@@ -726,13 +726,13 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
726726
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
727727
offer_id: offer.id(),
728728
invoice_request: InvoiceRequestFields {
729-
payer_id: invoice_request.payer_id(),
729+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
730730
quantity: None,
731731
payer_note_truncated: None,
732732
},
733733
});
734734
assert_eq!(invoice_request.amount_msats(), None);
735-
assert_ne!(invoice_request.payer_id(), bob_id);
735+
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
736736
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(bob_id));
737737

738738
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
@@ -779,7 +779,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
779779
.build().unwrap();
780780
assert_eq!(refund.amount_msats(), 10_000_000);
781781
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
782-
assert_ne!(refund.payer_id(), bob_id);
782+
assert_ne!(refund.payer_signing_pubkey(), bob_id);
783783
assert!(!refund.paths().is_empty());
784784
for path in refund.paths() {
785785
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -832,7 +832,7 @@ fn pays_for_offer_without_blinded_paths() {
832832
.clear_paths()
833833
.amount_msats(10_000_000)
834834
.build().unwrap();
835-
assert_eq!(offer.signing_pubkey(), Some(alice_id));
835+
assert_eq!(offer.issuer_signing_pubkey(), Some(alice_id));
836836
assert!(offer.paths().is_empty());
837837

838838
let payment_id = PaymentId([1; 32]);
@@ -846,7 +846,7 @@ fn pays_for_offer_without_blinded_paths() {
846846
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
847847
offer_id: offer.id(),
848848
invoice_request: InvoiceRequestFields {
849-
payer_id: invoice_request.payer_id(),
849+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
850850
quantity: None,
851851
payer_note_truncated: None,
852852
},
@@ -886,7 +886,7 @@ fn pays_for_refund_without_blinded_paths() {
886886
.unwrap()
887887
.clear_paths()
888888
.build().unwrap();
889-
assert_eq!(refund.payer_id(), bob_id);
889+
assert_eq!(refund.payer_signing_pubkey(), bob_id);
890890
assert!(refund.paths().is_empty());
891891
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
892892

@@ -955,7 +955,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
955955
.unwrap()
956956
.amount_msats(10_000_000)
957957
.build().unwrap();
958-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
958+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
959959
assert!(!offer.paths().is_empty());
960960
for path in offer.paths() {
961961
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -1040,7 +1040,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10401040
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
10411041
.unwrap()
10421042
.build().unwrap();
1043-
assert_ne!(refund.payer_id(), alice_id);
1043+
assert_ne!(refund.payer_signing_pubkey(), alice_id);
10441044
for path in refund.paths() {
10451045
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
10461046
}
@@ -1090,7 +1090,7 @@ fn creates_and_pays_for_offer_with_retry() {
10901090
.create_offer_builder(None).unwrap()
10911091
.amount_msats(10_000_000)
10921092
.build().unwrap();
1093-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
1093+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
10941094
assert!(!offer.paths().is_empty());
10951095
for path in offer.paths() {
10961096
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
@@ -1112,13 +1112,13 @@ fn creates_and_pays_for_offer_with_retry() {
11121112
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
11131113
offer_id: offer.id(),
11141114
invoice_request: InvoiceRequestFields {
1115-
payer_id: invoice_request.payer_id(),
1115+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
11161116
quantity: None,
11171117
payer_note_truncated: None,
11181118
},
11191119
});
11201120
assert_eq!(invoice_request.amount_msats(), None);
1121-
assert_ne!(invoice_request.payer_id(), bob_id);
1121+
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
11221122
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(bob_id));
11231123
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
11241124
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
@@ -1176,7 +1176,7 @@ fn pays_bolt12_invoice_asynchronously() {
11761176
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
11771177
offer_id: offer.id(),
11781178
invoice_request: InvoiceRequestFields {
1179-
payer_id: invoice_request.payer_id(),
1179+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
11801180
quantity: None,
11811181
payer_note_truncated: None,
11821182
},
@@ -1248,7 +1248,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
12481248
.create_offer_builder(None).unwrap()
12491249
.amount_msats(10_000_000)
12501250
.build().unwrap();
1251-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
1251+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
12521252
assert!(!offer.paths().is_empty());
12531253
for path in offer.paths() {
12541254
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -1265,12 +1265,12 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
12651265
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
12661266
offer_id: offer.id(),
12671267
invoice_request: InvoiceRequestFields {
1268-
payer_id: invoice_request.payer_id(),
1268+
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
12691269
quantity: None,
12701270
payer_note_truncated: None,
12711271
},
12721272
});
1273-
assert_ne!(invoice_request.payer_id(), bob_id);
1273+
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
12741274
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(alice_id));
12751275

12761276
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
@@ -1315,7 +1315,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
13151315
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
13161316
.unwrap()
13171317
.build().unwrap();
1318-
assert_ne!(refund.payer_id(), bob_id);
1318+
assert_ne!(refund.payer_signing_pubkey(), bob_id);
13191319
assert!(!refund.paths().is_empty());
13201320
for path in refund.paths() {
13211321
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
@@ -1379,7 +1379,7 @@ fn fails_authentication_when_handling_invoice_request() {
13791379
.amount_msats(10_000_000)
13801380
.build().unwrap();
13811381
assert_eq!(offer.metadata(), None);
1382-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
1382+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
13831383
assert!(!offer.paths().is_empty());
13841384
for path in offer.paths() {
13851385
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -1411,7 +1411,7 @@ fn fails_authentication_when_handling_invoice_request() {
14111411

14121412
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
14131413
assert_eq!(invoice_request.amount_msats(), None);
1414-
assert_ne!(invoice_request.payer_id(), david_id);
1414+
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
14151415
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
14161416

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

14421442
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
14431443
assert_eq!(invoice_request.amount_msats(), None);
1444-
assert_ne!(invoice_request.payer_id(), david_id);
1444+
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
14451445
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
14461446

14471447
assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None);
@@ -1490,7 +1490,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
14901490
.unwrap()
14911491
.amount_msats(10_000_000)
14921492
.build().unwrap();
1493-
assert_ne!(offer.signing_pubkey(), Some(alice_id));
1493+
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
14941494
assert!(!offer.paths().is_empty());
14951495
for path in offer.paths() {
14961496
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -1543,7 +1543,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
15431543

15441544
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
15451545
assert_eq!(invoice_request.amount_msats(), None);
1546-
assert_ne!(invoice_request.payer_id(), david_id);
1546+
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
15471547
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
15481548

15491549
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
@@ -1598,7 +1598,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
15981598
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
15991599
.unwrap()
16001600
.build().unwrap();
1601-
assert_ne!(refund.payer_id(), david_id);
1601+
assert_ne!(refund.payer_signing_pubkey(), david_id);
16021602
assert!(!refund.paths().is_empty());
16031603
for path in refund.paths() {
16041604
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
@@ -1632,7 +1632,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
16321632
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
16331633
.unwrap()
16341634
.build().unwrap();
1635-
assert_ne!(refund.payer_id(), david_id);
1635+
assert_ne!(refund.payer_signing_pubkey(), david_id);
16361636
assert!(!refund.paths().is_empty());
16371637
for path in refund.paths() {
16381638
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));

0 commit comments

Comments
 (0)