Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / BestBlock.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * The best known block as identified by its hash and height.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class BestBlock extends CommonBase {
15         BestBlock(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.BestBlock_free(ptr); }
20         }
21
22         long clone_ptr() {
23                 long ret = bindings.BestBlock_clone_ptr(this.ptr);
24                 return ret;
25         }
26
27         /**
28          * Creates a copy of the BestBlock
29          */
30         public BestBlock clone() {
31                 long ret = bindings.BestBlock_clone(this.ptr);
32                 if (ret >= 0 && ret <= 4096) { return null; }
33                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
34                 ret_hu_conv.ptrs_to.add(this);
35                 return ret_hu_conv;
36         }
37
38         /**
39          * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
40          * network.
41          */
42         public static BestBlock from_genesis(org.ldk.enums.Network network) {
43                 long ret = bindings.BestBlock_from_genesis(network);
44                 if (ret >= 0 && ret <= 4096) { return null; }
45                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
46                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
47                 return ret_hu_conv;
48         }
49
50         /**
51          * Returns a `BestBlock` as identified by the given block hash and height.
52          */
53         public static BestBlock of(byte[] block_hash, int height) {
54                 long ret = bindings.BestBlock_new(InternalUtils.check_arr_len(block_hash, 32), height);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
57                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Returns the best block hash.
63          */
64         public byte[] block_hash() {
65                 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
66                 return ret;
67         }
68
69         /**
70          * Returns the best block height.
71          */
72         public int height() {
73                 int ret = bindings.BestBlock_height(this.ptr);
74                 return ret;
75         }
76
77 }