1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * The best known block as identified by its hash and height.
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 {
19 if (ptr != 0) { bindings.BestBlock_free(ptr); }
23 long ret = bindings.BestBlock_clone_ptr(this.ptr);
28 * Creates a copy of the BestBlock
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);
39 * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
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);
51 * Returns a `BestBlock` as identified by the given block hash and height.
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);
62 * Returns the best block hash.
64 public byte[] block_hash() {
65 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
70 * Returns the best block height.
73 int ret = bindings.BestBlock_height(this.ptr);