1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An init message to be sent or received from a peer
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 {
20 if (ptr != 0) { bindings.Init_free(ptr); }
24 * The relevant features which the sender supports
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 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
31 ret_hu_conv.ptrs_to.add(this);
36 * The relevant features which the sender supports
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);
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.
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);
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.
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);
72 * Constructs a new Init given each field
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 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
80 ret_hu_conv.ptrs_to.add(ret_hu_conv);
85 long ret = bindings.Init_clone_ptr(this.ptr);
86 Reference.reachabilityFence(this);
91 * Creates a copy of the Init
94 long ret = bindings.Init_clone(this.ptr);
95 Reference.reachabilityFence(this);
96 if (ret >= 0 && ret <= 4096) { return null; }
97 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
98 ret_hu_conv.ptrs_to.add(this);
103 * Serialize the Init object into a byte array which can be read by Init_read
105 public byte[] write() {
106 byte[] ret = bindings.Init_write(this.ptr);
107 Reference.reachabilityFence(this);
112 * Read a Init from a byte array, created by Init_write
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);