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