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_fulfill_htlc`] message to be sent to or received from a peer.
14 * [`update_fulfill_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 UpdateFulfillHTLC extends CommonBase {
18 UpdateFulfillHTLC(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UpdateFulfillHTLC_free(ptr); }
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
46 public long get_htlc_id() {
47 long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
48 Reference.reachabilityFence(this);
55 public void set_htlc_id(long val) {
56 bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The pre-image of the payment hash, allowing HTLC redemption
64 public byte[] get_payment_preimage() {
65 byte[] ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
66 Reference.reachabilityFence(this);
71 * The pre-image of the payment hash, allowing HTLC redemption
73 public void set_payment_preimage(byte[] val) {
74 bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, InternalUtils.check_arr_len(val, 32));
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * Constructs a new UpdateFulfillHTLC given each field
82 public static UpdateFulfillHTLC of(byte[] channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) {
83 long ret = bindings.UpdateFulfillHTLC_new(InternalUtils.check_arr_len(channel_id_arg, 32), htlc_id_arg, InternalUtils.check_arr_len(payment_preimage_arg, 32));
84 Reference.reachabilityFence(channel_id_arg);
85 Reference.reachabilityFence(htlc_id_arg);
86 Reference.reachabilityFence(payment_preimage_arg);
87 if (ret >= 0 && ret <= 4096) { return null; }
88 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
89 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
94 long ret = bindings.UpdateFulfillHTLC_clone_ptr(this.ptr);
95 Reference.reachabilityFence(this);
100 * Creates a copy of the UpdateFulfillHTLC
102 public UpdateFulfillHTLC clone() {
103 long ret = bindings.UpdateFulfillHTLC_clone(this.ptr);
104 Reference.reachabilityFence(this);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
112 * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
115 long ret = bindings.UpdateFulfillHTLC_hash(this.ptr);
116 Reference.reachabilityFence(this);
120 @Override public int hashCode() {
121 return (int)this.hash();
124 * Checks if two UpdateFulfillHTLCs contain equal inner contents.
125 * This ignores pointers and is_owned flags and looks at the values in fields.
126 * Two objects with NULL inner values will be considered "equal" here.
128 public boolean eq(org.ldk.structs.UpdateFulfillHTLC b) {
129 boolean ret = bindings.UpdateFulfillHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
130 Reference.reachabilityFence(this);
131 Reference.reachabilityFence(b);
132 if (this != null) { this.ptrs_to.add(b); };
136 @Override public boolean equals(Object o) {
137 if (!(o instanceof UpdateFulfillHTLC)) return false;
138 return this.eq((UpdateFulfillHTLC)o);
141 * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
143 public byte[] write() {
144 byte[] ret = bindings.UpdateFulfillHTLC_write(this.ptr);
145 Reference.reachabilityFence(this);
150 * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
152 public static Result_UpdateFulfillHTLCDecodeErrorZ read(byte[] ser) {
153 long ret = bindings.UpdateFulfillHTLC_read(ser);
154 Reference.reachabilityFence(ser);
155 if (ret >= 0 && ret <= 4096) { return null; }
156 Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);