X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FBolt12InvoiceFeatures.cs;h=98b72e127b5b53f53b83ffd9f8ee16a26e5abd14;hb=239d70ea23fdf148440dfedf9479944dc0fbf394;hp=6695827a238e89b8578002b7d70cf3b7d77a936c;hpb=7811d2191440c55034e1abfbf3be442d4b25481b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/Bolt12InvoiceFeatures.cs b/c_sharp/src/org/ldk/structs/Bolt12InvoiceFeatures.cs index 6695827a..98b72e12 100644 --- a/c_sharp/src/org/ldk/structs/Bolt12InvoiceFeatures.cs +++ b/c_sharp/src/org/ldk/structs/Bolt12InvoiceFeatures.cs @@ -50,6 +50,18 @@ public class Bolt12InvoiceFeatures : CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. + */ + public long hash() { + long ret = bindings.Bolt12InvoiceFeatures_hash(this.ptr); + GC.KeepAlive(this); + return ret; + } + + public override int GetHashCode() { + return (int)this.hash(); + } /** * Create a blank Features with no features set */ @@ -82,6 +94,42 @@ public class Bolt12InvoiceFeatures : CommonBase { return ret; } + /** + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + */ + public Result_NoneNoneZ set_required_feature_bit(long bit) { + long ret = bindings.Bolt12InvoiceFeatures_set_required_feature_bit(this.ptr, bit); + GC.KeepAlive(this); + GC.KeepAlive(bit); + if (ret >= 0 && ret <= 4096) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + /** + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + */ + public Result_NoneNoneZ set_optional_feature_bit(long bit) { + long ret = bindings.Bolt12InvoiceFeatures_set_optional_feature_bit(this.ptr, bit); + GC.KeepAlive(this); + GC.KeepAlive(bit); + if (ret >= 0 && ret <= 4096) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined * by [bLIP 2] or if it is a known `T` feature. @@ -122,16 +170,18 @@ public class Bolt12InvoiceFeatures : CommonBase { * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read */ public byte[] write() { - byte[] ret = bindings.Bolt12InvoiceFeatures_write(this.ptr); + long ret = bindings.Bolt12InvoiceFeatures_write(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write */ public static Result_Bolt12InvoiceFeaturesDecodeErrorZ read(byte[] ser) { - long ret = bindings.Bolt12InvoiceFeatures_read(ser); + long ret = bindings.Bolt12InvoiceFeatures_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_Bolt12InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt12InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);