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