6b2ec479107bd7f589afa5e5fda9139b833ac764
[ldk-java] / c_sharp / src / org / ldk / structs / ReplyChannelRange.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 [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
11  * message.
12  * 
13  * Multiple `reply_channel_range` messages can be sent in reply
14  * to a single [`QueryChannelRange`] message. The query recipient makes a
15  * best effort to respond based on their local network view which may
16  * not be a perfect view of the network. The `short_channel_id`s in the
17  * reply are encoded. We only support `encoding_type=0` uncompressed
18  * serialization and do not support `encoding_type=1` zlib serialization.
19  * 
20  * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
21  */
22 public class ReplyChannelRange : CommonBase {
23         internal ReplyChannelRange(object _dummy, long ptr) : base(ptr) { }
24         ~ReplyChannelRange() {
25                 if (ptr != 0) { bindings.ReplyChannelRange_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.ReplyChannelRange_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.ReplyChannelRange_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 height of the first block in the range of the reply
50          */
51         public int get_first_blocknum() {
52                 int ret = bindings.ReplyChannelRange_get_first_blocknum(this.ptr);
53                 GC.KeepAlive(this);
54                 return ret;
55         }
56
57         /**
58          * The height of the first block in the range of the reply
59          */
60         public void set_first_blocknum(int val) {
61                 bindings.ReplyChannelRange_set_first_blocknum(this.ptr, val);
62                 GC.KeepAlive(this);
63                 GC.KeepAlive(val);
64         }
65
66         /**
67          * The number of blocks included in the range of the reply
68          */
69         public int get_number_of_blocks() {
70                 int ret = bindings.ReplyChannelRange_get_number_of_blocks(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * The number of blocks included in the range of the reply
77          */
78         public void set_number_of_blocks(int val) {
79                 bindings.ReplyChannelRange_set_number_of_blocks(this.ptr, val);
80                 GC.KeepAlive(this);
81                 GC.KeepAlive(val);
82         }
83
84         /**
85          * True when this is the final reply for a query
86          */
87         public bool get_sync_complete() {
88                 bool ret = bindings.ReplyChannelRange_get_sync_complete(this.ptr);
89                 GC.KeepAlive(this);
90                 return ret;
91         }
92
93         /**
94          * True when this is the final reply for a query
95          */
96         public void set_sync_complete(bool val) {
97                 bindings.ReplyChannelRange_set_sync_complete(this.ptr, val);
98                 GC.KeepAlive(this);
99                 GC.KeepAlive(val);
100         }
101
102         /**
103          * The `short_channel_id`s in the channel range
104          * 
105          * Returns a copy of the field.
106          */
107         public long[] get_short_channel_ids() {
108                 long ret = bindings.ReplyChannelRange_get_short_channel_ids(this.ptr);
109                 GC.KeepAlive(this);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
112                 return ret_conv;
113         }
114
115         /**
116          * The `short_channel_id`s in the channel range
117          */
118         public void set_short_channel_ids(long[] val) {
119                 bindings.ReplyChannelRange_set_short_channel_ids(this.ptr, InternalUtils.encodeUint64Array(val));
120                 GC.KeepAlive(this);
121                 GC.KeepAlive(val);
122         }
123
124         /**
125          * Constructs a new ReplyChannelRange given each field
126          */
127         public static ReplyChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, bool sync_complete_arg, long[] short_channel_ids_arg) {
128                 long ret = bindings.ReplyChannelRange_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, InternalUtils.encodeUint64Array(short_channel_ids_arg));
129                 GC.KeepAlive(chain_hash_arg);
130                 GC.KeepAlive(first_blocknum_arg);
131                 GC.KeepAlive(number_of_blocks_arg);
132                 GC.KeepAlive(sync_complete_arg);
133                 GC.KeepAlive(short_channel_ids_arg);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyChannelRange(null, ret); }
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
137                 return ret_hu_conv;
138         }
139
140         internal long clone_ptr() {
141                 long ret = bindings.ReplyChannelRange_clone_ptr(this.ptr);
142                 GC.KeepAlive(this);
143                 return ret;
144         }
145
146         /**
147          * Creates a copy of the ReplyChannelRange
148          */
149         public ReplyChannelRange clone() {
150                 long ret = bindings.ReplyChannelRange_clone(this.ptr);
151                 GC.KeepAlive(this);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 org.ldk.structs.ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyChannelRange(null, ret); }
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
155                 return ret_hu_conv;
156         }
157
158         /**
159          * Checks if two ReplyChannelRanges contain equal inner contents.
160          * This ignores pointers and is_owned flags and looks at the values in fields.
161          * Two objects with NULL inner values will be considered "equal" here.
162          */
163         public bool eq(org.ldk.structs.ReplyChannelRange b) {
164                 bool ret = bindings.ReplyChannelRange_eq(this.ptr, b == null ? 0 : b.ptr);
165                 GC.KeepAlive(this);
166                 GC.KeepAlive(b);
167                 if (this != null) { this.ptrs_to.AddLast(b); };
168                 return ret;
169         }
170
171         public override bool Equals(object o) {
172                 if (!(o is ReplyChannelRange)) return false;
173                 return this.eq((ReplyChannelRange)o);
174         }
175         /**
176          * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
177          */
178         public static Result_ReplyChannelRangeDecodeErrorZ read(byte[] ser) {
179                 long ret = bindings.ReplyChannelRange_read(InternalUtils.encodeUint8Array(ser));
180                 GC.KeepAlive(ser);
181                 if (ret >= 0 && ret <= 4096) { return null; }
182                 Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret);
183                 return ret_hu_conv;
184         }
185
186         /**
187          * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
188          */
189         public byte[] write() {
190                 long ret = bindings.ReplyChannelRange_write(this.ptr);
191                 GC.KeepAlive(this);
192                 if (ret >= 0 && ret <= 4096) { return null; }
193                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
194                 return ret_conv;
195         }
196
197 }
198 } } }