Update auto-updated Java files
[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                 ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
35                 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(ChannelPublicKeys val) {
43                 bindings.ChannelTransactionParameters_set_holder_pubkeys(this.ptr, val == null ? 0 : val.ptr & ~1);
44                 Reference.reachabilityFence(this);
45                 Reference.reachabilityFence(val);
46         }
47
48         /**
49          * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
50          */
51         public short get_holder_selected_contest_delay() {
52                 short ret = bindings.ChannelTransactionParameters_get_holder_selected_contest_delay(this.ptr);
53                 Reference.reachabilityFence(this);
54                 return ret;
55         }
56
57         /**
58          * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
59          */
60         public void set_holder_selected_contest_delay(short val) {
61                 bindings.ChannelTransactionParameters_set_holder_selected_contest_delay(this.ptr, val);
62                 Reference.reachabilityFence(this);
63                 Reference.reachabilityFence(val);
64         }
65
66         /**
67          * Whether the holder is the initiator of this channel.
68          * This is an input to the commitment number obscure factor computation.
69          */
70         public boolean get_is_outbound_from_holder() {
71                 boolean ret = bindings.ChannelTransactionParameters_get_is_outbound_from_holder(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         /**
77          * Whether the holder is the initiator of this channel.
78          * This is an input to the commitment number obscure factor computation.
79          */
80         public void set_is_outbound_from_holder(boolean val) {
81                 bindings.ChannelTransactionParameters_set_is_outbound_from_holder(this.ptr, val);
82                 Reference.reachabilityFence(this);
83                 Reference.reachabilityFence(val);
84         }
85
86         /**
87          * The late-bound counterparty channel transaction parameters.
88          * These parameters are populated at the point in the protocol where the counterparty provides them.
89          * 
90          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
91          */
92         @Nullable
93         public CounterpartyChannelTransactionParameters get_counterparty_parameters() {
94                 long ret = bindings.ChannelTransactionParameters_get_counterparty_parameters(this.ptr);
95                 Reference.reachabilityFence(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret); }
98                 ret_hu_conv.ptrs_to.add(this);
99                 return ret_hu_conv;
100         }
101
102         /**
103          * The late-bound counterparty channel transaction parameters.
104          * These parameters are populated at the point in the protocol where the counterparty provides them.
105          * 
106          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
107          */
108         public void set_counterparty_parameters(@Nullable CounterpartyChannelTransactionParameters val) {
109                 bindings.ChannelTransactionParameters_set_counterparty_parameters(this.ptr, val == null ? 0 : val.ptr & ~1);
110                 Reference.reachabilityFence(this);
111                 Reference.reachabilityFence(val);
112         }
113
114         /**
115          * The late-bound funding outpoint
116          * 
117          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
118          */
119         @Nullable
120         public OutPoint get_funding_outpoint() {
121                 long ret = bindings.ChannelTransactionParameters_get_funding_outpoint(this.ptr);
122                 Reference.reachabilityFence(this);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
125                 ret_hu_conv.ptrs_to.add(this);
126                 return ret_hu_conv;
127         }
128
129         /**
130          * The late-bound funding outpoint
131          * 
132          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
133          */
134         public void set_funding_outpoint(@Nullable OutPoint val) {
135                 bindings.ChannelTransactionParameters_set_funding_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
136                 Reference.reachabilityFence(this);
137                 Reference.reachabilityFence(val);
138         }
139
140         /**
141          * Are anchors used for this channel.  Boolean is serialization backwards-compatible
142          */
143         public COption_NoneZ get_opt_anchors() {
144                 COption_NoneZ ret = bindings.ChannelTransactionParameters_get_opt_anchors(this.ptr);
145                 Reference.reachabilityFence(this);
146                 return ret;
147         }
148
149         /**
150          * Are anchors used for this channel.  Boolean is serialization backwards-compatible
151          */
152         public void set_opt_anchors(org.ldk.enums.COption_NoneZ val) {
153                 bindings.ChannelTransactionParameters_set_opt_anchors(this.ptr, val);
154                 Reference.reachabilityFence(this);
155                 Reference.reachabilityFence(val);
156         }
157
158         /**
159          * Constructs a new ChannelTransactionParameters given each field
160          */
161         public static ChannelTransactionParameters of(ChannelPublicKeys holder_pubkeys_arg, short holder_selected_contest_delay_arg, boolean is_outbound_from_holder_arg, CounterpartyChannelTransactionParameters counterparty_parameters_arg, OutPoint funding_outpoint_arg, org.ldk.enums.COption_NoneZ opt_anchors_arg) {
162                 long ret = bindings.ChannelTransactionParameters_new(holder_pubkeys_arg == null ? 0 : holder_pubkeys_arg.ptr & ~1, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg == null ? 0 : counterparty_parameters_arg.ptr & ~1, funding_outpoint_arg == null ? 0 : funding_outpoint_arg.ptr & ~1, opt_anchors_arg);
163                 Reference.reachabilityFence(holder_pubkeys_arg);
164                 Reference.reachabilityFence(holder_selected_contest_delay_arg);
165                 Reference.reachabilityFence(is_outbound_from_holder_arg);
166                 Reference.reachabilityFence(counterparty_parameters_arg);
167                 Reference.reachabilityFence(funding_outpoint_arg);
168                 Reference.reachabilityFence(opt_anchors_arg);
169                 if (ret >= 0 && ret <= 4096) { return null; }
170                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
171                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
172                 return ret_hu_conv;
173         }
174
175         long clone_ptr() {
176                 long ret = bindings.ChannelTransactionParameters_clone_ptr(this.ptr);
177                 Reference.reachabilityFence(this);
178                 return ret;
179         }
180
181         /**
182          * Creates a copy of the ChannelTransactionParameters
183          */
184         public ChannelTransactionParameters clone() {
185                 long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
186                 Reference.reachabilityFence(this);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
189                 ret_hu_conv.ptrs_to.add(this);
190                 return ret_hu_conv;
191         }
192
193         /**
194          * Whether the late bound parameters are populated.
195          */
196         public boolean is_populated() {
197                 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
198                 Reference.reachabilityFence(this);
199                 return ret;
200         }
201
202         /**
203          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
204          * given that the holder is the broadcaster.
205          * 
206          * self.is_populated() must be true before calling this function.
207          */
208         public DirectedChannelTransactionParameters as_holder_broadcastable() {
209                 long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
210                 Reference.reachabilityFence(this);
211                 if (ret >= 0 && ret <= 4096) { return null; }
212                 DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
213                 ret_hu_conv.ptrs_to.add(this);
214                 return ret_hu_conv;
215         }
216
217         /**
218          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
219          * given that the counterparty is the broadcaster.
220          * 
221          * self.is_populated() must be true before calling this function.
222          */
223         public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
224                 long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
225                 Reference.reachabilityFence(this);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
228                 ret_hu_conv.ptrs_to.add(this);
229                 return ret_hu_conv;
230         }
231
232         /**
233          * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
234          */
235         public byte[] write() {
236                 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
237                 Reference.reachabilityFence(this);
238                 return ret;
239         }
240
241         /**
242          * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
243          */
244         public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
245                 long ret = bindings.ChannelTransactionParameters_read(ser);
246                 Reference.reachabilityFence(ser);
247                 if (ret >= 0 && ret <= 4096) { return null; }
248                 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
249                 return ret_hu_conv;
250         }
251
252 }