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 [`query_short_channel_ids`] message is used to query a peer for
13 * routing gossip messages related to one or more `short_channel_id`s.
15 * The query recipient will reply with the latest, if available,
16 * [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
17 * it maintains for the requested `short_channel_id`s followed by a
18 * [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
19 * this query are encoded. We only support `encoding_type=0` uncompressed
20 * serialization and do not support `encoding_type=1` zlib serialization.
22 * [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class QueryShortChannelIds extends CommonBase {
26 QueryShortChannelIds(Object _dummy, long ptr) { super(ptr); }
27 @Override @SuppressWarnings("deprecation")
28 protected void finalize() throws Throwable {
30 if (ptr != 0) { bindings.QueryShortChannelIds_free(ptr); }
34 * The genesis hash of the blockchain being queried
36 public byte[] get_chain_hash() {
37 byte[] ret = bindings.QueryShortChannelIds_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.QueryShortChannelIds_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
47 Reference.reachabilityFence(this);
48 Reference.reachabilityFence(val);
52 * The short_channel_ids that are being queried
54 * Returns a copy of the field.
56 public long[] get_short_channel_ids() {
57 long[] ret = bindings.QueryShortChannelIds_get_short_channel_ids(this.ptr);
58 Reference.reachabilityFence(this);
63 * The short_channel_ids that are being queried
65 public void set_short_channel_ids(long[] val) {
66 bindings.QueryShortChannelIds_set_short_channel_ids(this.ptr, val);
67 Reference.reachabilityFence(this);
68 Reference.reachabilityFence(val);
72 * Constructs a new QueryShortChannelIds given each field
74 public static QueryShortChannelIds of(byte[] chain_hash_arg, long[] short_channel_ids_arg) {
75 long ret = bindings.QueryShortChannelIds_new(InternalUtils.check_arr_len(chain_hash_arg, 32), short_channel_ids_arg);
76 Reference.reachabilityFence(chain_hash_arg);
77 Reference.reachabilityFence(short_channel_ids_arg);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 org.ldk.structs.QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryShortChannelIds(null, ret); }
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
85 long ret = bindings.QueryShortChannelIds_clone_ptr(this.ptr);
86 Reference.reachabilityFence(this);
91 * Creates a copy of the QueryShortChannelIds
93 public QueryShortChannelIds clone() {
94 long ret = bindings.QueryShortChannelIds_clone(this.ptr);
95 Reference.reachabilityFence(this);
96 if (ret >= 0 && ret <= 4096) { return null; }
97 org.ldk.structs.QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryShortChannelIds(null, ret); }
98 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103 * Checks if two QueryShortChannelIdss contain equal inner contents.
104 * This ignores pointers and is_owned flags and looks at the values in fields.
105 * Two objects with NULL inner values will be considered "equal" here.
107 public boolean eq(org.ldk.structs.QueryShortChannelIds b) {
108 boolean ret = bindings.QueryShortChannelIds_eq(this.ptr, b == null ? 0 : b.ptr);
109 Reference.reachabilityFence(this);
110 Reference.reachabilityFence(b);
111 if (this != null) { this.ptrs_to.add(b); };
115 @Override public boolean equals(Object o) {
116 if (!(o instanceof QueryShortChannelIds)) return false;
117 return this.eq((QueryShortChannelIds)o);
120 * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
122 public static Result_QueryShortChannelIdsDecodeErrorZ read(byte[] ser) {
123 long ret = bindings.QueryShortChannelIds_read(ser);
124 Reference.reachabilityFence(ser);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
131 * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
133 public byte[] write() {
134 byte[] ret = bindings.QueryShortChannelIds_write(this.ptr);
135 Reference.reachabilityFence(this);