Merge pull request #126 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / UpdateFailHTLC.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  * An [`update_fail_htlc`] message to be sent to or received from a peer.
13  * 
14  * [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UpdateFailHTLC extends CommonBase {
18         UpdateFailHTLC(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UpdateFailHTLC_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.UpdateFailHTLC_get_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The channel ID
36          */
37         public void set_channel_id(byte[] val) {
38                 bindings.UpdateFailHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The HTLC ID
45          */
46         public long get_htlc_id() {
47                 long ret = bindings.UpdateFailHTLC_get_htlc_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The HTLC ID
54          */
55         public void set_htlc_id(long val) {
56                 bindings.UpdateFailHTLC_set_htlc_id(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         long clone_ptr() {
62                 long ret = bindings.UpdateFailHTLC_clone_ptr(this.ptr);
63                 Reference.reachabilityFence(this);
64                 return ret;
65         }
66
67         /**
68          * Creates a copy of the UpdateFailHTLC
69          */
70         public UpdateFailHTLC clone() {
71                 long ret = bindings.UpdateFailHTLC_clone(this.ptr);
72                 Reference.reachabilityFence(this);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.UpdateFailHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, ret); }
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Checks if two UpdateFailHTLCs contain equal inner contents.
81          * This ignores pointers and is_owned flags and looks at the values in fields.
82          * Two objects with NULL inner values will be considered "equal" here.
83          */
84         public boolean eq(org.ldk.structs.UpdateFailHTLC b) {
85                 boolean ret = bindings.UpdateFailHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
86                 Reference.reachabilityFence(this);
87                 Reference.reachabilityFence(b);
88                 if (this != null) { this.ptrs_to.add(b); };
89                 return ret;
90         }
91
92         @Override public boolean equals(Object o) {
93                 if (!(o instanceof UpdateFailHTLC)) return false;
94                 return this.eq((UpdateFailHTLC)o);
95         }
96         /**
97          * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
98          */
99         public byte[] write() {
100                 byte[] ret = bindings.UpdateFailHTLC_write(this.ptr);
101                 Reference.reachabilityFence(this);
102                 return ret;
103         }
104
105         /**
106          * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
107          */
108         public static Result_UpdateFailHTLCDecodeErrorZ read(byte[] ser) {
109                 long ret = bindings.UpdateFailHTLC_read(ser);
110                 Reference.reachabilityFence(ser);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);
113                 return ret_hu_conv;
114         }
115
116 }