1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An [`update_fail_htlc`] message to be sent to or received from a peer.
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
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 {
22 if (ptr != 0) { bindings.UpdateFailHTLC_free(ptr); }
28 public ChannelId get_channel_id() {
29 long ret = bindings.UpdateFailHTLC_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40 public void set_channel_id(org.ldk.structs.ChannelId val) {
41 bindings.UpdateFailHTLC_set_channel_id(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
50 public long get_htlc_id() {
51 long ret = bindings.UpdateFailHTLC_get_htlc_id(this.ptr);
52 Reference.reachabilityFence(this);
59 public void set_htlc_id(long val) {
60 bindings.UpdateFailHTLC_set_htlc_id(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 long ret = bindings.UpdateFailHTLC_clone_ptr(this.ptr);
67 Reference.reachabilityFence(this);
72 * Creates a copy of the UpdateFailHTLC
74 public UpdateFailHTLC clone() {
75 long ret = bindings.UpdateFailHTLC_clone(this.ptr);
76 Reference.reachabilityFence(this);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 org.ldk.structs.UpdateFailHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, ret); }
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
84 * Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC.
87 long ret = bindings.UpdateFailHTLC_hash(this.ptr);
88 Reference.reachabilityFence(this);
92 @Override public int hashCode() {
93 return (int)this.hash();
96 * Checks if two UpdateFailHTLCs contain equal inner contents.
97 * This ignores pointers and is_owned flags and looks at the values in fields.
98 * Two objects with NULL inner values will be considered "equal" here.
100 public boolean eq(org.ldk.structs.UpdateFailHTLC b) {
101 boolean ret = bindings.UpdateFailHTLC_eq(this.ptr, b.ptr);
102 Reference.reachabilityFence(this);
103 Reference.reachabilityFence(b);
104 if (this != null) { this.ptrs_to.add(b); };
108 @Override public boolean equals(Object o) {
109 if (!(o instanceof UpdateFailHTLC)) return false;
110 return this.eq((UpdateFailHTLC)o);
113 * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
115 public byte[] write() {
116 byte[] ret = bindings.UpdateFailHTLC_write(this.ptr);
117 Reference.reachabilityFence(this);
122 * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
124 public static Result_UpdateFailHTLCDecodeErrorZ read(byte[] ser) {
125 long ret = bindings.UpdateFailHTLC_read(ser);
126 Reference.reachabilityFence(ser);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);