74550475afa572a6033de17318ce62710a80999e
[ldk-java] / src / main / java / org / ldk / structs / ReplyChannelRange.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 [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
13  * message.
14  * 
15  * Multiple `reply_channel_range` messages can be sent in reply
16  * to a single [`QueryChannelRange`] message. The query recipient makes a
17  * best effort to respond based on their local network view which may
18  * not be a perfect view of the network. The `short_channel_id`s in the
19  * reply are encoded. We only support `encoding_type=0` uncompressed
20  * serialization and do not support `encoding_type=1` zlib serialization.
21  * 
22  * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
23  */
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class ReplyChannelRange extends CommonBase {
26         ReplyChannelRange(Object _dummy, long ptr) { super(ptr); }
27         @Override @SuppressWarnings("deprecation")
28         protected void finalize() throws Throwable {
29                 super.finalize();
30                 if (ptr != 0) { bindings.ReplyChannelRange_free(ptr); }
31         }
32
33         /**
34          * The genesis hash of the blockchain being queried
35          */
36         public byte[] get_chain_hash() {
37                 byte[] ret = bindings.ReplyChannelRange_get_chain_hash(this.ptr);
38                 Reference.reachabilityFence(this);
39                 return ret;
40         }
41
42         /**
43          * The genesis hash of the blockchain being queried
44          */
45         public void set_chain_hash(byte[] val) {
46                 bindings.ReplyChannelRange_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
47                 Reference.reachabilityFence(this);
48                 Reference.reachabilityFence(val);
49         }
50
51         /**
52          * The height of the first block in the range of the reply
53          */
54         public int get_first_blocknum() {
55                 int ret = bindings.ReplyChannelRange_get_first_blocknum(this.ptr);
56                 Reference.reachabilityFence(this);
57                 return ret;
58         }
59
60         /**
61          * The height of the first block in the range of the reply
62          */
63         public void set_first_blocknum(int val) {
64                 bindings.ReplyChannelRange_set_first_blocknum(this.ptr, val);
65                 Reference.reachabilityFence(this);
66                 Reference.reachabilityFence(val);
67         }
68
69         /**
70          * The number of blocks included in the range of the reply
71          */
72         public int get_number_of_blocks() {
73                 int ret = bindings.ReplyChannelRange_get_number_of_blocks(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * The number of blocks included in the range of the reply
80          */
81         public void set_number_of_blocks(int val) {
82                 bindings.ReplyChannelRange_set_number_of_blocks(this.ptr, val);
83                 Reference.reachabilityFence(this);
84                 Reference.reachabilityFence(val);
85         }
86
87         /**
88          * True when this is the final reply for a query
89          */
90         public boolean get_sync_complete() {
91                 boolean ret = bindings.ReplyChannelRange_get_sync_complete(this.ptr);
92                 Reference.reachabilityFence(this);
93                 return ret;
94         }
95
96         /**
97          * True when this is the final reply for a query
98          */
99         public void set_sync_complete(boolean val) {
100                 bindings.ReplyChannelRange_set_sync_complete(this.ptr, val);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The `short_channel_id`s in the channel range
107          * 
108          * Returns a copy of the field.
109          */
110         public long[] get_short_channel_ids() {
111                 long[] ret = bindings.ReplyChannelRange_get_short_channel_ids(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * The `short_channel_id`s in the channel range
118          */
119         public void set_short_channel_ids(long[] val) {
120                 bindings.ReplyChannelRange_set_short_channel_ids(this.ptr, val);
121                 Reference.reachabilityFence(this);
122                 Reference.reachabilityFence(val);
123         }
124
125         /**
126          * Constructs a new ReplyChannelRange given each field
127          */
128         public static ReplyChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, boolean sync_complete_arg, long[] short_channel_ids_arg) {
129                 long ret = bindings.ReplyChannelRange_new(InternalUtils.check_arr_len(chain_hash_arg, 32), first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg);
130                 Reference.reachabilityFence(chain_hash_arg);
131                 Reference.reachabilityFence(first_blocknum_arg);
132                 Reference.reachabilityFence(number_of_blocks_arg);
133                 Reference.reachabilityFence(sync_complete_arg);
134                 Reference.reachabilityFence(short_channel_ids_arg);
135                 if (ret >= 0 && ret <= 4096) { return null; }
136                 org.ldk.structs.ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyChannelRange(null, ret); }
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
138                 return ret_hu_conv;
139         }
140
141         long clone_ptr() {
142                 long ret = bindings.ReplyChannelRange_clone_ptr(this.ptr);
143                 Reference.reachabilityFence(this);
144                 return ret;
145         }
146
147         /**
148          * Creates a copy of the ReplyChannelRange
149          */
150         public ReplyChannelRange clone() {
151                 long ret = bindings.ReplyChannelRange_clone(this.ptr);
152                 Reference.reachabilityFence(this);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyChannelRange(null, ret); }
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
156                 return ret_hu_conv;
157         }
158
159         /**
160          * Checks if two ReplyChannelRanges contain equal inner contents.
161          * This ignores pointers and is_owned flags and looks at the values in fields.
162          * Two objects with NULL inner values will be considered "equal" here.
163          */
164         public boolean eq(org.ldk.structs.ReplyChannelRange b) {
165                 boolean ret = bindings.ReplyChannelRange_eq(this.ptr, b == null ? 0 : b.ptr);
166                 Reference.reachabilityFence(this);
167                 Reference.reachabilityFence(b);
168                 if (this != null) { this.ptrs_to.add(b); };
169                 return ret;
170         }
171
172         @Override public boolean equals(Object o) {
173                 if (!(o instanceof ReplyChannelRange)) return false;
174                 return this.eq((ReplyChannelRange)o);
175         }
176         /**
177          * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
178          */
179         public static Result_ReplyChannelRangeDecodeErrorZ read(byte[] ser) {
180                 long ret = bindings.ReplyChannelRange_read(ser);
181                 Reference.reachabilityFence(ser);
182                 if (ret >= 0 && ret <= 4096) { return null; }
183                 Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret);
184                 return ret_hu_conv;
185         }
186
187         /**
188          * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
189          */
190         public byte[] write() {
191                 byte[] ret = bindings.ReplyChannelRange_write(this.ptr);
192                 Reference.reachabilityFence(this);
193                 return ret;
194         }
195
196 }