Skip to content

Commit 48a1a11

Browse files
committed
f - move docs to module-level
1 parent 522276c commit 48a1a11

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::genesis_block;
1350
use bitcoin::hash_types::BlockHash;
@@ -29,38 +66,9 @@ const SIGNATURE_TAG: &'static str = concat!("lightning", "invoice_request", "sig
2966

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