X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FQueryChannelRange.java;h=fb7b806094abc149d22b3872b1954e16536f294a;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=9d15fee3512292d2c6967668eb63e52da63fc776;hpb=ad15b3a4dbf3fbc7f08ef22d656bae79e8182008;p=ldk-java diff --git a/src/main/java/org/ldk/structs/QueryChannelRange.java b/src/main/java/org/ldk/structs/QueryChannelRange.java index 9d15fee3..fb7b8060 100644 --- a/src/main/java/org/ldk/structs/QueryChannelRange.java +++ b/src/main/java/org/ldk/structs/QueryChannelRange.java @@ -2,60 +2,140 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; + +/** + * A query_channel_range message is used to query a peer for channel + * UTXOs in a range of blocks. The recipient of a query makes a best + * effort to reply to the query using one or more reply_channel_range + * messages. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class QueryChannelRange extends CommonBase { QueryChannelRange(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); - bindings.QueryChannelRange_free(ptr); + if (ptr != 0) { bindings.QueryChannelRange_free(ptr); } } - public QueryChannelRange(QueryChannelRange orig) { - super(bindings.QueryChannelRange_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + /** + * The genesis hash of the blockchain being queried + */ + public byte[] get_chain_hash() { + byte[] ret = bindings.QueryChannelRange_get_chain_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; } - public byte[] get_chain_hash(QueryChannelRange this_ptr) { - byte[] ret = bindings.QueryChannelRange_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The genesis hash of the blockchain being queried + */ + public void set_chain_hash(byte[] val) { + bindings.QueryChannelRange_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32)); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * The height of the first block for the channel UTXOs being queried + */ + public int get_first_blocknum() { + int ret = bindings.QueryChannelRange_get_first_blocknum(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_chain_hash(QueryChannelRange this_ptr, byte[] val) { - bindings.QueryChannelRange_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The height of the first block for the channel UTXOs being queried + */ + public void set_first_blocknum(int val) { + bindings.QueryChannelRange_set_first_blocknum(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } - public int get_first_blocknum(QueryChannelRange this_ptr) { - int ret = bindings.QueryChannelRange_get_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The number of blocks to include in the query results + */ + public int get_number_of_blocks() { + int ret = bindings.QueryChannelRange_get_number_of_blocks(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_first_blocknum(QueryChannelRange this_ptr, int val) { - bindings.QueryChannelRange_set_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The number of blocks to include in the query results + */ + public void set_number_of_blocks(int val) { + bindings.QueryChannelRange_set_number_of_blocks(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Constructs a new QueryChannelRange given each field + */ + public static QueryChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) { + long ret = bindings.QueryChannelRange_new(InternalUtils.check_arr_len(chain_hash_arg, 32), first_blocknum_arg, number_of_blocks_arg); + Reference.reachabilityFence(chain_hash_arg); + Reference.reachabilityFence(first_blocknum_arg); + Reference.reachabilityFence(number_of_blocks_arg); + if (ret >= 0 && ret <= 4096) { return null; } + QueryChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new QueryChannelRange(null, ret); } + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; } - public int get_number_of_blocks(QueryChannelRange this_ptr) { - int ret = bindings.QueryChannelRange_get_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + long clone_ptr() { + long ret = bindings.QueryChannelRange_clone_ptr(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_number_of_blocks(QueryChannelRange this_ptr, int val) { - bindings.QueryChannelRange_set_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * Creates a copy of the QueryChannelRange + */ + public QueryChannelRange clone() { + long ret = bindings.QueryChannelRange_clone(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + QueryChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new QueryChannelRange(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public QueryChannelRange(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) { - super(bindings.QueryChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg)); + /** + * \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 + */ + public int end_blocknum() { + int ret = bindings.QueryChannelRange_end_blocknum(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + */ + public byte[] write() { + byte[] ret = bindings.QueryChannelRange_write(this.ptr); + Reference.reachabilityFence(this); + return ret; } - public QueryChannelRange(byte[] ser) { - super(bindings.QueryChannelRange_read(ser)); + /** + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + */ + public static Result_QueryChannelRangeDecodeErrorZ read(byte[] ser) { + long ret = bindings.QueryChannelRange_read(ser); + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; } - // Skipped QueryChannelRange_write }