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 ChannelId get_channel_id() {
29 long ret = bindings.ChannelReestablish_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.ChannelReestablish_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 next commitment number for the sender
50 public long get_next_local_commitment_number() {
51 long ret = bindings.ChannelReestablish_get_next_local_commitment_number(this.ptr);
52 Reference.reachabilityFence(this);
57 * The next commitment number for the sender
59 public void set_next_local_commitment_number(long val) {
60 bindings.ChannelReestablish_set_next_local_commitment_number(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * The next commitment number for the recipient
68 public long get_next_remote_commitment_number() {
69 long ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this.ptr);
70 Reference.reachabilityFence(this);
75 * The next commitment number for the recipient
77 public void set_next_remote_commitment_number(long val) {
78 bindings.ChannelReestablish_set_next_remote_commitment_number(this.ptr, val);
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * Proof that the sender knows the per-commitment secret of a specific commitment transaction
85 * belonging to the recipient
87 public byte[] get_your_last_per_commitment_secret() {
88 byte[] ret = bindings.ChannelReestablish_get_your_last_per_commitment_secret(this.ptr);
89 Reference.reachabilityFence(this);
94 * Proof that the sender knows the per-commitment secret of a specific commitment transaction
95 * belonging to the recipient
97 public void set_your_last_per_commitment_secret(byte[] val) {
98 bindings.ChannelReestablish_set_your_last_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(val);
104 * The sender's per-commitment point for their current commitment transaction
106 public byte[] get_my_current_per_commitment_point() {
107 byte[] ret = bindings.ChannelReestablish_get_my_current_per_commitment_point(this.ptr);
108 Reference.reachabilityFence(this);
113 * The sender's per-commitment point for their current commitment transaction
115 public void set_my_current_per_commitment_point(byte[] val) {
116 bindings.ChannelReestablish_set_my_current_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
117 Reference.reachabilityFence(this);
118 Reference.reachabilityFence(val);
122 * The next funding transaction ID
124 public Option_ThirtyTwoBytesZ get_next_funding_txid() {
125 long ret = bindings.ChannelReestablish_get_next_funding_txid(this.ptr);
126 Reference.reachabilityFence(this);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
129 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
134 * The next funding transaction ID
136 public void set_next_funding_txid(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
137 bindings.ChannelReestablish_set_next_funding_txid(this.ptr, val.ptr);
138 Reference.reachabilityFence(this);
139 Reference.reachabilityFence(val);
140 if (this != null) { this.ptrs_to.add(val); };
144 * Constructs a new ChannelReestablish given each field
146 public static ChannelReestablish of(org.ldk.structs.ChannelId channel_id_arg, long next_local_commitment_number_arg, long next_remote_commitment_number_arg, byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg, org.ldk.structs.Option_ThirtyTwoBytesZ next_funding_txid_arg) {
147 long ret = bindings.ChannelReestablish_new(channel_id_arg.ptr, next_local_commitment_number_arg, next_remote_commitment_number_arg, InternalUtils.check_arr_len(your_last_per_commitment_secret_arg, 32), InternalUtils.check_arr_len(my_current_per_commitment_point_arg, 33), next_funding_txid_arg.ptr);
148 Reference.reachabilityFence(channel_id_arg);
149 Reference.reachabilityFence(next_local_commitment_number_arg);
150 Reference.reachabilityFence(next_remote_commitment_number_arg);
151 Reference.reachabilityFence(your_last_per_commitment_secret_arg);
152 Reference.reachabilityFence(my_current_per_commitment_point_arg);
153 Reference.reachabilityFence(next_funding_txid_arg);
154 if (ret >= 0 && ret <= 4096) { return null; }
155 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
156 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
158 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(next_funding_txid_arg); };
163 long ret = bindings.ChannelReestablish_clone_ptr(this.ptr);
164 Reference.reachabilityFence(this);
169 * Creates a copy of the ChannelReestablish
171 public ChannelReestablish clone() {
172 long ret = bindings.ChannelReestablish_clone(this.ptr);
173 Reference.reachabilityFence(this);
174 if (ret >= 0 && ret <= 4096) { return null; }
175 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
176 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
181 * Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
184 long ret = bindings.ChannelReestablish_hash(this.ptr);
185 Reference.reachabilityFence(this);
189 @Override public int hashCode() {
190 return (int)this.hash();
193 * Checks if two ChannelReestablishs contain equal inner contents.
194 * This ignores pointers and is_owned flags and looks at the values in fields.
195 * Two objects with NULL inner values will be considered "equal" here.
197 public boolean eq(org.ldk.structs.ChannelReestablish b) {
198 boolean ret = bindings.ChannelReestablish_eq(this.ptr, b.ptr);
199 Reference.reachabilityFence(this);
200 Reference.reachabilityFence(b);
201 if (this != null) { this.ptrs_to.add(b); };
205 @Override public boolean equals(Object o) {
206 if (!(o instanceof ChannelReestablish)) return false;
207 return this.eq((ChannelReestablish)o);
210 * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
212 public byte[] write() {
213 byte[] ret = bindings.ChannelReestablish_write(this.ptr);
214 Reference.reachabilityFence(this);
219 * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
221 public static Result_ChannelReestablishDecodeErrorZ read(byte[] ser) {
222 long ret = bindings.ChannelReestablish_read(ser);
223 Reference.reachabilityFence(ser);
224 if (ret >= 0 && ret <= 4096) { return null; }
225 Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);