[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / UtilMethods.java
index e7ea1861b68bc9923a92da15ea758402799de734..7c53034ab6b3f49978075c0c580af1c7be17b7cf 100644 (file)
@@ -1,18 +1,60 @@
 package org.ldk.structs;
 import org.ldk.impl.bindings;
+import org.ldk.enums.*;
+import org.ldk.util.*;
 import java.util.Arrays;
+import java.lang.ref.Reference;
 import javax.annotation.Nullable;
-import org.ldk.enums.*;
 
 public class UtilMethods {
+       /**
+        * Constructs a new COption_NoneZ containing a
+        */
+       public static COption_NoneZ COption_NoneZ_some() {
+               COption_NoneZ ret = bindings.COption_NoneZ_some();
+               return ret;
+       }
+
+       /**
+        * Constructs a new COption_NoneZ containing nothing
+        */
+       public static COption_NoneZ COption_NoneZ_none() {
+               COption_NoneZ ret = bindings.COption_NoneZ_none();
+               return ret;
+       }
+
+       /**
+        * 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 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;
+       }
+
        /**
         * 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.
         */
        public static Result_StringErrorZ sign(byte[] msg, byte[] sk) {
-               long ret = bindings.sign(msg, sk);
-               if (ret < 1024) { return null; }
+               long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
+               Reference.reachabilityFence(msg);
+               Reference.reachabilityFence(sk);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -22,7 +64,9 @@ public class UtilMethods {
         */
        public static Result_PublicKeyErrorZ recover_pk(byte[] msg, java.lang.String sig) {
                long ret = bindings.recover_pk(msg, sig);
-               if (ret < 1024) { return null; }
+               Reference.reachabilityFence(msg);
+               Reference.reachabilityFence(sig);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -32,16 +76,42 @@ public class UtilMethods {
         * and the PublicKey.
         */
        public static boolean verify(byte[] msg, java.lang.String sig, byte[] pk) {
-               boolean ret = bindings.verify(msg, sig, pk);
+               boolean ret = bindings.verify(msg, sig, InternalUtils.check_arr_len(pk, 33));
+               Reference.reachabilityFence(msg);
+               Reference.reachabilityFence(sig);
+               Reference.reachabilityFence(pk);
                return ret;
        }
 
+       /**
+        * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
+        */
+       public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
+               byte[] ret = bindings.construct_invoice_preimage(hrp_bytes, data_without_signature != null ? InternalUtils.convUInt5Array(data_without_signature) : null);
+               Reference.reachabilityFence(hrp_bytes);
+               Reference.reachabilityFence(data_without_signature);
+               return ret;
+       }
+
+       /**
+        * Read a MonitorEvent from a byte array, created by MonitorEvent_write
+        */
+       public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
+               long ret = bindings.MonitorEvent_read(ser);
+               Reference.reachabilityFence(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
        /**
         * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
         */
-       public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ BlockHashChannelMonitorZ_read(byte[] ser, KeysInterface arg) {
+       public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, KeysInterface arg) {
                long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg == null ? 0 : arg.ptr);
-               if (ret < 1024) { return null; }
+               Reference.reachabilityFence(ser);
+               Reference.reachabilityFence(arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(arg);
                return ret_hu_conv;
@@ -50,25 +120,66 @@ public class UtilMethods {
        /**
         * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
         */
-       public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ BlockHashChannelManagerZ_read(byte[] ser, KeysInterface arg_keys_manager, FeeEstimator arg_fee_estimator, Watch arg_chain_monitor, BroadcasterInterface arg_tx_broadcaster, Logger arg_logger, UserConfig arg_default_config, ChannelMonitor[] arg_channel_monitors) {
+       public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(byte[] ser, KeysInterface arg_keys_manager, FeeEstimator arg_fee_estimator, Watch arg_chain_monitor, BroadcasterInterface arg_tx_broadcaster, Logger arg_logger, UserConfig arg_default_config, ChannelMonitor[] arg_channel_monitors) {
                long ret = bindings.C2Tuple_BlockHashChannelManagerZ_read(ser, bindings.ChannelManagerReadArgs_new(arg_keys_manager == null ? 0 : arg_keys_manager.ptr, arg_fee_estimator == null ? 0 : arg_fee_estimator.ptr, arg_chain_monitor == null ? 0 : arg_chain_monitor.ptr, arg_tx_broadcaster == null ? 0 : arg_tx_broadcaster.ptr, arg_logger == null ? 0 : arg_logger.ptr, arg_default_config == null ? 0 : arg_default_config.ptr & ~1, arg_channel_monitors != null ? Arrays.stream(arg_channel_monitors).mapToLong(arg_channel_monitors_conv_16 -> arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr & ~1).toArray() : null));
-               if (ret < 1024) { return null; }
+               Reference.reachabilityFence(ser);
+               Reference.reachabilityFence(arg_keys_manager);
+               Reference.reachabilityFence(arg_fee_estimator);
+               Reference.reachabilityFence(arg_chain_monitor);
+               Reference.reachabilityFence(arg_tx_broadcaster);
+               Reference.reachabilityFence(arg_logger);
+               Reference.reachabilityFence(arg_default_config);
+               Reference.reachabilityFence(arg_channel_monitors);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(arg_keys_manager);
                ret_hu_conv.ptrs_to.add(arg_fee_estimator);
                ret_hu_conv.ptrs_to.add(arg_chain_monitor);
                ret_hu_conv.ptrs_to.add(arg_tx_broadcaster);
                ret_hu_conv.ptrs_to.add(arg_logger);
-               ret_hu_conv.ptrs_to.add(arg_default_config);
-               /* TODO 2 ChannelMonitor  */;
+               ;
+               for (ChannelMonitor arg_channel_monitors_conv_16: arg_channel_monitors) { ret_hu_conv.ptrs_to.add(arg_channel_monitors_conv_16); };
                return ret_hu_conv;
        }
 
+       /**
+        * Gets the weight for an HTLC-Success transaction.
+        */
+       public static long htlc_success_tx_weight(boolean opt_anchors) {
+               long ret = bindings.htlc_success_tx_weight(opt_anchors);
+               Reference.reachabilityFence(opt_anchors);
+               return ret;
+       }
+
+       /**
+        * Gets the weight for an HTLC-Timeout transaction.
+        */
+       public static long htlc_timeout_tx_weight(boolean opt_anchors) {
+               long ret = bindings.htlc_timeout_tx_weight(opt_anchors);
+               Reference.reachabilityFence(opt_anchors);
+               return ret;
+       }
+
        /**
         * Build the commitment secret from the seed and the commitment number
         */
        public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
-               byte[] ret = bindings.build_commitment_secret(commitment_seed, idx);
+               byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
+               Reference.reachabilityFence(commitment_seed);
+               Reference.reachabilityFence(idx);
+               return ret;
+       }
+
+       /**
+        * Build a 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) {
+               byte[] ret = bindings.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1);
+               Reference.reachabilityFence(to_holder_value_sat);
+               Reference.reachabilityFence(to_counterparty_value_sat);
+               Reference.reachabilityFence(to_holder_script);
+               Reference.reachabilityFence(to_counterparty_script);
+               Reference.reachabilityFence(funding_outpoint);
                return ret;
        }
 
@@ -80,8 +191,10 @@ public class UtilMethods {
         * generated (ie our own).
         */
        public static Result_SecretKeyErrorZ derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
-               long ret = bindings.derive_private_key(per_commitment_point, base_secret);
-               if (ret < 1024) { return null; }
+               long ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
+               Reference.reachabilityFence(per_commitment_point);
+               Reference.reachabilityFence(base_secret);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -95,8 +208,10 @@ public class UtilMethods {
         * generated (ie our own).
         */
        public static Result_PublicKeyErrorZ derive_public_key(byte[] per_commitment_point, byte[] base_point) {
-               long ret = bindings.derive_public_key(per_commitment_point, base_point);
-               if (ret < 1024) { return null; }
+               long ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
+               Reference.reachabilityFence(per_commitment_point);
+               Reference.reachabilityFence(base_point);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -113,8 +228,10 @@ public class UtilMethods {
         * generated (ie our own).
         */
        public static Result_SecretKeyErrorZ derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
-               long ret = bindings.derive_private_revocation_key(per_commitment_secret, countersignatory_revocation_base_secret);
-               if (ret < 1024) { return null; }
+               long ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
+               Reference.reachabilityFence(per_commitment_secret);
+               Reference.reachabilityFence(countersignatory_revocation_base_secret);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -133,8 +250,10 @@ public class UtilMethods {
         * generated (ie our own).
         */
        public static Result_PublicKeyErrorZ derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
-               long ret = bindings.derive_public_revocation_key(per_commitment_point, countersignatory_revocation_base_point);
-               if (ret < 1024) { return null; }
+               long ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
+               Reference.reachabilityFence(per_commitment_point);
+               Reference.reachabilityFence(countersignatory_revocation_base_point);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -145,7 +264,10 @@ public class UtilMethods {
         * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
         */
        public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
-               byte[] ret = bindings.get_revokeable_redeemscript(revocation_key, contest_delay, broadcaster_delayed_payment_key);
+               byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
+               Reference.reachabilityFence(revocation_key);
+               Reference.reachabilityFence(contest_delay);
+               Reference.reachabilityFence(broadcaster_delayed_payment_key);
                return ret;
        }
 
@@ -153,10 +275,11 @@ public class UtilMethods {
         * 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.
         */
-       public static byte[] get_htlc_redeemscript(HTLCOutputInCommitment htlc, TxCreationKeys keys) {
-               byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr & ~1, keys == null ? 0 : keys.ptr & ~1);
-               // this.ptrs_to.add(htlc);
-               // this.ptrs_to.add(keys);
+       public static byte[] get_htlc_redeemscript(HTLCOutputInCommitment htlc, boolean opt_anchors, TxCreationKeys keys) {
+               byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr & ~1, opt_anchors, keys == null ? 0 : keys.ptr & ~1);
+               Reference.reachabilityFence(htlc);
+               Reference.reachabilityFence(opt_anchors);
+               Reference.reachabilityFence(keys);
                return ret;
        }
 
@@ -165,7 +288,9 @@ public class UtilMethods {
         * Note that the order of funding public keys does not matter.
         */
        public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
-               byte[] ret = bindings.make_funding_redeemscript(broadcaster, countersignatory);
+               byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
+               Reference.reachabilityFence(broadcaster);
+               Reference.reachabilityFence(countersignatory);
                return ret;
        }
 
@@ -178,9 +303,29 @@ public class UtilMethods {
         * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
         * commitment transaction).
         */
-       public static byte[] build_htlc_transaction(byte[] commitment_txid, int feerate_per_kw, short contest_delay, HTLCOutputInCommitment htlc, byte[] broadcaster_delayed_payment_key, byte[] revocation_key) {
-               byte[] ret = bindings.build_htlc_transaction(commitment_txid, feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr & ~1, broadcaster_delayed_payment_key, revocation_key);
-               // this.ptrs_to.add(htlc);
+       public static byte[] build_htlc_transaction(byte[] commitment_txid, int feerate_per_kw, short contest_delay, HTLCOutputInCommitment htlc, boolean opt_anchors, byte[] broadcaster_delayed_payment_key, byte[] revocation_key) {
+               byte[] ret = bindings.build_htlc_transaction(InternalUtils.check_arr_len(commitment_txid, 32), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr & ~1, opt_anchors, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
+               Reference.reachabilityFence(commitment_txid);
+               Reference.reachabilityFence(feerate_per_kw);
+               Reference.reachabilityFence(contest_delay);
+               Reference.reachabilityFence(htlc);
+               Reference.reachabilityFence(opt_anchors);
+               Reference.reachabilityFence(broadcaster_delayed_payment_key);
+               Reference.reachabilityFence(revocation_key);
+               return ret;
+       }
+
+       /**
+        * Gets the witnessScript for an anchor output from the funding public key.
+        * The witness in the spending input must be:
+        * <BIP 143 funding_signature>
+        * After 16 blocks of confirmation, an alternative satisfying witness could be:
+        * <>
+        * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
+        */
+       public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
+               byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
+               Reference.reachabilityFence(funding_pubkey);
                return ret;
        }
 
@@ -193,61 +338,72 @@ public class UtilMethods {
         * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
         */
        public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, boolean outbound_from_broadcaster) {
-               long ret = bindings.get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint, countersignatory_payment_basepoint, outbound_from_broadcaster);
+               long ret = bindings.get_commitment_transaction_number_obscure_factor(InternalUtils.check_arr_len(broadcaster_payment_basepoint, 33), InternalUtils.check_arr_len(countersignatory_payment_basepoint, 33), outbound_from_broadcaster);
+               Reference.reachabilityFence(broadcaster_payment_basepoint);
+               Reference.reachabilityFence(countersignatory_payment_basepoint);
+               Reference.reachabilityFence(outbound_from_broadcaster);
                return ret;
        }
 
        /**
-        * Gets a keysend route from us (payer) to the given target node (payee). This is needed because
-        * keysend payments do not have an invoice from which to pull the payee's supported features, which
-        * makes it tricky to otherwise supply the `payee_features` parameter of `get_route`.
-        * 
-        * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
+        * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
         */
-       public static Result_RouteLightningErrorZ get_keysend_route(byte[] our_node_id, NetworkGraph network, byte[] payee, @Nullable ChannelDetails[] first_hops, RouteHint[] last_hops, long final_value_msat, int final_cltv, Logger logger) {
-               long ret = bindings.get_keysend_route(our_node_id, network == null ? 0 : network.ptr & ~1, payee, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, last_hops != null ? Arrays.stream(last_hops).mapToLong(last_hops_conv_11 -> last_hops_conv_11 == null ? 0 : last_hops_conv_11.ptr & ~1).toArray() : null, final_value_msat, final_cltv, logger == null ? 0 : logger.ptr);
-               if (ret < 1024) { return null; }
-               Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(network);
-               /* TODO 2 ChannelDetails  */;
-               /* TODO 2 RouteHint  */;
-               ret_hu_conv.ptrs_to.add(logger);
+       public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
+               long ret = bindings.NetworkUpdate_read(ser);
+               Reference.reachabilityFence(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
 
        /**
-        * Gets a route from us (payer) to the given target node (payee).
+        * 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 payee_features.
+        * 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 `last_hops`.
-        * Currently, only the last hop in each path is considered.
+        * 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 our local
+        * channels from [`NetworkGraph`] 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
         * 
-        * If some channels aren't announced, it may be useful to fill in a first_hops with the
-        * results from a local ChannelManager::list_usable_channels() call. If it is filled in, our
-        * view of our local channels (from net_graph_msg_handler) will be ignored, and only those
-        * in first_hops will be used.
+        * 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 if first_hops contains channels without short_channel_ids
-        * (ChannelManager::list_usable_channels will never include such channels).
+        * # Panics
         * 
-        * The fees on channels from us to next-hops 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.
+        * 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::util::events::Event::PaymentPathFailed
         * 
-        * Note that payee_features (or a relevant inner pointer) may be NULL or all-0s to represent None
         * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public static Result_RouteLightningErrorZ get_route(byte[] our_node_id, NetworkGraph network, byte[] payee, @Nullable InvoiceFeatures payee_features, @Nullable ChannelDetails[] first_hops, RouteHint[] last_hops, long final_value_msat, int final_cltv, Logger logger) {
-               long ret = bindings.get_route(our_node_id, network == null ? 0 : network.ptr & ~1, payee, payee_features == null ? 0 : payee_features.ptr & ~1, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, last_hops != null ? Arrays.stream(last_hops).mapToLong(last_hops_conv_11 -> last_hops_conv_11 == null ? 0 : last_hops_conv_11.ptr & ~1).toArray() : null, final_value_msat, final_cltv, logger == null ? 0 : logger.ptr);
-               if (ret < 1024) { return null; }
+       public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, RouteParameters route_params, NetworkGraph network, @Nullable ChannelDetails[] first_hops, Logger logger, Score scorer, byte[] random_seed_bytes) {
+               long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), route_params == null ? 0 : route_params.ptr & ~1, network == null ? 0 : network.ptr & ~1, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
+               Reference.reachabilityFence(our_node_pubkey);
+               Reference.reachabilityFence(route_params);
+               Reference.reachabilityFence(network);
+               Reference.reachabilityFence(first_hops);
+               Reference.reachabilityFence(logger);
+               Reference.reachabilityFence(scorer);
+               Reference.reachabilityFence(random_seed_bytes);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(route_params);
                ret_hu_conv.ptrs_to.add(network);
-               ret_hu_conv.ptrs_to.add(payee_features);
-               /* TODO 2 ChannelDetails  */;
-               /* TODO 2 RouteHint  */;
+               for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
                ret_hu_conv.ptrs_to.add(logger);
+               ret_hu_conv.ptrs_to.add(scorer);
                return ret_hu_conv;
        }
 
@@ -257,12 +413,112 @@ public class UtilMethods {
         */
        public static Result_NoneErrorZ FilesystemPersister_persist_manager(java.lang.String data_dir, ChannelManager manager) {
                long ret = bindings.FilesystemPersister_persist_manager(data_dir, manager == null ? 0 : manager.ptr & ~1);
-               if (ret < 1024) { return null; }
+               Reference.reachabilityFence(data_dir);
+               Reference.reachabilityFence(manager);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(manager);
                return ret_hu_conv;
        }
 
+       /**
+        * Write the provided `NetworkGraph` to the path provided at `FilesystemPersister`
+        * initialization, within a file called \"network_graph\"
+        */
+       public static Result_NoneErrorZ FilesystemPersister_persist_network_graph(java.lang.String data_dir, NetworkGraph network_graph) {
+               long ret = bindings.FilesystemPersister_persist_network_graph(data_dir, network_graph == null ? 0 : network_graph.ptr & ~1);
+               Reference.reachabilityFence(data_dir);
+               Reference.reachabilityFence(network_graph);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(network_graph);
+               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` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
+        * [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
+        * participating node.
+        * 
+        * 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
+        * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
+        */
+       public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice(Option_u64Z amt_msat, java.lang.String description, byte[] payment_hash, byte[] payment_secret, PhantomRouteHints[] phantom_route_hints, KeysInterface keys_manager, org.ldk.enums.Currency network) {
+               long ret = bindings.create_phantom_invoice(amt_msat.ptr, description, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr & ~1).toArray() : null, keys_manager == null ? 0 : keys_manager.ptr, network);
+               Reference.reachabilityFence(amt_msat);
+               Reference.reachabilityFence(description);
+               Reference.reachabilityFence(payment_hash);
+               Reference.reachabilityFence(payment_secret);
+               Reference.reachabilityFence(phantom_route_hints);
+               Reference.reachabilityFence(keys_manager);
+               Reference.reachabilityFence(network);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(keys_manager);
+               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
+        * 
+        * `description_hash` is a SHA-256 hash of the description text
+        * 
+        * `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
+        * [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
+        * participating node.
+        * 
+        * 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
+        * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
+        */
+       public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(Option_u64Z amt_msat, Sha256 description_hash, byte[] payment_hash, byte[] payment_secret, PhantomRouteHints[] phantom_route_hints, KeysInterface keys_manager, org.ldk.enums.Currency network) {
+               long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr & ~1, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr & ~1).toArray() : null, keys_manager == null ? 0 : keys_manager.ptr, network);
+               Reference.reachabilityFence(amt_msat);
+               Reference.reachabilityFence(description_hash);
+               Reference.reachabilityFence(payment_hash);
+               Reference.reachabilityFence(payment_secret);
+               Reference.reachabilityFence(phantom_route_hints);
+               Reference.reachabilityFence(keys_manager);
+               Reference.reachabilityFence(network);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(keys_manager);
+               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
@@ -272,7 +528,74 @@ public class UtilMethods {
         */
        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, java.lang.String description) {
                long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description);
-               if (ret < 1024) { return null; }
+               Reference.reachabilityFence(channelmanager);
+               Reference.reachabilityFence(keys_manager);
+               Reference.reachabilityFence(network);
+               Reference.reachabilityFence(amt_msat);
+               Reference.reachabilityFence(description);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(channelmanager);
+               ret_hu_conv.ptrs_to.add(keys_manager);
+               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.
+        * Use this variant if you want to pass the `description_hash` to the invoice.
+        */
+       public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, Sha256 description_hash) {
+               long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr & ~1);
+               Reference.reachabilityFence(channelmanager);
+               Reference.reachabilityFence(keys_manager);
+               Reference.reachabilityFence(network);
+               Reference.reachabilityFence(amt_msat);
+               Reference.reachabilityFence(description_hash);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(channelmanager);
+               ret_hu_conv.ptrs_to.add(keys_manager);
+               return ret_hu_conv;
+       }
+
+       /**
+        * 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.
+        */
+       public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, Sha256 description_hash, long duration_since_epoch) {
+               long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr & ~1, duration_since_epoch);
+               Reference.reachabilityFence(channelmanager);
+               Reference.reachabilityFence(keys_manager);
+               Reference.reachabilityFence(network);
+               Reference.reachabilityFence(amt_msat);
+               Reference.reachabilityFence(description_hash);
+               Reference.reachabilityFence(duration_since_epoch);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(channelmanager);
+               ret_hu_conv.ptrs_to.add(keys_manager);
+               return ret_hu_conv;
+       }
+
+       /**
+        * 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.
+        */
+       public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, java.lang.String description, long duration_since_epoch) {
+               long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description, duration_since_epoch);
+               Reference.reachabilityFence(channelmanager);
+               Reference.reachabilityFence(keys_manager);
+               Reference.reachabilityFence(network);
+               Reference.reachabilityFence(amt_msat);
+               Reference.reachabilityFence(description);
+               Reference.reachabilityFence(duration_since_epoch);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(channelmanager);
                ret_hu_conv.ptrs_to.add(keys_manager);