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 * The parameters required to derive a channel signer via [`SignerProvider`].
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelDerivationParameters extends CommonBase {
16 ChannelDerivationParameters(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelDerivationParameters_free(ptr); }
24 * The value in satoshis of the channel we're attempting to spend the anchor output of.
26 public long get_value_satoshis() {
27 long ret = bindings.ChannelDerivationParameters_get_value_satoshis(this.ptr);
28 Reference.reachabilityFence(this);
33 * The value in satoshis of the channel we're attempting to spend the anchor output of.
35 public void set_value_satoshis(long val) {
36 bindings.ChannelDerivationParameters_set_value_satoshis(this.ptr, val);
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The unique identifier to re-derive the signer for the associated channel.
44 public byte[] get_keys_id() {
45 byte[] ret = bindings.ChannelDerivationParameters_get_keys_id(this.ptr);
46 Reference.reachabilityFence(this);
51 * The unique identifier to re-derive the signer for the associated channel.
53 public void set_keys_id(byte[] val) {
54 bindings.ChannelDerivationParameters_set_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * The necessary channel parameters that need to be provided to the re-derived signer through
61 * [`ChannelSigner::provide_channel_parameters`].
63 public ChannelTransactionParameters get_transaction_parameters() {
64 long ret = bindings.ChannelDerivationParameters_get_transaction_parameters(this.ptr);
65 Reference.reachabilityFence(this);
66 if (ret >= 0 && ret <= 4096) { return null; }
67 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
68 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
73 * The necessary channel parameters that need to be provided to the re-derived signer through
74 * [`ChannelSigner::provide_channel_parameters`].
76 public void set_transaction_parameters(org.ldk.structs.ChannelTransactionParameters val) {
77 bindings.ChannelDerivationParameters_set_transaction_parameters(this.ptr, val == null ? 0 : val.ptr);
78 Reference.reachabilityFence(this);
79 Reference.reachabilityFence(val);
80 if (this != null) { this.ptrs_to.add(val); };
84 * Constructs a new ChannelDerivationParameters given each field
86 public static ChannelDerivationParameters of(long value_satoshis_arg, byte[] keys_id_arg, org.ldk.structs.ChannelTransactionParameters transaction_parameters_arg) {
87 long ret = bindings.ChannelDerivationParameters_new(value_satoshis_arg, InternalUtils.check_arr_len(keys_id_arg, 32), transaction_parameters_arg == null ? 0 : transaction_parameters_arg.ptr);
88 Reference.reachabilityFence(value_satoshis_arg);
89 Reference.reachabilityFence(keys_id_arg);
90 Reference.reachabilityFence(transaction_parameters_arg);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
94 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(transaction_parameters_arg); };
99 long ret = bindings.ChannelDerivationParameters_clone_ptr(this.ptr);
100 Reference.reachabilityFence(this);
105 * Creates a copy of the ChannelDerivationParameters
107 public ChannelDerivationParameters clone() {
108 long ret = bindings.ChannelDerivationParameters_clone(this.ptr);
109 Reference.reachabilityFence(this);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
117 * Checks if two ChannelDerivationParameterss contain equal inner contents.
118 * This ignores pointers and is_owned flags and looks at the values in fields.
119 * Two objects with NULL inner values will be considered "equal" here.
121 public boolean eq(org.ldk.structs.ChannelDerivationParameters b) {
122 boolean ret = bindings.ChannelDerivationParameters_eq(this.ptr, b == null ? 0 : b.ptr);
123 Reference.reachabilityFence(this);
124 Reference.reachabilityFence(b);
125 if (this != null) { this.ptrs_to.add(b); };
129 @Override public boolean equals(Object o) {
130 if (!(o instanceof ChannelDerivationParameters)) return false;
131 return this.eq((ChannelDerivationParameters)o);
134 * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read
136 public byte[] write() {
137 byte[] ret = bindings.ChannelDerivationParameters_write(this.ptr);
138 Reference.reachabilityFence(this);
143 * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write
145 public static Result_ChannelDerivationParametersDecodeErrorZ read(byte[] ser) {
146 long ret = bindings.ChannelDerivationParameters_read(ser);
147 Reference.reachabilityFence(ser);
148 if (ret >= 0 && ret <= 4096) { return null; }
149 Result_ChannelDerivationParametersDecodeErrorZ ret_hu_conv = Result_ChannelDerivationParametersDecodeErrorZ.constr_from_ptr(ret);