]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename Refund::payer_id
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 14 Aug 2024 20:36:18 +0000 (15:36 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Mon, 16 Sep 2024 18:56:47 +0000 (13:56 -0500)
For consistency with Offer::issuer_signing_pubkey, rename
Refund::payer_id to use "signing_pubkey" instead of "id".

lightning/src/ln/channelmanager.rs
lightning/src/ln/offers_tests.rs
lightning/src/offers/invoice.rs
lightning/src/offers/invoice_request.rs
lightning/src/offers/payer.rs
lightning/src/offers/refund.rs

index 77a8123438de312d79b5b4cc16588829eed51090..b87c2ebf3b7522b99482ffad4895906b1d851a93 100644 (file)
@@ -9115,7 +9115,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
                        .and_then(|paths| paths.into_iter().next().ok_or(()))
                        .map_err(|_| Bolt12SemanticError::MissingPaths)?;
 
-               let builder = RefundBuilder::deriving_payer_id(
+               let builder = RefundBuilder::deriving_signing_pubkey(
                        node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
                )?
                        .chain_hash($self.chain_hash)
@@ -9315,9 +9315,9 @@ where
        /// # Limitations
        ///
        /// Requires a direct connection to an introduction node in [`Refund::paths`] or to
-       /// [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
-       /// node meeting the aforementioned criteria, but there's no guarantee that they will be
-       /// received and no retries will be made.
+       /// [`Refund::payer_signing_pubkey`], if empty. This request is best effort; an invoice will be
+       /// sent to each node meeting the aforementioned criteria, but there's no guarantee that they
+       /// will be received and no retries will be made.
        ///
        /// # Errors
        ///
@@ -9378,7 +9378,7 @@ where
                                if refund.paths().is_empty() {
                                        for reply_path in reply_paths {
                                                let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
-                                                       destination: Destination::Node(refund.payer_id()),
+                                                       destination: Destination::Node(refund.payer_signing_pubkey()),
                                                        reply_path,
                                                };
                                                let message = OffersMessage::Invoice(invoice.clone());
index 3a04befe7d6d84332241139483bfba951fbc693d..b8e6fca5bb86753009e5f6aa72e7baeae2cbe0c5 100644 (file)
@@ -651,7 +651,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
                .build().unwrap();
        assert_eq!(refund.amount_msats(), 10_000_000);
        assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
-       assert_ne!(refund.payer_id(), david_id);
+       assert_ne!(refund.payer_signing_pubkey(), david_id);
        assert!(!refund.paths().is_empty());
        for path in refund.paths() {
                assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
@@ -779,7 +779,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
                .build().unwrap();
        assert_eq!(refund.amount_msats(), 10_000_000);
        assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
-       assert_ne!(refund.payer_id(), bob_id);
+       assert_ne!(refund.payer_signing_pubkey(), bob_id);
        assert!(!refund.paths().is_empty());
        for path in refund.paths() {
                assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
@@ -886,7 +886,7 @@ fn pays_for_refund_without_blinded_paths() {
                .unwrap()
                .clear_paths()
                .build().unwrap();
-       assert_eq!(refund.payer_id(), bob_id);
+       assert_eq!(refund.payer_signing_pubkey(), bob_id);
        assert!(refund.paths().is_empty());
        expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
 
@@ -1040,7 +1040,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
                .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
                .unwrap()
                .build().unwrap();
-       assert_ne!(refund.payer_id(), alice_id);
+       assert_ne!(refund.payer_signing_pubkey(), alice_id);
        for path in refund.paths() {
                assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
        }
@@ -1315,7 +1315,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
                .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
                .unwrap()
                .build().unwrap();
-       assert_ne!(refund.payer_id(), bob_id);
+       assert_ne!(refund.payer_signing_pubkey(), bob_id);
        assert!(!refund.paths().is_empty());
        for path in refund.paths() {
                assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
@@ -1598,7 +1598,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
                .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
                .unwrap()
                .build().unwrap();
-       assert_ne!(refund.payer_id(), david_id);
+       assert_ne!(refund.payer_signing_pubkey(), david_id);
        assert!(!refund.paths().is_empty());
        for path in refund.paths() {
                assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
@@ -1632,7 +1632,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
                .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
                .unwrap()
                .build().unwrap();
-       assert_ne!(refund.payer_id(), david_id);
+       assert_ne!(refund.payer_signing_pubkey(), david_id);
        assert!(!refund.paths().is_empty());
        for path in refund.paths() {
                assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
index a3b3a43cb32c02ad0bb42bd6dd842eaa50c42cf8..648c0fba65149dcaa7c3a1d03a88da7aeb223d05 100644 (file)
@@ -1019,8 +1019,8 @@ impl InvoiceContents {
 
        fn payer_signing_pubkey(&self) -> PublicKey {
                match self {
-                       InvoiceContents::ForRefund { refund, .. } => refund.payer_id(),
                        InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.payer_signing_pubkey(),
+                       InvoiceContents::ForRefund { refund, .. } => refund.payer_signing_pubkey(),
                }
        }
 
index e1b40526c07b8f7b0cb564e0c7ad99e174624199..95100a2a2ec2ac1f1ab8c24f8382e3f9b911f534 100644 (file)
@@ -1054,9 +1054,10 @@ impl Readable for InvoiceRequest {
 /// Valid type range for invoice_request TLV records.
 pub(super) const INVOICE_REQUEST_TYPES: core::ops::Range<u64> = 80..160;
 
-/// TLV record type for [`InvoiceRequest::payer_signing_pubkey`] and [`Refund::payer_id`].
+/// TLV record type for [`InvoiceRequest::payer_signing_pubkey`] and
+/// [`Refund::payer_signing_pubkey`].
 ///
-/// [`Refund::payer_id`]: crate::offers::refund::Refund::payer_id
+/// [`Refund::payer_signing_pubkey`]: crate::offers::refund::Refund::payer_signing_pubkey
 pub(super) const INVOICE_REQUEST_PAYER_ID_TYPE: u64 = 88;
 
 // This TLV stream is used for both InvoiceRequest and Refund, but not all TLV records are valid for
index 7b941f15abd1cd43f96d4b3303a62730d3aceda9..0ec5721dc3846e8a0bf4d013abe8885bbaa4696b 100644 (file)
@@ -16,9 +16,10 @@ use crate::util::ser::WithoutLength;
 use crate::prelude::*;
 
 /// An unpredictable sequence of bytes typically containing information needed to derive
-/// [`InvoiceRequest::payer_signing_pubkey`].
+/// [`InvoiceRequest::payer_signing_pubkey`] and [`Refund::payer_signing_pubkey`].
 ///
 /// [`InvoiceRequest::payer_signing_pubkey`]: crate::offers::invoice_request::InvoiceRequest::payer_signing_pubkey
+/// [`Refund::payer_signing_pubkey`]: crate::offers::refund::Refund::payer_signing_pubkey
 #[derive(Clone, Debug)]
 #[cfg_attr(test, derive(PartialEq))]
 pub(super) struct PayerContents(pub Metadata);
index e0ce377a5fd6952ec96b8582087278ea1e328d1c..aa09253b2d3b9e12c784abaa2f846b0466e8d0d2 100644 (file)
@@ -150,8 +150,8 @@ pub struct RefundMaybeWithDerivedMetadataBuilder<'a> {
 }
 
 macro_rules! refund_explicit_metadata_builder_methods { () => {
-       /// Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to
-       /// send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey.
+       /// Creates a new builder for a refund using the `signing_pubkey` for the public node id to send
+       /// to if no [`Refund::paths`] are set. Otherwise, `signing_pubkey` may be a transient pubkey.
        ///
        /// Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`],
        /// and [`Refund::amount_msats`].
@@ -164,7 +164,7 @@ macro_rules! refund_explicit_metadata_builder_methods { () => {
        /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
        /// [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder
        pub fn new(
-               metadata: Vec<u8>, payer_id: PublicKey, amount_msats: u64
+               metadata: Vec<u8>, signing_pubkey: PublicKey, amount_msats: u64
        ) -> Result<Self, Bolt12SemanticError> {
                if amount_msats > MAX_VALUE_MSAT {
                        return Err(Bolt12SemanticError::InvalidAmount);
@@ -175,7 +175,7 @@ macro_rules! refund_explicit_metadata_builder_methods { () => {
                        refund: RefundContents {
                                payer: PayerContents(metadata), description: String::new(), absolute_expiry: None,
                                issuer: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
-                               quantity: None, payer_id, payer_note: None, paths: None,
+                               quantity: None, payer_signing_pubkey: signing_pubkey, payer_note: None, paths: None,
                        },
                        secp_ctx: None,
                })
@@ -202,7 +202,7 @@ macro_rules! refund_builder_methods { (
        /// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
        /// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data
        /// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
-       pub fn deriving_payer_id(
+       pub fn deriving_signing_pubkey(
                node_id: PublicKey, expanded_key: &ExpandedKey, nonce: Nonce,
                secp_ctx: &'a Secp256k1<$secp_context>, amount_msats: u64, payment_id: PaymentId
        ) -> Result<Self, Bolt12SemanticError> {
@@ -217,7 +217,7 @@ macro_rules! refund_builder_methods { (
                        refund: RefundContents {
                                payer: PayerContents(metadata), description: String::new(), absolute_expiry: None,
                                issuer: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
-                               quantity: None, payer_id: node_id, payer_note: None, paths: None,
+                               quantity: None, payer_signing_pubkey: node_id, payer_note: None, paths: None,
                        },
                        secp_ctx: Some(secp_ctx),
                })
@@ -249,7 +249,7 @@ macro_rules! refund_builder_methods { (
        }
 
        /// Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected
-       /// by private channels or if [`Refund::payer_id`] is not a public node id.
+       /// by private channels or if [`Refund::payer_signing_pubkey`] is not a public node id.
        ///
        /// Successive calls to this method will add another blinded path. Caller is responsible for not
        /// adding duplicate paths.
@@ -324,7 +324,7 @@ macro_rules! refund_builder_methods { (
                                metadata.derive_from(iv_bytes, tlv_stream, $self.secp_ctx);
                        metadata = derived_metadata;
                        if let Some(keys) = keys {
-                               $self.refund.payer_id = keys.public_key();
+                               $self.refund.payer_signing_pubkey = keys.public_key();
                        }
 
                        $self.refund.payer.0 = metadata;
@@ -434,7 +434,7 @@ pub(super) struct RefundContents {
        amount_msats: u64,
        features: InvoiceRequestFeatures,
        quantity: Option<u64>,
-       payer_id: PublicKey,
+       payer_signing_pubkey: PublicKey,
        payer_note: Option<String>,
        paths: Option<Vec<BlindedMessagePath>>,
 }
@@ -477,9 +477,9 @@ impl Refund {
        }
 
        /// An unpredictable series of bytes, typically containing information about the derivation of
-       /// [`payer_id`].
+       /// [`payer_signing_pubkey`].
        ///
-       /// [`payer_id`]: Self::payer_id
+       /// [`payer_signing_pubkey`]: Self::payer_signing_pubkey
        pub fn payer_metadata(&self) -> &[u8] {
                self.contents.metadata()
        }
@@ -510,8 +510,8 @@ impl Refund {
        /// transient pubkey.
        ///
        /// [`paths`]: Self::paths
-       pub fn payer_id(&self) -> PublicKey {
-               self.contents.payer_id()
+       pub fn payer_signing_pubkey(&self) -> PublicKey {
+               self.contents.payer_signing_pubkey()
        }
 
        /// Payer provided note to include in the invoice.
@@ -727,8 +727,8 @@ impl RefundContents {
        /// transient pubkey.
        ///
        /// [`paths`]: Self::paths
-       pub fn payer_id(&self) -> PublicKey {
-               self.payer_id
+       pub fn payer_signing_pubkey(&self) -> PublicKey {
+               self.payer_signing_pubkey
        }
 
        /// Payer provided note to include in the invoice.
@@ -765,7 +765,7 @@ impl RefundContents {
                        amount: Some(self.amount_msats),
                        features,
                        quantity: self.quantity,
-                       payer_id: Some(&self.payer_id),
+                       payer_id: Some(&self.payer_signing_pubkey),
                        payer_note: self.payer_note.as_ref(),
                        paths: self.paths.as_ref(),
                };
@@ -901,14 +901,14 @@ impl TryFrom<RefundTlvStream> for RefundContents {
 
                let features = features.unwrap_or_else(InvoiceRequestFeatures::empty);
 
-               let payer_id = match payer_id {
+               let payer_signing_pubkey = match payer_id {
                        None => return Err(Bolt12SemanticError::MissingPayerSigningPubkey),
                        Some(payer_id) => payer_id,
                };
 
                Ok(RefundContents {
                        payer, description, absolute_expiry, issuer, chain, amount_msats, features, quantity,
-                       payer_id, payer_note, paths,
+                       payer_signing_pubkey, payer_note, paths,
                })
        }
 }
@@ -985,7 +985,7 @@ mod tests {
                assert_eq!(refund.chain(), ChainHash::using_genesis_block(Network::Bitcoin));
                assert_eq!(refund.amount_msats(), 1000);
                assert_eq!(refund.features(), &InvoiceRequestFeatures::empty());
-               assert_eq!(refund.payer_id(), payer_pubkey());
+               assert_eq!(refund.payer_signing_pubkey(), payer_pubkey());
                assert_eq!(refund.payer_note(), None);
 
                assert_eq!(
@@ -1040,10 +1040,10 @@ mod tests {
                let payment_id = PaymentId([1; 32]);
 
                let refund = RefundBuilder
-                       ::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
+                       ::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
                        .unwrap()
                        .build().unwrap();
-               assert_eq!(refund.payer_id(), node_id);
+               assert_eq!(refund.payer_signing_pubkey(), node_id);
 
                // Fails verification with altered fields
                let invoice = refund
@@ -1089,7 +1089,7 @@ mod tests {
        }
 
        #[test]
-       fn builds_refund_with_derived_payer_id() {
+       fn builds_refund_with_derived_signing_pubkey() {
                let node_id = payer_pubkey();
                let expanded_key = ExpandedKey::new(&KeyMaterial([42; 32]));
                let entropy = FixedEntropy {};
@@ -1106,11 +1106,11 @@ mod tests {
                );
 
                let refund = RefundBuilder
-                       ::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
+                       ::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
                        .unwrap()
                        .path(blinded_path)
                        .build().unwrap();
-               assert_ne!(refund.payer_id(), node_id);
+               assert_ne!(refund.payer_signing_pubkey(), node_id);
 
                let invoice = refund
                        .respond_with_no_std(payment_paths(), payment_hash(), recipient_pubkey(), now())
@@ -1211,7 +1211,7 @@ mod tests {
                        .build()
                        .unwrap();
                let (_, _, invoice_request_tlv_stream) = refund.as_tlv_stream();
-               assert_eq!(refund.payer_id(), pubkey(42));
+               assert_eq!(refund.payer_signing_pubkey(), pubkey(42));
                assert_eq!(refund.paths(), paths.as_slice());
                assert_ne!(pubkey(42), pubkey(44));
                assert_eq!(invoice_request_tlv_stream.payer_id, Some(&pubkey(42)));