1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
13 * The fields are organized by holder/counterparty.
15 * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
16 * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
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 {
24 if (ptr != 0) { bindings.ChannelTransactionParameters_free(ptr); }
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); };
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); };
50 * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
52 public short get_holder_selected_contest_delay() {
53 short ret = bindings.ChannelTransactionParameters_get_holder_selected_contest_delay(this.ptr);
54 Reference.reachabilityFence(this);
59 * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
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);
68 * Whether the holder is the initiator of this channel.
69 * This is an input to the commitment number obscure factor computation.
71 public boolean get_is_outbound_from_holder() {
72 boolean ret = bindings.ChannelTransactionParameters_get_is_outbound_from_holder(this.ptr);
73 Reference.reachabilityFence(this);
78 * Whether the holder is the initiator of this channel.
79 * This is an input to the commitment number obscure factor computation.
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);
88 * The late-bound counterparty channel transaction parameters.
89 * These parameters are populated at the point in the protocol where the counterparty provides them.
91 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
104 * The late-bound counterparty channel transaction parameters.
105 * These parameters are populated at the point in the protocol where the counterparty provides them.
107 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
117 * The late-bound funding outpoint
119 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
132 * The late-bound funding outpoint
134 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
144 * This channel's type, as negotiated during channel open. For old objects where this field
145 * wasn't serialized, it will default to static_remote_key at deserialization.
147 public ChannelTypeFeatures get_channel_type_features() {
148 long ret = bindings.ChannelTransactionParameters_get_channel_type_features(this.ptr);
149 Reference.reachabilityFence(this);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
157 * This channel's type, as negotiated during channel open. For old objects where this field
158 * wasn't serialized, it will default to static_remote_key at deserialization.
160 public void set_channel_type_features(org.ldk.structs.ChannelTypeFeatures val) {
161 bindings.ChannelTransactionParameters_set_channel_type_features(this.ptr, val == null ? 0 : val.ptr);
162 Reference.reachabilityFence(this);
163 Reference.reachabilityFence(val);
164 if (this != null) { this.ptrs_to.add(val); };
168 * Constructs a new ChannelTransactionParameters given each field
170 * Note that counterparty_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
171 * Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
173 public static ChannelTransactionParameters of(org.ldk.structs.ChannelPublicKeys holder_pubkeys_arg, short holder_selected_contest_delay_arg, boolean is_outbound_from_holder_arg, @Nullable org.ldk.structs.CounterpartyChannelTransactionParameters counterparty_parameters_arg, @Nullable org.ldk.structs.OutPoint funding_outpoint_arg, org.ldk.structs.ChannelTypeFeatures channel_type_features_arg) {
174 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, channel_type_features_arg == null ? 0 : channel_type_features_arg.ptr);
175 Reference.reachabilityFence(holder_pubkeys_arg);
176 Reference.reachabilityFence(holder_selected_contest_delay_arg);
177 Reference.reachabilityFence(is_outbound_from_holder_arg);
178 Reference.reachabilityFence(counterparty_parameters_arg);
179 Reference.reachabilityFence(funding_outpoint_arg);
180 Reference.reachabilityFence(channel_type_features_arg);
181 if (ret >= 0 && ret <= 4096) { return null; }
182 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
183 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(holder_pubkeys_arg); };
185 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(counterparty_parameters_arg); };
186 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_outpoint_arg); };
187 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_features_arg); };
192 long ret = bindings.ChannelTransactionParameters_clone_ptr(this.ptr);
193 Reference.reachabilityFence(this);
198 * Creates a copy of the ChannelTransactionParameters
200 public ChannelTransactionParameters clone() {
201 long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
202 Reference.reachabilityFence(this);
203 if (ret >= 0 && ret <= 4096) { return null; }
204 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
205 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
210 * Generates a non-cryptographic 64-bit hash of the ChannelTransactionParameters.
213 long ret = bindings.ChannelTransactionParameters_hash(this.ptr);
214 Reference.reachabilityFence(this);
218 @Override public int hashCode() {
219 return (int)this.hash();
222 * Checks if two ChannelTransactionParameterss contain equal inner contents.
223 * This ignores pointers and is_owned flags and looks at the values in fields.
224 * Two objects with NULL inner values will be considered "equal" here.
226 public boolean eq(org.ldk.structs.ChannelTransactionParameters b) {
227 boolean ret = bindings.ChannelTransactionParameters_eq(this.ptr, b == null ? 0 : b.ptr);
228 Reference.reachabilityFence(this);
229 Reference.reachabilityFence(b);
230 if (this != null) { this.ptrs_to.add(b); };
234 @Override public boolean equals(Object o) {
235 if (!(o instanceof ChannelTransactionParameters)) return false;
236 return this.eq((ChannelTransactionParameters)o);
239 * Whether the late bound parameters are populated.
241 public boolean is_populated() {
242 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
243 Reference.reachabilityFence(this);
248 * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
249 * given that the holder is the broadcaster.
251 * self.is_populated() must be true before calling this function.
253 public DirectedChannelTransactionParameters as_holder_broadcastable() {
254 long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
255 Reference.reachabilityFence(this);
256 if (ret >= 0 && ret <= 4096) { return null; }
257 org.ldk.structs.DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DirectedChannelTransactionParameters(null, ret); }
258 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
263 * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
264 * given that the counterparty is the broadcaster.
266 * self.is_populated() must be true before calling this function.
268 public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
269 long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
270 Reference.reachabilityFence(this);
271 if (ret >= 0 && ret <= 4096) { return null; }
272 org.ldk.structs.DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DirectedChannelTransactionParameters(null, ret); }
273 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
278 * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
280 public byte[] write() {
281 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
282 Reference.reachabilityFence(this);
287 * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
289 public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
290 long ret = bindings.ChannelTransactionParameters_read(ser);
291 Reference.reachabilityFence(ser);
292 if (ret >= 0 && ret <= 4096) { return null; }
293 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);