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 * The extra fee skimmed by the sender of this message. See
117 * [`ChannelConfig::accept_underpaying_htlcs`].
119 * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
121 public Option_u64Z get_skimmed_fee_msat() {
122 long ret = bindings.UpdateAddHTLC_get_skimmed_fee_msat(this.ptr);
123 Reference.reachabilityFence(this);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
126 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
131 * The extra fee skimmed by the sender of this message. See
132 * [`ChannelConfig::accept_underpaying_htlcs`].
134 * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
136 public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
137 bindings.UpdateAddHTLC_set_skimmed_fee_msat(this.ptr, val.ptr);
138 Reference.reachabilityFence(this);
139 Reference.reachabilityFence(val);
140 if (this != null) { this.ptrs_to.add(val); };
144 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
145 Reference.reachabilityFence(this);
150 * Creates a copy of the UpdateAddHTLC
152 public UpdateAddHTLC clone() {
153 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
154 Reference.reachabilityFence(this);
155 if (ret >= 0 && ret <= 4096) { return null; }
156 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
162 * Checks if two UpdateAddHTLCs contain equal inner contents.
163 * This ignores pointers and is_owned flags and looks at the values in fields.
164 * Two objects with NULL inner values will be considered "equal" here.
166 public boolean eq(org.ldk.structs.UpdateAddHTLC b) {
167 boolean ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
168 Reference.reachabilityFence(this);
169 Reference.reachabilityFence(b);
170 if (this != null) { this.ptrs_to.add(b); };
174 @Override public boolean equals(Object o) {
175 if (!(o instanceof UpdateAddHTLC)) return false;
176 return this.eq((UpdateAddHTLC)o);
179 * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
181 public byte[] write() {
182 byte[] ret = bindings.UpdateAddHTLC_write(this.ptr);
183 Reference.reachabilityFence(this);
188 * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
190 public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
191 long ret = bindings.UpdateAddHTLC_read(ser);
192 Reference.reachabilityFence(ser);
193 if (ret >= 0 && ret <= 4096) { return null; }
194 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);