Module 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::Network;
use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey};
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::inbound_payment::ExpandedKey;
use lightning::types::features::OfferFeatures;
use lightning::offers::invoice_request::UnsignedInvoiceRequest;
use lightning::offers::offer::Offer;
use lightning::util::ser::Writeable;

let expanded_key = ExpandedKey::new([42; 32]);
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);
let mut buffer = Vec::new();

"lno1qcp4256ypq"
    .parse::<Offer>()?
    .request_invoice(&expanded_key, nonce, &secp_ctx, payment_id)?
    .chain(Network::Testnet)?
    .amount_msats(1000)?
    .quantity(5)?
    .payer_note("foo".to_string())
    .build_and_sign()?
    .write(&mut buffer)
    .unwrap();

Structs§

InvoiceRequest
An InvoiceRequest is a request for a Bolt12Invoice formulated from an Offer.
InvoiceRequestBuilder
Builds an InvoiceRequest from an Offer for the “offer to be paid” flow.
InvoiceRequestFields
Fields sent in an InvoiceRequest message to include in PaymentContext::Bolt12Offer.
UnsignedInvoiceRequest
A semantically valid InvoiceRequest that hasn’t been signed.
VerifiedInvoiceRequest
An InvoiceRequest that has been verified by InvoiceRequest::verify_using_metadata or InvoiceRequest::verify_using_recipient_data and exposes different ways to respond depending on whether the signing keys were derived.

Constants§

PAYER_NOTE_LIMIT
The maximum number of characters included in InvoiceRequestFields::payer_note_truncated.
SIGNATURE_TAG
Tag for the hash function used when signing an InvoiceRequest’s merkle root.

Traits§

SignInvoiceRequestFn
A function for signing an UnsignedInvoiceRequest.