/**
- * An address which can be used to connect to a remote peer
+ * An address which can be used to connect to a remote peer.
*/
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
public class NetAddress extends CommonBase {
}
/**
* A new-style Tor onion address/port on which the peer is listening.
- * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
+ *
+ * To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
* wrap as base32 and append \".onion\".
*/
public final static class OnionV3 extends NetAddress {
super(null, ptr);
long hostname = obj.hostname;
org.ldk.structs.Hostname hostname_hu_conv = null; if (hostname < 0 || hostname > 4096) { hostname_hu_conv = new org.ldk.structs.Hostname(null, hostname); }
- hostname_hu_conv.ptrs_to.add(this);
+ if (hostname_hu_conv != null) { hostname_hu_conv.ptrs_to.add(this); };
this.hostname = hostname_hu_conv;
this.port = obj.port;
}
Reference.reachabilityFence(this);
if (ret >= 0 && ret <= 4096) { return null; }
org.ldk.structs.NetAddress ret_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret);
- ret_hu_conv.ptrs_to.add(this);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
return ret_hu_conv;
}
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);
- ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
return ret_hu_conv;
}
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);
- ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
return ret_hu_conv;
}
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);
- ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
return ret_hu_conv;
}
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);
- ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ 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) {
+ public static NetAddress hostname(org.ldk.structs.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);
- ret_hu_conv.ptrs_to.add(ret_hu_conv);
- ret_hu_conv.ptrs_to.add(hostname);
+ 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(org.ldk.structs.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);
+ }
/**
* Serialize the NetAddress object into a byte array which can be read by NetAddress_read
*/