6 namespace org { namespace ldk { namespace structs {
10 * The best known block as identified by its hash and height.
12 public class BestBlock : CommonBase {
13 internal BestBlock(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.BestBlock_free(ptr); }
18 internal long clone_ptr() {
19 long ret = bindings.BestBlock_clone_ptr(this.ptr);
25 * Creates a copy of the BestBlock
27 public BestBlock clone() {
28 long ret = bindings.BestBlock_clone(this.ptr);
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); };
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.
41 public bool eq(org.ldk.structs.BestBlock b) {
42 bool ret = bindings.BestBlock_eq(this.ptr, b == null ? 0 : b.ptr);
45 if (this != null) { this.ptrs_to.AddLast(b); };
49 public override bool Equals(object o) {
50 if (!(o is BestBlock)) return false;
51 return this.eq((BestBlock)o);
54 * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
57 public static BestBlock from_genesis(Network network) {
58 long ret = bindings.BestBlock_from_genesis(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); };
67 * Returns a `BestBlock` as identified by the given block hash and height.
69 public static BestBlock of(byte[] block_hash, int height) {
70 long ret = bindings.BestBlock_new(InternalUtils.check_arr_len(block_hash, 32), height);
71 GC.KeepAlive(block_hash);
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); };
80 * Returns the best block hash.
82 public byte[] block_hash() {
83 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
89 * Returns the best block height.
92 int ret = bindings.BestBlock_height(this.ptr);