+ public static Result_RouteLightningErrorZ build_route_from_hops(byte[] our_node_pubkey, byte[][] hops, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Logger logger, byte[] random_seed_bytes) {
+ long ret = bindings.build_route_from_hops(InternalUtils.check_arr_len(our_node_pubkey, 33), hops != null ? Arrays.stream(hops).map(hops_conv_8 -> InternalUtils.check_arr_len(hops_conv_8, 33)).toArray(byte[][]::new) : null, route_params.ptr, network_graph.ptr, logger.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
+ Reference.reachabilityFence(our_node_pubkey);
+ Reference.reachabilityFence(hops);
+ Reference.reachabilityFence(route_params);
+ Reference.reachabilityFence(network_graph);
+ Reference.reachabilityFence(logger);
+ Reference.reachabilityFence(random_seed_bytes);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
+ * the given outputs, plus an output to the given change destination (if sufficient
+ * change value remains). The PSBT will have a feerate, at least, of the given value.
+ *
+ * The `locktime` argument is used to set the transaction's locktime. If `None`, the
+ * transaction will have a locktime of 0. It it recommended to set this to the current block
+ * height to avoid fee sniping, unless you have some specific reason to use a different
+ * locktime.
+ *
+ * Returns the PSBT and expected max transaction weight.
+ *
+ * Returns `Err(())` if the output value is greater than the input value minus required fee,
+ * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
+ * does not match the one we can spend.
+ *
+ * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
+ */
+ public static Result_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_u32Z locktime) {
+ long ret = bindings.SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors != null ? Arrays.stream(descriptors).mapToLong(descriptors_conv_27 -> descriptors_conv_27.ptr).toArray() : null, outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_7 -> outputs_conv_7.ptr).toArray() : null, change_destination_script, feerate_sat_per_1000_weight, locktime.ptr);
+ Reference.reachabilityFence(descriptors);
+ Reference.reachabilityFence(outputs);
+ Reference.reachabilityFence(change_destination_script);
+ Reference.reachabilityFence(feerate_sat_per_1000_weight);
+ Reference.reachabilityFence(locktime);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C2Tuple_CVec_u8Zu64ZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8Zu64ZNoneZ.constr_from_ptr(ret);
+ for (SpendableOutputDescriptor descriptors_conv_27: descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(descriptors_conv_27); }; };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(locktime); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
+ * `path`, first calling [`Destination::resolve`] on `path.destination` with the given
+ * [`ReadOnlyNetworkGraph`].
+ *
+ * Returns the node id of the peer to send the message to, the message itself, and any addresses
+ * needed to connect to the first node.
+ *
+ * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ public static Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.NodeIdLookUp node_id_lookup, org.ldk.structs.ReadOnlyNetworkGraph network_graph, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, @Nullable org.ldk.structs.BlindedPath reply_path) {
+ long ret = bindings.create_onion_message_resolving_destination(entropy_source.ptr, node_signer.ptr, node_id_lookup.ptr, network_graph.ptr, path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
+ Reference.reachabilityFence(entropy_source);
+ Reference.reachabilityFence(node_signer);
+ Reference.reachabilityFence(node_id_lookup);
+ Reference.reachabilityFence(network_graph);
+ Reference.reachabilityFence(path);
+ Reference.reachabilityFence(contents);
+ Reference.reachabilityFence(reply_path);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_id_lookup); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
+ * `path`.
+ *
+ * Returns the node id of the peer to send the message to, the message itself, and any addresses
+ * needed to connect to the first node.
+ *
+ * Returns [`SendError::UnresolvedIntroductionNode`] if:
+ * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`],
+ * - unless it can be resolved by [`NodeIdLookUp::next_node_id`].
+ * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node
+ * first with a [`ReadOnlyNetworkGraph`].
+ *
+ * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ public static Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.NodeIdLookUp node_id_lookup, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, @Nullable org.ldk.structs.BlindedPath reply_path) {
+ long ret = bindings.create_onion_message(entropy_source.ptr, node_signer.ptr, node_id_lookup.ptr, path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
+ Reference.reachabilityFence(entropy_source);
+ Reference.reachabilityFence(node_signer);
+ Reference.reachabilityFence(node_id_lookup);
+ Reference.reachabilityFence(path);
+ Reference.reachabilityFence(contents);
+ Reference.reachabilityFence(reply_path);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_id_lookup); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Decode one layer of an incoming [`OnionMessage`].
+ *
+ * Returns either the next layer of the onion for forwarding or the decrypted content for the
+ * receiver.
+ */
+ public static Result_PeeledOnionNoneZ peel_onion_message(org.ldk.structs.OnionMessage msg, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.structs.CustomOnionMessageHandler custom_handler) {
+ long ret = bindings.peel_onion_message(msg.ptr, node_signer.ptr, logger.ptr, custom_handler.ptr);
+ Reference.reachabilityFence(msg);
+ Reference.reachabilityFence(node_signer);
+ Reference.reachabilityFence(logger);
+ Reference.reachabilityFence(custom_handler);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_PeeledOnionNoneZ ret_hu_conv = Result_PeeledOnionNoneZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(custom_handler); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Returns whether `tlv_type` corresponds to a TLV record for Offers.
+ */
+ public static boolean OffersMessage_is_known_type(long tlv_type) {
+ boolean ret = bindings.OffersMessage_is_known_type(tlv_type);
+ Reference.reachabilityFence(tlv_type);
+ return ret;
+ }
+
+ /**
+ * Create a one-hop blinded path for a payment.
+ */
+ public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, short min_final_cltv_expiry_delta, org.ldk.structs.EntropySource entropy_source) {
+ long ret = bindings.BlindedPath_one_hop_for_payment(InternalUtils.check_arr_len(payee_node_id, 33), payee_tlvs.ptr, min_final_cltv_expiry_delta, entropy_source.ptr);
+ Reference.reachabilityFence(payee_node_id);
+ Reference.reachabilityFence(payee_tlvs);
+ Reference.reachabilityFence(min_final_cltv_expiry_delta);
+ Reference.reachabilityFence(entropy_source);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
+ *
+ * Errors if:
+ * a provided node id is invalid
+ * [`BlindedPayInfo`] calculation results in an integer overflow
+ * any unknown features are required in the provided [`ForwardTlvs`]
+ *
+ * [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
+ */
+ public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_new_for_payment(ForwardNode[] intermediate_nodes, byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, long htlc_maximum_msat, short min_final_cltv_expiry_delta, org.ldk.structs.EntropySource entropy_source) {
+ long ret = bindings.BlindedPath_new_for_payment(intermediate_nodes != null ? Arrays.stream(intermediate_nodes).mapToLong(intermediate_nodes_conv_13 -> intermediate_nodes_conv_13.ptr).toArray() : null, InternalUtils.check_arr_len(payee_node_id, 33), payee_tlvs.ptr, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source.ptr);
+ Reference.reachabilityFence(intermediate_nodes);
+ Reference.reachabilityFence(payee_node_id);
+ Reference.reachabilityFence(payee_tlvs);
+ Reference.reachabilityFence(htlc_maximum_msat);
+ Reference.reachabilityFence(min_final_cltv_expiry_delta);
+ Reference.reachabilityFence(entropy_source);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
+ for (ForwardNode intermediate_nodes_conv_13: intermediate_nodes) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(intermediate_nodes_conv_13); }; };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a PathFailure from a byte array, created by PathFailure_write
+ */
+ public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
+ long ret = bindings.PathFailure_read(ser);
+ Reference.reachabilityFence(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a ClosureReason from a byte array, created by ClosureReason_write
+ */
+ public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
+ long ret = bindings.ClosureReason_read(ser);
+ Reference.reachabilityFence(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a HTLCDestination from a byte array, created by HTLCDestination_write
+ */
+ public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
+ long ret = bindings.HTLCDestination_read(ser);
+ Reference.reachabilityFence(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a Event from a byte array, created by Event_write
+ */
+ public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
+ long ret = bindings.Event_read(ser);
+ Reference.reachabilityFence(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Builds the necessary parameters to pay or pre-flight probe the given zero-amount
+ * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
+ * [`ChannelManager::send_preflight_probes`].
+ *
+ * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
+ * same [`PaymentHash`] has never been paid before.
+ *
+ * Will always succeed unless the invoice has an amount specified, in which case
+ * [`payment_parameters_from_invoice`] should be used.
+ *
+ * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
+ */
+ public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat) {
+ long ret = bindings.payment_parameters_from_zero_amount_invoice(invoice.ptr, amount_msat);
+ Reference.reachabilityFence(invoice);
+ Reference.reachabilityFence(amount_msat);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using
+ * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`].
+ *
+ * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
+ * same [`PaymentHash`] has never been paid before.
+ *
+ * Will always succeed unless the invoice has no amount specified, in which case
+ * [`payment_parameters_from_zero_amount_invoice`] should be used.
+ *
+ * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
+ */
+ public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(org.ldk.structs.Bolt11Invoice invoice) {
+ long ret = bindings.payment_parameters_from_invoice(invoice.ptr);
+ Reference.reachabilityFence(invoice);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * 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::sign::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.
+ */
+ public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, java.lang.String description, int invoice_expiry_delta_secs, PhantomRouteHints[] phantom_route_hints, org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
+ long ret = bindings.create_phantom_invoice(amt_msat.ptr, payment_hash.ptr, description, invoice_expiry_delta_secs, phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
+ Reference.reachabilityFence(amt_msat);
+ Reference.reachabilityFence(payment_hash);
+ Reference.reachabilityFence(description);
+ Reference.reachabilityFence(invoice_expiry_delta_secs);
+ Reference.reachabilityFence(phantom_route_hints);
+ Reference.reachabilityFence(entropy_source);
+ Reference.reachabilityFence(node_signer);
+ Reference.reachabilityFence(logger);
+ Reference.reachabilityFence(network);
+ Reference.reachabilityFence(min_final_cltv_expiry_delta);
+ Reference.reachabilityFence(duration_since_epoch);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
+ for (PhantomRouteHints phantom_route_hints_conv_19: phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(phantom_route_hints_conv_19); }; };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * 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 the route hints generated from `phantom_route_hints` will be limited to a maximum
+ * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
+ * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
+ * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
+ * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
+ *
+ * `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::sign::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.
+ */
+ public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, int invoice_expiry_delta_secs, org.ldk.structs.Sha256 description_hash, PhantomRouteHints[] phantom_route_hints, org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
+ long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, payment_hash.ptr, invoice_expiry_delta_secs, description_hash.ptr, phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
+ Reference.reachabilityFence(amt_msat);
+ Reference.reachabilityFence(payment_hash);
+ Reference.reachabilityFence(invoice_expiry_delta_secs);
+ Reference.reachabilityFence(description_hash);
+ Reference.reachabilityFence(phantom_route_hints);
+ Reference.reachabilityFence(entropy_source);
+ Reference.reachabilityFence(node_signer);
+ Reference.reachabilityFence(logger);
+ Reference.reachabilityFence(network);
+ Reference.reachabilityFence(min_final_cltv_expiry_delta);
+ Reference.reachabilityFence(duration_since_epoch);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
+ for (PhantomRouteHints phantom_route_hints_conv_19: phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(phantom_route_hints_conv_19); }; };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * 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
+ */
+ public static Result_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.enums.Currency network, org.ldk.structs.Option_u64Z amt_msat, java.lang.String description, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
+ long ret = bindings.create_invoice_from_channelmanager(channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
+ Reference.reachabilityFence(channelmanager);
+ Reference.reachabilityFence(node_signer);
+ Reference.reachabilityFence(logger);
+ Reference.reachabilityFence(network);
+ Reference.reachabilityFence(amt_msat);
+ Reference.reachabilityFence(description);
+ Reference.reachabilityFence(invoice_expiry_delta_secs);
+ Reference.reachabilityFence(min_final_cltv_expiry_delta);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };