Skip to content

Commit b670d90

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 76a1e6b commit b670d90

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
@@ -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)
@@ -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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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));
@@ -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));
@@ -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

@@ -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
}
@@ -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));
@@ -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));

lightning/src/offers/invoice.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,10 @@ impl Readable for InvoiceRequest {
10541054
/// Valid type range for invoice_request TLV records.
10551055
pub(super) const INVOICE_REQUEST_TYPES: core::ops::Range<u64> = 80..160;
10561056

1057-
/// TLV record type for [`InvoiceRequest::payer_signing_pubkey`] and [`Refund::payer_id`].
1057+
/// TLV record type for [`InvoiceRequest::payer_signing_pubkey`] and
1058+
/// [`Refund::payer_signing_pubkey`].
10581059
///
1059-
/// [`Refund::payer_id`]: crate::offers::refund::Refund::payer_id
1060+
/// [`Refund::payer_signing_pubkey`]: crate::offers::refund::Refund::payer_signing_pubkey
10601061
pub(super) const INVOICE_REQUEST_PAYER_ID_TYPE: u64 = 88;
10611062

10621063
// 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<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)