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 [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
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.
22 * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
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 {
30 if (ptr != 0) { bindings.ReplyChannelRange_free(ptr); }
34 * The genesis hash of the blockchain being queried
36 public byte[] get_chain_hash() {
37 byte[] ret = bindings.ReplyChannelRange_get_chain_hash(this.ptr);
38 Reference.reachabilityFence(this);
43 * The genesis hash of the blockchain being queried
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);
52 * The height of the first block in the range of the reply
54 public int get_first_blocknum() {
55 int ret = bindings.ReplyChannelRange_get_first_blocknum(this.ptr);
56 Reference.reachabilityFence(this);
61 * The height of the first block in the range of the reply
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);
70 * The number of blocks included in the range of the reply
72 public int get_number_of_blocks() {
73 int ret = bindings.ReplyChannelRange_get_number_of_blocks(this.ptr);
74 Reference.reachabilityFence(this);
79 * The number of blocks included in the range of the reply
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);
88 * True when this is the final reply for a query
90 public boolean get_sync_complete() {
91 boolean ret = bindings.ReplyChannelRange_get_sync_complete(this.ptr);
92 Reference.reachabilityFence(this);
97 * True when this is the final reply for a query
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);
106 * The `short_channel_id`s in the channel range
108 * Returns a copy of the field.
110 public long[] get_short_channel_ids() {
111 long[] ret = bindings.ReplyChannelRange_get_short_channel_ids(this.ptr);
112 Reference.reachabilityFence(this);
117 * The `short_channel_id`s in the channel range
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);
126 * Constructs a new ReplyChannelRange given each field
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); };
142 long ret = bindings.ReplyChannelRange_clone_ptr(this.ptr);
143 Reference.reachabilityFence(this);
148 * Creates a copy of the ReplyChannelRange
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); };
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.
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); };
172 @Override public boolean equals(Object o) {
173 if (!(o instanceof ReplyChannelRange)) return false;
174 return this.eq((ReplyChannelRange)o);
177 * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
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);
188 * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
190 public byte[] write() {
191 byte[] ret = bindings.ReplyChannelRange_write(this.ptr);
192 Reference.reachabilityFence(this);