[C#] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / c_sharp / src / org / ldk / structs / BestBlock.cs
index 3d46e2b06aed97a4a1c025dc7c55539786e6acf8..b8b816ee958a819907cb600878500fb3173dda9f 100644 (file)
@@ -15,6 +15,57 @@ public class BestBlock : CommonBase {
                if (ptr != 0) { bindings.BestBlock_free(ptr); }
        }
 
+       /**
+        * The block's hash
+        */
+       public byte[] get_block_hash() {
+               long ret = bindings.BestBlock_get_block_hash(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+               return ret_conv;
+       }
+
+       /**
+        * The block's hash
+        */
+       public void set_block_hash(byte[] val) {
+               bindings.BestBlock_set_block_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
+               GC.KeepAlive(this);
+               GC.KeepAlive(val);
+       }
+
+       /**
+        * The height at which the block was confirmed.
+        */
+       public int get_height() {
+               int ret = bindings.BestBlock_get_height(this.ptr);
+               GC.KeepAlive(this);
+               return ret;
+       }
+
+       /**
+        * The height at which the block was confirmed.
+        */
+       public void set_height(int val) {
+               bindings.BestBlock_set_height(this.ptr, val);
+               GC.KeepAlive(this);
+               GC.KeepAlive(val);
+       }
+
+       /**
+        * Constructs a new BestBlock given each field
+        */
+       public static BestBlock of(byte[] block_hash_arg, int height_arg) {
+               long ret = bindings.BestBlock_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(block_hash_arg, 32)), height_arg);
+               GC.KeepAlive(block_hash_arg);
+               GC.KeepAlive(height_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
+               return ret_hu_conv;
+       }
+
        internal long clone_ptr() {
                long ret = bindings.BestBlock_clone_ptr(this.ptr);
                GC.KeepAlive(this);
@@ -33,13 +84,25 @@ public class BestBlock : CommonBase {
                return ret_hu_conv;
        }
 
+       /**
+        * Generates a non-cryptographic 64-bit hash of the BestBlock.
+        */
+       public long hash() {
+               long ret = bindings.BestBlock_hash(this.ptr);
+               GC.KeepAlive(this);
+               return ret;
+       }
+
+       public override int GetHashCode() {
+               return (int)this.hash();
+       }
        /**
         * Checks if two BestBlocks 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.BestBlock b) {
-               bool ret = bindings.BestBlock_eq(this.ptr, b == null ? 0 : b.ptr);
+               bool ret = bindings.BestBlock_eq(this.ptr, b.ptr);
                GC.KeepAlive(this);
                GC.KeepAlive(b);
                if (this != null) { this.ptrs_to.AddLast(b); };
@@ -64,23 +127,10 @@ public class BestBlock : CommonBase {
        }
 
        /**
-        * Returns a `BestBlock` as identified by the given block hash and height.
+        * Serialize the BestBlock object into a byte array which can be read by BestBlock_read
         */
-       public static BestBlock of(byte[] block_hash, int height) {
-               long ret = bindings.BestBlock_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(block_hash, 32)), height);
-               GC.KeepAlive(block_hash);
-               GC.KeepAlive(height);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
-               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
-               return ret_hu_conv;
-       }
-
-       /**
-        * Returns the best block hash.
-        */
-       public byte[] block_hash() {
-               long ret = bindings.BestBlock_block_hash(this.ptr);
+       public byte[] write() {
+               long ret = bindings.BestBlock_write(this.ptr);
                GC.KeepAlive(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
@@ -88,12 +138,14 @@ public class BestBlock : CommonBase {
        }
 
        /**
-        * Returns the best block height.
+        * Read a BestBlock from a byte array, created by BestBlock_write
         */
-       public int height() {
-               int ret = bindings.BestBlock_height(this.ptr);
-               GC.KeepAlive(this);
-               return ret;
+       public static Result_BestBlockDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.BestBlock_read(InternalUtils.encodeUint8Array(ser));
+               GC.KeepAlive(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_BestBlockDecodeErrorZ ret_hu_conv = Result_BestBlockDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
        }
 
 }