[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / AnchorDescriptor.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A descriptor used to sign for a commitment transaction's anchor output.
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.AnchorDescriptor_free(ptr); }
21         }
22
23         /**
24          * The parameters required to derive the signer for the anchor input.
25          */
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); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The parameters required to derive the signer for the anchor input.
37          */
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); };
43         }
44
45         /**
46          * The transaction input's outpoint corresponding to the commitment transaction's anchor
47          * output.
48          */
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); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * The transaction input's outpoint corresponding to the commitment transaction's anchor
60          * output.
61          */
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); };
67         }
68
69         /**
70          * Constructs a new AnchorDescriptor given each field
71          */
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); };
81                 return ret_hu_conv;
82         }
83
84         long clone_ptr() {
85                 long ret = bindings.AnchorDescriptor_clone_ptr(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * Creates a copy of the AnchorDescriptor
92          */
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); };
99                 return ret_hu_conv;
100         }
101
102         /**
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.
106          */
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); };
112                 return ret;
113         }
114
115         @Override public boolean equals(Object o) {
116                 if (!(o instanceof AnchorDescriptor)) return false;
117                 return this.eq((AnchorDescriptor)o);
118         }
119         /**
120          * Returns the UTXO to be spent by the anchor input, which can be obtained via
121          * [`Self::unsigned_tx_input`].
122          */
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);
128                 return ret_conv;
129         }
130
131         /**
132          * Returns the unsigned transaction input spending the anchor output in the commitment
133          * transaction.
134          */
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);
140                 return ret_conv;
141         }
142
143         /**
144          * Returns the witness script of the anchor output in the commitment transaction.
145          */
146         public byte[] witness_script() {
147                 byte[] ret = bindings.AnchorDescriptor_witness_script(this.ptr);
148                 Reference.reachabilityFence(this);
149                 return ret;
150         }
151
152         /**
153          * Returns the fully signed witness required to spend the anchor output in the commitment
154          * transaction.
155          */
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);
160                 return ret;
161         }
162
163         /**
164          * Derives the channel signer required to sign the anchor input.
165          */
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); };
174                 return ret_hu_conv;
175         }
176
177 }