c556b71d86e49c8f7e6861b39e59c1506457e9db
[ldk-java] / src / main / java / org / ldk / structs / QueryShortChannelIds.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 [`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.
14  * 
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.
21  * 
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
23  */
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 {
29                 super.finalize();
30                 if (ptr != 0) { bindings.QueryShortChannelIds_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.QueryShortChannelIds_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.QueryShortChannelIds_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
47                 Reference.reachabilityFence(this);
48                 Reference.reachabilityFence(val);
49         }
50
51         /**
52          * The short_channel_ids that are being queried
53          * 
54          * Returns a copy of the field.
55          */
56         public long[] get_short_channel_ids() {
57                 long[] ret = bindings.QueryShortChannelIds_get_short_channel_ids(this.ptr);
58                 Reference.reachabilityFence(this);
59                 return ret;
60         }
61
62         /**
63          * The short_channel_ids that are being queried
64          */
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);
69         }
70
71         /**
72          * Constructs a new QueryShortChannelIds given each field
73          */
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); };
81                 return ret_hu_conv;
82         }
83
84         long clone_ptr() {
85                 long ret = bindings.QueryShortChannelIds_clone_ptr(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * Creates a copy of the QueryShortChannelIds
92          */
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); };
99                 return ret_hu_conv;
100         }
101
102         /**
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.
106          */
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); };
112                 return ret;
113         }
114
115         @Override public boolean equals(Object o) {
116                 if (!(o instanceof QueryShortChannelIds)) return false;
117                 return this.eq((QueryShortChannelIds)o);
118         }
119         /**
120          * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
121          */
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);
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
132          */
133         public byte[] write() {
134                 byte[] ret = bindings.QueryShortChannelIds_write(this.ptr);
135                 Reference.reachabilityFence(this);
136                 return ret;
137         }
138
139 }