[Java] Update auto-generated bindings to 0.0.115
[ldk-java] / src / main / java / org / ldk / structs / ChannelTransactionParameters.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  * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
13  * The fields are organized by holder/counterparty.
14  * 
15  * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
16  * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class ChannelTransactionParameters extends CommonBase {
20         ChannelTransactionParameters(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.ChannelTransactionParameters_free(ptr); }
25         }
26
27         /**
28          * Holder public keys
29          */
30         public ChannelPublicKeys get_holder_pubkeys() {
31                 long ret = bindings.ChannelTransactionParameters_get_holder_pubkeys(this.ptr);
32                 Reference.reachabilityFence(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
35                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36                 return ret_hu_conv;
37         }
38
39         /**
40          * Holder public keys
41          */
42         public void set_holder_pubkeys(org.ldk.structs.ChannelPublicKeys val) {
43                 bindings.ChannelTransactionParameters_set_holder_pubkeys(this.ptr, val == null ? 0 : val.ptr);
44                 Reference.reachabilityFence(this);
45                 Reference.reachabilityFence(val);
46                 if (this != null) { this.ptrs_to.add(val); };
47         }
48
49         /**
50          * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
51          */
52         public short get_holder_selected_contest_delay() {
53                 short ret = bindings.ChannelTransactionParameters_get_holder_selected_contest_delay(this.ptr);
54                 Reference.reachabilityFence(this);
55                 return ret;
56         }
57
58         /**
59          * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
60          */
61         public void set_holder_selected_contest_delay(short val) {
62                 bindings.ChannelTransactionParameters_set_holder_selected_contest_delay(this.ptr, val);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * Whether the holder is the initiator of this channel.
69          * This is an input to the commitment number obscure factor computation.
70          */
71         public boolean get_is_outbound_from_holder() {
72                 boolean ret = bindings.ChannelTransactionParameters_get_is_outbound_from_holder(this.ptr);
73                 Reference.reachabilityFence(this);
74                 return ret;
75         }
76
77         /**
78          * Whether the holder is the initiator of this channel.
79          * This is an input to the commitment number obscure factor computation.
80          */
81         public void set_is_outbound_from_holder(boolean val) {
82                 bindings.ChannelTransactionParameters_set_is_outbound_from_holder(this.ptr, val);
83                 Reference.reachabilityFence(this);
84                 Reference.reachabilityFence(val);
85         }
86
87         /**
88          * The late-bound counterparty channel transaction parameters.
89          * These parameters are populated at the point in the protocol where the counterparty provides them.
90          * 
91          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
92          */
93         @Nullable
94         public CounterpartyChannelTransactionParameters get_counterparty_parameters() {
95                 long ret = bindings.ChannelTransactionParameters_get_counterparty_parameters(this.ptr);
96                 Reference.reachabilityFence(this);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 org.ldk.structs.CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyChannelTransactionParameters(null, ret); }
99                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
100                 return ret_hu_conv;
101         }
102
103         /**
104          * The late-bound counterparty channel transaction parameters.
105          * These parameters are populated at the point in the protocol where the counterparty provides them.
106          * 
107          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
108          */
109         public void set_counterparty_parameters(@Nullable org.ldk.structs.CounterpartyChannelTransactionParameters val) {
110                 bindings.ChannelTransactionParameters_set_counterparty_parameters(this.ptr, val == null ? 0 : val.ptr);
111                 Reference.reachabilityFence(this);
112                 Reference.reachabilityFence(val);
113                 if (this != null) { this.ptrs_to.add(val); };
114         }
115
116         /**
117          * The late-bound funding outpoint
118          * 
119          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
120          */
121         @Nullable
122         public OutPoint get_funding_outpoint() {
123                 long ret = bindings.ChannelTransactionParameters_get_funding_outpoint(this.ptr);
124                 Reference.reachabilityFence(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
128                 return ret_hu_conv;
129         }
130
131         /**
132          * The late-bound funding outpoint
133          * 
134          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
135          */
136         public void set_funding_outpoint(@Nullable org.ldk.structs.OutPoint val) {
137                 bindings.ChannelTransactionParameters_set_funding_outpoint(this.ptr, val == null ? 0 : val.ptr);
138                 Reference.reachabilityFence(this);
139                 Reference.reachabilityFence(val);
140                 if (this != null) { this.ptrs_to.add(val); };
141         }
142
143         /**
144          * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is
145          * serialization backwards-compatible.
146          */
147         public COption_NoneZ get_opt_anchors() {
148                 COption_NoneZ ret = bindings.ChannelTransactionParameters_get_opt_anchors(this.ptr);
149                 Reference.reachabilityFence(this);
150                 return ret;
151         }
152
153         /**
154          * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is
155          * serialization backwards-compatible.
156          */
157         public void set_opt_anchors(org.ldk.enums.COption_NoneZ val) {
158                 bindings.ChannelTransactionParameters_set_opt_anchors(this.ptr, val);
159                 Reference.reachabilityFence(this);
160                 Reference.reachabilityFence(val);
161         }
162
163         /**
164          * Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors)
165          * It is intended merely for backwards compatibility with signers that need it.
166          * There is no support for this feature in LDK channel negotiation.
167          */
168         public COption_NoneZ get_opt_non_zero_fee_anchors() {
169                 COption_NoneZ ret = bindings.ChannelTransactionParameters_get_opt_non_zero_fee_anchors(this.ptr);
170                 Reference.reachabilityFence(this);
171                 return ret;
172         }
173
174         /**
175          * Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors)
176          * It is intended merely for backwards compatibility with signers that need it.
177          * There is no support for this feature in LDK channel negotiation.
178          */
179         public void set_opt_non_zero_fee_anchors(org.ldk.enums.COption_NoneZ val) {
180                 bindings.ChannelTransactionParameters_set_opt_non_zero_fee_anchors(this.ptr, val);
181                 Reference.reachabilityFence(this);
182                 Reference.reachabilityFence(val);
183         }
184
185         /**
186          * Constructs a new ChannelTransactionParameters given each field
187          */
188         public static ChannelTransactionParameters of(org.ldk.structs.ChannelPublicKeys holder_pubkeys_arg, short holder_selected_contest_delay_arg, boolean is_outbound_from_holder_arg, org.ldk.structs.CounterpartyChannelTransactionParameters counterparty_parameters_arg, org.ldk.structs.OutPoint funding_outpoint_arg, org.ldk.enums.COption_NoneZ opt_anchors_arg, org.ldk.enums.COption_NoneZ opt_non_zero_fee_anchors_arg) {
189                 long ret = bindings.ChannelTransactionParameters_new(holder_pubkeys_arg == null ? 0 : holder_pubkeys_arg.ptr, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg == null ? 0 : counterparty_parameters_arg.ptr, funding_outpoint_arg == null ? 0 : funding_outpoint_arg.ptr, opt_anchors_arg, opt_non_zero_fee_anchors_arg);
190                 Reference.reachabilityFence(holder_pubkeys_arg);
191                 Reference.reachabilityFence(holder_selected_contest_delay_arg);
192                 Reference.reachabilityFence(is_outbound_from_holder_arg);
193                 Reference.reachabilityFence(counterparty_parameters_arg);
194                 Reference.reachabilityFence(funding_outpoint_arg);
195                 Reference.reachabilityFence(opt_anchors_arg);
196                 Reference.reachabilityFence(opt_non_zero_fee_anchors_arg);
197                 if (ret >= 0 && ret <= 4096) { return null; }
198                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
199                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
200                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(holder_pubkeys_arg); };
201                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(counterparty_parameters_arg); };
202                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_outpoint_arg); };
203                 return ret_hu_conv;
204         }
205
206         long clone_ptr() {
207                 long ret = bindings.ChannelTransactionParameters_clone_ptr(this.ptr);
208                 Reference.reachabilityFence(this);
209                 return ret;
210         }
211
212         /**
213          * Creates a copy of the ChannelTransactionParameters
214          */
215         public ChannelTransactionParameters clone() {
216                 long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
217                 Reference.reachabilityFence(this);
218                 if (ret >= 0 && ret <= 4096) { return null; }
219                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
220                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
221                 return ret_hu_conv;
222         }
223
224         /**
225          * Checks if two ChannelTransactionParameterss contain equal inner contents.
226          * This ignores pointers and is_owned flags and looks at the values in fields.
227          * Two objects with NULL inner values will be considered "equal" here.
228          */
229         public boolean eq(org.ldk.structs.ChannelTransactionParameters b) {
230                 boolean ret = bindings.ChannelTransactionParameters_eq(this.ptr, b == null ? 0 : b.ptr);
231                 Reference.reachabilityFence(this);
232                 Reference.reachabilityFence(b);
233                 if (this != null) { this.ptrs_to.add(b); };
234                 return ret;
235         }
236
237         @Override public boolean equals(Object o) {
238                 if (!(o instanceof ChannelTransactionParameters)) return false;
239                 return this.eq((ChannelTransactionParameters)o);
240         }
241         /**
242          * Whether the late bound parameters are populated.
243          */
244         public boolean is_populated() {
245                 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
246                 Reference.reachabilityFence(this);
247                 return ret;
248         }
249
250         /**
251          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
252          * given that the holder is the broadcaster.
253          * 
254          * self.is_populated() must be true before calling this function.
255          */
256         public DirectedChannelTransactionParameters as_holder_broadcastable() {
257                 long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
258                 Reference.reachabilityFence(this);
259                 if (ret >= 0 && ret <= 4096) { return null; }
260                 org.ldk.structs.DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DirectedChannelTransactionParameters(null, ret); }
261                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
262                 return ret_hu_conv;
263         }
264
265         /**
266          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
267          * given that the counterparty is the broadcaster.
268          * 
269          * self.is_populated() must be true before calling this function.
270          */
271         public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
272                 long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
273                 Reference.reachabilityFence(this);
274                 if (ret >= 0 && ret <= 4096) { return null; }
275                 org.ldk.structs.DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DirectedChannelTransactionParameters(null, ret); }
276                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
277                 return ret_hu_conv;
278         }
279
280         /**
281          * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
282          */
283         public byte[] write() {
284                 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
285                 Reference.reachabilityFence(this);
286                 return ret;
287         }
288
289         /**
290          * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
291          */
292         public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
293                 long ret = bindings.ChannelTransactionParameters_read(ser);
294                 Reference.reachabilityFence(ser);
295                 if (ret >= 0 && ret <= 4096) { return null; }
296                 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
297                 return ret_hu_conv;
298         }
299
300 }