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
8
9 /**
10  * The best known block as identified by its hash and height.
11  */
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class BestBlock extends CommonBase {
14         BestBlock(Object _dummy, long ptr) { super(ptr); }
15         @Override @SuppressWarnings("deprecation")
16         protected void finalize() throws Throwable {
17                 super.finalize();
18                 if (ptr != 0) { bindings.BestBlock_free(ptr); }
19         }
20
21         /**
22          * Creates a copy of the BestBlock
23          */
24         public BestBlock clone() {
25                 long ret = bindings.BestBlock_clone(this.ptr);
26                 if (ret < 1024) { return null; }
27                 BestBlock ret_hu_conv = new BestBlock(null, ret);
28                 ret_hu_conv.ptrs_to.add(this);
29                 return ret_hu_conv;
30         }
31
32         /**
33          * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
34          * network.
35          */
36         public static BestBlock from_genesis(Network network) {
37                 long ret = bindings.BestBlock_from_genesis(network);
38                 if (ret < 1024) { return null; }
39                 BestBlock ret_hu_conv = new BestBlock(null, ret);
40                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
41                 return ret_hu_conv;
42         }
43
44         /**
45          * Returns a `BestBlock` as identified by the given block hash and height.
46          */
47         public static BestBlock of(byte[] block_hash, int height) {
48                 long ret = bindings.BestBlock_new(block_hash, height);
49                 if (ret < 1024) { return null; }
50                 BestBlock ret_hu_conv = new BestBlock(null, ret);
51                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
52                 return ret_hu_conv;
53         }
54
55         /**
56          * Returns the best block hash.
57          */
58         public byte[] block_hash() {
59                 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
60                 return ret;
61         }
62
63         /**
64          * Returns the best block height.
65          */
66         public int height() {
67                 int ret = bindings.BestBlock_height(this.ptr);
68                 return ret;
69         }
70
71 }