[C#] Add marshaling logic for array C# -> C conversion
[ldk-java] / c_sharp / src / org / ldk / structs / BaseSign.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  * A trait to sign Lightning channel transactions as described in
10  * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
11  * 
12  * Signing services could be implemented on a hardware wallet and should implement signing
13  * policies in order to be secure. Please refer to the [VLS Policy
14  * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
15  * for an example of such policies.
16  */
17 public class BaseSign : CommonBase {
18         internal readonly bindings.LDKBaseSign bindings_instance;
19         internal BaseSign(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
20         private BaseSign(bindings.LDKBaseSign arg, ChannelPublicKeys pubkeys) : base(bindings.LDKBaseSign_new(arg, pubkeys == null ? 0 : pubkeys.clone_ptr())) {
21                 this.ptrs_to.AddLast(arg);
22                 this.bindings_instance = arg;
23         }
24         ~BaseSign() {
25                 if (ptr != 0) { bindings.BaseSign_free(ptr); }
26         }
27
28         public interface BaseSignInterface {
29                 /**
30                  * Gets the per-commitment point for a specific commitment number
31                  * 
32                  * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
33                  */
34                 byte[] get_per_commitment_point(long _idx);
35                 /**
36                  * Gets the commitment secret for a specific commitment number as part of the revocation process
37                  * 
38                  * An external signer implementation should error here if the commitment was already signed
39                  * and should refuse to sign it in the future.
40                  * 
41                  * May be called more than once for the same index.
42                  * 
43                  * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
44                  */
45                 byte[] release_commitment_secret(long _idx);
46                 /**
47                  * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
48                  * 
49                  * This is required in order for the signer to make sure that releasing a commitment
50                  * secret won't leave us without a broadcastable holder transaction.
51                  * Policy checks should be implemented in this function, including checking the amount
52                  * sent to us and checking the HTLCs.
53                  * 
54                  * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
55                  * A validating signer should ensure that an HTLC output is removed only when the matching
56                  * preimage is provided, or when the value to holder is restored.
57                  * 
58                  * Note that all the relevant preimages will be provided, but there may also be additional
59                  * irrelevant or duplicate preimages.
60                  */
61                 Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction _holder_tx, byte[][] _preimages);
62                 /**
63                  * Returns an arbitrary identifier describing the set of keys which are provided back to you in
64                  * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
65                  * [`BaseSign`] object uniquely and lookup or re-derive its keys.
66                  */
67                 byte[] channel_keys_id();
68                 /**
69                  * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
70                  * 
71                  * Note that if signing fails or is rejected, the channel will be force-closed.
72                  * 
73                  * Policy checks should be implemented in this function, including checking the amount
74                  * sent to us and checking the HTLCs.
75                  * 
76                  * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
77                  * A validating signer should ensure that an HTLC output is removed only when the matching
78                  * preimage is provided, or when the value to holder is restored.
79                  * 
80                  * Note that all the relevant preimages will be provided, but there may also be additional
81                  * irrelevant or duplicate preimages.
82                  */
83                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction _commitment_tx, byte[][] _preimages);
84                 /**
85                  * Validate the counterparty's revocation.
86                  * 
87                  * This is required in order for the signer to make sure that the state has moved
88                  * forward and it is safe to sign the next counterparty commitment.
89                  */
90                 Result_NoneNoneZ validate_counterparty_revocation(long _idx, byte[] _secret);
91                 /**
92                  * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
93                  * 
94                  * This will be called
95                  * - with a non-revoked `commitment_tx`.
96                  * - with the latest `commitment_tx` when we initiate a force-close.
97                  * - with the previous `commitment_tx`, just to get claiming HTLC
98                  * signatures, if we are reacting to a [`ChannelMonitor`]
99                  * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
100                  * that decided to broadcast before it had been updated to the latest `commitment_tx`.
101                  * 
102                  * This may be called multiple times for the same transaction.
103                  * 
104                  * An external signer implementation should check that the commitment has not been revoked.
105                  * 
106                  * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
107                  */
108                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction _commitment_tx);
109                 /**
110                  * Create a signature for the given input in a transaction spending an HTLC transaction output
111                  * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
112                  * 
113                  * A justice transaction may claim multiple outputs at the same time if timelocks are
114                  * similar, but only a signature for the input at index `input` should be signed for here.
115                  * It may be called multiple times for same output(s) if a fee-bump is needed with regards
116                  * to an upcoming timelock expiration.
117                  * 
118                  * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
119                  * 
120                  * `per_commitment_key` is revocation secret which was provided by our counterparty when they
121                  * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
122                  * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
123                  * so).
124                  */
125                 Result_SignatureNoneZ sign_justice_revoked_output(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key);
126                 /**
127                  * Create a signature for the given input in a transaction spending a commitment transaction
128                  * HTLC output when our counterparty broadcasts an old state.
129                  * 
130                  * A justice transaction may claim multiple outputs at the same time if timelocks are
131                  * similar, but only a signature for the input at index `input` should be signed for here.
132                  * It may be called multiple times for same output(s) if a fee-bump is needed with regards
133                  * to an upcoming timelock expiration.
134                  * 
135                  * `amount` is the value of the output spent by this input, committed to in the BIP 143
136                  * signature.
137                  * 
138                  * `per_commitment_key` is revocation secret which was provided by our counterparty when they
139                  * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
140                  * not allow the spending of any funds by itself (you need our holder revocation_secret to do
141                  * so).
142                  * 
143                  * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
144                  * (which is committed to in the BIP 143 signatures).
145                  */
146                 Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key, HTLCOutputInCommitment _htlc);
147                 /**
148                  * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
149                  * transaction, either offered or received.
150                  * 
151                  * Such a transaction may claim multiples offered outputs at same time if we know the
152                  * preimage for each when we create it, but only the input at index `input` should be
153                  * signed for here. It may be called multiple times for same output(s) if a fee-bump is
154                  * needed with regards to an upcoming timelock expiration.
155                  * 
156                  * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
157                  * outputs.
158                  * 
159                  * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
160                  * 
161                  * `per_commitment_point` is the dynamic point corresponding to the channel state
162                  * detected onchain. It has been generated by our counterparty and is used to derive
163                  * channel state keys, which are then included in the witness script and committed to in the
164                  * BIP 143 signature.
165                  */
166                 Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] _htlc_tx, long _input, long _amount, byte[] _per_commitment_point, HTLCOutputInCommitment _htlc);
167                 /**
168                  * Create a signature for a (proposed) closing transaction.
169                  * 
170                  * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
171                  * chosen to forgo their output as dust.
172                  */
173                 Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction _closing_tx);
174                 /**
175                  * Computes the signature for a commitment transaction's anchor output used as an
176                  * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
177                  */
178                 Result_SignatureNoneZ sign_holder_anchor_input(byte[] _anchor_tx, long _input);
179                 /**
180                  * Signs a channel announcement message with our funding key and our node secret key (aka
181                  * node_id or network_key), proving it comes from one of the channel participants.
182                  * 
183                  * The first returned signature should be from our node secret key, the second from our
184                  * funding key.
185                  * 
186                  * Note that if this fails or is rejected, the channel will not be publicly announced and
187                  * our counterparty may (though likely will not) close the channel on us for violating the
188                  * protocol.
189                  */
190                 Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement _msg);
191                 /**
192                  * Set the counterparty static channel data, including basepoints,
193                  * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. Since these
194                  * are static channel data, they MUST NOT be allowed to change to different values once set,
195                  * as LDK may call this method more than once.
196                  * 
197                  * channel_parameters.is_populated() MUST be true.
198                  */
199                 void provide_channel_parameters(ChannelTransactionParameters _channel_parameters);
200         }
201         private class LDKBaseSignHolder { internal BaseSign held; }
202         private class LDKBaseSignImpl : bindings.LDKBaseSign {
203                 internal LDKBaseSignImpl(BaseSignInterface arg, LDKBaseSignHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
204                 private BaseSignInterface arg;
205                 private LDKBaseSignHolder impl_holder;
206                 public byte[] get_per_commitment_point(long _idx) {
207                         byte[] ret = arg.get_per_commitment_point(_idx);
208                                 GC.KeepAlive(arg);
209                         byte[] result = InternalUtils.check_arr_len(ret, 33);
210                         return result;
211                 }
212                 public byte[] release_commitment_secret(long _idx) {
213                         byte[] ret = arg.release_commitment_secret(_idx);
214                                 GC.KeepAlive(arg);
215                         byte[] result = InternalUtils.check_arr_len(ret, 32);
216                         return result;
217                 }
218                 public long validate_holder_commitment(long _holder_tx, byte[][] _preimages) {
219                         org.ldk.structs.HolderCommitmentTransaction _holder_tx_hu_conv = null; if (_holder_tx < 0 || _holder_tx > 4096) { _holder_tx_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, _holder_tx); }
220                         Result_NoneNoneZ ret = arg.validate_holder_commitment(_holder_tx_hu_conv, _preimages);
221                                 GC.KeepAlive(arg);
222                         long result = ret == null ? 0 : ret.clone_ptr();
223                         return result;
224                 }
225                 public byte[] channel_keys_id() {
226                         byte[] ret = arg.channel_keys_id();
227                                 GC.KeepAlive(arg);
228                         byte[] result = InternalUtils.check_arr_len(ret, 32);
229                         return result;
230                 }
231                 public long sign_counterparty_commitment(long _commitment_tx, byte[][] _preimages) {
232                         org.ldk.structs.CommitmentTransaction _commitment_tx_hu_conv = null; if (_commitment_tx < 0 || _commitment_tx > 4096) { _commitment_tx_hu_conv = new org.ldk.structs.CommitmentTransaction(null, _commitment_tx); }
233                         Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(_commitment_tx_hu_conv, _preimages);
234                                 GC.KeepAlive(arg);
235                         long result = ret == null ? 0 : ret.clone_ptr();
236                         return result;
237                 }
238                 public long validate_counterparty_revocation(long _idx, byte[] _secret) {
239                         Result_NoneNoneZ ret = arg.validate_counterparty_revocation(_idx, _secret);
240                                 GC.KeepAlive(arg);
241                         long result = ret == null ? 0 : ret.clone_ptr();
242                         return result;
243                 }
244                 public long sign_holder_commitment_and_htlcs(long _commitment_tx) {
245                         org.ldk.structs.HolderCommitmentTransaction _commitment_tx_hu_conv = null; if (_commitment_tx < 0 || _commitment_tx > 4096) { _commitment_tx_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, _commitment_tx); }
246                         Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(_commitment_tx_hu_conv);
247                                 GC.KeepAlive(arg);
248                         long result = ret == null ? 0 : ret.clone_ptr();
249                         return result;
250                 }
251                 public long sign_justice_revoked_output(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key) {
252                         Result_SignatureNoneZ ret = arg.sign_justice_revoked_output(_justice_tx, _input, _amount, _per_commitment_key);
253                                 GC.KeepAlive(arg);
254                         long result = ret == null ? 0 : ret.clone_ptr();
255                         return result;
256                 }
257                 public long sign_justice_revoked_htlc(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key, long _htlc) {
258                         org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
259                         Result_SignatureNoneZ ret = arg.sign_justice_revoked_htlc(_justice_tx, _input, _amount, _per_commitment_key, _htlc_hu_conv);
260                                 GC.KeepAlive(arg);
261                         long result = ret == null ? 0 : ret.clone_ptr();
262                         return result;
263                 }
264                 public long sign_counterparty_htlc_transaction(byte[] _htlc_tx, long _input, long _amount, byte[] _per_commitment_point, long _htlc) {
265                         org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
266                         Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(_htlc_tx, _input, _amount, _per_commitment_point, _htlc_hu_conv);
267                                 GC.KeepAlive(arg);
268                         long result = ret == null ? 0 : ret.clone_ptr();
269                         return result;
270                 }
271                 public long sign_closing_transaction(long _closing_tx) {
272                         org.ldk.structs.ClosingTransaction _closing_tx_hu_conv = null; if (_closing_tx < 0 || _closing_tx > 4096) { _closing_tx_hu_conv = new org.ldk.structs.ClosingTransaction(null, _closing_tx); }
273                         Result_SignatureNoneZ ret = arg.sign_closing_transaction(_closing_tx_hu_conv);
274                                 GC.KeepAlive(arg);
275                         long result = ret == null ? 0 : ret.clone_ptr();
276                         return result;
277                 }
278                 public long sign_holder_anchor_input(byte[] _anchor_tx, long _input) {
279                         Result_SignatureNoneZ ret = arg.sign_holder_anchor_input(_anchor_tx, _input);
280                                 GC.KeepAlive(arg);
281                         long result = ret == null ? 0 : ret.clone_ptr();
282                         return result;
283                 }
284                 public long sign_channel_announcement(long _msg) {
285                         org.ldk.structs.UnsignedChannelAnnouncement _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, _msg); }
286                         Result_C2Tuple_SignatureSignatureZNoneZ ret = arg.sign_channel_announcement(_msg_hu_conv);
287                                 GC.KeepAlive(arg);
288                         long result = ret == null ? 0 : ret.clone_ptr();
289                         return result;
290                 }
291                 public void provide_channel_parameters(long _channel_parameters) {
292                         org.ldk.structs.ChannelTransactionParameters _channel_parameters_hu_conv = null; if (_channel_parameters < 0 || _channel_parameters > 4096) { _channel_parameters_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, _channel_parameters); }
293                         arg.provide_channel_parameters(_channel_parameters_hu_conv);
294                                 GC.KeepAlive(arg);
295                 }
296         }
297         public static BaseSign new_impl(BaseSignInterface arg, ChannelPublicKeys pubkeys) {
298                 LDKBaseSignHolder impl_holder = new LDKBaseSignHolder();
299                 impl_holder.held = new BaseSign(new LDKBaseSignImpl(arg, impl_holder), pubkeys);
300                 return impl_holder.held;
301         }
302         /**
303          * Gets the per-commitment point for a specific commitment number
304          * 
305          * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
306          */
307         public byte[] get_per_commitment_point(long idx) {
308                 byte[] ret = bindings.BaseSign_get_per_commitment_point(this.ptr, idx);
309                 GC.KeepAlive(this);
310                 GC.KeepAlive(idx);
311                 return ret;
312         }
313
314         /**
315          * Gets the commitment secret for a specific commitment number as part of the revocation process
316          * 
317          * An external signer implementation should error here if the commitment was already signed
318          * and should refuse to sign it in the future.
319          * 
320          * May be called more than once for the same index.
321          * 
322          * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
323          */
324         public byte[] release_commitment_secret(long idx) {
325                 byte[] ret = bindings.BaseSign_release_commitment_secret(this.ptr, idx);
326                 GC.KeepAlive(this);
327                 GC.KeepAlive(idx);
328                 return ret;
329         }
330
331         /**
332          * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
333          * 
334          * This is required in order for the signer to make sure that releasing a commitment
335          * secret won't leave us without a broadcastable holder transaction.
336          * Policy checks should be implemented in this function, including checking the amount
337          * sent to us and checking the HTLCs.
338          * 
339          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
340          * A validating signer should ensure that an HTLC output is removed only when the matching
341          * preimage is provided, or when the value to holder is restored.
342          * 
343          * Note that all the relevant preimages will be provided, but there may also be additional
344          * irrelevant or duplicate preimages.
345          */
346         public Result_NoneNoneZ validate_holder_commitment(org.ldk.structs.HolderCommitmentTransaction holder_tx, byte[][] preimages) {
347                 long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr, preimages != null ? InternalUtils.mapArray(preimages, preimages_conv_8 => InternalUtils.check_arr_len(preimages_conv_8, 32)) : null);
348                 GC.KeepAlive(this);
349                 GC.KeepAlive(holder_tx);
350                 GC.KeepAlive(preimages);
351                 if (ret >= 0 && ret <= 4096) { return null; }
352                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
353                 if (this != null) { this.ptrs_to.AddLast(holder_tx); };
354                 return ret_hu_conv;
355         }
356
357         /**
358          * Returns an arbitrary identifier describing the set of keys which are provided back to you in
359          * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
360          * [`BaseSign`] object uniquely and lookup or re-derive its keys.
361          */
362         public byte[] channel_keys_id() {
363                 byte[] ret = bindings.BaseSign_channel_keys_id(this.ptr);
364                 GC.KeepAlive(this);
365                 return ret;
366         }
367
368         /**
369          * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
370          * 
371          * Note that if signing fails or is rejected, the channel will be force-closed.
372          * 
373          * Policy checks should be implemented in this function, including checking the amount
374          * sent to us and checking the HTLCs.
375          * 
376          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
377          * A validating signer should ensure that an HTLC output is removed only when the matching
378          * preimage is provided, or when the value to holder is restored.
379          * 
380          * Note that all the relevant preimages will be provided, but there may also be additional
381          * irrelevant or duplicate preimages.
382          */
383         public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] preimages) {
384                 long ret = bindings.BaseSign_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr, preimages != null ? InternalUtils.mapArray(preimages, preimages_conv_8 => InternalUtils.check_arr_len(preimages_conv_8, 32)) : null);
385                 GC.KeepAlive(this);
386                 GC.KeepAlive(commitment_tx);
387                 GC.KeepAlive(preimages);
388                 if (ret >= 0 && ret <= 4096) { return null; }
389                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
390                 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
391                 return ret_hu_conv;
392         }
393
394         /**
395          * Validate the counterparty's revocation.
396          * 
397          * This is required in order for the signer to make sure that the state has moved
398          * forward and it is safe to sign the next counterparty commitment.
399          */
400         public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
401                 long ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, InternalUtils.check_arr_len(secret, 32));
402                 GC.KeepAlive(this);
403                 GC.KeepAlive(idx);
404                 GC.KeepAlive(secret);
405                 if (ret >= 0 && ret <= 4096) { return null; }
406                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
407                 return ret_hu_conv;
408         }
409
410         /**
411          * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
412          * 
413          * This will be called
414          * - with a non-revoked `commitment_tx`.
415          * - with the latest `commitment_tx` when we initiate a force-close.
416          * - with the previous `commitment_tx`, just to get claiming HTLC
417          * signatures, if we are reacting to a [`ChannelMonitor`]
418          * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
419          * that decided to broadcast before it had been updated to the latest `commitment_tx`.
420          * 
421          * This may be called multiple times for the same transaction.
422          * 
423          * An external signer implementation should check that the commitment has not been revoked.
424          * 
425          * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
426          */
427         public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
428                 long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr);
429                 GC.KeepAlive(this);
430                 GC.KeepAlive(commitment_tx);
431                 if (ret >= 0 && ret <= 4096) { return null; }
432                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
433                 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
434                 return ret_hu_conv;
435         }
436
437         /**
438          * Create a signature for the given input in a transaction spending an HTLC transaction output
439          * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
440          * 
441          * A justice transaction may claim multiple outputs at the same time if timelocks are
442          * similar, but only a signature for the input at index `input` should be signed for here.
443          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
444          * to an upcoming timelock expiration.
445          * 
446          * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
447          * 
448          * `per_commitment_key` is revocation secret which was provided by our counterparty when they
449          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
450          * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
451          * so).
452          */
453         public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
454                 long ret = bindings.BaseSign_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32));
455                 GC.KeepAlive(this);
456                 GC.KeepAlive(justice_tx);
457                 GC.KeepAlive(input);
458                 GC.KeepAlive(amount);
459                 GC.KeepAlive(per_commitment_key);
460                 if (ret >= 0 && ret <= 4096) { return null; }
461                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
462                 return ret_hu_conv;
463         }
464
465         /**
466          * Create a signature for the given input in a transaction spending a commitment transaction
467          * HTLC output when our counterparty broadcasts an old state.
468          * 
469          * A justice transaction may claim multiple outputs at the same time if timelocks are
470          * similar, but only a signature for the input at index `input` should be signed for here.
471          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
472          * to an upcoming timelock expiration.
473          * 
474          * `amount` is the value of the output spent by this input, committed to in the BIP 143
475          * signature.
476          * 
477          * `per_commitment_key` is revocation secret which was provided by our counterparty when they
478          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
479          * not allow the spending of any funds by itself (you need our holder revocation_secret to do
480          * so).
481          * 
482          * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
483          * (which is committed to in the BIP 143 signatures).
484          */
485         public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
486                 long ret = bindings.BaseSign_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32), htlc == null ? 0 : htlc.ptr);
487                 GC.KeepAlive(this);
488                 GC.KeepAlive(justice_tx);
489                 GC.KeepAlive(input);
490                 GC.KeepAlive(amount);
491                 GC.KeepAlive(per_commitment_key);
492                 GC.KeepAlive(htlc);
493                 if (ret >= 0 && ret <= 4096) { return null; }
494                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
495                 if (this != null) { this.ptrs_to.AddLast(htlc); };
496                 return ret_hu_conv;
497         }
498
499         /**
500          * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
501          * transaction, either offered or received.
502          * 
503          * Such a transaction may claim multiples offered outputs at same time if we know the
504          * preimage for each when we create it, but only the input at index `input` should be
505          * signed for here. It may be called multiple times for same output(s) if a fee-bump is
506          * needed with regards to an upcoming timelock expiration.
507          * 
508          * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
509          * outputs.
510          * 
511          * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
512          * 
513          * `per_commitment_point` is the dynamic point corresponding to the channel state
514          * detected onchain. It has been generated by our counterparty and is used to derive
515          * channel state keys, which are then included in the witness script and committed to in the
516          * BIP 143 signature.
517          */
518         public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
519                 long ret = bindings.BaseSign_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, InternalUtils.check_arr_len(per_commitment_point, 33), htlc == null ? 0 : htlc.ptr);
520                 GC.KeepAlive(this);
521                 GC.KeepAlive(htlc_tx);
522                 GC.KeepAlive(input);
523                 GC.KeepAlive(amount);
524                 GC.KeepAlive(per_commitment_point);
525                 GC.KeepAlive(htlc);
526                 if (ret >= 0 && ret <= 4096) { return null; }
527                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
528                 if (this != null) { this.ptrs_to.AddLast(htlc); };
529                 return ret_hu_conv;
530         }
531
532         /**
533          * Create a signature for a (proposed) closing transaction.
534          * 
535          * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
536          * chosen to forgo their output as dust.
537          */
538         public Result_SignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
539                 long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr);
540                 GC.KeepAlive(this);
541                 GC.KeepAlive(closing_tx);
542                 if (ret >= 0 && ret <= 4096) { return null; }
543                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
544                 if (this != null) { this.ptrs_to.AddLast(closing_tx); };
545                 return ret_hu_conv;
546         }
547
548         /**
549          * Computes the signature for a commitment transaction's anchor output used as an
550          * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
551          */
552         public Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
553                 long ret = bindings.BaseSign_sign_holder_anchor_input(this.ptr, anchor_tx, input);
554                 GC.KeepAlive(this);
555                 GC.KeepAlive(anchor_tx);
556                 GC.KeepAlive(input);
557                 if (ret >= 0 && ret <= 4096) { return null; }
558                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
559                 return ret_hu_conv;
560         }
561
562         /**
563          * Signs a channel announcement message with our funding key and our node secret key (aka
564          * node_id or network_key), proving it comes from one of the channel participants.
565          * 
566          * The first returned signature should be from our node secret key, the second from our
567          * funding key.
568          * 
569          * Note that if this fails or is rejected, the channel will not be publicly announced and
570          * our counterparty may (though likely will not) close the channel on us for violating the
571          * protocol.
572          */
573         public Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(org.ldk.structs.UnsignedChannelAnnouncement msg) {
574                 long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr);
575                 GC.KeepAlive(this);
576                 GC.KeepAlive(msg);
577                 if (ret >= 0 && ret <= 4096) { return null; }
578                 Result_C2Tuple_SignatureSignatureZNoneZ ret_hu_conv = Result_C2Tuple_SignatureSignatureZNoneZ.constr_from_ptr(ret);
579                 if (this != null) { this.ptrs_to.AddLast(msg); };
580                 return ret_hu_conv;
581         }
582
583         /**
584          * Set the counterparty static channel data, including basepoints,
585          * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. Since these
586          * are static channel data, they MUST NOT be allowed to change to different values once set,
587          * as LDK may call this method more than once.
588          * 
589          * channel_parameters.is_populated() MUST be true.
590          */
591         public void provide_channel_parameters(org.ldk.structs.ChannelTransactionParameters channel_parameters) {
592                 bindings.BaseSign_provide_channel_parameters(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr);
593                 GC.KeepAlive(this);
594                 GC.KeepAlive(channel_parameters);
595                 if (this != null) { this.ptrs_to.AddLast(channel_parameters); };
596         }
597
598         /**
599          * Frees any resources associated with this object given its this_arg pointer.
600          * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
601          */
602         public ChannelPublicKeys get_pubkeys() {
603                 long ret = bindings.BaseSign_get_pubkeys(this.ptr);
604                 GC.KeepAlive(this);
605                 if (ret >= 0 && ret <= 4096) { return null; }
606                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
607                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
608                 return ret_hu_conv;
609         }
610
611 }
612 } } }