]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/Bolt12InvoiceFeatures.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[ldk-java] / c_sharp / src / org / ldk / structs / Bolt12InvoiceFeatures.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  * Features used within an `invoice`.
11  */
12 public class Bolt12InvoiceFeatures : CommonBase {
13         internal Bolt12InvoiceFeatures(object _dummy, long ptr) : base(ptr) { }
14         ~Bolt12InvoiceFeatures() {
15                 if (ptr != 0) { bindings.Bolt12InvoiceFeatures_free(ptr); }
16         }
17
18         /**
19          * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read
20          */
21         public byte[] write() {
22                 long ret = bindings.Bolt12InvoiceFeatures_write(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
26                 return ret_conv;
27         }
28
29         /**
30          * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write
31          */
32         public static Result_Bolt12InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
33                 long ret = bindings.Bolt12InvoiceFeatures_read(InternalUtils.encodeUint8Array(ser));
34                 GC.KeepAlive(ser);
35                 if (ret >= 0 && ret <= 4096) { return null; }
36                 Result_Bolt12InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt12InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Checks if two Bolt12InvoiceFeaturess contain equal inner contents.
42          * This ignores pointers and is_owned flags and looks at the values in fields.
43          * Two objects with NULL inner values will be considered "equal" here.
44          */
45         public bool eq(org.ldk.structs.Bolt12InvoiceFeatures b) {
46                 bool ret = bindings.Bolt12InvoiceFeatures_eq(this.ptr, b.ptr);
47                 GC.KeepAlive(this);
48                 GC.KeepAlive(b);
49                 if (this != null) { this.ptrs_to.AddLast(b); };
50                 return ret;
51         }
52
53         public override bool Equals(object o) {
54                 if (!(o is Bolt12InvoiceFeatures)) return false;
55                 return this.eq((Bolt12InvoiceFeatures)o);
56         }
57         internal long clone_ptr() {
58                 long ret = bindings.Bolt12InvoiceFeatures_clone_ptr(this.ptr);
59                 GC.KeepAlive(this);
60                 return ret;
61         }
62
63         /**
64          * Creates a copy of the Bolt12InvoiceFeatures
65          */
66         public Bolt12InvoiceFeatures clone() {
67                 long ret = bindings.Bolt12InvoiceFeatures_clone(this.ptr);
68                 GC.KeepAlive(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures.
77          */
78         public long hash() {
79                 long ret = bindings.Bolt12InvoiceFeatures_hash(this.ptr);
80                 GC.KeepAlive(this);
81                 return ret;
82         }
83
84         public override int GetHashCode() {
85                 return (int)this.hash();
86         }
87         /**
88          * Create a blank Features with no features set
89          */
90         public static Bolt12InvoiceFeatures empty() {
91                 long ret = bindings.Bolt12InvoiceFeatures_empty();
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order
100          * from most on-the-wire encodings.
101          */
102         public byte[] le_flags() {
103                 long ret = bindings.Bolt12InvoiceFeatures_le_flags(this.ptr);
104                 GC.KeepAlive(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
107                 return ret_conv;
108         }
109
110         /**
111          * Returns true if this `Features` has any optional flags set
112          */
113         public bool supports_any_optional_bits() {
114                 bool ret = bindings.Bolt12InvoiceFeatures_supports_any_optional_bits(this.ptr);
115                 GC.KeepAlive(this);
116                 return ret;
117         }
118
119         /**
120          * Returns true if this `Features` object contains required features unknown by `other`.
121          */
122         public bool requires_unknown_bits_from(org.ldk.structs.Bolt12InvoiceFeatures other) {
123                 bool ret = bindings.Bolt12InvoiceFeatures_requires_unknown_bits_from(this.ptr, other.ptr);
124                 GC.KeepAlive(this);
125                 GC.KeepAlive(other);
126                 if (this != null) { this.ptrs_to.AddLast(other); };
127                 return ret;
128         }
129
130         /**
131          * Returns the set of required features unknown by `other`, as their bit position.
132          */
133         public long[] required_unknown_bits_from(org.ldk.structs.Bolt12InvoiceFeatures other) {
134                 long ret = bindings.Bolt12InvoiceFeatures_required_unknown_bits_from(this.ptr, other.ptr);
135                 GC.KeepAlive(this);
136                 GC.KeepAlive(other);
137                 if (ret >= 0 && ret <= 4096) { return null; }
138                 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
139                 if (this != null) { this.ptrs_to.AddLast(other); };
140                 return ret_conv;
141         }
142
143         /**
144          * Returns true if this `Features` object contains unknown feature flags which are set as
145          * \"required\".
146          */
147         public bool requires_unknown_bits() {
148                 bool ret = bindings.Bolt12InvoiceFeatures_requires_unknown_bits(this.ptr);
149                 GC.KeepAlive(this);
150                 return ret;
151         }
152
153         /**
154          * Returns true if this `Features` supports any bits which we do not know of
155          */
156         public bool supports_unknown_bits() {
157                 bool ret = bindings.Bolt12InvoiceFeatures_supports_unknown_bits(this.ptr);
158                 GC.KeepAlive(this);
159                 return ret;
160         }
161
162         /**
163          * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
164          * by [BOLT 9].
165          * 
166          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
167          * be set instead (i.e., `bit - 1`).
168          * 
169          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
170          */
171         public Result_NoneNoneZ set_required_feature_bit(long bit) {
172                 long ret = bindings.Bolt12InvoiceFeatures_set_required_feature_bit(this.ptr, bit);
173                 GC.KeepAlive(this);
174                 GC.KeepAlive(bit);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
182          * by [BOLT 9].
183          * 
184          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
185          * set instead (i.e., `bit + 1`).
186          * 
187          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
188          */
189         public Result_NoneNoneZ set_optional_feature_bit(long bit) {
190                 long ret = bindings.Bolt12InvoiceFeatures_set_optional_feature_bit(this.ptr, bit);
191                 GC.KeepAlive(this);
192                 GC.KeepAlive(bit);
193                 if (ret >= 0 && ret <= 4096) { return null; }
194                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
195                 return ret_hu_conv;
196         }
197
198         /**
199          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
200          * by [bLIP 2] or if it is a known `T` feature.
201          * 
202          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
203          * be set instead (i.e., `bit - 1`).
204          * 
205          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
206          */
207         public Result_NoneNoneZ set_required_custom_bit(long bit) {
208                 long ret = bindings.Bolt12InvoiceFeatures_set_required_custom_bit(this.ptr, bit);
209                 GC.KeepAlive(this);
210                 GC.KeepAlive(bit);
211                 if (ret >= 0 && ret <= 4096) { return null; }
212                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
218          * by [bLIP 2] or if it is a known `T` feature.
219          * 
220          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
221          * set instead (i.e., `bit + 1`).
222          * 
223          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
224          */
225         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
226                 long ret = bindings.Bolt12InvoiceFeatures_set_optional_custom_bit(this.ptr, bit);
227                 GC.KeepAlive(this);
228                 GC.KeepAlive(bit);
229                 if (ret >= 0 && ret <= 4096) { return null; }
230                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
231                 return ret_hu_conv;
232         }
233
234         /**
235          * Set this feature as optional.
236          */
237         public void set_basic_mpp_optional() {
238                 bindings.Bolt12InvoiceFeatures_set_basic_mpp_optional(this.ptr);
239                 GC.KeepAlive(this);
240         }
241
242         /**
243          * Set this feature as required.
244          */
245         public void set_basic_mpp_required() {
246                 bindings.Bolt12InvoiceFeatures_set_basic_mpp_required(this.ptr);
247                 GC.KeepAlive(this);
248         }
249
250         /**
251          * Checks if this feature is supported.
252          */
253         public bool supports_basic_mpp() {
254                 bool ret = bindings.Bolt12InvoiceFeatures_supports_basic_mpp(this.ptr);
255                 GC.KeepAlive(this);
256                 return ret;
257         }
258
259         /**
260          * Checks if this feature is required.
261          */
262         public bool requires_basic_mpp() {
263                 bool ret = bindings.Bolt12InvoiceFeatures_requires_basic_mpp(this.ptr);
264                 GC.KeepAlive(this);
265                 return ret;
266         }
267
268 }
269 } } }