[Java] Update auto-generated Java bindings for 0.0.113
[ldk-java] / src / main / java / org / ldk / structs / BestBlock.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * The best known block as identified by its hash and height.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class BestBlock extends CommonBase {
16         BestBlock(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.BestBlock_free(ptr); }
21         }
22
23         long clone_ptr() {
24                 long ret = bindings.BestBlock_clone_ptr(this.ptr);
25                 Reference.reachabilityFence(this);
26                 return ret;
27         }
28
29         /**
30          * Creates a copy of the BestBlock
31          */
32         public BestBlock clone() {
33                 long ret = bindings.BestBlock_clone(this.ptr);
34                 Reference.reachabilityFence(this);
35                 if (ret >= 0 && ret <= 4096) { return null; }
36                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
37                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Checks if two BestBlocks contain equal inner contents.
43          * This ignores pointers and is_owned flags and looks at the values in fields.
44          * Two objects with NULL inner values will be considered "equal" here.
45          */
46         public boolean eq(org.ldk.structs.BestBlock b) {
47                 boolean ret = bindings.BestBlock_eq(this.ptr, b == null ? 0 : b.ptr);
48                 Reference.reachabilityFence(this);
49                 Reference.reachabilityFence(b);
50                 if (this != null) { this.ptrs_to.add(b); };
51                 return ret;
52         }
53
54         @Override public boolean equals(Object o) {
55                 if (!(o instanceof BestBlock)) return false;
56                 return this.eq((BestBlock)o);
57         }
58         /**
59          * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
60          * network.
61          */
62         public static BestBlock from_genesis(org.ldk.enums.Network network) {
63                 long ret = bindings.BestBlock_from_genesis(network);
64                 Reference.reachabilityFence(network);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Returns a `BestBlock` as identified by the given block hash and height.
73          */
74         public static BestBlock of(byte[] block_hash, int height) {
75                 long ret = bindings.BestBlock_new(InternalUtils.check_arr_len(block_hash, 32), height);
76                 Reference.reachabilityFence(block_hash);
77                 Reference.reachabilityFence(height);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Returns the best block hash.
86          */
87         public byte[] block_hash() {
88                 byte[] ret = bindings.BestBlock_block_hash(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * Returns the best block height.
95          */
96         public int height() {
97                 int ret = bindings.BestBlock_height(this.ptr);
98                 Reference.reachabilityFence(this);
99                 return ret;
100         }
101
102 }