X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FUnsignedChannelUpdate.cs;h=48dd7bd253c9bfed9a8b6fee8d2d88b790ed775e;hb=12fdbefaac81d5b4be6bb67addd6dcd7c46a182b;hp=41705bea2e7f48bfb9590ad1c6af947d9ddb65bf;hpb=7811d2191440c55034e1abfbf3be442d4b25481b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/UnsignedChannelUpdate.cs b/c_sharp/src/org/ldk/structs/UnsignedChannelUpdate.cs index 41705bea..48dd7bd2 100644 --- a/c_sharp/src/org/ldk/structs/UnsignedChannelUpdate.cs +++ b/c_sharp/src/org/ldk/structs/UnsignedChannelUpdate.cs @@ -21,16 +21,18 @@ public class UnsignedChannelUpdate : CommonBase { * The genesis hash of the blockchain where the channel is to be opened */ public byte[] get_chain_hash() { - byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr); + long ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * The genesis hash of the blockchain where the channel is to be opened */ public void set_chain_hash(byte[] val) { - bindings.UnsignedChannelUpdate_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.UnsignedChannelUpdate_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -206,9 +208,11 @@ public class UnsignedChannelUpdate : CommonBase { * Returns a copy of the field. */ public byte[] get_excess_data() { - byte[] ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr); + long ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** @@ -218,7 +222,7 @@ public class UnsignedChannelUpdate : CommonBase { * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ public void set_excess_data(byte[] val) { - bindings.UnsignedChannelUpdate_set_excess_data(this.ptr, val); + bindings.UnsignedChannelUpdate_set_excess_data(this.ptr, InternalUtils.encodeUint8Array(val)); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -227,7 +231,7 @@ public class UnsignedChannelUpdate : CommonBase { * Constructs a new UnsignedChannelUpdate given each field */ public static UnsignedChannelUpdate of(byte[] chain_hash_arg, long short_channel_id_arg, int timestamp_arg, byte flags_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, long htlc_maximum_msat_arg, int fee_base_msat_arg, int fee_proportional_millionths_arg, byte[] excess_data_arg) { - long ret = bindings.UnsignedChannelUpdate_new(InternalUtils.check_arr_len(chain_hash_arg, 32), short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg); + long ret = bindings.UnsignedChannelUpdate_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, InternalUtils.encodeUint8Array(excess_data_arg)); GC.KeepAlive(chain_hash_arg); GC.KeepAlive(short_channel_id_arg); GC.KeepAlive(timestamp_arg); @@ -262,6 +266,18 @@ public class UnsignedChannelUpdate : CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate. + */ + public long hash() { + long ret = bindings.UnsignedChannelUpdate_hash(this.ptr); + GC.KeepAlive(this); + return ret; + } + + public override int GetHashCode() { + return (int)this.hash(); + } /** * Checks if two UnsignedChannelUpdates contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -283,16 +299,18 @@ public class UnsignedChannelUpdate : CommonBase { * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read */ public byte[] write() { - byte[] ret = bindings.UnsignedChannelUpdate_write(this.ptr); + long ret = bindings.UnsignedChannelUpdate_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 UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write */ public static Result_UnsignedChannelUpdateDecodeErrorZ read(byte[] ser) { - long ret = bindings.UnsignedChannelUpdate_read(ser); + long ret = bindings.UnsignedChannelUpdate_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);