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_reestablish`] message to be sent to or received from a peer.
14 * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelReestablish extends CommonBase {
18 ChannelReestablish(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.ChannelReestablish_free(ptr); }
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.ChannelReestablish_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.ChannelReestablish_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The next commitment number for the sender
46 public long get_next_local_commitment_number() {
47 long ret = bindings.ChannelReestablish_get_next_local_commitment_number(this.ptr);
48 Reference.reachabilityFence(this);
53 * The next commitment number for the sender
55 public void set_next_local_commitment_number(long val) {
56 bindings.ChannelReestablish_set_next_local_commitment_number(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The next commitment number for the recipient
64 public long get_next_remote_commitment_number() {
65 long ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this.ptr);
66 Reference.reachabilityFence(this);
71 * The next commitment number for the recipient
73 public void set_next_remote_commitment_number(long val) {
74 bindings.ChannelReestablish_set_next_remote_commitment_number(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 long ret = bindings.ChannelReestablish_clone_ptr(this.ptr);
81 Reference.reachabilityFence(this);
86 * Creates a copy of the ChannelReestablish
88 public ChannelReestablish clone() {
89 long ret = bindings.ChannelReestablish_clone(this.ptr);
90 Reference.reachabilityFence(this);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
98 * Checks if two ChannelReestablishs contain equal inner contents.
99 * This ignores pointers and is_owned flags and looks at the values in fields.
100 * Two objects with NULL inner values will be considered "equal" here.
102 public boolean eq(org.ldk.structs.ChannelReestablish b) {
103 boolean ret = bindings.ChannelReestablish_eq(this.ptr, b == null ? 0 : b.ptr);
104 Reference.reachabilityFence(this);
105 Reference.reachabilityFence(b);
106 if (this != null) { this.ptrs_to.add(b); };
110 @Override public boolean equals(Object o) {
111 if (!(o instanceof ChannelReestablish)) return false;
112 return this.eq((ChannelReestablish)o);
115 * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
117 public byte[] write() {
118 byte[] ret = bindings.ChannelReestablish_write(this.ptr);
119 Reference.reachabilityFence(this);
124 * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
126 public static Result_ChannelReestablishDecodeErrorZ read(byte[] ser) {
127 long ret = bindings.ChannelReestablish_read(ser);
128 Reference.reachabilityFence(ser);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);