[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ChannelReady.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A [`channel_ready`] message to be sent to or received from a peer.
13  * 
14  * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ChannelReady_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.ChannelReady_get_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The channel ID
36          */
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);
41         }
42
43         /**
44          * The per-commitment point of the second commitment transaction
45          */
46         public byte[] get_next_per_commitment_point() {
47                 byte[] ret = bindings.ChannelReady_get_next_per_commitment_point(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The per-commitment point of the second commitment transaction
54          */
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);
59         }
60
61         /**
62          * If set, provides a `short_channel_id` alias for this channel.
63          * 
64          * The sender will accept payments to be forwarded over this SCID and forward them to this
65          * messages' recipient.
66          */
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); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * If set, provides a `short_channel_id` alias for this channel.
78          * 
79          * The sender will accept payments to be forwarded over this SCID and forward them to this
80          * messages' recipient.
81          */
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); };
87         }
88
89         /**
90          * Constructs a new ChannelReady given each field
91          */
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); };
101                 return ret_hu_conv;
102         }
103
104         long clone_ptr() {
105                 long ret = bindings.ChannelReady_clone_ptr(this.ptr);
106                 Reference.reachabilityFence(this);
107                 return ret;
108         }
109
110         /**
111          * Creates a copy of the ChannelReady
112          */
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); };
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Generates a non-cryptographic 64-bit hash of the ChannelReady.
124          */
125         public long hash() {
126                 long ret = bindings.ChannelReady_hash(this.ptr);
127                 Reference.reachabilityFence(this);
128                 return ret;
129         }
130
131         @Override public int hashCode() {
132                 return (int)this.hash();
133         }
134         /**
135          * Checks if two ChannelReadys contain equal inner contents.
136          * This ignores pointers and is_owned flags and looks at the values in fields.
137          * Two objects with NULL inner values will be considered "equal" here.
138          */
139         public boolean eq(org.ldk.structs.ChannelReady b) {
140                 boolean ret = bindings.ChannelReady_eq(this.ptr, b == null ? 0 : b.ptr);
141                 Reference.reachabilityFence(this);
142                 Reference.reachabilityFence(b);
143                 if (this != null) { this.ptrs_to.add(b); };
144                 return ret;
145         }
146
147         @Override public boolean equals(Object o) {
148                 if (!(o instanceof ChannelReady)) return false;
149                 return this.eq((ChannelReady)o);
150         }
151         /**
152          * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
153          */
154         public byte[] write() {
155                 byte[] ret = bindings.ChannelReady_write(this.ptr);
156                 Reference.reachabilityFence(this);
157                 return ret;
158         }
159
160         /**
161          * Read a ChannelReady from a byte array, created by ChannelReady_write
162          */
163         public static Result_ChannelReadyDecodeErrorZ read(byte[] ser) {
164                 long ret = bindings.ChannelReady_read(ser);
165                 Reference.reachabilityFence(ser);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 Result_ChannelReadyDecodeErrorZ ret_hu_conv = Result_ChannelReadyDecodeErrorZ.constr_from_ptr(ret);
168                 return ret_hu_conv;
169         }
170
171 }