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 to or received from a peer.
14 * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UpdateAddHTLC extends CommonBase {
18 UpdateAddHTLC(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.UpdateAddHTLC_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.UpdateAddHTLC_get_htlc_id(this.ptr);
48 Reference.reachabilityFence(this);
55 public void set_htlc_id(long val) {
56 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The HTLC value in milli-satoshi
64 public long get_amount_msat() {
65 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
66 Reference.reachabilityFence(this);
71 * The HTLC value in milli-satoshi
73 public void set_amount_msat(long val) {
74 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The payment hash, the pre-image of which controls HTLC redemption
82 public byte[] get_payment_hash() {
83 byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
84 Reference.reachabilityFence(this);
89 * The payment hash, the pre-image of which controls HTLC redemption
91 public void set_payment_hash(byte[] val) {
92 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * The expiry height of the HTLC
100 public int get_cltv_expiry() {
101 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
102 Reference.reachabilityFence(this);
107 * The expiry height of the HTLC
109 public void set_cltv_expiry(int val) {
110 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
111 Reference.reachabilityFence(this);
112 Reference.reachabilityFence(val);
116 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
117 Reference.reachabilityFence(this);
122 * Creates a copy of the UpdateAddHTLC
124 public UpdateAddHTLC clone() {
125 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
126 Reference.reachabilityFence(this);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
129 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
134 * Checks if two UpdateAddHTLCs contain equal inner contents.
135 * This ignores pointers and is_owned flags and looks at the values in fields.
136 * Two objects with NULL inner values will be considered "equal" here.
138 public boolean eq(org.ldk.structs.UpdateAddHTLC b) {
139 boolean ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
140 Reference.reachabilityFence(this);
141 Reference.reachabilityFence(b);
142 if (this != null) { this.ptrs_to.add(b); };
146 @Override public boolean equals(Object o) {
147 if (!(o instanceof UpdateAddHTLC)) return false;
148 return this.eq((UpdateAddHTLC)o);
151 * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
153 public byte[] write() {
154 byte[] ret = bindings.UpdateAddHTLC_write(this.ptr);
155 Reference.reachabilityFence(this);
160 * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
162 public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
163 long ret = bindings.UpdateAddHTLC_read(ser);
164 Reference.reachabilityFence(ser);
165 if (ret >= 0 && ret <= 4096) { return null; }
166 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);