1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A [`channel_ready`] message to be sent to or received from a peer.
14 * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelReady extends CommonBase {
18 ChannelReady(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.ChannelReady_free(ptr); }
28 public ChannelId get_channel_id() {
29 long ret = bindings.ChannelReady_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40 public void set_channel_id(org.ldk.structs.ChannelId val) {
41 bindings.ChannelReady_set_channel_id(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * The per-commitment point of the second commitment transaction
50 public byte[] get_next_per_commitment_point() {
51 byte[] ret = bindings.ChannelReady_get_next_per_commitment_point(this.ptr);
52 Reference.reachabilityFence(this);
57 * The per-commitment point of the second commitment transaction
59 public void set_next_per_commitment_point(byte[] val) {
60 bindings.ChannelReady_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * If set, provides a `short_channel_id` alias for this channel.
68 * The sender will accept payments to be forwarded over this SCID and forward them to this
69 * messages' recipient.
71 public Option_u64Z get_short_channel_id_alias() {
72 long ret = bindings.ChannelReady_get_short_channel_id_alias(this.ptr);
73 Reference.reachabilityFence(this);
74 if (ret >= 0 && ret <= 4096) { return null; }
75 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
76 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
81 * If set, provides a `short_channel_id` alias for this channel.
83 * The sender will accept payments to be forwarded over this SCID and forward them to this
84 * messages' recipient.
86 public void set_short_channel_id_alias(org.ldk.structs.Option_u64Z val) {
87 bindings.ChannelReady_set_short_channel_id_alias(this.ptr, val.ptr);
88 Reference.reachabilityFence(this);
89 Reference.reachabilityFence(val);
90 if (this != null) { this.ptrs_to.add(val); };
94 * Constructs a new ChannelReady given each field
96 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) {
97 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);
98 Reference.reachabilityFence(channel_id_arg);
99 Reference.reachabilityFence(next_per_commitment_point_arg);
100 Reference.reachabilityFence(short_channel_id_alias_arg);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, ret); }
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id_alias_arg); };
110 long ret = bindings.ChannelReady_clone_ptr(this.ptr);
111 Reference.reachabilityFence(this);
116 * Creates a copy of the ChannelReady
118 public ChannelReady clone() {
119 long ret = bindings.ChannelReady_clone(this.ptr);
120 Reference.reachabilityFence(this);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, ret); }
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
128 * Generates a non-cryptographic 64-bit hash of the ChannelReady.
131 long ret = bindings.ChannelReady_hash(this.ptr);
132 Reference.reachabilityFence(this);
136 @Override public int hashCode() {
137 return (int)this.hash();
140 * Checks if two ChannelReadys contain equal inner contents.
141 * This ignores pointers and is_owned flags and looks at the values in fields.
142 * Two objects with NULL inner values will be considered "equal" here.
144 public boolean eq(org.ldk.structs.ChannelReady b) {
145 boolean ret = bindings.ChannelReady_eq(this.ptr, b.ptr);
146 Reference.reachabilityFence(this);
147 Reference.reachabilityFence(b);
148 if (this != null) { this.ptrs_to.add(b); };
152 @Override public boolean equals(Object o) {
153 if (!(o instanceof ChannelReady)) return false;
154 return this.eq((ChannelReady)o);
157 * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
159 public byte[] write() {
160 byte[] ret = bindings.ChannelReady_write(this.ptr);
161 Reference.reachabilityFence(this);
166 * Read a ChannelReady from a byte array, created by ChannelReady_write
168 public static Result_ChannelReadyDecodeErrorZ read(byte[] ser) {
169 long ret = bindings.ChannelReady_read(ser);
170 Reference.reachabilityFence(ser);
171 if (ret >= 0 && ret <= 4096) { return null; }
172 Result_ChannelReadyDecodeErrorZ ret_hu_conv = Result_ChannelReadyDecodeErrorZ.constr_from_ptr(ret);