1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * A query_channel_range message is used to query a peer for channel
12 * UTXOs in a range of blocks. The recipient of a query makes a best
13 * effort to reply to the query using one or more reply_channel_range
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class QueryChannelRange extends CommonBase {
18 QueryChannelRange(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.QueryChannelRange_free(ptr); }
26 * The genesis hash of the blockchain being queried
28 public byte[] get_chain_hash() {
29 byte[] ret = bindings.QueryChannelRange_get_chain_hash(this.ptr);
34 * The genesis hash of the blockchain being queried
36 public void set_chain_hash(byte[] val) {
37 bindings.QueryChannelRange_set_chain_hash(this.ptr, val);
41 * The height of the first block for the channel UTXOs being queried
43 public int get_first_blocknum() {
44 int ret = bindings.QueryChannelRange_get_first_blocknum(this.ptr);
49 * The height of the first block for the channel UTXOs being queried
51 public void set_first_blocknum(int val) {
52 bindings.QueryChannelRange_set_first_blocknum(this.ptr, val);
56 * The number of blocks to include in the query results
58 public int get_number_of_blocks() {
59 int ret = bindings.QueryChannelRange_get_number_of_blocks(this.ptr);
64 * The number of blocks to include in the query results
66 public void set_number_of_blocks(int val) {
67 bindings.QueryChannelRange_set_number_of_blocks(this.ptr, val);
71 * Constructs a new QueryChannelRange given each field
73 public static QueryChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) {
74 long ret = bindings.QueryChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg);
75 if (ret < 1024) { return null; }
76 QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret);
77 ret_hu_conv.ptrs_to.add(ret_hu_conv);
82 * Creates a copy of the QueryChannelRange
84 public QueryChannelRange clone() {
85 long ret = bindings.QueryChannelRange_clone(this.ptr);
86 if (ret < 1024) { return null; }
87 QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret);
88 ret_hu_conv.ptrs_to.add(this);
93 * \n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t
95 public int end_blocknum() {
96 int ret = bindings.QueryChannelRange_end_blocknum(this.ptr);
101 * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
103 public byte[] write() {
104 byte[] ret = bindings.QueryChannelRange_write(this.ptr);
109 * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
111 public static Result_QueryChannelRangeDecodeErrorZ read(byte[] ser) {
112 long ret = bindings.QueryChannelRange_read(ser);
113 if (ret < 1024) { return null; }
114 Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret);