Skip to content

Commit 2782110

Browse files
committed
Rename Offer::signing_pubkey to Offer::issuer_signing_pubkey
The spec was recently changed to use offer_issuer_id instead of offer_node_id. LDK always used signing_pubkey to avoid confusion with a node_id. Rename it to issuer_signing_pubkey now as InvoiceRequest and Bolt12Invoice will have similarly named methods in upcoming commits.
1 parent 6662c5c commit 2782110

File tree

9 files changed

+121
-114
lines changed

9 files changed

+121
-114
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -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(())

lightning/src/ln/offers_tests.rs

Lines changed: 11 additions & 11 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));
@@ -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));
@@ -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]);
@@ -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));
@@ -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));
@@ -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));
@@ -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));
@@ -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));

lightning/src/offers/invoice.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
13351335

13361336
check_invoice_signing_pubkey(&fields.signing_pubkey, &offer_tlv_stream)?;
13371337

1338-
if offer_tlv_stream.node_id.is_none() && offer_tlv_stream.paths.is_none() {
1338+
if offer_tlv_stream.issuer_id.is_none() && offer_tlv_stream.paths.is_none() {
13391339
let refund = RefundContents::try_from(
13401340
(payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream)
13411341
)?;
@@ -1373,9 +1373,9 @@ pub(super) fn construct_payment_paths(
13731373
pub(super) fn check_invoice_signing_pubkey(
13741374
invoice_signing_pubkey: &PublicKey, offer_tlv_stream: &OfferTlvStream
13751375
) -> Result<(), Bolt12SemanticError> {
1376-
match (&offer_tlv_stream.node_id, &offer_tlv_stream.paths) {
1377-
(Some(expected_signing_pubkey), _) => {
1378-
if invoice_signing_pubkey != expected_signing_pubkey {
1376+
match (&offer_tlv_stream.issuer_id, &offer_tlv_stream.paths) {
1377+
(Some(issuer_signing_pubkey), _) => {
1378+
if invoice_signing_pubkey != issuer_signing_pubkey {
13791379
return Err(Bolt12SemanticError::InvalidSigningPubkey);
13801380
}
13811381
},
@@ -1561,7 +1561,7 @@ mod tests {
15611561
paths: None,
15621562
issuer: None,
15631563
quantity_max: None,
1564-
node_id: Some(&recipient_pubkey()),
1564+
issuer_id: Some(&recipient_pubkey()),
15651565
},
15661566
InvoiceRequestTlvStreamRef {
15671567
chain: None,
@@ -1654,7 +1654,7 @@ mod tests {
16541654
paths: None,
16551655
issuer: None,
16561656
quantity_max: None,
1657-
node_id: None,
1657+
issuer_id: None,
16581658
},
16591659
InvoiceRequestTlvStreamRef {
16601660
chain: None,
@@ -1791,7 +1791,7 @@ mod tests {
17911791

17921792
let offer = OfferBuilder::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx)
17931793
.amount_msats(1000)
1794-
// Omit the path so that node_id is used for the signing pubkey instead of deriving
1794+
// Omit the path so that node_id is used for the signing pubkey instead of deriving it
17951795
.build().unwrap();
17961796
let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
17971797
.build().unwrap()
@@ -2359,7 +2359,7 @@ mod tests {
23592359
};
23602360

23612361
let invoice = OfferBuilder::new(recipient_pubkey())
2362-
.clear_signing_pubkey()
2362+
.clear_issuer_signing_pubkey()
23632363
.amount_msats(1000)
23642364
.path(paths[0].clone())
23652365
.path(paths[1].clone())
@@ -2381,7 +2381,7 @@ mod tests {
23812381
}
23822382

23832383
let invoice = OfferBuilder::new(recipient_pubkey())
2384-
.clear_signing_pubkey()
2384+
.clear_issuer_signing_pubkey()
23852385
.amount_msats(1000)
23862386
.path(paths[0].clone())
23872387
.path(paths[1].clone())

lightning/src/offers/invoice_request.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ macro_rules! invoice_request_respond_with_explicit_signing_pubkey_methods { (
728728
/// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
729729
/// must contain one or more elements ordered from most-preferred to least-preferred, if there's
730730
/// a preference. Note, however, that any privacy is lost if a public node id was used for
731-
/// [`Offer::signing_pubkey`].
731+
/// [`Offer::issuer_signing_pubkey`].
732732
///
733733
/// Errors if the request contains unknown required features.
734734
///
@@ -749,9 +749,9 @@ macro_rules! invoice_request_respond_with_explicit_signing_pubkey_methods { (
749749
return Err(Bolt12SemanticError::UnknownRequiredFeatures);
750750
}
751751

752-
let signing_pubkey = match $contents.contents.inner.offer.signing_pubkey() {
752+
let signing_pubkey = match $contents.contents.inner.offer.issuer_signing_pubkey() {
753753
Some(signing_pubkey) => signing_pubkey,
754-
None => return Err(Bolt12SemanticError::MissingSigningPubkey),
754+
None => return Err(Bolt12SemanticError::MissingIssuerSigningPubkey),
755755
};
756756

757757
<$builder>::for_offer(&$contents, payment_paths, created_at, payment_hash, signing_pubkey)
@@ -763,7 +763,7 @@ macro_rules! invoice_request_respond_with_explicit_signing_pubkey_methods { (
763763
&$self, payment_paths: Vec<BlindedPaymentPath>, payment_hash: PaymentHash,
764764
created_at: core::time::Duration, signing_pubkey: PublicKey
765765
) -> Result<$builder, Bolt12SemanticError> {
766-
debug_assert!($contents.contents.inner.offer.signing_pubkey().is_none());
766+
debug_assert!($contents.contents.inner.offer.issuer_signing_pubkey().is_none());
767767

768768
if $contents.invoice_request_features().requires_unknown_bits() {
769769
return Err(Bolt12SemanticError::UnknownRequiredFeatures);
@@ -914,9 +914,9 @@ macro_rules! invoice_request_respond_with_derived_signing_pubkey_methods { (
914914
Some(keys) => keys,
915915
};
916916

917-
match $contents.contents.inner.offer.signing_pubkey() {
917+
match $contents.contents.inner.offer.issuer_signing_pubkey() {
918918
Some(signing_pubkey) => debug_assert_eq!(signing_pubkey, keys.public_key()),
919-
None => return Err(Bolt12SemanticError::MissingSigningPubkey),
919+
None => return Err(Bolt12SemanticError::MissingIssuerSigningPubkey),
920920
}
921921

922922
<$builder>::for_offer_using_keys(
@@ -1297,7 +1297,7 @@ mod tests {
12971297
assert_eq!(unsigned_invoice_request.paths(), &[]);
12981298
assert_eq!(unsigned_invoice_request.issuer(), None);
12991299
assert_eq!(unsigned_invoice_request.supported_quantity(), Quantity::One);
1300-
assert_eq!(unsigned_invoice_request.signing_pubkey(), Some(recipient_pubkey()));
1300+
assert_eq!(unsigned_invoice_request.issuer_signing_pubkey(), Some(recipient_pubkey()));
13011301
assert_eq!(unsigned_invoice_request.chain(), ChainHash::using_genesis_block(Network::Bitcoin));
13021302
assert_eq!(unsigned_invoice_request.amount_msats(), None);
13031303
assert_eq!(unsigned_invoice_request.invoice_request_features(), &InvoiceRequestFeatures::empty());
@@ -1329,7 +1329,7 @@ mod tests {
13291329
assert_eq!(invoice_request.paths(), &[]);
13301330
assert_eq!(invoice_request.issuer(), None);
13311331
assert_eq!(invoice_request.supported_quantity(), Quantity::One);
1332-
assert_eq!(invoice_request.signing_pubkey(), Some(recipient_pubkey()));
1332+
assert_eq!(invoice_request.issuer_signing_pubkey(), Some(recipient_pubkey()));
13331333
assert_eq!(invoice_request.chain(), ChainHash::using_genesis_block(Network::Bitcoin));
13341334
assert_eq!(invoice_request.amount_msats(), None);
13351335
assert_eq!(invoice_request.invoice_request_features(), &InvoiceRequestFeatures::empty());
@@ -1355,7 +1355,7 @@ mod tests {
13551355
paths: None,
13561356
issuer: None,
13571357
quantity_max: None,
1358-
node_id: Some(&recipient_pubkey()),
1358+
issuer_id: Some(&recipient_pubkey()),
13591359
},
13601360
InvoiceRequestTlvStreamRef {
13611361
chain: None,
@@ -2234,22 +2234,22 @@ mod tests {
22342234
}
22352235

22362236
#[test]
2237-
fn fails_parsing_invoice_request_without_node_id() {
2237+
fn fails_parsing_invoice_request_without_issuer_id() {
22382238
let offer = OfferBuilder::new(recipient_pubkey())
22392239
.amount_msats(1000)
22402240
.build().unwrap();
22412241
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
22422242
.build().unwrap();
22432243
let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
2244-
tlv_stream.1.node_id = None;
2244+
tlv_stream.1.issuer_id = None;
22452245

22462246
let mut buffer = Vec::new();
22472247
tlv_stream.write(&mut buffer).unwrap();
22482248

22492249
match InvoiceRequest::try_from(buffer) {
22502250
Ok(_) => panic!("expected error"),
22512251
Err(e) => {
2252-
assert_eq!(e, Bolt12ParseError::InvalidSemantics(Bolt12SemanticError::MissingSigningPubkey));
2252+
assert_eq!(e, Bolt12ParseError::InvalidSemantics(Bolt12SemanticError::MissingIssuerSigningPubkey));
22532253
},
22542254
}
22552255
}
@@ -2334,7 +2334,7 @@ mod tests {
23342334
.amount_msats(1000)
23352335
.supported_quantity(Quantity::Unbounded)
23362336
.build().unwrap();
2337-
assert_eq!(offer.signing_pubkey(), Some(node_id));
2337+
assert_eq!(offer.issuer_signing_pubkey(), Some(node_id));
23382338

23392339
let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
23402340
.chain(Network::Testnet).unwrap()

lightning/src/offers/nonce.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use crate::prelude::*;
2020

2121
/// A 128-bit number used only once.
2222
///
23-
/// Needed when constructing [`Offer::metadata`] and deriving [`Offer::signing_pubkey`] from
23+
/// Needed when constructing [`Offer::metadata`] and deriving [`Offer::issuer_signing_pubkey`] from
2424
/// [`ExpandedKey`]. Must not be reused for any other derivation without first hashing.
2525
///
2626
/// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
27-
/// [`Offer::signing_pubkey`]: crate::offers::offer::Offer::signing_pubkey
27+
/// [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey
2828
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
2929
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
3030
pub struct Nonce(pub(crate) [u8; Self::LENGTH]);

0 commit comments

Comments
 (0)