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