1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * The best known block as identified by its hash and height.
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 {
18 if (ptr != 0) { bindings.BestBlock_free(ptr); }
22 * Creates a copy of the BestBlock
24 public BestBlock clone() {
25 long ret = bindings.BestBlock_clone(this.ptr);
26 BestBlock ret_hu_conv = new BestBlock(null, ret);
27 ret_hu_conv.ptrs_to.add(this);
32 * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
35 public static BestBlock from_genesis(Network network) {
36 long ret = bindings.BestBlock_from_genesis(network);
37 BestBlock ret_hu_conv = new BestBlock(null, ret);
38 ret_hu_conv.ptrs_to.add(ret_hu_conv);
43 * Returns a `BestBlock` as identified by the given block hash and height.
45 public static BestBlock of(byte[] block_hash, int height) {
46 long ret = bindings.BestBlock_new(block_hash, height);
47 BestBlock ret_hu_conv = new BestBlock(null, ret);
48 ret_hu_conv.ptrs_to.add(ret_hu_conv);
53 * Returns the best block hash.
55 public byte[] block_hash() {
56 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
61 * Returns the best block height.
64 int ret = bindings.BestBlock_height(this.ptr);