f374fd26cf7d6cd5542f02e225d94a3556fcaa0c
[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                 byte[] ret = bindings.QueryShortChannelIds_get_chain_hash(this.ptr);
33                 GC.KeepAlive(this);
34                 return ret;
35         }
36
37         /**
38          * The genesis hash of the blockchain being queried
39          */
40         public void set_chain_hash(byte[] val) {
41                 bindings.QueryShortChannelIds_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
42                 GC.KeepAlive(this);
43                 GC.KeepAlive(val);
44         }
45
46         /**
47          * The short_channel_ids that are being queried
48          * 
49          * Returns a copy of the field.
50          */
51         public long[] get_short_channel_ids() {
52                 long[] ret = bindings.QueryShortChannelIds_get_short_channel_ids(this.ptr);
53                 GC.KeepAlive(this);
54                 return ret;
55         }
56
57         /**
58          * The short_channel_ids that are being queried
59          */
60         public void set_short_channel_ids(long[] val) {
61                 bindings.QueryShortChannelIds_set_short_channel_ids(this.ptr, val);
62                 GC.KeepAlive(this);
63                 GC.KeepAlive(val);
64         }
65
66         /**
67          * Constructs a new QueryShortChannelIds given each field
68          */
69         public static QueryShortChannelIds of(byte[] chain_hash_arg, long[] short_channel_ids_arg) {
70                 long ret = bindings.QueryShortChannelIds_new(InternalUtils.check_arr_len(chain_hash_arg, 32), short_channel_ids_arg);
71                 GC.KeepAlive(chain_hash_arg);
72                 GC.KeepAlive(short_channel_ids_arg);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryShortChannelIds(null, ret); }
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
76                 return ret_hu_conv;
77         }
78
79         internal long clone_ptr() {
80                 long ret = bindings.QueryShortChannelIds_clone_ptr(this.ptr);
81                 GC.KeepAlive(this);
82                 return ret;
83         }
84
85         /**
86          * Creates a copy of the QueryShortChannelIds
87          */
88         public QueryShortChannelIds clone() {
89                 long ret = bindings.QueryShortChannelIds_clone(this.ptr);
90                 GC.KeepAlive(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryShortChannelIds(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Checks if two QueryShortChannelIdss contain equal inner contents.
99          * This ignores pointers and is_owned flags and looks at the values in fields.
100          * Two objects with NULL inner values will be considered "equal" here.
101          */
102         public bool eq(org.ldk.structs.QueryShortChannelIds b) {
103                 bool ret = bindings.QueryShortChannelIds_eq(this.ptr, b == null ? 0 : b.ptr);
104                 GC.KeepAlive(this);
105                 GC.KeepAlive(b);
106                 if (this != null) { this.ptrs_to.AddLast(b); };
107                 return ret;
108         }
109
110         public override bool Equals(object o) {
111                 if (!(o is QueryShortChannelIds)) return false;
112                 return this.eq((QueryShortChannelIds)o);
113         }
114         /**
115          * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
116          */
117         public static Result_QueryShortChannelIdsDecodeErrorZ read(byte[] ser) {
118                 long ret = bindings.QueryShortChannelIds_read(ser);
119                 GC.KeepAlive(ser);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
127          */
128         public byte[] write() {
129                 byte[] ret = bindings.QueryShortChannelIds_write(this.ptr);
130                 GC.KeepAlive(this);
131                 return ret;
132         }
133
134 }
135 } } }