Skip to content

Commit c1f70ff

Browse files
committed
f - move docs to module-level
1 parent 4bd258b commit c1f70ff

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,43 @@
88
// licenses.
99

1010
//! Data structures and encoding for `invoice_request` messages.
11+
//!
12+
//! An [`InvoiceRequest`] can be either built from a parsed [`Offer`] for the user-pays-merchant
13+
//! flow or built directly for the merchant-pays-user flow.
14+
//!
15+
//! ```
16+
//! extern crate bitcoin;
17+
//! extern crate lightning;
18+
//!
19+
//! use bitcoin::network::constants::Network;
20+
//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
21+
//! use lightning::ln::features::OfferFeatures;
22+
//! use lightning::offers::Offer;
23+
//! use lightning::util::ser::Writeable;
24+
//!
25+
//! # fn parse() -> Result<(), lightning::offers::ParseError> {
26+
//! let secp_ctx = Secp256k1::new();
27+
//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
28+
//! let pubkey = PublicKey::from(keys);
29+
//! let mut buffer = Vec::new();
30+
//!
31+
//! // User-pays-merchant flow
32+
//! "lno1qcp4256ypq"
33+
//! .parse::<Offer>()?
34+
//! .request_invoice(pubkey)
35+
//! .payer_info(vec![42; 64])
36+
//! .chain(Network::Testnet)?
37+
//! .amount_msats(1000)?
38+
//! .features(OfferFeatures::known())
39+
//! .quantity(5)?
40+
//! .payer_note("foo".to_string())
41+
//! .build()?
42+
//! .sign(|digest| secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))?
43+
//! .write(&mut buffer)
44+
//! .unwrap();
45+
//! # Ok(())
46+
//! # }
47+
//! ```
1148
1249
use bitcoin::blockdata::constants::ChainHash;
1350
use bitcoin::network::constants::Network;
@@ -28,38 +65,9 @@ const SIGNATURE_TAG: &'static str = concat!("lightning", "invoice_request", "sig
2865

2966
/// Builds an [`InvoiceRequest`] from an [`Offer`] for the user-pays-merchant flow.
3067
///
31-
/// ```
32-
/// extern crate bitcoin;
33-
/// extern crate lightning;
68+
/// See [module-level documentation] for usage.
3469
///
35-
/// use bitcoin::network::constants::Network;
36-
/// use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
37-
/// use lightning::ln::features::OfferFeatures;
38-
/// use lightning::offers::Offer;
39-
/// use lightning::util::ser::Writeable;
40-
///
41-
/// # fn parse() -> Result<(), lightning::offers::ParseError> {
42-
/// let secp_ctx = Secp256k1::new();
43-
/// let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
44-
/// let pubkey = PublicKey::from(keys);
45-
/// let mut buffer = Vec::new();
46-
///
47-
/// "lno1qcp4256ypq"
48-
/// .parse::<Offer>()?
49-
/// .request_invoice(pubkey)
50-
/// .payer_info(vec![42; 64])
51-
/// .chain(Network::Testnet)?
52-
/// .amount_msats(1000)?
53-
/// .features(OfferFeatures::known())
54-
/// .quantity(5)?
55-
/// .payer_note("foo".to_string())
56-
/// .build()?
57-
/// .sign(|digest| secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))?
58-
/// .write(&mut buffer)
59-
/// .unwrap();
60-
/// # Ok(())
61-
/// # }
62-
/// ```
70+
/// [module-level documentation]: self
6371
pub struct InvoiceRequestBuilder<'a> {
6472
offer: &'a Offer,
6573
invoice_request: InvoiceRequestContents,

lightning/src/offers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! Implementation of Lightning Offers
1111
//! ([BOLT 12](https://github.com/lightning/bolts/blob/master/12-offer-encoding.md)).
1212
13-
mod invoice_request;
13+
pub mod invoice_request;
1414
mod merkle;
1515
mod offer;
1616
mod parse;

0 commit comments

Comments
 (0)