Class UtilMethods


  • public class UtilMethods
    extends Object
    • Constructor Detail

      • UtilMethods

        public UtilMethods()
    • Method Detail

      • U128_le_bytes

        public static byte[] U128_le_bytes​(UInt128 val)
        Gets the 128-bit integer, as 16 little-endian bytes
      • U128_new

        public static UInt128 U128_new​(byte[] le_bytes)
        Constructs a new U128 from 16 little-endian bytes
      • COption_NoneZ_some

        public static COption_NoneZ COption_NoneZ_some()
        Constructs a new COption_NoneZ containing a
      • COption_NoneZ_none

        public static COption_NoneZ COption_NoneZ_none()
        Constructs a new COption_NoneZ containing nothing
      • sign

        public static Result_StringErrorZ sign​(byte[] msg,
                                               byte[] sk)
        Creates a digital signature of a message given a SecretKey, like the node's secret. A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
      • recover_pk

        public static Result_PublicKeyErrorZ recover_pk​(byte[] msg,
                                                        String sig)
        Recovers the PublicKey of the signer of the message given the message and the signature.
      • verify

        public static boolean verify​(byte[] msg,
                                     String sig,
                                     byte[] pk)
        Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, and the PublicKey.
      • construct_invoice_preimage

        public static byte[] construct_invoice_preimage​(byte[] hrp_bytes,
                                                        UInt5[] data_without_signature)
        Construct the invoice's HRP and signatureless data into a preimage to be hashed.
      • provided_init_features

        public static InitFeatures provided_init_features​(UserConfig _config)
        Fetches the set of [`InitFeatures`] flags which are provided by or required by [`ChannelManager`].
      • create

        public static Result_C2Tuple_PaymentHashPaymentSecretZNoneZ create​(ExpandedKey keys,
                                                                           Option_u64Z min_value_msat,
                                                                           int invoice_expiry_delta_secs,
                                                                           EntropySource entropy_source,
                                                                           long current_time,
                                                                           Option_u16Z min_final_cltv_expiry_delta)
        Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without a `ChannelManager`. `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not regenerate it for each new inbound payment. `current_time` is a Unix timestamp representing the current time. Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable on versions of LDK prior to 0.0.114. [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material
      • create_from_hash

        public static Result_PaymentSecretNoneZ create_from_hash​(ExpandedKey keys,
                                                                 Option_u64Z min_value_msat,
                                                                 byte[] payment_hash,
                                                                 int invoice_expiry_delta_secs,
                                                                 long current_time,
                                                                 Option_u16Z min_final_cltv_expiry_delta)
        Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without a `ChannelManager`. See [`create`] for information on the `keys` and `current_time` parameters. Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable on versions of LDK prior to 0.0.114. [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
      • htlc_success_tx_weight

        public static long htlc_success_tx_weight​(boolean opt_anchors)
        Gets the weight for an HTLC-Success transaction.
      • htlc_timeout_tx_weight

        public static long htlc_timeout_tx_weight​(boolean opt_anchors)
        Gets the weight for an HTLC-Timeout transaction.
      • HTLCClaim_from_witness

        public static Option_HTLCClaimZ HTLCClaim_from_witness​(byte[] witness)
        Check if a given input witness attempts to claim a HTLC.
      • build_commitment_secret

        public static byte[] build_commitment_secret​(byte[] commitment_seed,
                                                     long idx)
        Build the commitment secret from the seed and the commitment number
      • build_closing_transaction

        public static byte[] build_closing_transaction​(long to_holder_value_sat,
                                                       long to_counterparty_value_sat,
                                                       byte[] to_holder_script,
                                                       byte[] to_counterparty_script,
                                                       OutPoint funding_outpoint)
        Build a closing transaction
      • derive_private_key

        public static byte[] derive_private_key​(byte[] per_commitment_point,
                                                byte[] base_secret)
        Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) from the base secret and the per_commitment_point.
      • derive_public_key

        public static byte[] derive_public_key​(byte[] per_commitment_point,
                                               byte[] base_point)
        Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) from the base point and the per_commitment_key. This is the public equivalent of derive_private_key - using only public keys to derive a public key instead of private keys.
      • derive_private_revocation_key

        public static byte[] derive_private_revocation_key​(byte[] per_commitment_secret,
                                                           byte[] countersignatory_revocation_base_secret)
        Derives a per-commitment-transaction revocation key from its constituent parts. Only the cheating participant owns a valid witness to propagate a revoked commitment transaction, thus per_commitment_secret always come from cheater and revocation_base_secret always come from punisher, which is the broadcaster of the transaction spending with this key knowledge.
      • derive_public_revocation_key

        public static byte[] derive_public_revocation_key​(byte[] per_commitment_point,
                                                          byte[] countersignatory_revocation_base_point)
        Derives a per-commitment-transaction revocation public key from its constituent parts. This is the public equivalend of derive_private_revocation_key - using only public keys to derive a public key instead of private keys. Only the cheating participant owns a valid witness to propagate a revoked commitment transaction, thus per_commitment_point always come from cheater and revocation_base_point always come from punisher, which is the broadcaster of the transaction spending with this key knowledge. Note that this is infallible iff we trust that at least one of the two input keys are randomly generated (ie our own).
      • get_revokeable_redeemscript

        public static byte[] get_revokeable_redeemscript​(byte[] revocation_key,
                                                         short contest_delay,
                                                         byte[] broadcaster_delayed_payment_key)
        A script either spendable by the revocation key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
      • get_htlc_redeemscript

        public static byte[] get_htlc_redeemscript​(HTLCOutputInCommitment htlc,
                                                   boolean opt_anchors,
                                                   TxCreationKeys keys)
        Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc does not need to have its previous_output_index filled.
      • make_funding_redeemscript

        public static byte[] make_funding_redeemscript​(byte[] broadcaster,
                                                       byte[] countersignatory)
        Gets the redeemscript for a funding output from the two funding public keys. Note that the order of funding public keys does not matter.
      • build_htlc_transaction

        public static byte[] build_htlc_transaction​(byte[] commitment_txid,
                                                    int feerate_per_kw,
                                                    short contest_delay,
                                                    HTLCOutputInCommitment htlc,
                                                    boolean opt_anchors,
                                                    boolean use_non_zero_fee_anchors,
                                                    byte[] broadcaster_delayed_payment_key,
                                                    byte[] revocation_key)
        Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the transaction which needs signing, and can be used to construct an HTLC transaction which is broadcastable given a counterparty HTLC signature. Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the commitment transaction).
      • build_htlc_input_witness

        public static byte[] build_htlc_input_witness​(byte[] local_sig,
                                                      byte[] remote_sig,
                                                      @Nullable
                                                      byte[] preimage,
                                                      byte[] redeem_script,
                                                      boolean opt_anchors)
        Returns the witness required to satisfy and spend a HTLC input. Note that preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
      • get_to_countersignatory_with_anchors_redeemscript

        public static byte[] get_to_countersignatory_with_anchors_redeemscript​(byte[] payment_point)
        Gets the witnessScript for the to_remote output when anchors are enabled.
      • get_anchor_redeemscript

        public static byte[] get_anchor_redeemscript​(byte[] funding_pubkey)
        Gets the witnessScript for an anchor output from the funding public key. The witness in the spending input must be: After 16 blocks of confirmation, an alternative satisfying witness could be: <> (empty vector required to satisfy compliance with MINIMALIF-standard rule)
      • build_anchor_input_witness

        public static byte[] build_anchor_input_witness​(byte[] funding_key,
                                                        byte[] funding_sig)
        Returns the witness required to satisfy and spend an anchor input.
      • get_commitment_transaction_number_obscure_factor

        public static long get_commitment_transaction_number_obscure_factor​(byte[] broadcaster_payment_basepoint,
                                                                            byte[] countersignatory_payment_basepoint,
                                                                            boolean outbound_from_broadcaster)
        Commitment transaction numbers which appear in the transactions themselves are XOR'd with a shared secret first. This prevents on-chain observers from discovering how many commitment transactions occurred in a channel before it was closed. This function gets the shared secret from relevant channel public keys and can be used to \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
      • find_route

        public static Result_RouteLightningErrorZ find_route​(byte[] our_node_pubkey,
                                                             RouteParameters route_params,
                                                             NetworkGraph network_graph,
                                                             @Nullable
                                                             ChannelDetails[] first_hops,
                                                             Logger logger,
                                                             Score scorer,
                                                             byte[] random_seed_bytes)
        Finds a route from us (payer) to the given target node (payee). If the payee provided features in their invoice, they should be provided via `params.payee`. Without this, MPP will only be used if the payee's features are available in the network graph. Private routing paths between a public node and the target may be included in `params.payee`. If some channels aren't announced, it may be useful to fill in `first_hops` with the results from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels from `network_graph` will be ignored, and only those in `first_hops` will be used. The fees on channels from us to the next hop are ignored as they are assumed to all be equal. However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / `htlc_maximum_msat` *are* checked as they may change based on the receiving node. # Note May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this function. # Panics Panics if first_hops contains channels without short_channel_ids; [`ChannelManager::list_usable_channels`] will never include such channels. [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed [`NetworkGraph`]: crate::routing::gossip::NetworkGraph Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
      • build_route_from_hops

        public static Result_RouteLightningErrorZ build_route_from_hops​(byte[] our_node_pubkey,
                                                                        byte[][] hops,
                                                                        RouteParameters route_params,
                                                                        NetworkGraph network_graph,
                                                                        Logger logger,
                                                                        byte[] random_seed_bytes)
        Construct a route from us (payer) to the target node (payee) via the given hops (which should exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. Re-uses logic from `find_route`, so the restrictions described there also apply here.
      • pay_invoice

        public static Result_PaymentIdPaymentErrorZ pay_invoice​(Invoice invoice,
                                                                Retry retry_strategy,
                                                                ChannelManager channelmanager)
        Pays the given [`Invoice`], retrying if needed based on [`Retry`]. [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long as the payment is still pending. Once the payment completes or fails, you must ensure that a second payment with the same [`PaymentHash`] is never sent. If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
      • pay_invoice_with_id

        public static Result_NonePaymentErrorZ pay_invoice_with_id​(Invoice invoice,
                                                                   byte[] payment_id,
                                                                   Retry retry_strategy,
                                                                   ChannelManager channelmanager)
        Pays the given [`Invoice`] with a custom idempotency key, retrying if needed based on [`Retry`]. Note that idempotency is only guaranteed as long as the payment is still pending. Once the payment completes or fails, no idempotency guarantees are made. You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] has never been paid before. See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
      • pay_zero_value_invoice

        public static Result_PaymentIdPaymentErrorZ pay_zero_value_invoice​(Invoice invoice,
                                                                           long amount_msats,
                                                                           Retry retry_strategy,
                                                                           ChannelManager channelmanager)
        Pays the given zero-value [`Invoice`] using the given amount, retrying if needed based on [`Retry`]. [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long as the payment is still pending. Once the payment completes or fails, you must ensure that a second payment with the same [`PaymentHash`] is never sent. If you wish to use a different payment idempotency token, see [`pay_zero_value_invoice_with_id`].
      • pay_zero_value_invoice_with_id

        public static Result_NonePaymentErrorZ pay_zero_value_invoice_with_id​(Invoice invoice,
                                                                              long amount_msats,
                                                                              byte[] payment_id,
                                                                              Retry retry_strategy,
                                                                              ChannelManager channelmanager)
        Pays the given zero-value [`Invoice`] using the given amount and custom idempotency key, , retrying if needed based on [`Retry`]. Note that idempotency is only guaranteed as long as the payment is still pending. Once the payment completes or fails, no idempotency guarantees are made. You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] has never been paid before. See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
      • create_phantom_invoice

        public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice​(Option_u64Z amt_msat,
                                                                                @Nullable
                                                                                byte[] payment_hash,
                                                                                String description,
                                                                                int invoice_expiry_delta_secs,
                                                                                PhantomRouteHints[] phantom_route_hints,
                                                                                EntropySource entropy_source,
                                                                                NodeSigner node_signer,
                                                                                Logger logger,
                                                                                Currency network,
                                                                                Option_u16Z min_final_cltv_expiry_delta,
                                                                                long duration_since_epoch)
        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). [`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 [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA 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. Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None
      • create_phantom_invoice_with_description_hash

        public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash​(Option_u64Z amt_msat,
                                                                                                      @Nullable
                                                                                                      byte[] payment_hash,
                                                                                                      int invoice_expiry_delta_secs,
                                                                                                      Sha256 description_hash,
                                                                                                      PhantomRouteHints[] phantom_route_hints,
                                                                                                      EntropySource entropy_source,
                                                                                                      NodeSigner node_signer,
                                                                                                      Logger logger,
                                                                                                      Currency network,
                                                                                                      Option_u16Z min_final_cltv_expiry_delta,
                                                                                                      long duration_since_epoch)
        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. `duration_since_epoch` is the current time since epoch in seconds. Note that the provided `keys_manager`'s `NodeSigner` 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 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. Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None
      • create_invoice_from_channelmanager

        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager​(ChannelManager channelmanager,
                                                                                            NodeSigner node_signer,
                                                                                            Logger logger,
                                                                                            Currency network,
                                                                                            Option_u64Z amt_msat,
                                                                                            String description,
                                                                                            int invoice_expiry_delta_secs,
                                                                                            Option_u16Z min_final_cltv_expiry_delta)
        Utility to construct an invoice. Generally, unless you want to do something like a custom cltv_expiry, this is what you should be using to create an invoice. The reason being, this method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify that the payment secret is valid when the invoice is paid. `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for in excess of the current time. 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`]. 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. [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
      • create_invoice_from_channelmanager_with_description_hash

        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash​(ChannelManager channelmanager,
                                                                                                                  NodeSigner node_signer,
                                                                                                                  Logger logger,
                                                                                                                  Currency network,
                                                                                                                  Option_u64Z amt_msat,
                                                                                                                  Sha256 description_hash,
                                                                                                                  int invoice_expiry_delta_secs,
                                                                                                                  Option_u16Z min_final_cltv_expiry_delta)
        Utility to construct an invoice. Generally, unless you want to do something like a custom cltv_expiry, this is what you should be using to create an invoice. The reason being, this method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify that the payment secret is valid when the invoice is paid. Use this variant if you want to pass the `description_hash` to the invoice. `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for in excess of the current time. 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`]. 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. [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
      • create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch

        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch​(ChannelManager channelmanager,
                                                                                                                                           NodeSigner node_signer,
                                                                                                                                           Logger logger,
                                                                                                                                           Currency network,
                                                                                                                                           Option_u64Z amt_msat,
                                                                                                                                           Sha256 description_hash,
                                                                                                                                           long duration_since_epoch,
                                                                                                                                           int invoice_expiry_delta_secs,
                                                                                                                                           Option_u16Z min_final_cltv_expiry_delta)
        See [`create_invoice_from_channelmanager_with_description_hash`] This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller.
      • create_invoice_from_channelmanager_and_duration_since_epoch

        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch​(ChannelManager channelmanager,
                                                                                                                     NodeSigner node_signer,
                                                                                                                     Logger logger,
                                                                                                                     Currency network,
                                                                                                                     Option_u64Z amt_msat,
                                                                                                                     String description,
                                                                                                                     long duration_since_epoch,
                                                                                                                     int invoice_expiry_delta_secs,
                                                                                                                     Option_u16Z min_final_cltv_expiry_delta)
        See [`create_invoice_from_channelmanager`] This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller.
      • create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash

        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash​(ChannelManager channelmanager,
                                                                                                                                       NodeSigner node_signer,
                                                                                                                                       Logger logger,
                                                                                                                                       Currency network,
                                                                                                                                       Option_u64Z amt_msat,
                                                                                                                                       String description,
                                                                                                                                       long duration_since_epoch,
                                                                                                                                       int invoice_expiry_delta_secs,
                                                                                                                                       byte[] payment_hash,
                                                                                                                                       Option_u16Z min_final_cltv_expiry_delta)
        See [`create_invoice_from_channelmanager_and_duration_since_epoch`] This version allows for providing a custom [`PaymentHash`] for the invoice. This may be useful if you're building an on-chain swap or involving another protocol where the payment hash is also involved outside the scope of lightning.