Module breez_sdk_core::lightning::offers::invoice_request
Expand description
Data structures and encoding for invoice_request
messages.
An InvoiceRequest
can be built from a parsed Offer
as an “offer to be paid”. It is
typically constructed by a customer and sent to the merchant who had published the corresponding
offer. The recipient of the request responds with a Bolt12Invoice
.
For an “offer for money” (e.g., refund, ATM withdrawal), where an offer doesn’t exist as a
precursor, see Refund
.
extern crate bitcoin;
extern crate lightning;
use bitcoin::network::constants::Network;
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
use core::convert::Infallible;
use lightning::ln::features::OfferFeatures;
use lightning::offers::offer::Offer;
use lightning::util::ser::Writeable;
let secp_ctx = Secp256k1::new();
let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
let pubkey = PublicKey::from(keys);
let mut buffer = Vec::new();
"lno1qcp4256ypq"
.parse::<Offer>()?
.request_invoice(vec![42; 64], pubkey)?
.chain(Network::Testnet)?
.amount_msats(1000)?
.quantity(5)?
.payer_note("foo".to_string())
.build()?
.sign::<_, Infallible>(
|message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
)
.expect("failed verifying signature")
.write(&mut buffer)
.unwrap();
Structs§
InvoiceRequest::payer_id
will be derived.InvoiceRequest::payer_id
will be explicitly set.- Builds an
InvoiceRequest
from anOffer
for the “offer to be paid” flow. - A semantically valid
InvoiceRequest
that hasn’t been signed. - An
InvoiceRequest
that has been verified byInvoiceRequest::verify
and exposes different ways to respond depending on whether the signing keys were derived.
Constants§
- Tag for the hash function used when signing an
InvoiceRequest
’s merkle root.
Traits§
- Indicates how
InvoiceRequest::payer_id
will be set.