Skip to content

Commit 0a43a30

Browse files
fixup! Add payer_offer() accessor method for invoice requests
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent ba7e9e9 commit 0a43a30

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ macro_rules! invoice_request_accessors { ($self: ident, $contents: expr) => {
784784
}
785785

786786
/// Returns the payer offer if present in the invoice request.
787-
pub fn payer_offer(&$self) -> Option<&[u8]> {
787+
pub fn payer_offer(&$self) -> Option<crate::offers::offer::Offer> {
788788
$contents.payer_offer()
789789
}
790790
} }
@@ -1096,9 +1096,7 @@ macro_rules! fields_accessor {
10961096

10971097
// Extract BLIP-42 contact information if present
10981098
let contact_secret = $self.contact_secret();
1099-
let payer_offer = $self
1100-
.payer_offer()
1101-
.and_then(|bytes| crate::offers::offer::Offer::try_from(bytes.to_vec()).ok());
1099+
let payer_offer = $self.payer_offer();
11021100

11031101
InvoiceRequestFields {
11041102
payer_signing_pubkey: *payer_signing_pubkey,
@@ -1231,8 +1229,8 @@ impl InvoiceRequestContents {
12311229
self.inner.invreq_contact_secret
12321230
}
12331231

1234-
pub(super) fn payer_offer(&self) -> Option<&[u8]> {
1235-
self.inner.invreq_payer_offer.as_ref().map(|offer| offer.as_slice())
1232+
pub(super) fn payer_offer(&self) -> Option<crate::offers::offer::Offer> {
1233+
self.inner.invreq_payer_offer.as_ref().and_then(|bytes| crate::offers::offer::Offer::try_from(bytes.clone()).ok())
12361234
}
12371235

12381236
pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef<'_> {

0 commit comments

Comments
 (0)