1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class NetAddress extends CommonBase {
10 private NetAddress(Object _dummy, long ptr) { super(ptr); }
11 @Override @SuppressWarnings("deprecation")
12 protected void finalize() throws Throwable {
14 if (ptr != 0) { bindings.NetAddress_free(ptr); }
16 static NetAddress constr_from_ptr(long ptr) {
17 bindings.LDKNetAddress raw_val = bindings.LDKNetAddress_ref_from_ptr(ptr);
18 if (raw_val.getClass() == bindings.LDKNetAddress.IPv4.class) {
19 return new IPv4(ptr, (bindings.LDKNetAddress.IPv4)raw_val);
21 if (raw_val.getClass() == bindings.LDKNetAddress.IPv6.class) {
22 return new IPv6(ptr, (bindings.LDKNetAddress.IPv6)raw_val);
24 if (raw_val.getClass() == bindings.LDKNetAddress.OnionV2.class) {
25 return new OnionV2(ptr, (bindings.LDKNetAddress.OnionV2)raw_val);
27 if (raw_val.getClass() == bindings.LDKNetAddress.OnionV3.class) {
28 return new OnionV3(ptr, (bindings.LDKNetAddress.OnionV3)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
33 public final static class IPv4 extends NetAddress {
34 public final byte[] addr;
35 public final short port;
36 private IPv4(long ptr, bindings.LDKNetAddress.IPv4 obj) {
42 public final static class IPv6 extends NetAddress {
43 public final byte[] addr;
44 public final short port;
45 private IPv6(long ptr, bindings.LDKNetAddress.IPv6 obj) {
51 public final static class OnionV2 extends NetAddress {
52 public final byte[] addr;
53 public final short port;
54 private OnionV2(long ptr, bindings.LDKNetAddress.OnionV2 obj) {
60 public final static class OnionV3 extends NetAddress {
61 public final byte[] ed25519_pubkey;
62 public final short checksum;
63 public final byte version;
64 public final short port;
65 private OnionV3(long ptr, bindings.LDKNetAddress.OnionV3 obj) {
67 this.ed25519_pubkey = obj.ed25519_pubkey;
68 this.checksum = obj.checksum;
69 this.version = obj.version;