1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
12 * The fields are organized by holder/counterparty.
14 * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
15 * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
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 {
23 if (ptr != 0) { bindings.ChannelTransactionParameters_free(ptr); }
29 public ChannelPublicKeys get_holder_pubkeys() {
30 long ret = bindings.ChannelTransactionParameters_get_holder_pubkeys(this.ptr);
31 if (ret < 1024) { return null; }
32 ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
33 ret_hu_conv.ptrs_to.add(this);
40 public void set_holder_pubkeys(ChannelPublicKeys val) {
41 bindings.ChannelTransactionParameters_set_holder_pubkeys(this.ptr, val == null ? 0 : val.ptr & ~1);
45 * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
47 public short get_holder_selected_contest_delay() {
48 short ret = bindings.ChannelTransactionParameters_get_holder_selected_contest_delay(this.ptr);
53 * The contest delay selected by the holder, which applies to counterparty-broadcast transactions
55 public void set_holder_selected_contest_delay(short val) {
56 bindings.ChannelTransactionParameters_set_holder_selected_contest_delay(this.ptr, val);
60 * Whether the holder is the initiator of this channel.
61 * This is an input to the commitment number obscure factor computation.
63 public boolean get_is_outbound_from_holder() {
64 boolean ret = bindings.ChannelTransactionParameters_get_is_outbound_from_holder(this.ptr);
69 * Whether the holder is the initiator of this channel.
70 * This is an input to the commitment number obscure factor computation.
72 public void set_is_outbound_from_holder(boolean val) {
73 bindings.ChannelTransactionParameters_set_is_outbound_from_holder(this.ptr, val);
77 * The late-bound counterparty channel transaction parameters.
78 * These parameters are populated at the point in the protocol where the counterparty provides them.
80 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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);
92 * The late-bound counterparty channel transaction parameters.
93 * These parameters are populated at the point in the protocol where the counterparty provides them.
95 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
97 public void set_counterparty_parameters(@Nullable CounterpartyChannelTransactionParameters val) {
98 bindings.ChannelTransactionParameters_set_counterparty_parameters(this.ptr, val == null ? 0 : val.ptr & ~1);
102 * The late-bound funding outpoint
104 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
107 public OutPoint get_funding_outpoint() {
108 long ret = bindings.ChannelTransactionParameters_get_funding_outpoint(this.ptr);
109 if (ret < 1024) { return null; }
110 OutPoint ret_hu_conv = new OutPoint(null, ret);
111 ret_hu_conv.ptrs_to.add(this);
116 * The late-bound funding outpoint
118 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
120 public void set_funding_outpoint(@Nullable OutPoint val) {
121 bindings.ChannelTransactionParameters_set_funding_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
125 * Constructs a new ChannelTransactionParameters given each field
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 < 1024) { return null; }
130 ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
131 ret_hu_conv.ptrs_to.add(ret_hu_conv);
136 * Creates a copy of the ChannelTransactionParameters
138 public ChannelTransactionParameters clone() {
139 long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
140 if (ret < 1024) { return null; }
141 ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
142 ret_hu_conv.ptrs_to.add(this);
147 * Whether the late bound parameters are populated.
149 public boolean is_populated() {
150 boolean ret = bindings.ChannelTransactionParameters_is_populated(this.ptr);
155 * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
156 * given that the holder is the broadcaster.
158 * self.is_populated() must be true before calling this function.
160 public DirectedChannelTransactionParameters as_holder_broadcastable() {
161 long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
162 if (ret < 1024) { return null; }
163 DirectedChannelTransactionParameters ret_hu_conv = new DirectedChannelTransactionParameters(null, ret);
164 ret_hu_conv.ptrs_to.add(this);
169 * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
170 * given that the counterparty is the broadcaster.
172 * self.is_populated() must be true before calling this function.
174 public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
175 long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
176 if (ret < 1024) { return null; }
177 DirectedChannelTransactionParameters ret_hu_conv = new DirectedChannelTransactionParameters(null, ret);
178 ret_hu_conv.ptrs_to.add(this);
183 * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read
185 public byte[] write() {
186 byte[] ret = bindings.ChannelTransactionParameters_write(this.ptr);
191 * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write
193 public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
194 long ret = bindings.ChannelTransactionParameters_read(ser);
195 if (ret < 1024) { return null; }
196 Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);