X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FClosingSigned.cs;h=9f47f3db5fa1cc5aec04a9ab6900084ac9a6a1e2;hb=HEAD;hp=cf10db07a9a7ff983618bbbb3d3c200a820668ad;hpb=7811d2191440c55034e1abfbf3be442d4b25481b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/ClosingSigned.cs b/c_sharp/src/org/ldk/structs/ClosingSigned.cs index cf10db07..9f47f3db 100644 --- a/c_sharp/src/org/ldk/structs/ClosingSigned.cs +++ b/c_sharp/src/org/ldk/structs/ClosingSigned.cs @@ -20,19 +20,23 @@ public class ClosingSigned : CommonBase { /** * The channel ID */ - public byte[] get_channel_id() { - byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr); + public ChannelId get_channel_id() { + long ret = bindings.ClosingSigned_get_channel_id(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; } /** * The channel ID */ - public void set_channel_id(byte[] val) { - bindings.ClosingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32)); + public void set_channel_id(org.ldk.structs.ChannelId val) { + bindings.ClosingSigned_set_channel_id(this.ptr, val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); + if (this != null) { this.ptrs_to.AddLast(val); }; } /** @@ -57,16 +61,18 @@ public class ClosingSigned : CommonBase { * A signature on the closing transaction */ public byte[] get_signature() { - byte[] ret = bindings.ClosingSigned_get_signature(this.ptr); + long ret = bindings.ClosingSigned_get_signature(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * A signature on the closing transaction */ public void set_signature(byte[] val) { - bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64)); + bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -101,9 +107,11 @@ public class ClosingSigned : CommonBase { /** * Constructs a new ClosingSigned given each field + * + * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, org.ldk.structs.ClosingSignedFeeRange fee_range_arg) { - long ret = bindings.ClosingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), fee_satoshis_arg, InternalUtils.check_arr_len(signature_arg, 64), fee_range_arg == null ? 0 : fee_range_arg.ptr); + public static ClosingSigned of(org.ldk.structs.ChannelId channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, org.ldk.structs.ClosingSignedFeeRange fee_range_arg) { + long ret = bindings.ClosingSigned_new(channel_id_arg.ptr, fee_satoshis_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), fee_range_arg == null ? 0 : fee_range_arg.ptr); GC.KeepAlive(channel_id_arg); GC.KeepAlive(fee_satoshis_arg); GC.KeepAlive(signature_arg); @@ -111,6 +119,7 @@ public class ClosingSigned : CommonBase { if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_range_arg); }; return ret_hu_conv; } @@ -133,13 +142,25 @@ public class ClosingSigned : CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the ClosingSigned. + */ + public long hash() { + long ret = bindings.ClosingSigned_hash(this.ptr); + GC.KeepAlive(this); + return ret; + } + + public override int GetHashCode() { + return (int)this.hash(); + } /** * Checks if two ClosingSigneds contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ public bool eq(org.ldk.structs.ClosingSigned b) { - bool ret = bindings.ClosingSigned_eq(this.ptr, b == null ? 0 : b.ptr); + bool ret = bindings.ClosingSigned_eq(this.ptr, b.ptr); GC.KeepAlive(this); GC.KeepAlive(b); if (this != null) { this.ptrs_to.AddLast(b); }; @@ -154,16 +175,18 @@ public class ClosingSigned : CommonBase { * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read */ public byte[] write() { - byte[] ret = bindings.ClosingSigned_write(this.ptr); + long ret = bindings.ClosingSigned_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 ClosingSigned from a byte array, created by ClosingSigned_write */ public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) { - long ret = bindings.ClosingSigned_read(ser); + long ret = bindings.ClosingSigned_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);