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 or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class UpdateFulfillHTLC extends CommonBase {
16 UpdateFulfillHTLC(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.UpdateFulfillHTLC_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
35 public void set_channel_id(byte[] val) {
36 bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
44 public long get_htlc_id() {
45 long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
46 Reference.reachabilityFence(this);
53 public void set_htlc_id(long val) {
54 bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * The pre-image of the payment hash, allowing HTLC redemption
62 public byte[] get_payment_preimage() {
63 byte[] ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
64 Reference.reachabilityFence(this);
69 * The pre-image of the payment hash, allowing HTLC redemption
71 public void set_payment_preimage(byte[] val) {
72 bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, InternalUtils.check_arr_len(val, 32));
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
78 * Constructs a new UpdateFulfillHTLC given each field
80 public static UpdateFulfillHTLC of(byte[] channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) {
81 long ret = bindings.UpdateFulfillHTLC_new(InternalUtils.check_arr_len(channel_id_arg, 32), htlc_id_arg, InternalUtils.check_arr_len(payment_preimage_arg, 32));
82 Reference.reachabilityFence(channel_id_arg);
83 Reference.reachabilityFence(htlc_id_arg);
84 Reference.reachabilityFence(payment_preimage_arg);
85 if (ret >= 0 && ret <= 4096) { return null; }
86 UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFulfillHTLC(null, ret); }
87 ret_hu_conv.ptrs_to.add(ret_hu_conv);
92 long ret = bindings.UpdateFulfillHTLC_clone_ptr(this.ptr);
93 Reference.reachabilityFence(this);
98 * Creates a copy of the UpdateFulfillHTLC
100 public UpdateFulfillHTLC clone() {
101 long ret = bindings.UpdateFulfillHTLC_clone(this.ptr);
102 Reference.reachabilityFence(this);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFulfillHTLC(null, ret); }
105 ret_hu_conv.ptrs_to.add(this);
110 * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
112 public byte[] write() {
113 byte[] ret = bindings.UpdateFulfillHTLC_write(this.ptr);
114 Reference.reachabilityFence(this);
119 * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
121 public static Result_UpdateFulfillHTLCDecodeErrorZ read(byte[] ser) {
122 long ret = bindings.UpdateFulfillHTLC_read(ser);
123 Reference.reachabilityFence(ser);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);