X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelReady.java;h=95364b2ca77f32354ce9b2c8319d01e95f50654b;hb=ffdd56c967087cba7548599934585b8a9a3102e2;hp=c3eb0ca2a3684ace5ae35e07328e2a48885246c4;hpb=330ca992be304d0eac79bd59b411980dff294b03;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelReady.java b/src/main/java/org/ldk/structs/ChannelReady.java index c3eb0ca2..95364b2c 100644 --- a/src/main/java/org/ldk/structs/ChannelReady.java +++ b/src/main/java/org/ldk/structs/ChannelReady.java @@ -9,7 +9,9 @@ import javax.annotation.Nullable; /** - * A channel_ready message to be sent or received from a peer + * A [`channel_ready`] message to be sent to or received from a peer. + * + * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelReady extends CommonBase { @@ -23,19 +25,23 @@ public class ChannelReady extends CommonBase { /** * The channel ID */ - public byte[] get_channel_id() { - byte[] ret = bindings.ChannelReady_get_channel_id(this.ptr); + public ChannelId get_channel_id() { + long ret = bindings.ChannelReady_get_channel_id(this.ptr); Reference.reachabilityFence(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** * The channel ID */ - public void set_channel_id(byte[] val) { - bindings.ChannelReady_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32)); + public void set_channel_id(org.ldk.structs.ChannelId val) { + bindings.ChannelReady_set_channel_id(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -57,8 +63,10 @@ public class ChannelReady extends CommonBase { } /** - * If set, provides a short_channel_id alias for this channel. The sender will accept payments - * to be forwarded over this SCID and forward them to this messages' recipient. + * If set, provides a `short_channel_id` alias for this channel. + * + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. */ public Option_u64Z get_short_channel_id_alias() { long ret = bindings.ChannelReady_get_short_channel_id_alias(this.ptr); @@ -70,26 +78,31 @@ public class ChannelReady extends CommonBase { } /** - * If set, provides a short_channel_id alias for this channel. The sender will accept payments - * to be forwarded over this SCID and forward them to this messages' recipient. + * If set, provides a `short_channel_id` alias for this channel. + * + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. */ public void set_short_channel_id_alias(org.ldk.structs.Option_u64Z val) { bindings.ChannelReady_set_short_channel_id_alias(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** * Constructs a new ChannelReady given each field */ - public static ChannelReady of(byte[] channel_id_arg, byte[] next_per_commitment_point_arg, org.ldk.structs.Option_u64Z short_channel_id_alias_arg) { - long ret = bindings.ChannelReady_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(next_per_commitment_point_arg, 33), short_channel_id_alias_arg.ptr); + public static ChannelReady of(org.ldk.structs.ChannelId channel_id_arg, byte[] next_per_commitment_point_arg, org.ldk.structs.Option_u64Z short_channel_id_alias_arg) { + long ret = bindings.ChannelReady_new(channel_id_arg.ptr, InternalUtils.check_arr_len(next_per_commitment_point_arg, 33), short_channel_id_alias_arg.ptr); Reference.reachabilityFence(channel_id_arg); Reference.reachabilityFence(next_per_commitment_point_arg); Reference.reachabilityFence(short_channel_id_alias_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, 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(channel_id_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id_alias_arg); }; return ret_hu_conv; } @@ -111,13 +124,25 @@ public class ChannelReady extends CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the ChannelReady. + */ + public long hash() { + long ret = bindings.ChannelReady_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } /** * Checks if two ChannelReadys 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.ChannelReady b) { - boolean ret = bindings.ChannelReady_eq(this.ptr, b == null ? 0 : b.ptr); + boolean ret = bindings.ChannelReady_eq(this.ptr, b.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(b); if (this != null) { this.ptrs_to.add(b); };