Skip to content

Commit 41bd77a

Browse files
committed
f - rename some Bolt12Invoice methods and clarify docs
1 parent 4df2f6b commit 41bd77a

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

lightning/src/offers/invoice.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -481,14 +481,16 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
481481
/// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
482482
///
483483
/// [`Offer::chains`]: crate::offers::offer::Offer::chains
484-
pub fn chains(&$self) -> Option<Vec<ChainHash>> {
485-
$contents.chains()
484+
pub fn offer_chains(&$self) -> Option<Vec<ChainHash>> {
485+
$contents.offer_chains()
486486
}
487487

488-
/// A chain that the originating offer or refund is valid for.
488+
/// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
489+
/// invoice originated from an offer.
489490
///
490491
/// From [`InvoiceRequest::chain`] or [`Refund::chain`].
491492
///
493+
/// [`offer_chains`]: Self::offer_chains
492494
/// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
493495
pub fn chain(&$self) -> ChainHash {
494496
$contents.chain()
@@ -559,8 +561,8 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
559561
/// From [`Offer::paths`] or [`Refund::paths`].
560562
///
561563
/// [`Offer::paths`]: crate::offers::offer::Offer::paths
562-
pub fn paths(&$self) -> &[BlindedPath] {
563-
$contents.paths()
564+
pub fn message_paths(&$self) -> &[BlindedPath] {
565+
$contents.message_paths()
564566
}
565567

566568
/// The quantity of items supported.
@@ -595,9 +597,9 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
595597
}
596598

597599
/// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
598-
/// refund in case there are no [`paths`].
600+
/// refund in case there are no [`message_paths`].
599601
///
600-
/// [`paths`]: Self::paths
602+
/// [`message_paths`]: Self::message_paths
601603
pub fn payer_id(&$self) -> PublicKey {
602604
$contents.payer_id()
603605
}
@@ -712,7 +714,7 @@ impl InvoiceContents {
712714
}
713715
}
714716

715-
fn chains(&self) -> Option<Vec<ChainHash>> {
717+
fn offer_chains(&self) -> Option<Vec<ChainHash>> {
716718
match self {
717719
InvoiceContents::ForOffer { invoice_request, .. } =>
718720
Some(invoice_request.inner.offer.chains()),
@@ -779,7 +781,7 @@ impl InvoiceContents {
779781
}
780782
}
781783

782-
fn paths(&self) -> &[BlindedPath] {
784+
fn message_paths(&self) -> &[BlindedPath] {
783785
match self {
784786
InvoiceContents::ForOffer { invoice_request, .. } => {
785787
invoice_request.inner.offer.paths()
@@ -1324,13 +1326,13 @@ mod tests {
13241326

13251327
assert_eq!(unsigned_invoice.bytes, buffer.as_slice());
13261328
assert_eq!(unsigned_invoice.payer_metadata(), &[1; 32]);
1327-
assert_eq!(unsigned_invoice.chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
1329+
assert_eq!(unsigned_invoice.offer_chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
13281330
assert_eq!(unsigned_invoice.metadata(), None);
13291331
assert_eq!(unsigned_invoice.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
13301332
assert_eq!(unsigned_invoice.description(), PrintableString("foo"));
13311333
assert_eq!(unsigned_invoice.offer_features(), Some(&OfferFeatures::empty()));
13321334
assert_eq!(unsigned_invoice.absolute_expiry(), None);
1333-
assert_eq!(unsigned_invoice.paths(), &[]);
1335+
assert_eq!(unsigned_invoice.message_paths(), &[]);
13341336
assert_eq!(unsigned_invoice.issuer(), None);
13351337
assert_eq!(unsigned_invoice.supported_quantity(), Some(Quantity::One));
13361338
assert_eq!(unsigned_invoice.signing_pubkey(), recipient_pubkey());
@@ -1366,13 +1368,13 @@ mod tests {
13661368

13671369
assert_eq!(invoice.bytes, buffer.as_slice());
13681370
assert_eq!(invoice.payer_metadata(), &[1; 32]);
1369-
assert_eq!(invoice.chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
1371+
assert_eq!(invoice.offer_chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
13701372
assert_eq!(invoice.metadata(), None);
13711373
assert_eq!(invoice.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
13721374
assert_eq!(invoice.description(), PrintableString("foo"));
13731375
assert_eq!(invoice.offer_features(), Some(&OfferFeatures::empty()));
13741376
assert_eq!(invoice.absolute_expiry(), None);
1375-
assert_eq!(invoice.paths(), &[]);
1377+
assert_eq!(invoice.message_paths(), &[]);
13761378
assert_eq!(invoice.issuer(), None);
13771379
assert_eq!(invoice.supported_quantity(), Some(Quantity::One));
13781380
assert_eq!(invoice.signing_pubkey(), recipient_pubkey());
@@ -1465,13 +1467,13 @@ mod tests {
14651467

14661468
assert_eq!(invoice.bytes, buffer.as_slice());
14671469
assert_eq!(invoice.payer_metadata(), &[1; 32]);
1468-
assert_eq!(invoice.chains(), None);
1470+
assert_eq!(invoice.offer_chains(), None);
14691471
assert_eq!(invoice.metadata(), None);
14701472
assert_eq!(invoice.amount(), None);
14711473
assert_eq!(invoice.description(), PrintableString("foo"));
14721474
assert_eq!(invoice.offer_features(), None);
14731475
assert_eq!(invoice.absolute_expiry(), None);
1474-
assert_eq!(invoice.paths(), &[]);
1476+
assert_eq!(invoice.message_paths(), &[]);
14751477
assert_eq!(invoice.issuer(), None);
14761478
assert_eq!(invoice.supported_quantity(), None);
14771479
assert_eq!(invoice.signing_pubkey(), recipient_pubkey());

0 commit comments

Comments
 (0)