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