+ /**
+ * Utility method to constructs a new IPv4-variant NetAddress
+ */
+ public static NetAddress ipv4(byte[] addr, short port) {
+ long ret = bindings.NetAddress_ipv4(InternalUtils.check_arr_len(addr, 4), port);
+ Reference.reachabilityFence(addr);
+ Reference.reachabilityFence(port);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.NetAddress ret_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new IPv6-variant NetAddress
+ */
+ public static NetAddress ipv6(byte[] addr, short port) {
+ long ret = bindings.NetAddress_ipv6(InternalUtils.check_arr_len(addr, 16), port);
+ Reference.reachabilityFence(addr);
+ Reference.reachabilityFence(port);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.NetAddress ret_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new OnionV2-variant NetAddress
+ */
+ public static NetAddress onion_v2(byte[] a) {
+ long ret = bindings.NetAddress_onion_v2(InternalUtils.check_arr_len(a, 12));
+ Reference.reachabilityFence(a);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.NetAddress ret_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new OnionV3-variant NetAddress
+ */
+ public static NetAddress onion_v3(byte[] ed25519_pubkey, short checksum, byte version, short port) {
+ long ret = bindings.NetAddress_onion_v3(InternalUtils.check_arr_len(ed25519_pubkey, 32), checksum, version, port);
+ Reference.reachabilityFence(ed25519_pubkey);
+ Reference.reachabilityFence(checksum);
+ Reference.reachabilityFence(version);
+ Reference.reachabilityFence(port);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.NetAddress ret_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new Hostname-variant NetAddress
+ */
+ public static NetAddress hostname(Hostname hostname, short port) {
+ long ret = bindings.NetAddress_hostname(hostname == null ? 0 : hostname.ptr, port);
+ Reference.reachabilityFence(hostname);
+ Reference.reachabilityFence(port);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.NetAddress ret_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(hostname); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Checks if two NetAddresss contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+ public boolean eq(NetAddress b) {
+ boolean ret = bindings.NetAddress_eq(this.ptr, b == null ? 0 : b.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(b);
+ return ret;
+ }
+
+ @Override public boolean equals(Object o) {
+ if (!(o instanceof NetAddress)) return false;
+ return this.eq((NetAddress)o);
+ }