Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / NetworkUpdate.java
index 25e22024e2d7c5676544d0eb1acbd78b1155a25e..8abc8b58ee59ce596220bb8abd4f1f63e059d584 100644 (file)
@@ -35,6 +35,10 @@ public class NetworkUpdate extends CommonBase {
                assert false; return null; // Unreachable without extending the (internal) bindings interface
        }
 
+       /**
+        * An error indicating a `channel_update` messages should be applied via
+        * [`NetworkGraph::update_channel`].
+        */
        public final static class ChannelUpdateMessage extends NetworkUpdate {
                /**
                 * The update to apply via [`NetworkGraph::update_channel`].
@@ -43,11 +47,15 @@ public class NetworkUpdate extends CommonBase {
                private ChannelUpdateMessage(long ptr, bindings.LDKNetworkUpdate.ChannelUpdateMessage obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
+                       ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
        }
+       /**
+        * An error indicating only that a channel has been closed, which should be applied via
+        * [`NetworkGraph::close_channel_from_update`].
+        */
        public final static class ChannelClosed extends NetworkUpdate {
                /**
                 * The short channel id of the closed channel.
@@ -64,6 +72,10 @@ public class NetworkUpdate extends CommonBase {
                        this.is_permanent = obj.is_permanent;
                }
        }
+       /**
+        * An error indicating only that a node has failed, which should be applied via
+        * [`NetworkGraph::fail_node`].
+        */
        public final static class NodeFailure extends NetworkUpdate {
                /**
                 * The node id of the failed node.
@@ -80,12 +92,17 @@ public class NetworkUpdate extends CommonBase {
                        this.is_permanent = obj.is_permanent;
                }
        }
+       long clone_ptr() {
+               long ret = bindings.NetworkUpdate_clone_ptr(this.ptr);
+               return ret;
+       }
+
        /**
         * Creates a copy of the NetworkUpdate
         */
        public NetworkUpdate clone() {
                long ret = bindings.NetworkUpdate_clone(this.ptr);
-               if (ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -96,10 +113,9 @@ public class NetworkUpdate extends CommonBase {
         */
        public static NetworkUpdate channel_update_message(ChannelUpdate msg) {
                long ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1);
-               if (ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
-               ret_hu_conv.ptrs_to.add(msg);
                return ret_hu_conv;
        }
 
@@ -108,7 +124,7 @@ public class NetworkUpdate extends CommonBase {
         */
        public static NetworkUpdate channel_closed(long short_channel_id, boolean is_permanent) {
                long ret = bindings.NetworkUpdate_channel_closed(short_channel_id, is_permanent);
-               if (ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -118,8 +134,8 @@ public class NetworkUpdate extends CommonBase {
         * Utility method to constructs a new NodeFailure-variant NetworkUpdate
         */
        public static NetworkUpdate node_failure(byte[] node_id, boolean is_permanent) {
-               long ret = bindings.NetworkUpdate_node_failure(node_id, is_permanent);
-               if (ret < 1024) { return null; }
+               long ret = bindings.NetworkUpdate_node_failure(InternalUtils.check_arr_len(node_id, 33), is_permanent);
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;