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 * A descriptor used to sign for a commitment transaction's anchor output.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class AnchorDescriptor extends CommonBase {
16 AnchorDescriptor(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.AnchorDescriptor_free(ptr); }
24 * The parameters required to derive the signer for the anchor input.
26 public ChannelDerivationParameters get_channel_derivation_parameters() {
27 long ret = bindings.AnchorDescriptor_get_channel_derivation_parameters(this.ptr);
28 Reference.reachabilityFence(this);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36 * The parameters required to derive the signer for the anchor input.
38 public void set_channel_derivation_parameters(org.ldk.structs.ChannelDerivationParameters val) {
39 bindings.AnchorDescriptor_set_channel_derivation_parameters(this.ptr, val == null ? 0 : val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
42 if (this != null) { this.ptrs_to.add(val); };
46 * The transaction input's outpoint corresponding to the commitment transaction's anchor
49 public OutPoint get_outpoint() {
50 long ret = bindings.AnchorDescriptor_get_outpoint(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59 * The transaction input's outpoint corresponding to the commitment transaction's anchor
62 public void set_outpoint(org.ldk.structs.OutPoint val) {
63 bindings.AnchorDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
64 Reference.reachabilityFence(this);
65 Reference.reachabilityFence(val);
66 if (this != null) { this.ptrs_to.add(val); };
70 * Constructs a new AnchorDescriptor given each field
72 public static AnchorDescriptor of(org.ldk.structs.ChannelDerivationParameters channel_derivation_parameters_arg, org.ldk.structs.OutPoint outpoint_arg) {
73 long ret = bindings.AnchorDescriptor_new(channel_derivation_parameters_arg == null ? 0 : channel_derivation_parameters_arg.ptr, outpoint_arg == null ? 0 : outpoint_arg.ptr);
74 Reference.reachabilityFence(channel_derivation_parameters_arg);
75 Reference.reachabilityFence(outpoint_arg);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 org.ldk.structs.AnchorDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AnchorDescriptor(null, ret); }
78 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_derivation_parameters_arg); };
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
85 long ret = bindings.AnchorDescriptor_clone_ptr(this.ptr);
86 Reference.reachabilityFence(this);
91 * Creates a copy of the AnchorDescriptor
93 public AnchorDescriptor clone() {
94 long ret = bindings.AnchorDescriptor_clone(this.ptr);
95 Reference.reachabilityFence(this);
96 if (ret >= 0 && ret <= 4096) { return null; }
97 org.ldk.structs.AnchorDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AnchorDescriptor(null, ret); }
98 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103 * Checks if two AnchorDescriptors contain equal inner contents.
104 * This ignores pointers and is_owned flags and looks at the values in fields.
105 * Two objects with NULL inner values will be considered "equal" here.
107 public boolean eq(org.ldk.structs.AnchorDescriptor b) {
108 boolean ret = bindings.AnchorDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
109 Reference.reachabilityFence(this);
110 Reference.reachabilityFence(b);
111 if (this != null) { this.ptrs_to.add(b); };
115 @Override public boolean equals(Object o) {
116 if (!(o instanceof AnchorDescriptor)) return false;
117 return this.eq((AnchorDescriptor)o);
120 * Returns the UTXO to be spent by the anchor input, which can be obtained via
121 * [`Self::unsigned_tx_input`].
123 public TxOut previous_utxo() {
124 long ret = bindings.AnchorDescriptor_previous_utxo(this.ptr);
125 Reference.reachabilityFence(this);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 TxOut ret_conv = new TxOut(null, ret);
132 * Returns the unsigned transaction input spending the anchor output in the commitment
135 public TxIn unsigned_tx_input() {
136 long ret = bindings.AnchorDescriptor_unsigned_tx_input(this.ptr);
137 Reference.reachabilityFence(this);
138 if (ret >= 0 && ret <= 4096) { return null; }
139 TxIn ret_conv = new TxIn(null, ret);
144 * Returns the witness script of the anchor output in the commitment transaction.
146 public byte[] witness_script() {
147 byte[] ret = bindings.AnchorDescriptor_witness_script(this.ptr);
148 Reference.reachabilityFence(this);
153 * Returns the fully signed witness required to spend the anchor output in the commitment
156 public byte[] tx_input_witness(byte[] signature) {
157 byte[] ret = bindings.AnchorDescriptor_tx_input_witness(this.ptr, InternalUtils.check_arr_len(signature, 64));
158 Reference.reachabilityFence(this);
159 Reference.reachabilityFence(signature);
164 * Derives the channel signer required to sign the anchor input.
166 public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
167 long ret = bindings.AnchorDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
168 Reference.reachabilityFence(this);
169 Reference.reachabilityFence(signer_provider);
170 if (ret >= 0 && ret <= 4096) { return null; }
171 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
172 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
173 if (this != null) { this.ptrs_to.add(signer_provider); };