[Java] Update auto-generated Java bindings
[ldk-java] / src / main / java / org / ldk / structs / HTLCUpdate.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  * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
13  * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
14  * preimage claim backward will lead to loss of funds.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class HTLCUpdate extends CommonBase {
18         HTLCUpdate(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.HTLCUpdate_free(ptr); }
23         }
24
25         long clone_ptr() {
26                 long ret = bindings.HTLCUpdate_clone_ptr(this.ptr);
27                 Reference.reachabilityFence(this);
28                 return ret;
29         }
30
31         /**
32          * Creates a copy of the HTLCUpdate
33          */
34         public HTLCUpdate clone() {
35                 long ret = bindings.HTLCUpdate_clone(this.ptr);
36                 Reference.reachabilityFence(this);
37                 if (ret >= 0 && ret <= 4096) { return null; }
38                 org.ldk.structs.HTLCUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCUpdate(null, ret); }
39                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40                 return ret_hu_conv;
41         }
42
43         /**
44          * Checks if two HTLCUpdates contain equal inner contents.
45          * This ignores pointers and is_owned flags and looks at the values in fields.
46          * Two objects with NULL inner values will be considered "equal" here.
47          */
48         public boolean eq(HTLCUpdate b) {
49                 boolean ret = bindings.HTLCUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
50                 Reference.reachabilityFence(this);
51                 Reference.reachabilityFence(b);
52                 if (this != null) { this.ptrs_to.add(b); };
53                 return ret;
54         }
55
56         @Override public boolean equals(Object o) {
57                 if (!(o instanceof HTLCUpdate)) return false;
58                 return this.eq((HTLCUpdate)o);
59         }
60         /**
61          * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read
62          */
63         public byte[] write() {
64                 byte[] ret = bindings.HTLCUpdate_write(this.ptr);
65                 Reference.reachabilityFence(this);
66                 return ret;
67         }
68
69         /**
70          * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write
71          */
72         public static Result_HTLCUpdateDecodeErrorZ read(byte[] ser) {
73                 long ret = bindings.HTLCUpdate_read(ser);
74                 Reference.reachabilityFence(ser);
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 Result_HTLCUpdateDecodeErrorZ ret_hu_conv = Result_HTLCUpdateDecodeErrorZ.constr_from_ptr(ret);
77                 return ret_hu_conv;
78         }
79
80 }