Function lightning_invoice::utils::create_phantom_invoice

source ·
pub fn create_phantom_invoice<ES: Deref, NS: Deref, L: Deref>(
    amt_msat: Option<u64>,
    payment_hash: Option<PaymentHash>,
    description: String,
    invoice_expiry_delta_secs: u32,
    phantom_route_hints: Vec<PhantomRouteHints>,
    entropy_source: ES,
    node_signer: NS,
    logger: L,
    network: Currency,
    min_final_cltv_expiry_delta: Option<u16>,
    duration_since_epoch: Duration
) -> Result<Bolt11Invoice, SignOrCreationError<()>>
Expand description

Utility to create an invoice that can be paid to one of multiple nodes, or a “phantom invoice.” See PhantomKeysManager for more information on phantom node payments.

phantom_route_hints parameter:

  • Contains channel info for all nodes participating in the phantom invoice
  • Entries are retrieved from a call to ChannelManager::get_phantom_route_hints on each participating node
  • It is fine to cache phantom_route_hints and reuse it across invoices, as long as the data is updated when a channel becomes disabled or closes
  • Note that if too many channels are included in PhantomRouteHints::channels, the invoice may be too long for QR code scanning. To fix this, PhantomRouteHints::channels may be pared down

payment_hash can be specified if you have a specific need for a custom payment hash (see the difference between ChannelManager::create_inbound_payment and ChannelManager::create_inbound_payment_for_hash). If None is provided for payment_hash, then one will be created.

invoice_expiry_delta_secs describes the number of seconds that the invoice is valid for in excess of the current time.

duration_since_epoch is the current time since epoch in seconds.

You can specify a custom min_final_cltv_expiry_delta, or let LDK default it to MIN_FINAL_CLTV_EXPIRY_DELTA. The provided expiry must be at least MIN_FINAL_CLTV_EXPIRY_DELTA - 3. Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block confirmations during routing.

Note that the provided keys_manager’s NodeSigner implementation must support phantom invoices in its sign_invoice implementation (PhantomKeysManager satisfies this requirement).

This can be used in a no_std environment, where std::time::SystemTime is not available and the current time is supplied by the caller.