X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FBestBlock.java;h=9d3629ebe4c016a63fe31e4eff59802e69ef6118;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=fce6df52153b0c6fd71f0e61fad02bde5e7a9aa8;hpb=6f84978154512148a47502caad48038e3f264392;p=ldk-java diff --git a/src/main/java/org/ldk/structs/BestBlock.java b/src/main/java/org/ldk/structs/BestBlock.java index fce6df52..9d3629eb 100644 --- a/src/main/java/org/ldk/structs/BestBlock.java +++ b/src/main/java/org/ldk/structs/BestBlock.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import javax.annotation.Nullable; /** @@ -23,27 +24,31 @@ public class BestBlock extends CommonBase { */ public BestBlock clone() { long ret = bindings.BestBlock_clone(this.ptr); - BestBlock ret_hu_conv = new BestBlock(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } /** - * Returns the best block from the genesis of the given network. + * Constructs a `BestBlock` that represents the genesis block at height 0 of the given + * network. */ - public static BestBlock constructor_from_genesis(LDKNetwork network) { + public static BestBlock from_genesis(org.ldk.enums.Network network) { long ret = bindings.BestBlock_from_genesis(network); - BestBlock ret_hu_conv = new BestBlock(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } /** - * Returns the best block as identified by the given block hash and height. + * Returns a `BestBlock` as identified by the given block hash and height. */ - public static BestBlock constructor_new(byte[] block_hash, int height) { + public static BestBlock of(byte[] block_hash, int height) { long ret = bindings.BestBlock_new(block_hash, height); - BestBlock ret_hu_conv = new BestBlock(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; }