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 byte[] get_channel_id() {
29 byte[] ret = bindings.ChannelReady_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.ChannelReady_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The per-commitment point of the second commitment transaction
46 public byte[] get_next_per_commitment_point() {
47 byte[] ret = bindings.ChannelReady_get_next_per_commitment_point(this.ptr);
48 Reference.reachabilityFence(this);
53 * The per-commitment point of the second commitment transaction
55 public void set_next_per_commitment_point(byte[] val) {
56 bindings.ChannelReady_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * If set, provides a `short_channel_id` alias for this channel.
64 * The sender will accept payments to be forwarded over this SCID and forward them to this
65 * messages' recipient.
67 public Option_u64Z get_short_channel_id_alias() {
68 long ret = bindings.ChannelReady_get_short_channel_id_alias(this.ptr);
69 Reference.reachabilityFence(this);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
77 * If set, provides a `short_channel_id` alias for this channel.
79 * The sender will accept payments to be forwarded over this SCID and forward them to this
80 * messages' recipient.
82 public void set_short_channel_id_alias(org.ldk.structs.Option_u64Z val) {
83 bindings.ChannelReady_set_short_channel_id_alias(this.ptr, val.ptr);
84 Reference.reachabilityFence(this);
85 Reference.reachabilityFence(val);
86 if (this != null) { this.ptrs_to.add(val); };
90 * Constructs a new ChannelReady given each field
92 public static ChannelReady of(byte[] channel_id_arg, byte[] next_per_commitment_point_arg, org.ldk.structs.Option_u64Z short_channel_id_alias_arg) {
93 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);
94 Reference.reachabilityFence(channel_id_arg);
95 Reference.reachabilityFence(next_per_commitment_point_arg);
96 Reference.reachabilityFence(short_channel_id_alias_arg);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, ret); }
99 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
100 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(short_channel_id_alias_arg); };
105 long ret = bindings.ChannelReady_clone_ptr(this.ptr);
106 Reference.reachabilityFence(this);
111 * Creates a copy of the ChannelReady
113 public ChannelReady clone() {
114 long ret = bindings.ChannelReady_clone(this.ptr);
115 Reference.reachabilityFence(this);
116 if (ret >= 0 && ret <= 4096) { return null; }
117 org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, ret); }
118 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
123 * Checks if two ChannelReadys contain equal inner contents.
124 * This ignores pointers and is_owned flags and looks at the values in fields.
125 * Two objects with NULL inner values will be considered "equal" here.
127 public boolean eq(org.ldk.structs.ChannelReady b) {
128 boolean ret = bindings.ChannelReady_eq(this.ptr, b == null ? 0 : b.ptr);
129 Reference.reachabilityFence(this);
130 Reference.reachabilityFence(b);
131 if (this != null) { this.ptrs_to.add(b); };
135 @Override public boolean equals(Object o) {
136 if (!(o instanceof ChannelReady)) return false;
137 return this.eq((ChannelReady)o);
140 * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
142 public byte[] write() {
143 byte[] ret = bindings.ChannelReady_write(this.ptr);
144 Reference.reachabilityFence(this);
149 * Read a ChannelReady from a byte array, created by ChannelReady_write
151 public static Result_ChannelReadyDecodeErrorZ read(byte[] ser) {
152 long ret = bindings.ChannelReady_read(ser);
153 Reference.reachabilityFence(ser);
154 if (ret >= 0 && ret <= 4096) { return null; }
155 Result_ChannelReadyDecodeErrorZ ret_hu_conv = Result_ChannelReadyDecodeErrorZ.constr_from_ptr(ret);