[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ChannelCounterparty.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  * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
13  * to better separate parameters.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class ChannelCounterparty extends CommonBase {
17         ChannelCounterparty(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.ChannelCounterparty_free(ptr); }
22         }
23
24         /**
25          * The node_id of our counterparty
26          */
27         public byte[] get_node_id() {
28                 byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * The node_id of our counterparty
35          */
36         public void set_node_id(byte[] val) {
37                 bindings.ChannelCounterparty_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
38                 Reference.reachabilityFence(this);
39                 Reference.reachabilityFence(val);
40         }
41
42         /**
43          * The Features the channel counterparty provided upon last connection.
44          * Useful for routing as it is the most up-to-date copy of the counterparty's features and
45          * many routing-relevant features are present in the init context.
46          */
47         public InitFeatures get_features() {
48                 long ret = bindings.ChannelCounterparty_get_features(this.ptr);
49                 Reference.reachabilityFence(this);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
52                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
53                 return ret_hu_conv;
54         }
55
56         /**
57          * The Features the channel counterparty provided upon last connection.
58          * Useful for routing as it is the most up-to-date copy of the counterparty's features and
59          * many routing-relevant features are present in the init context.
60          */
61         public void set_features(org.ldk.structs.InitFeatures val) {
62                 bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65                 if (this != null) { this.ptrs_to.add(val); };
66         }
67
68         /**
69          * The value, in satoshis, that must always be held in the channel for our counterparty. This
70          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
71          * claiming at least this value on chain.
72          * 
73          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
74          * 
75          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
76          */
77         public long get_unspendable_punishment_reserve() {
78                 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
79                 Reference.reachabilityFence(this);
80                 return ret;
81         }
82
83         /**
84          * The value, in satoshis, that must always be held in the channel for our counterparty. This
85          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
86          * claiming at least this value on chain.
87          * 
88          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
89          * 
90          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
91          */
92         public void set_unspendable_punishment_reserve(long val) {
93                 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
94                 Reference.reachabilityFence(this);
95                 Reference.reachabilityFence(val);
96         }
97
98         /**
99          * Information on the fees and requirements that the counterparty requires when forwarding
100          * payments to us through this channel.
101          * 
102          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
103          */
104         @Nullable
105         public CounterpartyForwardingInfo get_forwarding_info() {
106                 long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
107                 Reference.reachabilityFence(this);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyForwardingInfo(null, ret); }
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Information on the fees and requirements that the counterparty requires when forwarding
116          * payments to us through this channel.
117          * 
118          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
119          */
120         public void set_forwarding_info(@Nullable org.ldk.structs.CounterpartyForwardingInfo val) {
121                 bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr);
122                 Reference.reachabilityFence(this);
123                 Reference.reachabilityFence(val);
124                 if (this != null) { this.ptrs_to.add(val); };
125         }
126
127         /**
128          * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
129          * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
130          * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
131          */
132         public Option_u64Z get_outbound_htlc_minimum_msat() {
133                 long ret = bindings.ChannelCounterparty_get_outbound_htlc_minimum_msat(this.ptr);
134                 Reference.reachabilityFence(this);
135                 if (ret >= 0 && ret <= 4096) { return null; }
136                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
138                 return ret_hu_conv;
139         }
140
141         /**
142          * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
143          * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
144          * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
145          */
146         public void set_outbound_htlc_minimum_msat(org.ldk.structs.Option_u64Z val) {
147                 bindings.ChannelCounterparty_set_outbound_htlc_minimum_msat(this.ptr, val.ptr);
148                 Reference.reachabilityFence(this);
149                 Reference.reachabilityFence(val);
150                 if (this != null) { this.ptrs_to.add(val); };
151         }
152
153         /**
154          * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
155          */
156         public Option_u64Z get_outbound_htlc_maximum_msat() {
157                 long ret = bindings.ChannelCounterparty_get_outbound_htlc_maximum_msat(this.ptr);
158                 Reference.reachabilityFence(this);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
161                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
162                 return ret_hu_conv;
163         }
164
165         /**
166          * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
167          */
168         public void set_outbound_htlc_maximum_msat(org.ldk.structs.Option_u64Z val) {
169                 bindings.ChannelCounterparty_set_outbound_htlc_maximum_msat(this.ptr, val.ptr);
170                 Reference.reachabilityFence(this);
171                 Reference.reachabilityFence(val);
172                 if (this != null) { this.ptrs_to.add(val); };
173         }
174
175         /**
176          * Constructs a new ChannelCounterparty given each field
177          * 
178          * Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
179          */
180         public static ChannelCounterparty of(byte[] node_id_arg, org.ldk.structs.InitFeatures features_arg, long unspendable_punishment_reserve_arg, @Nullable org.ldk.structs.CounterpartyForwardingInfo forwarding_info_arg, org.ldk.structs.Option_u64Z outbound_htlc_minimum_msat_arg, org.ldk.structs.Option_u64Z outbound_htlc_maximum_msat_arg) {
181                 long ret = bindings.ChannelCounterparty_new(InternalUtils.check_arr_len(node_id_arg, 33), features_arg == null ? 0 : features_arg.ptr, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr, outbound_htlc_minimum_msat_arg.ptr, outbound_htlc_maximum_msat_arg.ptr);
182                 Reference.reachabilityFence(node_id_arg);
183                 Reference.reachabilityFence(features_arg);
184                 Reference.reachabilityFence(unspendable_punishment_reserve_arg);
185                 Reference.reachabilityFence(forwarding_info_arg);
186                 Reference.reachabilityFence(outbound_htlc_minimum_msat_arg);
187                 Reference.reachabilityFence(outbound_htlc_maximum_msat_arg);
188                 if (ret >= 0 && ret <= 4096) { return null; }
189                 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
190                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
191                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features_arg); };
192                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(forwarding_info_arg); };
193                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outbound_htlc_minimum_msat_arg); };
194                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outbound_htlc_maximum_msat_arg); };
195                 return ret_hu_conv;
196         }
197
198         long clone_ptr() {
199                 long ret = bindings.ChannelCounterparty_clone_ptr(this.ptr);
200                 Reference.reachabilityFence(this);
201                 return ret;
202         }
203
204         /**
205          * Creates a copy of the ChannelCounterparty
206          */
207         public ChannelCounterparty clone() {
208                 long ret = bindings.ChannelCounterparty_clone(this.ptr);
209                 Reference.reachabilityFence(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
218          */
219         public byte[] write() {
220                 byte[] ret = bindings.ChannelCounterparty_write(this.ptr);
221                 Reference.reachabilityFence(this);
222                 return ret;
223         }
224
225         /**
226          * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
227          */
228         public static Result_ChannelCounterpartyDecodeErrorZ read(byte[] ser) {
229                 long ret = bindings.ChannelCounterparty_read(ser);
230                 Reference.reachabilityFence(ser);
231                 if (ret >= 0 && ret <= 4096) { return null; }
232                 Result_ChannelCounterpartyDecodeErrorZ ret_hu_conv = Result_ChannelCounterpartyDecodeErrorZ.constr_from_ptr(ret);
233                 return ret_hu_conv;
234         }
235
236 }