X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FReplyShortChannelIdsEnd.java;h=8af922d85d8294d725eb4d6f2537582896bbe9c9;hb=2bb592fb946e316dba9f4d1123f8ac72ff4e9bf8;hp=9af5948df0ad1ce8207e9e6775de4e1ded00ed5a;hpb=592c4f92dd3011a2f2a7988ce66ed166c3a8f58c;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java index 9af5948d..8af922d8 100644 --- a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java +++ b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java @@ -2,54 +2,145 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; + +/** + * A [`reply_short_channel_ids_end`] message is sent as a reply to a + * message. The query recipient makes a best + * effort to respond based on their local network view which may not be + * a perfect view of the network. + * + * [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ReplyShortChannelIdsEnd extends CommonBase { ReplyShortChannelIdsEnd(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); - bindings.ReplyShortChannelIdsEnd_free(ptr); + if (ptr != 0) { bindings.ReplyShortChannelIdsEnd_free(ptr); } + } + + /** + * The genesis hash of the blockchain that was queried + */ + public byte[] get_chain_hash() { + byte[] ret = bindings.ReplyShortChannelIdsEnd_get_chain_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; } - public ReplyShortChannelIdsEnd(ReplyShortChannelIdsEnd orig) { - super(bindings.ReplyShortChannelIdsEnd_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + /** + * The genesis hash of the blockchain that was queried + */ + public void set_chain_hash(byte[] val) { + bindings.ReplyShortChannelIdsEnd_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32)); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } - public byte[] get_chain_hash(ReplyShortChannelIdsEnd this_ptr) { - byte[] ret = bindings.ReplyShortChannelIdsEnd_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` + */ + public boolean get_full_information() { + boolean ret = bindings.ReplyShortChannelIdsEnd_get_full_information(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_chain_hash(ReplyShortChannelIdsEnd this_ptr, byte[] val) { - bindings.ReplyShortChannelIdsEnd_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` + */ + public void set_full_information(boolean val) { + bindings.ReplyShortChannelIdsEnd_set_full_information(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Constructs a new ReplyShortChannelIdsEnd given each field + */ + public static ReplyShortChannelIdsEnd of(byte[] chain_hash_arg, boolean full_information_arg) { + long ret = bindings.ReplyShortChannelIdsEnd_new(InternalUtils.check_arr_len(chain_hash_arg, 32), full_information_arg); + Reference.reachabilityFence(chain_hash_arg); + Reference.reachabilityFence(full_information_arg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ReplyShortChannelIdsEnd ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyShortChannelIdsEnd(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + return ret_hu_conv; } - public boolean get_full_information(ReplyShortChannelIdsEnd this_ptr) { - boolean ret = bindings.ReplyShortChannelIdsEnd_get_full_information(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + long clone_ptr() { + long ret = bindings.ReplyShortChannelIdsEnd_clone_ptr(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_full_information(ReplyShortChannelIdsEnd this_ptr, boolean val) { - bindings.ReplyShortChannelIdsEnd_set_full_information(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * Creates a copy of the ReplyShortChannelIdsEnd + */ + public ReplyShortChannelIdsEnd clone() { + long ret = bindings.ReplyShortChannelIdsEnd_clone(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ReplyShortChannelIdsEnd ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyShortChannelIdsEnd(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } - public ReplyShortChannelIdsEnd(byte[] chain_hash_arg, boolean full_information_arg) { - super(bindings.ReplyShortChannelIdsEnd_new(chain_hash_arg, full_information_arg)); + /** + * Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd. + */ + public long hash() { + long ret = bindings.ReplyShortChannelIdsEnd_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; } - public ReplyShortChannelIdsEnd(byte[] ser) { - super(bindings.ReplyShortChannelIdsEnd_read(ser)); + @Override public int hashCode() { + return (int)this.hash(); + } + /** + * Checks if two ReplyShortChannelIdsEnds 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.ReplyShortChannelIdsEnd b) { + boolean ret = bindings.ReplyShortChannelIdsEnd_eq(this.ptr, b == null ? 0 : b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + if (this != null) { this.ptrs_to.add(b); }; + return ret; } - public byte[] write(ReplyShortChannelIdsEnd obj) { - byte[] ret = bindings.ReplyShortChannelIdsEnd_write(obj == null ? 0 : obj.ptr & ~1); - this.ptrs_to.add(obj); + @Override public boolean equals(Object o) { + if (!(o instanceof ReplyShortChannelIdsEnd)) return false; + return this.eq((ReplyShortChannelIdsEnd)o); + } + /** + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + */ + public byte[] write() { + byte[] ret = bindings.ReplyShortChannelIdsEnd_write(this.ptr); + Reference.reachabilityFence(this); return ret; } + /** + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + */ + public static Result_ReplyShortChannelIdsEndDecodeErrorZ read(byte[] ser) { + long ret = bindings.ReplyShortChannelIdsEnd_read(ser); + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_ReplyShortChannelIdsEndDecodeErrorZ ret_hu_conv = Result_ReplyShortChannelIdsEndDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + }