+pub fn create_phantom_invoice<K: Deref, L: Deref>(
+ amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: String,
+ invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
+ logger: L, network: Currency,
+) -> Result<Invoice, SignOrCreationError<()>>
+where
+ K::Target: KeysInterface,
+ L::Target: Logger,
+{
+ let description = Description::new(description).map_err(SignOrCreationError::CreationError)?;
+ let description = InvoiceDescription::Direct(&description,);
+ _create_phantom_invoice::<K, L>(
+ amt_msat, payment_hash, description, invoice_expiry_delta_secs, phantom_route_hints,
+ keys_manager, logger, network,
+ )
+}
+
+#[cfg(feature = "std")]
+/// 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
+///
+/// `description_hash` is a SHA-256 hash of the description text
+///
+/// `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.
+///
+/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
+/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
+/// requirement).
+///
+/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
+/// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
+/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
+/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
+/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
+pub fn create_phantom_invoice_with_description_hash<K: Deref, L: Deref>(
+ amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, invoice_expiry_delta_secs: u32,
+ description_hash: Sha256, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
+ logger: L, network: Currency
+) -> Result<Invoice, SignOrCreationError<()>>
+where
+ K::Target: KeysInterface,
+ L::Target: Logger,
+{
+ _create_phantom_invoice::<K, L>(
+ amt_msat, payment_hash, InvoiceDescription::Hash(&description_hash),
+ invoice_expiry_delta_secs, phantom_route_hints, keys_manager, logger, network,
+ )
+}
+
+#[cfg(feature = "std")]
+fn _create_phantom_invoice<K: Deref, L: Deref>(
+ amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: InvoiceDescription,
+ invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
+ logger: L, network: Currency,
+) -> Result<Invoice, SignOrCreationError<()>>
+where
+ K::Target: KeysInterface,
+ L::Target: Logger,
+{
+ use std::time::{SystemTime, UNIX_EPOCH};
+