Skip to content

Commit 125858a

Browse files
committed
Move BOLT 12 offer method implementations
1 parent 4c470be commit 125858a

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

lightning/src/offers/offer.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,14 @@ impl Offer {
398398

399399
/// Features pertaining to the offer.
400400
pub fn features(&self) -> &OfferFeatures {
401-
&self.contents.features
401+
&self.contents.features()
402402
}
403403

404404
/// Duration since the Unix epoch when an invoice should no longer be requested.
405405
///
406406
/// If `None`, the offer does not expire.
407407
pub fn absolute_expiry(&self) -> Option<Duration> {
408-
self.contents.absolute_expiry
408+
self.contents.absolute_expiry()
409409
}
410410

411411
/// Whether the offer has expired.
@@ -417,13 +417,13 @@ impl Offer {
417417
/// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
418418
/// displayed to the user but with the caveat that it has not been verified in any way.
419419
pub fn issuer(&self) -> Option<PrintableString> {
420-
self.contents.issuer.as_ref().map(|issuer| PrintableString(issuer.as_str()))
420+
self.contents.issuer()
421421
}
422422

423423
/// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
424424
/// recipient privacy by obfuscating its node id.
425425
pub fn paths(&self) -> &[BlindedPath] {
426-
self.contents.paths.as_ref().map(|paths| paths.as_slice()).unwrap_or(&[])
426+
self.contents.paths()
427427
}
428428

429429
/// The quantity of items supported.
@@ -551,10 +551,22 @@ impl OfferContents {
551551
self.metadata.as_ref().and_then(|metadata| metadata.as_bytes())
552552
}
553553

554+
pub fn amount(&self) -> Option<&Amount> {
555+
self.amount.as_ref()
556+
}
557+
554558
pub fn description(&self) -> PrintableString {
555559
PrintableString(&self.description)
556560
}
557561

562+
pub fn features(&self) -> &OfferFeatures {
563+
&self.features
564+
}
565+
566+
pub fn absolute_expiry(&self) -> Option<Duration> {
567+
self.absolute_expiry
568+
}
569+
558570
#[cfg(feature = "std")]
559571
pub(super) fn is_expired(&self) -> bool {
560572
match self.absolute_expiry {
@@ -566,8 +578,12 @@ impl OfferContents {
566578
}
567579
}
568580

569-
pub fn amount(&self) -> Option<&Amount> {
570-
self.amount.as_ref()
581+
pub fn issuer(&self) -> Option<PrintableString> {
582+
self.issuer.as_ref().map(|issuer| PrintableString(issuer.as_str()))
583+
}
584+
585+
pub fn paths(&self) -> &[BlindedPath] {
586+
self.paths.as_ref().map(|paths| paths.as_slice()).unwrap_or(&[])
571587
}
572588

573589
pub(super) fn check_amount_msats_for_quantity(

0 commit comments

Comments
 (0)