5e748fae43175411747789fc566d4a84709f78ba
[ldk-java] / src / main / java / org / ldk / structs / UpdateAddHTLC.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An [`update_add_htlc`] message to be sent to or received from a peer.
13  * 
14  * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The channel ID
36          */
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);
41         }
42
43         /**
44          * The HTLC ID
45          */
46         public long get_htlc_id() {
47                 long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The HTLC ID
54          */
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);
59         }
60
61         /**
62          * The HTLC value in milli-satoshi
63          */
64         public long get_amount_msat() {
65                 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The HTLC value in milli-satoshi
72          */
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);
77         }
78
79         /**
80          * The payment hash, the pre-image of which controls HTLC redemption
81          */
82         public byte[] get_payment_hash() {
83                 byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The payment hash, the pre-image of which controls HTLC redemption
90          */
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);
95         }
96
97         /**
98          * The expiry height of the HTLC
99          */
100         public int get_cltv_expiry() {
101                 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * The expiry height of the HTLC
108          */
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);
113         }
114
115         /**
116          * The extra fee skimmed by the sender of this message. See
117          * [`ChannelConfig::accept_underpaying_htlcs`].
118          * 
119          * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
120          */
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); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * The extra fee skimmed by the sender of this message. See
132          * [`ChannelConfig::accept_underpaying_htlcs`].
133          * 
134          * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
135          */
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); };
141         }
142
143         long clone_ptr() {
144                 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
145                 Reference.reachabilityFence(this);
146                 return ret;
147         }
148
149         /**
150          * Creates a copy of the UpdateAddHTLC
151          */
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); };
158                 return ret_hu_conv;
159         }
160
161         /**
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.
165          */
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); };
171                 return ret;
172         }
173
174         @Override public boolean equals(Object o) {
175                 if (!(o instanceof UpdateAddHTLC)) return false;
176                 return this.eq((UpdateAddHTLC)o);
177         }
178         /**
179          * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
180          */
181         public byte[] write() {
182                 byte[] ret = bindings.UpdateAddHTLC_write(this.ptr);
183                 Reference.reachabilityFence(this);
184                 return ret;
185         }
186
187         /**
188          * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
189          */
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);
195                 return ret_hu_conv;
196         }
197
198 }