[Java] Print error stack trace when tests fail
[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         /**
24          * The block's hash
25          */
26         public byte[] get_block_hash() {
27                 byte[] ret = bindings.BestBlock_get_block_hash(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The block's hash
34          */
35         public void set_block_hash(byte[] val) {
36                 bindings.BestBlock_set_block_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The height at which the block was confirmed.
43          */
44         public int get_height() {
45                 int ret = bindings.BestBlock_get_height(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * The height at which the block was confirmed.
52          */
53         public void set_height(int val) {
54                 bindings.BestBlock_set_height(this.ptr, val);
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * Constructs a new BestBlock given each field
61          */
62         public static BestBlock of(byte[] block_hash_arg, int height_arg) {
63                 long ret = bindings.BestBlock_new(InternalUtils.check_arr_len(block_hash_arg, 32), height_arg);
64                 Reference.reachabilityFence(block_hash_arg);
65                 Reference.reachabilityFence(height_arg);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
69                 return ret_hu_conv;
70         }
71
72         long clone_ptr() {
73                 long ret = bindings.BestBlock_clone_ptr(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the BestBlock
80          */
81         public BestBlock clone() {
82                 long ret = bindings.BestBlock_clone(this.ptr);
83                 Reference.reachabilityFence(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Generates a non-cryptographic 64-bit hash of the BestBlock.
92          */
93         public long hash() {
94                 long ret = bindings.BestBlock_hash(this.ptr);
95                 Reference.reachabilityFence(this);
96                 return ret;
97         }
98
99         @Override public int hashCode() {
100                 return (int)this.hash();
101         }
102         /**
103          * Checks if two BestBlocks contain equal inner contents.
104          * This ignores pointers and is_owned flags and looks at the values in fields.
105          * Two objects with NULL inner values will be considered "equal" here.
106          */
107         public boolean eq(org.ldk.structs.BestBlock b) {
108                 boolean ret = bindings.BestBlock_eq(this.ptr, b.ptr);
109                 Reference.reachabilityFence(this);
110                 Reference.reachabilityFence(b);
111                 if (this != null) { this.ptrs_to.add(b); };
112                 return ret;
113         }
114
115         @Override public boolean equals(Object o) {
116                 if (!(o instanceof BestBlock)) return false;
117                 return this.eq((BestBlock)o);
118         }
119         /**
120          * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
121          * network.
122          */
123         public static BestBlock from_network(org.ldk.enums.Network network) {
124                 long ret = bindings.BestBlock_from_network(network);
125                 Reference.reachabilityFence(network);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Serialize the BestBlock object into a byte array which can be read by BestBlock_read
134          */
135         public byte[] write() {
136                 byte[] ret = bindings.BestBlock_write(this.ptr);
137                 Reference.reachabilityFence(this);
138                 return ret;
139         }
140
141         /**
142          * Read a BestBlock from a byte array, created by BestBlock_write
143          */
144         public static Result_BestBlockDecodeErrorZ read(byte[] ser) {
145                 long ret = bindings.BestBlock_read(ser);
146                 Reference.reachabilityFence(ser);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 Result_BestBlockDecodeErrorZ ret_hu_conv = Result_BestBlockDecodeErrorZ.constr_from_ptr(ret);
149                 return ret_hu_conv;
150         }
151
152 }