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 ret_hu_conv.ptrs_to.add(this);
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);
49 * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
51 public short get_holder_selected_contest_delay() {
52 short ret = bindings.ChannelTransactionParameters_get_holder_selected_contest_delay(this.ptr);
53 Reference.reachabilityFence(this);
58 * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
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);
67 * Whether the holder is the initiator of this channel.
68 * This is an input to the commitment number obscure factor computation.
70 public boolean get_is_outbound_from_holder() {
71 boolean ret = bindings.ChannelTransactionParameters_get_is_outbound_from_holder(this.ptr);
72 Reference.reachabilityFence(this);
77 * Whether the holder is the initiator of this channel.
78 * This is an input to the commitment number obscure factor computation.
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);
87 * The late-bound counterparty channel transaction parameters.
88 * These parameters are populated at the point in the protocol where the counterparty provides them.
90 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 org.ldk.structs.CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyChannelTransactionParameters(null, ret); }
98 ret_hu_conv.ptrs_to.add(this);
103 * The late-bound counterparty channel transaction parameters.
104 * These parameters are populated at the point in the protocol where the counterparty provides them.
106 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
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);
115 * The late-bound funding outpoint
117 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
125 ret_hu_conv.ptrs_to.add(this);
130 * The late-bound funding outpoint
132 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
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);
141 * Are anchors used for this channel. Boolean is serialization backwards-compatible
143 public COption_NoneZ get_opt_anchors() {
144 COption_NoneZ ret = bindings.ChannelTransactionParameters_get_opt_anchors(this.ptr);
145 Reference.reachabilityFence(this);
150 * Are anchors used for this channel. Boolean is serialization backwards-compatible
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);
159 * Constructs a new ChannelTransactionParameters given each field
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 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
171 ret_hu_conv.ptrs_to.add(ret_hu_conv);
176 long ret = bindings.ChannelTransactionParameters_clone_ptr(this.ptr);
177 Reference.reachabilityFence(this);
182 * Creates a copy of the ChannelTransactionParameters
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 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
189 ret_hu_conv.ptrs_to.add(this);
194 * Whether the late bound parameters are populated.
196 public boolean is_populated() {
197 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
198 Reference.reachabilityFence(this);
203 * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
204 * given that the holder is the broadcaster.
206 * self.is_populated() must be true before calling this function.
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 org.ldk.structs.DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DirectedChannelTransactionParameters(null, ret); }
213 ret_hu_conv.ptrs_to.add(this);
218 * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
219 * given that the counterparty is the broadcaster.
221 * self.is_populated() must be true before calling this function.
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 org.ldk.structs.DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DirectedChannelTransactionParameters(null, ret); }
228 ret_hu_conv.ptrs_to.add(this);
233 * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
235 public byte[] write() {
236 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
237 Reference.reachabilityFence(this);
242 * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
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);