6 namespace org { namespace ldk { namespace structs {
10 * The best known block as identified by its hash and height.
12 public class BestBlock : CommonBase {
13 internal BestBlock(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.BestBlock_free(ptr); }
21 public byte[] get_block_hash() {
22 long ret = bindings.BestBlock_get_block_hash(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
32 public void set_block_hash(byte[] val) {
33 bindings.BestBlock_set_block_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
39 * The height at which the block was confirmed.
41 public int get_height() {
42 int ret = bindings.BestBlock_get_height(this.ptr);
48 * The height at which the block was confirmed.
50 public void set_height(int val) {
51 bindings.BestBlock_set_height(this.ptr, val);
57 * Constructs a new BestBlock given each field
59 public static BestBlock of(byte[] block_hash_arg, int height_arg) {
60 long ret = bindings.BestBlock_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(block_hash_arg, 32)), height_arg);
61 GC.KeepAlive(block_hash_arg);
62 GC.KeepAlive(height_arg);
63 if (ret >= 0 && ret <= 4096) { return null; }
64 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
65 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
69 internal long clone_ptr() {
70 long ret = bindings.BestBlock_clone_ptr(this.ptr);
76 * Creates a copy of the BestBlock
78 public BestBlock clone() {
79 long ret = bindings.BestBlock_clone(this.ptr);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
83 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
88 * Generates a non-cryptographic 64-bit hash of the BestBlock.
91 long ret = bindings.BestBlock_hash(this.ptr);
96 public override int GetHashCode() {
97 return (int)this.hash();
100 * Checks if two BestBlocks contain equal inner contents.
101 * This ignores pointers and is_owned flags and looks at the values in fields.
102 * Two objects with NULL inner values will be considered "equal" here.
104 public bool eq(org.ldk.structs.BestBlock b) {
105 bool ret = bindings.BestBlock_eq(this.ptr, b.ptr);
108 if (this != null) { this.ptrs_to.AddLast(b); };
112 public override bool Equals(object o) {
113 if (!(o is BestBlock)) return false;
114 return this.eq((BestBlock)o);
117 * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
120 public static BestBlock from_network(Network network) {
121 long ret = bindings.BestBlock_from_network(network);
122 GC.KeepAlive(network);
123 if (ret >= 0 && ret <= 4096) { return null; }
124 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
125 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
130 * Serialize the BestBlock object into a byte array which can be read by BestBlock_read
132 public byte[] write() {
133 long ret = bindings.BestBlock_write(this.ptr);
135 if (ret >= 0 && ret <= 4096) { return null; }
136 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
141 * Read a BestBlock from a byte array, created by BestBlock_write
143 public static Result_BestBlockDecodeErrorZ read(byte[] ser) {
144 long ret = bindings.BestBlock_read(InternalUtils.encodeUint8Array(ser));
146 if (ret >= 0 && ret <= 4096) { return null; }
147 Result_BestBlockDecodeErrorZ ret_hu_conv = Result_BestBlockDecodeErrorZ.constr_from_ptr(ret);