@@ -26,7 +26,39 @@ use util::ser::{Readable, WithoutLength, Writeable, Writer};
26
26
///
27
27
const SIGNATURE_TAG : & ' static str = concat ! ( "lightning" , "invoice_request" , "signature" ) ;
28
28
29
+ /// Builds an [`InvoiceRequest`] from an [`Offer`] for the user-pays-merchant flow.
29
30
///
31
+ /// ```
32
+ /// extern crate bitcoin;
33
+ /// extern crate lightning;
34
+ ///
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_signed(|digest| secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))?
57
+ /// .write(&mut buffer)
58
+ /// .unwrap();
59
+ /// # Ok(())
60
+ /// # }
61
+ /// ```
30
62
pub struct InvoiceRequestBuilder < ' a > {
31
63
offer : & ' a Offer ,
32
64
invoice_request : InvoiceRequestContents ,
0 commit comments