Update auto-generated bindings to 0.0.103
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
12  * The fields are organized by holder/counterparty.
13  * 
14  * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
15  * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class ChannelTransactionParameters extends CommonBase {
19         ChannelTransactionParameters(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.ChannelTransactionParameters_free(ptr); }
24         }
25
26         /**
27          * Holder public keys
28          */
29         public ChannelPublicKeys get_holder_pubkeys() {
30                 long ret = bindings.ChannelTransactionParameters_get_holder_pubkeys(this.ptr);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
33                 ret_hu_conv.ptrs_to.add(this);
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Holder public keys
39          */
40         public void set_holder_pubkeys(ChannelPublicKeys val) {
41                 bindings.ChannelTransactionParameters_set_holder_pubkeys(this.ptr, val == null ? 0 : val.ptr & ~1);
42         }
43
44         /**
45          * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
46          */
47         public short get_holder_selected_contest_delay() {
48                 short ret = bindings.ChannelTransactionParameters_get_holder_selected_contest_delay(this.ptr);
49                 return ret;
50         }
51
52         /**
53          * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
54          */
55         public void set_holder_selected_contest_delay(short val) {
56                 bindings.ChannelTransactionParameters_set_holder_selected_contest_delay(this.ptr, val);
57         }
58
59         /**
60          * Whether the holder is the initiator of this channel.
61          * This is an input to the commitment number obscure factor computation.
62          */
63         public boolean get_is_outbound_from_holder() {
64                 boolean ret = bindings.ChannelTransactionParameters_get_is_outbound_from_holder(this.ptr);
65                 return ret;
66         }
67
68         /**
69          * Whether the holder is the initiator of this channel.
70          * This is an input to the commitment number obscure factor computation.
71          */
72         public void set_is_outbound_from_holder(boolean val) {
73                 bindings.ChannelTransactionParameters_set_is_outbound_from_holder(this.ptr, val);
74         }
75
76         /**
77          * The late-bound counterparty channel transaction parameters.
78          * These parameters are populated at the point in the protocol where the counterparty provides them.
79          * 
80          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
81          */
82         @Nullable
83         public CounterpartyChannelTransactionParameters get_counterparty_parameters() {
84                 long ret = bindings.ChannelTransactionParameters_get_counterparty_parameters(this.ptr);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret); }
87                 ret_hu_conv.ptrs_to.add(this);
88                 return ret_hu_conv;
89         }
90
91         /**
92          * The late-bound counterparty channel transaction parameters.
93          * These parameters are populated at the point in the protocol where the counterparty provides them.
94          * 
95          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
96          */
97         public void set_counterparty_parameters(@Nullable CounterpartyChannelTransactionParameters val) {
98                 bindings.ChannelTransactionParameters_set_counterparty_parameters(this.ptr, val == null ? 0 : val.ptr & ~1);
99         }
100
101         /**
102          * The late-bound funding outpoint
103          * 
104          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
105          */
106         @Nullable
107         public OutPoint get_funding_outpoint() {
108                 long ret = bindings.ChannelTransactionParameters_get_funding_outpoint(this.ptr);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
111                 ret_hu_conv.ptrs_to.add(this);
112                 return ret_hu_conv;
113         }
114
115         /**
116          * The late-bound funding outpoint
117          * 
118          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
119          */
120         public void set_funding_outpoint(@Nullable OutPoint val) {
121                 bindings.ChannelTransactionParameters_set_funding_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
122         }
123
124         /**
125          * Constructs a new ChannelTransactionParameters given each field
126          */
127         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) {
128                 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);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
131                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Creates a copy of the ChannelTransactionParameters
137          */
138         public ChannelTransactionParameters clone() {
139                 long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
142                 ret_hu_conv.ptrs_to.add(this);
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Whether the late bound parameters are populated.
148          */
149         public boolean is_populated() {
150                 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
151                 return ret;
152         }
153
154         /**
155          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
156          * given that the holder is the broadcaster.
157          * 
158          * self.is_populated() must be true before calling this function.
159          */
160         public DirectedChannelTransactionParameters as_holder_broadcastable() {
161                 long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
164                 ret_hu_conv.ptrs_to.add(this);
165                 return ret_hu_conv;
166         }
167
168         /**
169          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
170          * given that the counterparty is the broadcaster.
171          * 
172          * self.is_populated() must be true before calling this function.
173          */
174         public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
175                 long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
178                 ret_hu_conv.ptrs_to.add(this);
179                 return ret_hu_conv;
180         }
181
182         /**
183          * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
184          */
185         public byte[] write() {
186                 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
187                 return ret;
188         }
189
190         /**
191          * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
192          */
193         public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
194                 long ret = bindings.ChannelTransactionParameters_read(ser);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
197                 return ret_hu_conv;
198         }
199
200 }