Skip to content

Commit ce74ceb

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 1a1a930 commit ce74ceb

File tree

6 files changed

+43
-41
lines changed

6 files changed

+43
-41
lines changed

lightning/src/ln/channelmanager.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8954,7 +8954,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
89548954
.and_then(|paths| paths.into_iter().next().ok_or(()))
89558955
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
89568956

8957-
let builder = RefundBuilder::deriving_payer_id(
8957+
let builder = RefundBuilder::deriving_signing_pubkey(
89588958
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
89598959
)?
89608960
.chain_hash($self.chain_hash)
@@ -9139,9 +9139,9 @@ where
91399139
/// # Limitations
91409140
///
91419141
/// Requires a direct connection to an introduction node in [`Refund::paths`] or to
9142-
/// [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
9143-
/// node meeting the aforementioned criteria, but there's no guarantee that they will be
9144-
/// received and no retries will be made.
9142+
/// [`Refund::payer_signing_pubkey`], if empty. This request is best effort; an invoice will be
9143+
/// sent to each node meeting the aforementioned criteria, but there's no guarantee that they
9144+
/// will be received and no retries will be made.
91459145
///
91469146
/// # Errors
91479147
///
@@ -9200,7 +9200,7 @@ where
92009200
if refund.paths().is_empty() {
92019201
for reply_path in reply_paths {
92029202
let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
9203-
destination: Destination::Node(refund.payer_id()),
9203+
destination: Destination::Node(refund.payer_signing_pubkey()),
92049204
reply_path,
92059205
};
92069206
let message = OffersMessage::Invoice(invoice.clone());

lightning/src/ln/offers_tests.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
641641
.build().unwrap();
642642
assert_eq!(refund.amount_msats(), 10_000_000);
643643
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
644-
assert_ne!(refund.payer_id(), david_id);
644+
assert_ne!(refund.payer_signing_pubkey(), david_id);
645645
assert!(!refund.paths().is_empty());
646646
for path in refund.paths() {
647647
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
@@ -766,7 +766,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
766766
.build().unwrap();
767767
assert_eq!(refund.amount_msats(), 10_000_000);
768768
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
769-
assert_ne!(refund.payer_id(), bob_id);
769+
assert_ne!(refund.payer_signing_pubkey(), bob_id);
770770
assert!(!refund.paths().is_empty());
771771
for path in refund.paths() {
772772
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -872,7 +872,7 @@ fn pays_for_refund_without_blinded_paths() {
872872
.unwrap()
873873
.clear_paths()
874874
.build().unwrap();
875-
assert_eq!(refund.payer_id(), bob_id);
875+
assert_eq!(refund.payer_signing_pubkey(), bob_id);
876876
assert!(refund.paths().is_empty());
877877
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
878878

@@ -1026,7 +1026,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10261026
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
10271027
.unwrap()
10281028
.build().unwrap();
1029-
assert_ne!(refund.payer_id(), alice_id);
1029+
assert_ne!(refund.payer_signing_pubkey(), alice_id);
10301030
for path in refund.paths() {
10311031
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
10321032
}
@@ -1228,7 +1228,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
12281228
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
12291229
.unwrap()
12301230
.build().unwrap();
1231-
assert_ne!(refund.payer_id(), bob_id);
1231+
assert_ne!(refund.payer_signing_pubkey(), bob_id);
12321232
assert!(!refund.paths().is_empty());
12331233
for path in refund.paths() {
12341234
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
@@ -1511,7 +1511,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
15111511
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
15121512
.unwrap()
15131513
.build().unwrap();
1514-
assert_ne!(refund.payer_id(), david_id);
1514+
assert_ne!(refund.payer_signing_pubkey(), david_id);
15151515
assert!(!refund.paths().is_empty());
15161516
for path in refund.paths() {
15171517
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
@@ -1545,7 +1545,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
15451545
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
15461546
.unwrap()
15471547
.build().unwrap();
1548-
assert_ne!(refund.payer_id(), david_id);
1548+
assert_ne!(refund.payer_signing_pubkey(), david_id);
15491549
assert!(!refund.paths().is_empty());
15501550
for path in refund.paths() {
15511551
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));

lightning/src/offers/invoice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,8 @@ impl InvoiceContents {
10191019

10201020
fn payer_signing_pubkey(&self) -> PublicKey {
10211021
match self {
1022-
InvoiceContents::ForRefund { refund, .. } => refund.payer_id(),
10231022
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.payer_signing_pubkey(),
1023+
InvoiceContents::ForRefund { refund, .. } => refund.payer_signing_pubkey(),
10241024
}
10251025
}
10261026

lightning/src/offers/invoice_request.rs

+3-2
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

+2-1
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

+25-25
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<BlindedMessagePath>>,
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
}
@@ -985,7 +985,7 @@ mod tests {
985985
assert_eq!(refund.chain(), ChainHash::using_genesis_block(Network::Bitcoin));
986986
assert_eq!(refund.amount_msats(), 1000);
987987
assert_eq!(refund.features(), &InvoiceRequestFeatures::empty());
988-
assert_eq!(refund.payer_id(), payer_pubkey());
988+
assert_eq!(refund.payer_signing_pubkey(), payer_pubkey());
989989
assert_eq!(refund.payer_note(), None);
990990

991991
assert_eq!(
@@ -1040,10 +1040,10 @@ mod tests {
10401040
let payment_id = PaymentId([1; 32]);
10411041

10421042
let refund = RefundBuilder
1043-
::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
1043+
::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
10441044
.unwrap()
10451045
.build().unwrap();
1046-
assert_eq!(refund.payer_id(), node_id);
1046+
assert_eq!(refund.payer_signing_pubkey(), node_id);
10471047

10481048
// Fails verification with altered fields
10491049
let invoice = refund
@@ -1089,7 +1089,7 @@ mod tests {
10891089
}
10901090

10911091
#[test]
1092-
fn builds_refund_with_derived_payer_id() {
1092+
fn builds_refund_with_derived_signing_pubkey() {
10931093
let node_id = payer_pubkey();
10941094
let expanded_key = ExpandedKey::new(&KeyMaterial([42; 32]));
10951095
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())
@@ -1211,7 +1211,7 @@ mod tests {
12111211
.build()
12121212
.unwrap();
12131213
let (_, _, invoice_request_tlv_stream) = refund.as_tlv_stream();
1214-
assert_eq!(refund.payer_id(), pubkey(42));
1214+
assert_eq!(refund.payer_signing_pubkey(), pubkey(42));
12151215
assert_eq!(refund.paths(), paths.as_slice());
12161216
assert_ne!(pubkey(42), pubkey(44));
12171217
assert_eq!(invoice_request_tlv_stream.payer_id, Some(&pubkey(42)));

0 commit comments

Comments
 (0)