Skip to content

Commit 5732a55

Browse files
committed
f - rename some Bolt12Invoice methods and clarify docs
1 parent 9a45f9a commit 5732a55

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
@@ -487,14 +487,16 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
487487
/// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
488488
///
489489
/// [`Offer::chains`]: crate::offers::offer::Offer::chains
490-
pub fn chains(&$self) -> Option<Vec<ChainHash>> {
491-
$contents.chains()
490+
pub fn offer_chains(&$self) -> Option<Vec<ChainHash>> {
491+
$contents.offer_chains()
492492
}
493493

494-
/// A chain that the originating offer or refund is valid for.
494+
/// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
495+
/// invoice originated from an offer.
495496
///
496497
/// From [`InvoiceRequest::chain`] or [`Refund::chain`].
497498
///
499+
/// [`offer_chains`]: Self::offer_chains
498500
/// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
499501
pub fn chain(&$self) -> ChainHash {
500502
$contents.chain()
@@ -565,8 +567,8 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
565567
/// From [`Offer::paths`] or [`Refund::paths`].
566568
///
567569
/// [`Offer::paths`]: crate::offers::offer::Offer::paths
568-
pub fn paths(&$self) -> &[BlindedPath] {
569-
$contents.paths()
570+
pub fn message_paths(&$self) -> &[BlindedPath] {
571+
$contents.message_paths()
570572
}
571573

572574
/// The quantity of items supported.
@@ -601,9 +603,9 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
601603
}
602604

603605
/// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
604-
/// refund in case there are no [`paths`].
606+
/// refund in case there are no [`message_paths`].
605607
///
606-
/// [`paths`]: Self::paths
608+
/// [`message_paths`]: Self::message_paths
607609
pub fn payer_id(&$self) -> PublicKey {
608610
$contents.payer_id()
609611
}
@@ -718,7 +720,7 @@ impl InvoiceContents {
718720
}
719721
}
720722

721-
fn chains(&self) -> Option<Vec<ChainHash>> {
723+
fn offer_chains(&self) -> Option<Vec<ChainHash>> {
722724
match self {
723725
InvoiceContents::ForOffer { invoice_request, .. } =>
724726
Some(invoice_request.inner.offer.chains()),
@@ -785,7 +787,7 @@ impl InvoiceContents {
785787
}
786788
}
787789

788-
fn paths(&self) -> &[BlindedPath] {
790+
fn message_paths(&self) -> &[BlindedPath] {
789791
match self {
790792
InvoiceContents::ForOffer { invoice_request, .. } => {
791793
invoice_request.inner.offer.paths()
@@ -1330,13 +1332,13 @@ mod tests {
13301332

13311333
assert_eq!(unsigned_invoice.bytes, buffer.as_slice());
13321334
assert_eq!(unsigned_invoice.payer_metadata(), &[1; 32]);
1333-
assert_eq!(unsigned_invoice.chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
1335+
assert_eq!(unsigned_invoice.offer_chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
13341336
assert_eq!(unsigned_invoice.metadata(), None);
13351337
assert_eq!(unsigned_invoice.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
13361338
assert_eq!(unsigned_invoice.description(), PrintableString("foo"));
13371339
assert_eq!(unsigned_invoice.offer_features(), Some(&OfferFeatures::empty()));
13381340
assert_eq!(unsigned_invoice.absolute_expiry(), None);
1339-
assert_eq!(unsigned_invoice.paths(), &[]);
1341+
assert_eq!(unsigned_invoice.message_paths(), &[]);
13401342
assert_eq!(unsigned_invoice.issuer(), None);
13411343
assert_eq!(unsigned_invoice.supported_quantity(), Some(Quantity::One));
13421344
assert_eq!(unsigned_invoice.signing_pubkey(), recipient_pubkey());
@@ -1372,13 +1374,13 @@ mod tests {
13721374

13731375
assert_eq!(invoice.bytes, buffer.as_slice());
13741376
assert_eq!(invoice.payer_metadata(), &[1; 32]);
1375-
assert_eq!(invoice.chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
1377+
assert_eq!(invoice.offer_chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
13761378
assert_eq!(invoice.metadata(), None);
13771379
assert_eq!(invoice.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
13781380
assert_eq!(invoice.description(), PrintableString("foo"));
13791381
assert_eq!(invoice.offer_features(), Some(&OfferFeatures::empty()));
13801382
assert_eq!(invoice.absolute_expiry(), None);
1381-
assert_eq!(invoice.paths(), &[]);
1383+
assert_eq!(invoice.message_paths(), &[]);
13821384
assert_eq!(invoice.issuer(), None);
13831385
assert_eq!(invoice.supported_quantity(), Some(Quantity::One));
13841386
assert_eq!(invoice.signing_pubkey(), recipient_pubkey());
@@ -1471,13 +1473,13 @@ mod tests {
14711473

14721474
assert_eq!(invoice.bytes, buffer.as_slice());
14731475
assert_eq!(invoice.payer_metadata(), &[1; 32]);
1474-
assert_eq!(invoice.chains(), None);
1476+
assert_eq!(invoice.offer_chains(), None);
14751477
assert_eq!(invoice.metadata(), None);
14761478
assert_eq!(invoice.amount(), None);
14771479
assert_eq!(invoice.description(), PrintableString("foo"));
14781480
assert_eq!(invoice.offer_features(), None);
14791481
assert_eq!(invoice.absolute_expiry(), None);
1480-
assert_eq!(invoice.paths(), &[]);
1482+
assert_eq!(invoice.message_paths(), &[]);
14811483
assert_eq!(invoice.issuer(), None);
14821484
assert_eq!(invoice.supported_quantity(), None);
14831485
assert_eq!(invoice.signing_pubkey(), recipient_pubkey());

0 commit comments

Comments
 (0)