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
8
9 /**
10  * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
11  * The fields are organized by holder/counterparty.
12  * 
13  * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
14  * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelTransactionParameters extends CommonBase {
18         ChannelTransactionParameters(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ChannelTransactionParameters_free(ptr); }
23         }
24
25         /**
26          * Holder public keys
27          */
28         public ChannelPublicKeys get_holder_pubkeys() {
29                 long ret = bindings.ChannelTransactionParameters_get_holder_pubkeys(this.ptr);
30                 if (ret < 1024) { return null; }
31                 ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
32                 ret_hu_conv.ptrs_to.add(this);
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Holder public keys
38          */
39         public void set_holder_pubkeys(ChannelPublicKeys val) {
40                 bindings.ChannelTransactionParameters_set_holder_pubkeys(this.ptr, val == null ? 0 : val.ptr & ~1);
41                 this.ptrs_to.add(val);
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 < 1024) { return null; }
86                 CounterpartyChannelTransactionParameters 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                 this.ptrs_to.add(val);
100         }
101
102         /**
103          * The late-bound funding outpoint
104          * 
105          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
106          */
107         @Nullable
108         public OutPoint get_funding_outpoint() {
109                 long ret = bindings.ChannelTransactionParameters_get_funding_outpoint(this.ptr);
110                 if (ret < 1024) { return null; }
111                 OutPoint ret_hu_conv = new OutPoint(null, ret);
112                 ret_hu_conv.ptrs_to.add(this);
113                 return ret_hu_conv;
114         }
115
116         /**
117          * The late-bound funding outpoint
118          * 
119          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
120          */
121         public void set_funding_outpoint(@Nullable OutPoint val) {
122                 bindings.ChannelTransactionParameters_set_funding_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
123                 this.ptrs_to.add(val);
124         }
125
126         /**
127          * Constructs a new ChannelTransactionParameters given each field
128          */
129         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) {
130                 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);
131                 if (ret < 1024) { return null; }
132                 ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
133                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
134                 ret_hu_conv.ptrs_to.add(holder_pubkeys_arg);
135                 ret_hu_conv.ptrs_to.add(counterparty_parameters_arg);
136                 ret_hu_conv.ptrs_to.add(funding_outpoint_arg);
137                 return ret_hu_conv;
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 < 1024) { return null; }
146                 ChannelTransactionParameters 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 < 1024) { return null; }
168                 DirectedChannelTransactionParameters 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 < 1024) { return null; }
182                 DirectedChannelTransactionParameters 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 < 1024) { return null; }
201                 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
202                 return ret_hu_conv;
203         }
204
205 }