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_add_htlc message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class UpdateAddHTLC extends CommonBase {
16 UpdateAddHTLC(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
35 public void set_channel_id(byte[] val) {
36 bindings.UpdateAddHTLC_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.UpdateAddHTLC_get_htlc_id(this.ptr);
46 Reference.reachabilityFence(this);
53 public void set_htlc_id(long val) {
54 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * The HTLC value in milli-satoshi
62 public long get_amount_msat() {
63 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
64 Reference.reachabilityFence(this);
69 * The HTLC value in milli-satoshi
71 public void set_amount_msat(long val) {
72 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
78 * The payment hash, the pre-image of which controls HTLC redemption
80 public byte[] get_payment_hash() {
81 byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
82 Reference.reachabilityFence(this);
87 * The payment hash, the pre-image of which controls HTLC redemption
89 public void set_payment_hash(byte[] val) {
90 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
91 Reference.reachabilityFence(this);
92 Reference.reachabilityFence(val);
96 * The expiry height of the HTLC
98 public int get_cltv_expiry() {
99 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
100 Reference.reachabilityFence(this);
105 * The expiry height of the HTLC
107 public void set_cltv_expiry(int val) {
108 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
109 Reference.reachabilityFence(this);
110 Reference.reachabilityFence(val);
114 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
115 Reference.reachabilityFence(this);
120 * Creates a copy of the UpdateAddHTLC
122 public UpdateAddHTLC clone() {
123 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
124 Reference.reachabilityFence(this);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
132 * Checks if two UpdateAddHTLCs contain equal inner contents.
133 * This ignores pointers and is_owned flags and looks at the values in fields.
134 * Two objects with NULL inner values will be considered "equal" here.
136 public boolean eq(UpdateAddHTLC b) {
137 boolean ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
138 Reference.reachabilityFence(this);
139 Reference.reachabilityFence(b);
140 if (this != null) { this.ptrs_to.add(b); };
144 @Override public boolean equals(Object o) {
145 if (!(o instanceof UpdateAddHTLC)) return false;
146 return this.eq((UpdateAddHTLC)o);
149 * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
151 public byte[] write() {
152 byte[] ret = bindings.UpdateAddHTLC_write(this.ptr);
153 Reference.reachabilityFence(this);
158 * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
160 public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
161 long ret = bindings.UpdateAddHTLC_read(ser);
162 Reference.reachabilityFence(ser);
163 if (ret >= 0 && ret <= 4096) { return null; }
164 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);