6 namespace org { namespace ldk { namespace structs {
10 * Features used within an `invoice`.
12 public class Bolt12InvoiceFeatures : CommonBase {
13 internal Bolt12InvoiceFeatures(object _dummy, long ptr) : base(ptr) { }
14 ~Bolt12InvoiceFeatures() {
15 if (ptr != 0) { bindings.Bolt12InvoiceFeatures_free(ptr); }
19 * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read
21 public byte[] write() {
22 long ret = bindings.Bolt12InvoiceFeatures_write(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30 * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write
32 public static Result_Bolt12InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
33 long ret = bindings.Bolt12InvoiceFeatures_read(InternalUtils.encodeUint8Array(ser));
35 if (ret >= 0 && ret <= 4096) { return null; }
36 Result_Bolt12InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt12InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
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.
45 public bool eq(org.ldk.structs.Bolt12InvoiceFeatures b) {
46 bool ret = bindings.Bolt12InvoiceFeatures_eq(this.ptr, b.ptr);
49 if (this != null) { this.ptrs_to.AddLast(b); };
53 public override bool Equals(object o) {
54 if (!(o is Bolt12InvoiceFeatures)) return false;
55 return this.eq((Bolt12InvoiceFeatures)o);
57 internal long clone_ptr() {
58 long ret = bindings.Bolt12InvoiceFeatures_clone_ptr(this.ptr);
64 * Creates a copy of the Bolt12InvoiceFeatures
66 public Bolt12InvoiceFeatures clone() {
67 long ret = bindings.Bolt12InvoiceFeatures_clone(this.ptr);
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); };
76 * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures.
79 long ret = bindings.Bolt12InvoiceFeatures_hash(this.ptr);
84 public override int GetHashCode() {
85 return (int)this.hash();
88 * Create a blank Features with no features set
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); };
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.
102 public byte[] le_flags() {
103 long ret = bindings.Bolt12InvoiceFeatures_le_flags(this.ptr);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
111 * Returns true if this `Features` has any optional flags set
113 public bool supports_any_optional_bits() {
114 bool ret = bindings.Bolt12InvoiceFeatures_supports_any_optional_bits(this.ptr);
120 * Returns true if this `Features` object contains required features unknown by `other`.
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);
126 if (this != null) { this.ptrs_to.AddLast(other); };
131 * Returns the set of required features unknown by `other`, as their bit position.
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);
137 if (ret >= 0 && ret <= 4096) { return null; }
138 long[] ret_conv = InternalUtils.decodeUint64Array(ret);
139 if (this != null) { this.ptrs_to.AddLast(other); };
144 * Returns true if this `Features` object contains unknown feature flags which are set as
147 public bool requires_unknown_bits() {
148 bool ret = bindings.Bolt12InvoiceFeatures_requires_unknown_bits(this.ptr);
154 * Returns true if this `Features` supports any bits which we do not know of
156 public bool supports_unknown_bits() {
157 bool ret = bindings.Bolt12InvoiceFeatures_supports_unknown_bits(this.ptr);
163 * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
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`).
169 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
171 public Result_NoneNoneZ set_required_feature_bit(long bit) {
172 long ret = bindings.Bolt12InvoiceFeatures_set_required_feature_bit(this.ptr, bit);
175 if (ret >= 0 && ret <= 4096) { return null; }
176 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
181 * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
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`).
187 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
189 public Result_NoneNoneZ set_optional_feature_bit(long bit) {
190 long ret = bindings.Bolt12InvoiceFeatures_set_optional_feature_bit(this.ptr, bit);
193 if (ret >= 0 && ret <= 4096) { return null; }
194 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
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.
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`).
205 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
207 public Result_NoneNoneZ set_required_custom_bit(long bit) {
208 long ret = bindings.Bolt12InvoiceFeatures_set_required_custom_bit(this.ptr, bit);
211 if (ret >= 0 && ret <= 4096) { return null; }
212 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
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.
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`).
223 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
225 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
226 long ret = bindings.Bolt12InvoiceFeatures_set_optional_custom_bit(this.ptr, bit);
229 if (ret >= 0 && ret <= 4096) { return null; }
230 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
235 * Set this feature as optional.
237 public void set_basic_mpp_optional() {
238 bindings.Bolt12InvoiceFeatures_set_basic_mpp_optional(this.ptr);
243 * Set this feature as required.
245 public void set_basic_mpp_required() {
246 bindings.Bolt12InvoiceFeatures_set_basic_mpp_required(this.ptr);
251 * Checks if this feature is supported.
253 public bool supports_basic_mpp() {
254 bool ret = bindings.Bolt12InvoiceFeatures_supports_basic_mpp(this.ptr);
260 * Checks if this feature is required.
262 public bool requires_basic_mpp() {
263 bool ret = bindings.Bolt12InvoiceFeatures_requires_basic_mpp(this.ptr);