Move BOLT 12 InvoiceRequest method implementations
authorJeffrey Czyz <jkczyz@gmail.com>
Mon, 14 Aug 2023 17:55:34 +0000 (12:55 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 22 Aug 2023 00:14:28 +0000 (19:14 -0500)
lightning/src/offers/invoice_request.rs

index b05f9af8481bff6ed333856cc74e7c28e5f43d59..c3b9f5bdd20386cb45cd26334f341919bf6806cf 100644 (file)
@@ -460,29 +460,28 @@ impl InvoiceRequest {
        ///
        /// [`chain`]: Self::chain
        pub fn amount_msats(&self) -> Option<u64> {
-               self.contents.inner.amount_msats
+               self.contents.amount_msats()
        }
 
        /// Features pertaining to requesting an invoice.
        pub fn features(&self) -> &InvoiceRequestFeatures {
-               &self.contents.inner.features
+               &self.contents.features()
        }
 
        /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
        pub fn quantity(&self) -> Option<u64> {
-               self.contents.inner.quantity
+               self.contents.quantity()
        }
 
        /// A possibly transient pubkey used to sign the invoice request.
        pub fn payer_id(&self) -> PublicKey {
-               self.contents.payer_id
+               self.contents.payer_id()
        }
 
        /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
        /// response.
        pub fn payer_note(&self) -> Option<PrintableString> {
-               self.contents.inner.payer_note.as_ref()
-                       .map(|payer_note| PrintableString(payer_note.as_str()))
+               self.contents.payer_note()
        }
 
        /// Signature of the invoice request using [`payer_id`].
@@ -626,10 +625,27 @@ impl InvoiceRequestContents {
                self.inner.chain()
        }
 
+       fn amount_msats(&self) -> Option<u64> {
+               self.inner.amount_msats
+       }
+
+       fn features(&self) -> &InvoiceRequestFeatures {
+               &self.inner.features
+       }
+
+       fn quantity(&self) -> Option<u64> {
+               self.inner.quantity
+       }
+
        pub(super) fn payer_id(&self) -> PublicKey {
                self.payer_id
        }
 
+       fn payer_note(&self) -> Option<PrintableString> {
+               self.inner.payer_note.as_ref()
+                       .map(|payer_note| PrintableString(payer_note.as_str()))
+       }
+
        pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef {
                let (payer, offer, mut invoice_request) = self.inner.as_tlv_stream();
                invoice_request.payer_id = Some(&self.payer_id);