Update auto-generated bindings to 0.0.103
[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         /**
23          * Creates a copy of the BestBlock
24          */
25         public BestBlock clone() {
26                 long ret = bindings.BestBlock_clone(this.ptr);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
29                 ret_hu_conv.ptrs_to.add(this);
30                 return ret_hu_conv;
31         }
32
33         /**
34          * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
35          * network.
36          */
37         public static BestBlock from_genesis(org.ldk.enums.Network network) {
38                 long ret = bindings.BestBlock_from_genesis(network);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
41                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
42                 return ret_hu_conv;
43         }
44
45         /**
46          * Returns a `BestBlock` as identified by the given block hash and height.
47          */
48         public static BestBlock of(byte[] block_hash, int height) {
49                 long ret = bindings.BestBlock_new(block_hash, height);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
52                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Returns the best block hash.
58          */
59         public byte[] block_hash() {
60                 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
61                 return ret;
62         }
63
64         /**
65          * Returns the best block height.
66          */
67         public int height() {
68                 int ret = bindings.BestBlock_height(this.ptr);
69                 return ret;
70         }
71
72 }