f450b34ff730ea3c58089a49d57c30257d33e5e6
[ldk-java] / c_sharp / src / org / ldk / structs / QueryShortChannelIds.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A [`query_short_channel_ids`] message is used to query a peer for
11  * routing gossip messages related to one or more `short_channel_id`s.
12  * 
13  * The query recipient will reply with the latest, if available,
14  * [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
15  * it maintains for the requested `short_channel_id`s followed by a
16  * [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
17  * this query are encoded. We only support `encoding_type=0` uncompressed
18  * serialization and do not support `encoding_type=1` zlib serialization.
19  * 
20  * [`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
21  */
22 public class QueryShortChannelIds : CommonBase {
23         internal QueryShortChannelIds(object _dummy, long ptr) : base(ptr) { }
24         ~QueryShortChannelIds() {
25                 if (ptr != 0) { bindings.QueryShortChannelIds_free(ptr); }
26         }
27
28         /**
29          * The genesis hash of the blockchain being queried
30          */
31         public byte[] get_chain_hash() {
32                 long ret = bindings.QueryShortChannelIds_get_chain_hash(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
36                 return ret_conv;
37         }
38
39         /**
40          * The genesis hash of the blockchain being queried
41          */
42         public void set_chain_hash(byte[] val) {
43                 bindings.QueryShortChannelIds_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
44                 GC.KeepAlive(this);
45                 GC.KeepAlive(val);
46         }
47
48         /**
49          * The short_channel_ids that are being queried
50          * 
51          * Returns a copy of the field.
52          */
53         public long[] get_short_channel_ids() {
54                 long ret = bindings.QueryShortChannelIds_get_short_channel_ids(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
58                 return ret_conv;
59         }
60
61         /**
62          * The short_channel_ids that are being queried
63          */
64         public void set_short_channel_ids(long[] val) {
65                 bindings.QueryShortChannelIds_set_short_channel_ids(this.ptr, InternalUtils.encodeUint64Array(val));
66                 GC.KeepAlive(this);
67                 GC.KeepAlive(val);
68         }
69
70         /**
71          * Constructs a new QueryShortChannelIds given each field
72          */
73         public static QueryShortChannelIds of(byte[] chain_hash_arg, long[] short_channel_ids_arg) {
74                 long ret = bindings.QueryShortChannelIds_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), InternalUtils.encodeUint64Array(short_channel_ids_arg));
75                 GC.KeepAlive(chain_hash_arg);
76                 GC.KeepAlive(short_channel_ids_arg);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 org.ldk.structs.QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryShortChannelIds(null, ret); }
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
80                 return ret_hu_conv;
81         }
82
83         internal long clone_ptr() {
84                 long ret = bindings.QueryShortChannelIds_clone_ptr(this.ptr);
85                 GC.KeepAlive(this);
86                 return ret;
87         }
88
89         /**
90          * Creates a copy of the QueryShortChannelIds
91          */
92         public QueryShortChannelIds clone() {
93                 long ret = bindings.QueryShortChannelIds_clone(this.ptr);
94                 GC.KeepAlive(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryShortChannelIds(null, ret); }
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Checks if two QueryShortChannelIdss contain equal inner contents.
103          * This ignores pointers and is_owned flags and looks at the values in fields.
104          * Two objects with NULL inner values will be considered "equal" here.
105          */
106         public bool eq(org.ldk.structs.QueryShortChannelIds b) {
107                 bool ret = bindings.QueryShortChannelIds_eq(this.ptr, b == null ? 0 : b.ptr);
108                 GC.KeepAlive(this);
109                 GC.KeepAlive(b);
110                 if (this != null) { this.ptrs_to.AddLast(b); };
111                 return ret;
112         }
113
114         public override bool Equals(object o) {
115                 if (!(o is QueryShortChannelIds)) return false;
116                 return this.eq((QueryShortChannelIds)o);
117         }
118         /**
119          * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
120          */
121         public static Result_QueryShortChannelIdsDecodeErrorZ read(byte[] ser) {
122                 long ret = bindings.QueryShortChannelIds_read(InternalUtils.encodeUint8Array(ser));
123                 GC.KeepAlive(ser);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
131          */
132         public byte[] write() {
133                 long ret = bindings.QueryShortChannelIds_write(this.ptr);
134                 GC.KeepAlive(this);
135                 if (ret >= 0 && ret <= 4096) { return null; }
136                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
137                 return ret_conv;
138         }
139
140 }
141 } } }