From 85c471aac254cb4b7a93f0fa38a26ad0b637cbe3 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Mon, 14 Aug 2023 12:55:34 -0500 Subject: [PATCH] Move BOLT 12 InvoiceRequest method implementations --- lightning/src/offers/invoice_request.rs | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index b05f9af84..c3b9f5bdd 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -460,29 +460,28 @@ impl InvoiceRequest { /// /// [`chain`]: Self::chain pub fn amount_msats(&self) -> Option { - 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 { - 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 { - 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 { + self.inner.amount_msats + } + + fn features(&self) -> &InvoiceRequestFeatures { + &self.inner.features + } + + fn quantity(&self) -> Option { + self.inner.quantity + } + pub(super) fn payer_id(&self) -> PublicKey { self.payer_id } + fn payer_note(&self) -> Option { + 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); -- 2.39.5