Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / UtilMethods.java
index dac1f32ce06ef0e9da6ea26cc7ecf08f8113daf9..f3bc9b1704ac32640ea9107ca13ff3900b0b011a 100644 (file)
@@ -1,17 +1,38 @@
 package org.ldk.structs;
 import org.ldk.impl.bindings;
+import org.ldk.enums.*;
+import org.ldk.util.*;
 import java.util.Arrays;
 import javax.annotation.Nullable;
-import org.ldk.enums.*;
 
 public class UtilMethods {
+       /**
+        * 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);
+               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);
+               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);
+               long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
@@ -32,10 +53,20 @@ 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));
                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);
+               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
         */
@@ -68,7 +99,7 @@ public class UtilMethods {
         * 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);
                return ret;
        }
 
@@ -88,7 +119,7 @@ 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);
+               long ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
@@ -103,7 +134,7 @@ 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);
+               long ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
@@ -121,7 +152,7 @@ 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);
+               long ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
@@ -141,7 +172,7 @@ 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);
+               long ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
@@ -153,7 +184,7 @@ 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));
                return ret;
        }
 
@@ -173,7 +204,7 @@ 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));
                return ret;
        }
 
@@ -187,7 +218,7 @@ public class UtilMethods {
         * 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);
+               byte[] ret = bindings.build_htlc_transaction(InternalUtils.check_arr_len(commitment_txid, 32), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr & ~1, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
                // this.ptrs_to.add(htlc);
                return ret;
        }
@@ -201,10 +232,20 @@ 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);
                return ret;
        }
 
+       /**
+        * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
+        */
+       public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
+               long ret = bindings.NetworkUpdate_read(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;
+       }
+
        /**
         * Finds a route from us (payer) to the given target node (payee).
         * 
@@ -238,7 +279,7 @@ public class UtilMethods {
         * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
        public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, RouteParameters params, NetworkGraph network, @Nullable ChannelDetails[] first_hops, Logger logger, Score scorer) {
-               long ret = bindings.find_route(our_node_pubkey, params == null ? 0 : 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);
+               long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), params == null ? 0 : 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);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(params);