[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ClaimedHTLC.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  * Information about an HTLC that is part of a payment that can be claimed.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ClaimedHTLC extends CommonBase {
16         ClaimedHTLC(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ClaimedHTLC_free(ptr); }
21         }
22
23         /**
24          * The `channel_id` of the channel over which the HTLC was received.
25          */
26         public byte[] get_channel_id() {
27                 byte[] ret = bindings.ClaimedHTLC_get_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The `channel_id` of the channel over which the HTLC was received.
34          */
35         public void set_channel_id(byte[] val) {
36                 bindings.ClaimedHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The `user_channel_id` of the channel over which the HTLC was received. This is the value
43          * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
44          * [`ChannelManager::accept_inbound_channel`] for inbound channels if
45          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
46          * `user_channel_id` will be randomized for an inbound channel.
47          * 
48          * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
49          * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
50          * was not actually claimed until after upgrading.)
51          * 
52          * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
53          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
54          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
55          */
56         public UInt128 get_user_channel_id() {
57                 byte[] ret = bindings.ClaimedHTLC_get_user_channel_id(this.ptr);
58                 Reference.reachabilityFence(this);
59                 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
60                 return ret_conv;
61         }
62
63         /**
64          * The `user_channel_id` of the channel over which the HTLC was received. This is the value
65          * passed in to [`ChannelManager::create_channel`] for outbound channels, or to
66          * [`ChannelManager::accept_inbound_channel`] for inbound channels if
67          * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
68          * `user_channel_id` will be randomized for an inbound channel.
69          * 
70          * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
71          * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
72          * was not actually claimed until after upgrading.)
73          * 
74          * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
75          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
76          * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
77          */
78         public void set_user_channel_id(org.ldk.util.UInt128 val) {
79                 bindings.ClaimedHTLC_set_user_channel_id(this.ptr, val.getLEBytes());
80                 Reference.reachabilityFence(this);
81                 Reference.reachabilityFence(val);
82         }
83
84         /**
85          * The block height at which this HTLC expires.
86          */
87         public int get_cltv_expiry() {
88                 int ret = bindings.ClaimedHTLC_get_cltv_expiry(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * The block height at which this HTLC expires.
95          */
96         public void set_cltv_expiry(int val) {
97                 bindings.ClaimedHTLC_set_cltv_expiry(this.ptr, val);
98                 Reference.reachabilityFence(this);
99                 Reference.reachabilityFence(val);
100         }
101
102         /**
103          * The amount (in msats) of this part of an MPP.
104          */
105         public long get_value_msat() {
106                 long ret = bindings.ClaimedHTLC_get_value_msat(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * The amount (in msats) of this part of an MPP.
113          */
114         public void set_value_msat(long val) {
115                 bindings.ClaimedHTLC_set_value_msat(this.ptr, val);
116                 Reference.reachabilityFence(this);
117                 Reference.reachabilityFence(val);
118         }
119
120         /**
121          * The extra fee our counterparty skimmed off the top of this HTLC, if any.
122          * 
123          * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to
124          * 0.0.119.
125          */
126         public long get_counterparty_skimmed_fee_msat() {
127                 long ret = bindings.ClaimedHTLC_get_counterparty_skimmed_fee_msat(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * The extra fee our counterparty skimmed off the top of this HTLC, if any.
134          * 
135          * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to
136          * 0.0.119.
137          */
138         public void set_counterparty_skimmed_fee_msat(long val) {
139                 bindings.ClaimedHTLC_set_counterparty_skimmed_fee_msat(this.ptr, val);
140                 Reference.reachabilityFence(this);
141                 Reference.reachabilityFence(val);
142         }
143
144         /**
145          * Constructs a new ClaimedHTLC given each field
146          */
147         public static ClaimedHTLC of(byte[] channel_id_arg, org.ldk.util.UInt128 user_channel_id_arg, int cltv_expiry_arg, long value_msat_arg, long counterparty_skimmed_fee_msat_arg) {
148                 long ret = bindings.ClaimedHTLC_new(InternalUtils.check_arr_len(channel_id_arg, 32), user_channel_id_arg.getLEBytes(), cltv_expiry_arg, value_msat_arg, counterparty_skimmed_fee_msat_arg);
149                 Reference.reachabilityFence(channel_id_arg);
150                 Reference.reachabilityFence(user_channel_id_arg);
151                 Reference.reachabilityFence(cltv_expiry_arg);
152                 Reference.reachabilityFence(value_msat_arg);
153                 Reference.reachabilityFence(counterparty_skimmed_fee_msat_arg);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
157                 return ret_hu_conv;
158         }
159
160         long clone_ptr() {
161                 long ret = bindings.ClaimedHTLC_clone_ptr(this.ptr);
162                 Reference.reachabilityFence(this);
163                 return ret;
164         }
165
166         /**
167          * Creates a copy of the ClaimedHTLC
168          */
169         public ClaimedHTLC clone() {
170                 long ret = bindings.ClaimedHTLC_clone(this.ptr);
171                 Reference.reachabilityFence(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 org.ldk.structs.ClaimedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClaimedHTLC(null, ret); }
174                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
175                 return ret_hu_conv;
176         }
177
178         /**
179          * Checks if two ClaimedHTLCs contain equal inner contents.
180          * This ignores pointers and is_owned flags and looks at the values in fields.
181          * Two objects with NULL inner values will be considered "equal" here.
182          */
183         public boolean eq(org.ldk.structs.ClaimedHTLC b) {
184                 boolean ret = bindings.ClaimedHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
185                 Reference.reachabilityFence(this);
186                 Reference.reachabilityFence(b);
187                 if (this != null) { this.ptrs_to.add(b); };
188                 return ret;
189         }
190
191         @Override public boolean equals(Object o) {
192                 if (!(o instanceof ClaimedHTLC)) return false;
193                 return this.eq((ClaimedHTLC)o);
194         }
195         /**
196          * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
197          */
198         public byte[] write() {
199                 byte[] ret = bindings.ClaimedHTLC_write(this.ptr);
200                 Reference.reachabilityFence(this);
201                 return ret;
202         }
203
204         /**
205          * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write
206          */
207         public static Result_ClaimedHTLCDecodeErrorZ read(byte[] ser) {
208                 long ret = bindings.ClaimedHTLC_read(ser);
209                 Reference.reachabilityFence(ser);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 Result_ClaimedHTLCDecodeErrorZ ret_hu_conv = Result_ClaimedHTLCDecodeErrorZ.constr_from_ptr(ret);
212                 return ret_hu_conv;
213         }
214
215 }