[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / QueryChannelRange.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_channel_range`] message is used to query a peer for channel
11  * UTXOs in a range of blocks. The recipient of a query makes a best
12  * effort to reply to the query using one or more [`ReplyChannelRange`]
13  * messages.
14  * 
15  * [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
16  */
17 public class QueryChannelRange : CommonBase {
18         internal QueryChannelRange(object _dummy, long ptr) : base(ptr) { }
19         ~QueryChannelRange() {
20                 if (ptr != 0) { bindings.QueryChannelRange_free(ptr); }
21         }
22
23         /**
24          * The genesis hash of the blockchain being queried
25          */
26         public byte[] get_chain_hash() {
27                 long ret = bindings.QueryChannelRange_get_chain_hash(this.ptr);
28                 GC.KeepAlive(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
31                 return ret_conv;
32         }
33
34         /**
35          * The genesis hash of the blockchain being queried
36          */
37         public void set_chain_hash(byte[] val) {
38                 bindings.QueryChannelRange_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
39                 GC.KeepAlive(this);
40                 GC.KeepAlive(val);
41         }
42
43         /**
44          * The height of the first block for the channel UTXOs being queried
45          */
46         public int get_first_blocknum() {
47                 int ret = bindings.QueryChannelRange_get_first_blocknum(this.ptr);
48                 GC.KeepAlive(this);
49                 return ret;
50         }
51
52         /**
53          * The height of the first block for the channel UTXOs being queried
54          */
55         public void set_first_blocknum(int val) {
56                 bindings.QueryChannelRange_set_first_blocknum(this.ptr, val);
57                 GC.KeepAlive(this);
58                 GC.KeepAlive(val);
59         }
60
61         /**
62          * The number of blocks to include in the query results
63          */
64         public int get_number_of_blocks() {
65                 int ret = bindings.QueryChannelRange_get_number_of_blocks(this.ptr);
66                 GC.KeepAlive(this);
67                 return ret;
68         }
69
70         /**
71          * The number of blocks to include in the query results
72          */
73         public void set_number_of_blocks(int val) {
74                 bindings.QueryChannelRange_set_number_of_blocks(this.ptr, val);
75                 GC.KeepAlive(this);
76                 GC.KeepAlive(val);
77         }
78
79         /**
80          * Constructs a new QueryChannelRange given each field
81          */
82         public static QueryChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) {
83                 long ret = bindings.QueryChannelRange_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), first_blocknum_arg, number_of_blocks_arg);
84                 GC.KeepAlive(chain_hash_arg);
85                 GC.KeepAlive(first_blocknum_arg);
86                 GC.KeepAlive(number_of_blocks_arg);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 org.ldk.structs.QueryChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryChannelRange(null, ret); }
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
90                 return ret_hu_conv;
91         }
92
93         internal long clone_ptr() {
94                 long ret = bindings.QueryChannelRange_clone_ptr(this.ptr);
95                 GC.KeepAlive(this);
96                 return ret;
97         }
98
99         /**
100          * Creates a copy of the QueryChannelRange
101          */
102         public QueryChannelRange clone() {
103                 long ret = bindings.QueryChannelRange_clone(this.ptr);
104                 GC.KeepAlive(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.QueryChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.QueryChannelRange(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
113          */
114         public long hash() {
115                 long ret = bindings.QueryChannelRange_hash(this.ptr);
116                 GC.KeepAlive(this);
117                 return ret;
118         }
119
120         public override int GetHashCode() {
121                 return (int)this.hash();
122         }
123         /**
124          * Checks if two QueryChannelRanges contain equal inner contents.
125          * This ignores pointers and is_owned flags and looks at the values in fields.
126          * Two objects with NULL inner values will be considered "equal" here.
127          */
128         public bool eq(org.ldk.structs.QueryChannelRange b) {
129                 bool ret = bindings.QueryChannelRange_eq(this.ptr, b == null ? 0 : b.ptr);
130                 GC.KeepAlive(this);
131                 GC.KeepAlive(b);
132                 if (this != null) { this.ptrs_to.AddLast(b); };
133                 return ret;
134         }
135
136         public override bool Equals(object o) {
137                 if (!(o is QueryChannelRange)) return false;
138                 return this.eq((QueryChannelRange)o);
139         }
140         /**
141          * Calculates the overflow safe ending block height for the query.
142          * 
143          * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
144          */
145         public int end_blocknum() {
146                 int ret = bindings.QueryChannelRange_end_blocknum(this.ptr);
147                 GC.KeepAlive(this);
148                 return ret;
149         }
150
151         /**
152          * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
153          */
154         public byte[] write() {
155                 long ret = bindings.QueryChannelRange_write(this.ptr);
156                 GC.KeepAlive(this);
157                 if (ret >= 0 && ret <= 4096) { return null; }
158                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
159                 return ret_conv;
160         }
161
162         /**
163          * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
164          */
165         public static Result_QueryChannelRangeDecodeErrorZ read(byte[] ser) {
166                 long ret = bindings.QueryChannelRange_read(InternalUtils.encodeUint8Array(ser));
167                 GC.KeepAlive(ser);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret);
170                 return ret_hu_conv;
171         }
172
173 }
174 } } }