X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FUnsignedNodeAnnouncement.java;h=80f508fbe462d7d01d57896e1a259e6e9002ebdc;hb=a672396f21c0448656bb400cfe28b9df6e5a842b;hp=62b834b09070327b6148c352fd76e749e5cad6eb;hpb=13cdf8bde340072288b39a5e29f0946d3e095ad4;p=ldk-java diff --git a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java index 62b834b0..80f508fb 100644 --- a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java +++ b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java @@ -9,7 +9,9 @@ import javax.annotation.Nullable; /** - * The unsigned part of a node_announcement + * The unsigned part of a [`node_announcement`] message. + * + * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UnsignedNodeAnnouncement extends CommonBase { @@ -28,18 +30,18 @@ public class UnsignedNodeAnnouncement extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); } - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** * The advertised features */ - public void set_features(NodeFeatures val) { + public void set_features(org.ldk.structs.NodeFeatures val) { bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); - this.ptrs_to.add(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -61,23 +63,27 @@ public class UnsignedNodeAnnouncement extends CommonBase { } /** - * The node_id this announcement originated from (don't rebroadcast the node_announcement back + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back * to this node). */ - public byte[] get_node_id() { - byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr); + public NodeId get_node_id() { + long ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr); Reference.reachabilityFence(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** - * The node_id this announcement originated from (don't rebroadcast the node_announcement back + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back * to this node). */ - public void set_node_id(byte[] val) { - bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33)); + public void set_node_id(org.ldk.structs.NodeId val) { + bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val == null ? 0 : val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -99,23 +105,29 @@ public class UnsignedNodeAnnouncement extends CommonBase { } /** - * An alias, for UI purposes. This should be sanitized before use. There is no guarantee - * of uniqueness. + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ - public byte[] get_alias() { - byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr); + public NodeAlias get_alias() { + long ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr); Reference.reachabilityFence(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** - * An alias, for UI purposes. This should be sanitized before use. There is no guarantee - * of uniqueness. + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ - public void set_alias(byte[] val) { - bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, InternalUtils.check_arr_len(val, 32)); + public void set_alias(org.ldk.structs.NodeAlias val) { + bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, val == null ? 0 : val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -131,7 +143,7 @@ public class UnsignedNodeAnnouncement extends CommonBase { for (int m = 0; m < ret_conv_12_len; m++) { long ret_conv_12 = ret[m]; org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12); - ret_conv_12_hu_conv.ptrs_to.add(this); + if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.add(this); }; ret_conv_12_arr[m] = ret_conv_12_hu_conv; } return ret_conv_12_arr; @@ -144,6 +156,7 @@ public class UnsignedNodeAnnouncement extends CommonBase { bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + for (NetAddress val_conv_12: val) { if (this != null) { this.ptrs_to.add(val_conv_12); }; }; } long clone_ptr() { @@ -160,10 +173,27 @@ public class UnsignedNodeAnnouncement extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); } - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } + /** + * Checks if two UnsignedNodeAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(org.ldk.structs.UnsignedNodeAnnouncement b) { + boolean ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + if (this != null) { this.ptrs_to.add(b); }; + return ret; + } + + @Override public boolean equals(Object o) { + if (!(o instanceof UnsignedNodeAnnouncement)) return false; + return this.eq((UnsignedNodeAnnouncement)o); + } /** * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */