Update auto-generated bindings
[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         long clone_ptr() {
136                 long ret = bindings.ChannelTransactionParameters_clone_ptr(this.ptr);
137                 return ret;
138         }
139
140         /**
141          * Creates a copy of the ChannelTransactionParameters
142          */
143         public ChannelTransactionParameters clone() {
144                 long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
147                 ret_hu_conv.ptrs_to.add(this);
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Whether the late bound parameters are populated.
153          */
154         public boolean is_populated() {
155                 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
156                 return ret;
157         }
158
159         /**
160          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
161          * given that the holder is the broadcaster.
162          * 
163          * self.is_populated() must be true before calling this function.
164          */
165         public DirectedChannelTransactionParameters as_holder_broadcastable() {
166                 long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
169                 ret_hu_conv.ptrs_to.add(this);
170                 return ret_hu_conv;
171         }
172
173         /**
174          * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
175          * given that the counterparty is the broadcaster.
176          * 
177          * self.is_populated() must be true before calling this function.
178          */
179         public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
180                 long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
181                 if (ret >= 0 && ret <= 4096) { return null; }
182                 DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
183                 ret_hu_conv.ptrs_to.add(this);
184                 return ret_hu_conv;
185         }
186
187         /**
188          * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
189          */
190         public byte[] write() {
191                 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
192                 return ret;
193         }
194
195         /**
196          * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
197          */
198         public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
199                 long ret = bindings.ChannelTransactionParameters_read(ser);
200                 if (ret >= 0 && ret <= 4096) { return null; }
201                 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
202                 return ret_hu_conv;
203         }
204
205 }