Skip to content

Commit eb43a3c

Browse files
committed
Rename Refund::payer_id
For consistency with Offer::issuer_signing_pubkey, rename Refund::payer_id to use "signing_pubkey" instead of "id".
1 parent caa25c0 commit eb43a3c

File tree

6 files changed

+43
-41
lines changed

6 files changed

+43
-41
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8891,7 +8891,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
88918891
.and_then(|paths| paths.into_iter().next().ok_or(()))
88928892
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
88938893

8894-
let builder = RefundBuilder::deriving_payer_id(
8894+
let builder = RefundBuilder::deriving_signing_pubkey(
88958895
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
88968896
)?
88978897
.chain_hash($self.chain_hash)
@@ -9075,9 +9075,9 @@ where
90759075
/// # Limitations
90769076
///
90779077
/// Requires a direct connection to an introduction node in [`Refund::paths`] or to
9078-
/// [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
9079-
/// node meeting the aforementioned criteria, but there's no guarantee that they will be
9080-
/// received and no retries will be made.
9078+
/// [`Refund::payer_signing_pubkey`], if empty. This request is best effort; an invoice will be
9079+
/// sent to each node meeting the aforementioned criteria, but there's no guarantee that they
9080+
/// will be received and no retries will be made.
90819081
///
90829082
/// # Errors
90839083
///
@@ -9137,7 +9137,7 @@ where
91379137
for reply_path in reply_paths {
91389138
let message = new_pending_onion_message(
91399139
OffersMessage::Invoice(invoice.clone()),
9140-
Destination::Node(refund.payer_id()),
9140+
Destination::Node(refund.payer_signing_pubkey()),
91419141
Some(reply_path),
91429142
);
91439143
pending_offers_messages.push(message);

lightning/src/ln/offers_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
627627
.build().unwrap();
628628
assert_eq!(refund.amount_msats(), 10_000_000);
629629
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
630-
assert_ne!(refund.payer_id(), david_id);
630+
assert_ne!(refund.payer_signing_pubkey(), david_id);
631631
assert!(!refund.paths().is_empty());
632632
for path in refund.paths() {
633633
assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id));
@@ -752,7 +752,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
752752
.build().unwrap();
753753
assert_eq!(refund.amount_msats(), 10_000_000);
754754
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
755-
assert_ne!(refund.payer_id(), bob_id);
755+
assert_ne!(refund.payer_signing_pubkey(), bob_id);
756756
assert!(!refund.paths().is_empty());
757757
for path in refund.paths() {
758758
assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id));
@@ -858,7 +858,7 @@ fn pays_for_refund_without_blinded_paths() {
858858
.unwrap()
859859
.clear_paths()
860860
.build().unwrap();
861-
assert_eq!(refund.payer_id(), bob_id);
861+
assert_eq!(refund.payer_signing_pubkey(), bob_id);
862862
assert!(refund.paths().is_empty());
863863
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
864864

@@ -1012,7 +1012,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10121012
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
10131013
.unwrap()
10141014
.build().unwrap();
1015-
assert_ne!(refund.payer_id(), alice_id);
1015+
assert_ne!(refund.payer_signing_pubkey(), alice_id);
10161016
for path in refund.paths() {
10171017
assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id));
10181018
}
@@ -1214,7 +1214,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
12141214
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
12151215
.unwrap()
12161216
.build().unwrap();
1217-
assert_ne!(refund.payer_id(), bob_id);
1217+
assert_ne!(refund.payer_signing_pubkey(), bob_id);
12181218
assert!(!refund.paths().is_empty());
12191219
for path in refund.paths() {
12201220
assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id));
@@ -1506,7 +1506,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
15061506
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
15071507
.unwrap()
15081508
.build().unwrap();
1509-
assert_ne!(refund.payer_id(), david_id);
1509+
assert_ne!(refund.payer_signing_pubkey(), david_id);
15101510
assert!(!refund.paths().is_empty());
15111511
for path in refund.paths() {
15121512
assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id));
@@ -1543,7 +1543,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
15431543
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
15441544
.unwrap()
15451545
.build().unwrap();
1546-
assert_ne!(refund.payer_id(), david_id);
1546+
assert_ne!(refund.payer_signing_pubkey(), david_id);
15471547
assert!(!refund.paths().is_empty());
15481548
for path in refund.paths() {
15491549
assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id));

lightning/src/offers/invoice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,8 @@ impl InvoiceContents {
10101010

10111011
fn payer_signing_pubkey(&self) -> PublicKey {
10121012
match self {
1013-
InvoiceContents::ForRefund { refund, .. } => refund.payer_id(),
10141013
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.payer_signing_pubkey(),
1014+
InvoiceContents::ForRefund { refund, .. } => refund.payer_signing_pubkey(),
10151015
}
10161016
}
10171017

lightning/src/offers/invoice_request.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,10 @@ impl Writeable for InvoiceRequestContents {
10421042
/// Valid type range for invoice_request TLV records.
10431043
pub(super) const INVOICE_REQUEST_TYPES: core::ops::Range<u64> = 80..160;
10441044

1045-
/// TLV record type for [`InvoiceRequest::payer_signing_pubkey`] and [`Refund::payer_id`].
1045+
/// TLV record type for [`InvoiceRequest::payer_signing_pubkey`] and
1046+
/// [`Refund::payer_signing_pubkey`].
10461047
///
1047-
/// [`Refund::payer_id`]: crate::offers::refund::Refund::payer_id
1048+
/// [`Refund::payer_signing_pubkey`]: crate::offers::refund::Refund::payer_signing_pubkey
10481049
pub(super) const INVOICE_REQUEST_PAYER_ID_TYPE: u64 = 88;
10491050

10501051
// This TLV stream is used for both InvoiceRequest and Refund, but not all TLV records are valid for

lightning/src/offers/payer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ use crate::util::ser::WithoutLength;
1616
use crate::prelude::*;
1717

1818
/// An unpredictable sequence of bytes typically containing information needed to derive
19-
/// [`InvoiceRequest::payer_signing_pubkey`].
19+
/// [`InvoiceRequest::payer_signing_pubkey`] and [`Refund::payer_signing_pubkey`].
2020
///
2121
/// [`InvoiceRequest::payer_signing_pubkey`]: crate::offers::invoice_request::InvoiceRequest::payer_signing_pubkey
22+
/// [`Refund::payer_signing_pubkey`]: crate::offers::refund::Refund::payer_signing_pubkey
2223
#[derive(Clone, Debug)]
2324
#[cfg_attr(test, derive(PartialEq))]
2425
pub(super) struct PayerContents(pub Metadata);

lightning/src/offers/refund.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ pub struct RefundMaybeWithDerivedMetadataBuilder<'a> {
150150
}
151151

152152
macro_rules! refund_explicit_metadata_builder_methods { () => {
153-
/// Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to
154-
/// send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey.
153+
/// Creates a new builder for a refund using the `signing_pubkey` for the public node id to send
154+
/// to if no [`Refund::paths`] are set. Otherwise, `signing_pubkey` may be a transient pubkey.
155155
///
156156
/// Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`],
157157
/// and [`Refund::amount_msats`].
@@ -164,7 +164,7 @@ macro_rules! refund_explicit_metadata_builder_methods { () => {
164164
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
165165
/// [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder
166166
pub fn new(
167-
metadata: Vec<u8>, payer_id: PublicKey, amount_msats: u64
167+
metadata: Vec<u8>, signing_pubkey: PublicKey, amount_msats: u64
168168
) -> Result<Self, Bolt12SemanticError> {
169169
if amount_msats > MAX_VALUE_MSAT {
170170
return Err(Bolt12SemanticError::InvalidAmount);
@@ -175,7 +175,7 @@ macro_rules! refund_explicit_metadata_builder_methods { () => {
175175
refund: RefundContents {
176176
payer: PayerContents(metadata), description: String::new(), absolute_expiry: None,
177177
issuer: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
178-
quantity: None, payer_id, payer_note: None, paths: None,
178+
quantity: None, payer_signing_pubkey: signing_pubkey, payer_note: None, paths: None,
179179
},
180180
secp_ctx: None,
181181
})
@@ -202,7 +202,7 @@ macro_rules! refund_builder_methods { (
202202
/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
203203
/// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data
204204
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
205-
pub fn deriving_payer_id(
205+
pub fn deriving_signing_pubkey(
206206
node_id: PublicKey, expanded_key: &ExpandedKey, nonce: Nonce,
207207
secp_ctx: &'a Secp256k1<$secp_context>, amount_msats: u64, payment_id: PaymentId
208208
) -> Result<Self, Bolt12SemanticError> {
@@ -217,7 +217,7 @@ macro_rules! refund_builder_methods { (
217217
refund: RefundContents {
218218
payer: PayerContents(metadata), description: String::new(), absolute_expiry: None,
219219
issuer: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
220-
quantity: None, payer_id: node_id, payer_note: None, paths: None,
220+
quantity: None, payer_signing_pubkey: node_id, payer_note: None, paths: None,
221221
},
222222
secp_ctx: Some(secp_ctx),
223223
})
@@ -249,7 +249,7 @@ macro_rules! refund_builder_methods { (
249249
}
250250

251251
/// Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected
252-
/// by private channels or if [`Refund::payer_id`] is not a public node id.
252+
/// by private channels or if [`Refund::payer_signing_pubkey`] is not a public node id.
253253
///
254254
/// Successive calls to this method will add another blinded path. Caller is responsible for not
255255
/// adding duplicate paths.
@@ -324,7 +324,7 @@ macro_rules! refund_builder_methods { (
324324
metadata.derive_from(iv_bytes, tlv_stream, $self.secp_ctx);
325325
metadata = derived_metadata;
326326
if let Some(keys) = keys {
327-
$self.refund.payer_id = keys.public_key();
327+
$self.refund.payer_signing_pubkey = keys.public_key();
328328
}
329329

330330
$self.refund.payer.0 = metadata;
@@ -434,7 +434,7 @@ pub(super) struct RefundContents {
434434
amount_msats: u64,
435435
features: InvoiceRequestFeatures,
436436
quantity: Option<u64>,
437-
payer_id: PublicKey,
437+
payer_signing_pubkey: PublicKey,
438438
payer_note: Option<String>,
439439
paths: Option<Vec<BlindedPath>>,
440440
}
@@ -477,9 +477,9 @@ impl Refund {
477477
}
478478

479479
/// An unpredictable series of bytes, typically containing information about the derivation of
480-
/// [`payer_id`].
480+
/// [`payer_signing_pubkey`].
481481
///
482-
/// [`payer_id`]: Self::payer_id
482+
/// [`payer_signing_pubkey`]: Self::payer_signing_pubkey
483483
pub fn payer_metadata(&self) -> &[u8] {
484484
self.contents.metadata()
485485
}
@@ -510,8 +510,8 @@ impl Refund {
510510
/// transient pubkey.
511511
///
512512
/// [`paths`]: Self::paths
513-
pub fn payer_id(&self) -> PublicKey {
514-
self.contents.payer_id()
513+
pub fn payer_signing_pubkey(&self) -> PublicKey {
514+
self.contents.payer_signing_pubkey()
515515
}
516516

517517
/// Payer provided note to include in the invoice.
@@ -727,8 +727,8 @@ impl RefundContents {
727727
/// transient pubkey.
728728
///
729729
/// [`paths`]: Self::paths
730-
pub fn payer_id(&self) -> PublicKey {
731-
self.payer_id
730+
pub fn payer_signing_pubkey(&self) -> PublicKey {
731+
self.payer_signing_pubkey
732732
}
733733

734734
/// Payer provided note to include in the invoice.
@@ -765,7 +765,7 @@ impl RefundContents {
765765
amount: Some(self.amount_msats),
766766
features,
767767
quantity: self.quantity,
768-
payer_id: Some(&self.payer_id),
768+
payer_id: Some(&self.payer_signing_pubkey),
769769
payer_note: self.payer_note.as_ref(),
770770
paths: self.paths.as_ref(),
771771
};
@@ -901,14 +901,14 @@ impl TryFrom<RefundTlvStream> for RefundContents {
901901

902902
let features = features.unwrap_or_else(InvoiceRequestFeatures::empty);
903903

904-
let payer_id = match payer_id {
904+
let payer_signing_pubkey = match payer_id {
905905
None => return Err(Bolt12SemanticError::MissingPayerSigningPubkey),
906906
Some(payer_id) => payer_id,
907907
};
908908

909909
Ok(RefundContents {
910910
payer, description, absolute_expiry, issuer, chain, amount_msats, features, quantity,
911-
payer_id, payer_note, paths,
911+
payer_signing_pubkey, payer_note, paths,
912912
})
913913
}
914914
}
@@ -984,7 +984,7 @@ mod tests {
984984
assert_eq!(refund.chain(), ChainHash::using_genesis_block(Network::Bitcoin));
985985
assert_eq!(refund.amount_msats(), 1000);
986986
assert_eq!(refund.features(), &InvoiceRequestFeatures::empty());
987-
assert_eq!(refund.payer_id(), payer_pubkey());
987+
assert_eq!(refund.payer_signing_pubkey(), payer_pubkey());
988988
assert_eq!(refund.payer_note(), None);
989989

990990
assert_eq!(
@@ -1039,10 +1039,10 @@ mod tests {
10391039
let payment_id = PaymentId([1; 32]);
10401040

10411041
let refund = RefundBuilder
1042-
::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
1042+
::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
10431043
.unwrap()
10441044
.build().unwrap();
1045-
assert_eq!(refund.payer_id(), node_id);
1045+
assert_eq!(refund.payer_signing_pubkey(), node_id);
10461046

10471047
// Fails verification with altered fields
10481048
let invoice = refund
@@ -1088,7 +1088,7 @@ mod tests {
10881088
}
10891089

10901090
#[test]
1091-
fn builds_refund_with_derived_payer_id() {
1091+
fn builds_refund_with_derived_signing_pubkey() {
10921092
let node_id = payer_pubkey();
10931093
let expanded_key = ExpandedKey::new(&KeyMaterial([42; 32]));
10941094
let entropy = FixedEntropy {};
@@ -1106,11 +1106,11 @@ mod tests {
11061106
};
11071107

11081108
let refund = RefundBuilder
1109-
::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
1109+
::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
11101110
.unwrap()
11111111
.path(blinded_path)
11121112
.build().unwrap();
1113-
assert_ne!(refund.payer_id(), node_id);
1113+
assert_ne!(refund.payer_signing_pubkey(), node_id);
11141114

11151115
let invoice = refund
11161116
.respond_with_no_std(payment_paths(), payment_hash(), recipient_pubkey(), now())
@@ -1213,7 +1213,7 @@ mod tests {
12131213
.build()
12141214
.unwrap();
12151215
let (_, _, invoice_request_tlv_stream) = refund.as_tlv_stream();
1216-
assert_eq!(refund.payer_id(), pubkey(42));
1216+
assert_eq!(refund.payer_signing_pubkey(), pubkey(42));
12171217
assert_eq!(refund.paths(), paths.as_slice());
12181218
assert_ne!(pubkey(42), pubkey(44));
12191219
assert_eq!(invoice_request_tlv_stream.payer_id, Some(&pubkey(42)));

0 commit comments

Comments
 (0)