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 * Creates a copy of the BestBlock
25 public BestBlock clone() {
26 long ret = bindings.BestBlock_clone(this.ptr);
27 if (ret < 1024) { return null; }
28 BestBlock ret_hu_conv = new BestBlock(null, ret);
29 ret_hu_conv.ptrs_to.add(this);
34 * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
37 public static BestBlock from_genesis(org.ldk.enums.Network network) {
38 long ret = bindings.BestBlock_from_genesis(network);
39 if (ret < 1024) { return null; }
40 BestBlock ret_hu_conv = new BestBlock(null, ret);
41 ret_hu_conv.ptrs_to.add(ret_hu_conv);
46 * Returns a `BestBlock` as identified by the given block hash and height.
48 public static BestBlock of(byte[] block_hash, int height) {
49 long ret = bindings.BestBlock_new(block_hash, height);
50 if (ret < 1024) { return null; }
51 BestBlock ret_hu_conv = new BestBlock(null, ret);
52 ret_hu_conv.ptrs_to.add(ret_hu_conv);
57 * Returns the best block hash.
59 public byte[] block_hash() {
60 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
65 * Returns the best block height.
68 int ret = bindings.BestBlock_height(this.ptr);