[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / BestBlock.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * The best known block as identified by its hash and height.
11  */
12 public class BestBlock : CommonBase {
13         internal BestBlock(object _dummy, long ptr) : base(ptr) { }
14         ~BestBlock() {
15                 if (ptr != 0) { bindings.BestBlock_free(ptr); }
16         }
17
18         internal long clone_ptr() {
19                 long ret = bindings.BestBlock_clone_ptr(this.ptr);
20                 GC.KeepAlive(this);
21                 return ret;
22         }
23
24         /**
25          * Creates a copy of the BestBlock
26          */
27         public BestBlock clone() {
28                 long ret = bindings.BestBlock_clone(this.ptr);
29                 GC.KeepAlive(this);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
32                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Checks if two BestBlocks contain equal inner contents.
38          * This ignores pointers and is_owned flags and looks at the values in fields.
39          * Two objects with NULL inner values will be considered "equal" here.
40          */
41         public bool eq(org.ldk.structs.BestBlock b) {
42                 bool ret = bindings.BestBlock_eq(this.ptr, b == null ? 0 : b.ptr);
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(b);
45                 if (this != null) { this.ptrs_to.AddLast(b); };
46                 return ret;
47         }
48
49         public override bool Equals(object o) {
50                 if (!(o is BestBlock)) return false;
51                 return this.eq((BestBlock)o);
52         }
53         /**
54          * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
55          * network.
56          */
57         public static BestBlock from_network(Network network) {
58                 long ret = bindings.BestBlock_from_network(network);
59                 GC.KeepAlive(network);
60                 if (ret >= 0 && ret <= 4096) { return null; }
61                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
62                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Returns a `BestBlock` as identified by the given block hash and height.
68          */
69         public static BestBlock of(byte[] block_hash, int height) {
70                 long ret = bindings.BestBlock_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(block_hash, 32)), height);
71                 GC.KeepAlive(block_hash);
72                 GC.KeepAlive(height);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Returns the best block hash.
81          */
82         public byte[] block_hash() {
83                 long ret = bindings.BestBlock_block_hash(this.ptr);
84                 GC.KeepAlive(this);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
87                 return ret_conv;
88         }
89
90         /**
91          * Returns the best block height.
92          */
93         public int height() {
94                 int ret = bindings.BestBlock_height(this.ptr);
95                 GC.KeepAlive(this);
96                 return ret;
97         }
98
99 }
100 } } }