[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / Init.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An init message to be sent or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Init extends CommonBase {
16         Init(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Init_free(ptr); }
21         }
22
23         /**
24          * The relevant features which the sender supports
25          */
26         public InitFeatures get_features() {
27                 long ret = bindings.Init_get_features(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
31                 ret_hu_conv.ptrs_to.add(this);
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The relevant features which the sender supports
37          */
38         public void set_features(InitFeatures val) {
39                 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42         }
43
44         /**
45          * The receipient's network address. This adds the option to report a remote IP address
46          * back to a connecting peer using the init message. A node can decide to use that information
47          * to discover a potential update to its public IPv4 address (NAT) and use
48          * that for a node_announcement update message containing the new address.
49          */
50         public Option_NetAddressZ get_remote_network_address() {
51                 long ret = bindings.Init_get_remote_network_address(this.ptr);
52                 Reference.reachabilityFence(this);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 org.ldk.structs.Option_NetAddressZ ret_hu_conv = org.ldk.structs.Option_NetAddressZ.constr_from_ptr(ret);
55                 ret_hu_conv.ptrs_to.add(this);
56                 return ret_hu_conv;
57         }
58
59         /**
60          * The receipient's network address. This adds the option to report a remote IP address
61          * back to a connecting peer using the init message. A node can decide to use that information
62          * to discover a potential update to its public IPv4 address (NAT) and use
63          * that for a node_announcement update message containing the new address.
64          */
65         public void set_remote_network_address(Option_NetAddressZ val) {
66                 bindings.Init_set_remote_network_address(this.ptr, val.ptr);
67                 Reference.reachabilityFence(this);
68                 Reference.reachabilityFence(val);
69         }
70
71         /**
72          * Constructs a new Init given each field
73          */
74         public static Init of(InitFeatures features_arg, Option_NetAddressZ remote_network_address_arg) {
75                 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr & ~1, remote_network_address_arg.ptr);
76                 Reference.reachabilityFence(features_arg);
77                 Reference.reachabilityFence(remote_network_address_arg);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); }
80                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
81                 return ret_hu_conv;
82         }
83
84         long clone_ptr() {
85                 long ret = bindings.Init_clone_ptr(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * Creates a copy of the Init
92          */
93         public Init clone() {
94                 long ret = bindings.Init_clone(this.ptr);
95                 Reference.reachabilityFence(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); }
98                 ret_hu_conv.ptrs_to.add(this);
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Serialize the Init object into a byte array which can be read by Init_read
104          */
105         public byte[] write() {
106                 byte[] ret = bindings.Init_write(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * Read a Init from a byte array, created by Init_write
113          */
114         public static Result_InitDecodeErrorZ read(byte[] ser) {
115                 long ret = bindings.Init_read(ser);
116                 Reference.reachabilityFence(ser);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
119                 return ret_hu_conv;
120         }
121
122 }