[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / HTLCDescriptor.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A descriptor used to sign for a commitment transaction's HTLC output.
11  */
12 public class HTLCDescriptor : CommonBase {
13         internal HTLCDescriptor(object _dummy, long ptr) : base(ptr) { }
14         ~HTLCDescriptor() {
15                 if (ptr != 0) { bindings.HTLCDescriptor_free(ptr); }
16         }
17
18         /**
19          * The parameters required to derive the signer for the HTLC input.
20          */
21         public ChannelDerivationParameters get_channel_derivation_parameters() {
22                 long ret = bindings.HTLCDescriptor_get_channel_derivation_parameters(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * The parameters required to derive the signer for the HTLC input.
32          */
33         public void set_channel_derivation_parameters(org.ldk.structs.ChannelDerivationParameters val) {
34                 bindings.HTLCDescriptor_set_channel_derivation_parameters(this.ptr, val == null ? 0 : val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * The number of the commitment transaction in which the HTLC output lives.
42          */
43         public long get_per_commitment_number() {
44                 long ret = bindings.HTLCDescriptor_get_per_commitment_number(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * The number of the commitment transaction in which the HTLC output lives.
51          */
52         public void set_per_commitment_number(long val) {
53                 bindings.HTLCDescriptor_set_per_commitment_number(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * The key tweak corresponding to the number of the commitment transaction in which the HTLC
60          * output lives. This tweak is applied to all the basepoints for both parties in the channel to
61          * arrive at unique keys per commitment.
62          * 
63          * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
64          */
65         public byte[] get_per_commitment_point() {
66                 long ret = bindings.HTLCDescriptor_get_per_commitment_point(this.ptr);
67                 GC.KeepAlive(this);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
70                 return ret_conv;
71         }
72
73         /**
74          * The key tweak corresponding to the number of the commitment transaction in which the HTLC
75          * output lives. This tweak is applied to all the basepoints for both parties in the channel to
76          * arrive at unique keys per commitment.
77          * 
78          * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
79          */
80         public void set_per_commitment_point(byte[] val) {
81                 bindings.HTLCDescriptor_set_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
82                 GC.KeepAlive(this);
83                 GC.KeepAlive(val);
84         }
85
86         /**
87          * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
88          * originating from a channel supporting anchor outputs, otherwise it is the channel's
89          * negotiated feerate at the time the commitment transaction was built.
90          */
91         public int get_feerate_per_kw() {
92                 int ret = bindings.HTLCDescriptor_get_feerate_per_kw(this.ptr);
93                 GC.KeepAlive(this);
94                 return ret;
95         }
96
97         /**
98          * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
99          * originating from a channel supporting anchor outputs, otherwise it is the channel's
100          * negotiated feerate at the time the commitment transaction was built.
101          */
102         public void set_feerate_per_kw(int val) {
103                 bindings.HTLCDescriptor_set_feerate_per_kw(this.ptr, val);
104                 GC.KeepAlive(this);
105                 GC.KeepAlive(val);
106         }
107
108         /**
109          * The details of the HTLC as it appears in the commitment transaction.
110          */
111         public HTLCOutputInCommitment get_htlc() {
112                 long ret = bindings.HTLCDescriptor_get_htlc(this.ptr);
113                 GC.KeepAlive(this);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
117                 return ret_hu_conv;
118         }
119
120         /**
121          * The details of the HTLC as it appears in the commitment transaction.
122          */
123         public void set_htlc(org.ldk.structs.HTLCOutputInCommitment val) {
124                 bindings.HTLCDescriptor_set_htlc(this.ptr, val == null ? 0 : val.ptr);
125                 GC.KeepAlive(this);
126                 GC.KeepAlive(val);
127                 if (this != null) { this.ptrs_to.AddLast(val); };
128         }
129
130         /**
131          * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
132          * taken.
133          */
134         public Option_ThirtyTwoBytesZ get_preimage() {
135                 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
136                 GC.KeepAlive(this);
137                 if (ret >= 0 && ret <= 4096) { return null; }
138                 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
139                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
140                 return ret_hu_conv;
141         }
142
143         /**
144          * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
145          * taken.
146          */
147         public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
148                 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
149                 GC.KeepAlive(this);
150                 GC.KeepAlive(val);
151                 if (this != null) { this.ptrs_to.AddLast(val); };
152         }
153
154         /**
155          * The counterparty's signature required to spend the HTLC output.
156          */
157         public byte[] get_counterparty_sig() {
158                 long ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
159                 GC.KeepAlive(this);
160                 if (ret >= 0 && ret <= 4096) { return null; }
161                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
162                 return ret_conv;
163         }
164
165         /**
166          * The counterparty's signature required to spend the HTLC output.
167          */
168         public void set_counterparty_sig(byte[] val) {
169                 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
170                 GC.KeepAlive(this);
171                 GC.KeepAlive(val);
172         }
173
174         internal long clone_ptr() {
175                 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
176                 GC.KeepAlive(this);
177                 return ret;
178         }
179
180         /**
181          * Creates a copy of the HTLCDescriptor
182          */
183         public HTLCDescriptor clone() {
184                 long ret = bindings.HTLCDescriptor_clone(this.ptr);
185                 GC.KeepAlive(this);
186                 if (ret >= 0 && ret <= 4096) { return null; }
187                 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
188                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
189                 return ret_hu_conv;
190         }
191
192         /**
193          * Checks if two HTLCDescriptors contain equal inner contents.
194          * This ignores pointers and is_owned flags and looks at the values in fields.
195          * Two objects with NULL inner values will be considered "equal" here.
196          */
197         public bool eq(org.ldk.structs.HTLCDescriptor b) {
198                 bool ret = bindings.HTLCDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
199                 GC.KeepAlive(this);
200                 GC.KeepAlive(b);
201                 if (this != null) { this.ptrs_to.AddLast(b); };
202                 return ret;
203         }
204
205         public override bool Equals(object o) {
206                 if (!(o is HTLCDescriptor)) return false;
207                 return this.eq((HTLCDescriptor)o);
208         }
209         /**
210          * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
211          */
212         public byte[] write() {
213                 long ret = bindings.HTLCDescriptor_write(this.ptr);
214                 GC.KeepAlive(this);
215                 if (ret >= 0 && ret <= 4096) { return null; }
216                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
217                 return ret_conv;
218         }
219
220         /**
221          * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
222          */
223         public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
224                 long ret = bindings.HTLCDescriptor_read(InternalUtils.encodeUint8Array(ser));
225                 GC.KeepAlive(ser);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
228                 return ret_hu_conv;
229         }
230
231         /**
232          * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
233          * being spent by the HTLC input in the HTLC transaction.
234          */
235         public OutPoint outpoint() {
236                 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
237                 GC.KeepAlive(this);
238                 if (ret >= 0 && ret <= 4096) { return null; }
239                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
240                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
241                 return ret_hu_conv;
242         }
243
244         /**
245          * Returns the UTXO to be spent by the HTLC input, which can be obtained via
246          * [`Self::unsigned_tx_input`].
247          */
248         public TxOut previous_utxo() {
249                 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
250                 GC.KeepAlive(this);
251                 if (ret >= 0 && ret <= 4096) { return null; }
252                 TxOut ret_conv = new TxOut(null, ret);
253                 return ret_conv;
254         }
255
256         /**
257          * Returns the unsigned transaction input spending the HTLC output in the commitment
258          * transaction.
259          */
260         public TxIn unsigned_tx_input() {
261                 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
262                 GC.KeepAlive(this);
263                 if (ret >= 0 && ret <= 4096) { return null; }
264                 TxIn ret_conv = new TxIn(null, ret);
265                 return ret_conv;
266         }
267
268         /**
269          * Returns the delayed output created as a result of spending the HTLC output in the commitment
270          * transaction.
271          */
272         public TxOut tx_output() {
273                 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
274                 GC.KeepAlive(this);
275                 if (ret >= 0 && ret <= 4096) { return null; }
276                 TxOut ret_conv = new TxOut(null, ret);
277                 return ret_conv;
278         }
279
280         /**
281          * Returns the witness script of the HTLC output in the commitment transaction.
282          */
283         public byte[] witness_script() {
284                 long ret = bindings.HTLCDescriptor_witness_script(this.ptr);
285                 GC.KeepAlive(this);
286                 if (ret >= 0 && ret <= 4096) { return null; }
287                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
288                 return ret_conv;
289         }
290
291         /**
292          * Returns the fully signed witness required to spend the HTLC output in the commitment
293          * transaction.
294          */
295         public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
296                 long ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature, 64)), InternalUtils.encodeUint8Array(witness_script));
297                 GC.KeepAlive(this);
298                 GC.KeepAlive(signature);
299                 GC.KeepAlive(witness_script);
300                 if (ret >= 0 && ret <= 4096) { return null; }
301                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
302                 return ret_conv;
303         }
304
305         /**
306          * Derives the channel signer required to sign the HTLC input.
307          */
308         public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
309                 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
310                 GC.KeepAlive(this);
311                 GC.KeepAlive(signer_provider);
312                 if (ret >= 0 && ret <= 4096) { return null; }
313                 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
314                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
315                 if (this != null) { this.ptrs_to.AddLast(signer_provider); };
316                 return ret_hu_conv;
317         }
318
319 }
320 } } }