cb33ab8895ce22ac5f95389337851e6fd5b63600
[ldk-java] / c_sharp / src / org / ldk / structs / EcdsaChannelSigner.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of EcdsaChannelSigner */
12 public interface EcdsaChannelSignerInterface {
13         /**Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
14          * 
15          * Note that if signing fails or is rejected, the channel will be force-closed.
16          * 
17          * Policy checks should be implemented in this function, including checking the amount
18          * sent to us and checking the HTLCs.
19          * 
20          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
21          * A validating signer should ensure that an HTLC output is removed only when the matching
22          * preimage is provided, or when the value to holder is restored.
23          * 
24          * Note that all the relevant preimages will be provided, but there may also be additional
25          * irrelevant or duplicate preimages.
26          */
27         Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages);
28         /**Validate the counterparty's revocation.
29          * 
30          * This is required in order for the signer to make sure that the state has moved
31          * forward and it is safe to sign the next counterparty commitment.
32          */
33         Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret);
34         /**Creates a signature for a holder's commitment transaction.
35          * 
36          * This will be called
37          * - with a non-revoked `commitment_tx`.
38          * - with the latest `commitment_tx` when we initiate a force-close.
39          * 
40          * This may be called multiple times for the same transaction.
41          * 
42          * An external signer implementation should check that the commitment has not been revoked.
43          */
44         Result_ECDSASignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction commitment_tx);
45         /**Create a signature for the given input in a transaction spending an HTLC transaction output
46          * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
47          * 
48          * A justice transaction may claim multiple outputs at the same time if timelocks are
49          * similar, but only a signature for the input at index `input` should be signed for here.
50          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
51          * to an upcoming timelock expiration.
52          * 
53          * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
54          * 
55          * `per_commitment_key` is revocation secret which was provided by our counterparty when they
56          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
57          * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
58          * so).
59          */
60         Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key);
61         /**Create a signature for the given input in a transaction spending a commitment transaction
62          * HTLC output when our counterparty broadcasts an old state.
63          * 
64          * A justice transaction may claim multiple outputs at the same time if timelocks are
65          * similar, but only a signature for the input at index `input` should be signed for here.
66          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
67          * to an upcoming timelock expiration.
68          * 
69          * `amount` is the value of the output spent by this input, committed to in the BIP 143
70          * signature.
71          * 
72          * `per_commitment_key` is revocation secret which was provided by our counterparty when they
73          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
74          * not allow the spending of any funds by itself (you need our holder revocation_secret to do
75          * so).
76          * 
77          * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
78          * (which is committed to in the BIP 143 signatures).
79          */
80         Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc);
81         /**Computes the signature for a commitment transaction's HTLC output used as an input within
82          * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
83          * must be be computed using [`EcdsaSighashType::All`].
84          * 
85          * Note that this may be called for HTLCs in the penultimate commitment transaction if a
86          * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
87          * broadcasts it before receiving the update for the latest commitment transaction.
88          * 
89          * [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
90          * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
91          */
92         Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, HTLCDescriptor htlc_descriptor);
93         /**Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
94          * transaction, either offered or received.
95          * 
96          * Such a transaction may claim multiples offered outputs at same time if we know the
97          * preimage for each when we create it, but only the input at index `input` should be
98          * signed for here. It may be called multiple times for same output(s) if a fee-bump is
99          * needed with regards to an upcoming timelock expiration.
100          * 
101          * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
102          * outputs.
103          * 
104          * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
105          * 
106          * `per_commitment_point` is the dynamic point corresponding to the channel state
107          * detected onchain. It has been generated by our counterparty and is used to derive
108          * channel state keys, which are then included in the witness script and committed to in the
109          * BIP 143 signature.
110          */
111         Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc);
112         /**Create a signature for a (proposed) closing transaction.
113          * 
114          * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
115          * chosen to forgo their output as dust.
116          */
117         Result_ECDSASignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
118         /**Computes the signature for a commitment transaction's anchor output used as an
119          * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
120          */
121         Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input);
122         /**Signs a channel announcement message with our funding key proving it comes from one of the
123          * channel participants.
124          * 
125          * Channel announcements also require a signature from each node's network key. Our node
126          * signature is computed through [`NodeSigner::sign_gossip_message`].
127          * 
128          * Note that if this fails or is rejected, the channel will not be publicly announced and
129          * our counterparty may (though likely will not) close the channel on us for violating the
130          * protocol.
131          */
132         Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg);
133 }
134
135 /**
136  * A trait to sign Lightning channel transactions as described in
137  * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
138  * 
139  * Signing services could be implemented on a hardware wallet and should implement signing
140  * policies in order to be secure. Please refer to the [VLS Policy
141  * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
142  * for an example of such policies.
143  */
144 public class EcdsaChannelSigner : CommonBase {
145         internal bindings.LDKEcdsaChannelSigner bindings_instance;
146         internal long instance_idx;
147
148         internal EcdsaChannelSigner(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
149         ~EcdsaChannelSigner() {
150                 if (ptr != 0) { bindings.EcdsaChannelSigner_free(ptr); }
151         }
152
153         private class LDKEcdsaChannelSignerHolder { internal EcdsaChannelSigner held; }
154         private class LDKEcdsaChannelSignerImpl : bindings.LDKEcdsaChannelSigner {
155                 internal LDKEcdsaChannelSignerImpl(EcdsaChannelSignerInterface arg, LDKEcdsaChannelSignerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
156                 private EcdsaChannelSignerInterface arg;
157                 private LDKEcdsaChannelSignerHolder impl_holder;
158                 public long sign_counterparty_commitment(long _commitment_tx, long _preimages) {
159                         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); }
160                         int _preimages_conv_8_len = InternalUtils.getArrayLength(_preimages);
161                         byte[][] _preimages_conv_8_arr = new byte[_preimages_conv_8_len][];
162                         for (int i = 0; i < _preimages_conv_8_len; i++) {
163                                 long _preimages_conv_8 = InternalUtils.getU64ArrayElem(_preimages, i);
164                                 byte[] _preimages_conv_8_conv = InternalUtils.decodeUint8Array(_preimages_conv_8);
165                                 _preimages_conv_8_arr[i] = _preimages_conv_8_conv;
166                         }
167                         bindings.free_buffer(_preimages);
168                         Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret = arg.sign_counterparty_commitment(_commitment_tx_hu_conv, _preimages_conv_8_arr);
169                                 GC.KeepAlive(arg);
170                         long result = ret == null ? 0 : ret.clone_ptr();
171                         return result;
172                 }
173                 public long validate_counterparty_revocation(long _idx, long _secret) {
174                         byte[] _secret_conv = InternalUtils.decodeUint8Array(_secret);
175                         Result_NoneNoneZ ret = arg.validate_counterparty_revocation(_idx, _secret_conv);
176                                 GC.KeepAlive(arg);
177                         long result = ret == null ? 0 : ret.clone_ptr();
178                         return result;
179                 }
180                 public long sign_holder_commitment(long _commitment_tx) {
181                         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); }
182                         Result_ECDSASignatureNoneZ ret = arg.sign_holder_commitment(_commitment_tx_hu_conv);
183                                 GC.KeepAlive(arg);
184                         long result = ret == null ? 0 : ret.clone_ptr();
185                         return result;
186                 }
187                 public long sign_justice_revoked_output(long _justice_tx, long _input, long _amount, long _per_commitment_key) {
188                         byte[] _justice_tx_conv = InternalUtils.decodeUint8Array(_justice_tx);
189                         byte[] _per_commitment_key_conv = InternalUtils.decodeUint8Array(_per_commitment_key);
190                         Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_output(_justice_tx_conv, _input, _amount, _per_commitment_key_conv);
191                                 GC.KeepAlive(arg);
192                         long result = ret == null ? 0 : ret.clone_ptr();
193                         return result;
194                 }
195                 public long sign_justice_revoked_htlc(long _justice_tx, long _input, long _amount, long _per_commitment_key, long _htlc) {
196                         byte[] _justice_tx_conv = InternalUtils.decodeUint8Array(_justice_tx);
197                         byte[] _per_commitment_key_conv = InternalUtils.decodeUint8Array(_per_commitment_key);
198                         org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
199                         Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_htlc(_justice_tx_conv, _input, _amount, _per_commitment_key_conv, _htlc_hu_conv);
200                                 GC.KeepAlive(arg);
201                         long result = ret == null ? 0 : ret.clone_ptr();
202                         return result;
203                 }
204                 public long sign_holder_htlc_transaction(long _htlc_tx, long _input, long _htlc_descriptor) {
205                         byte[] _htlc_tx_conv = InternalUtils.decodeUint8Array(_htlc_tx);
206                         org.ldk.structs.HTLCDescriptor _htlc_descriptor_hu_conv = null; if (_htlc_descriptor < 0 || _htlc_descriptor > 4096) { _htlc_descriptor_hu_conv = new org.ldk.structs.HTLCDescriptor(null, _htlc_descriptor); }
207                         Result_ECDSASignatureNoneZ ret = arg.sign_holder_htlc_transaction(_htlc_tx_conv, _input, _htlc_descriptor_hu_conv);
208                                 GC.KeepAlive(arg);
209                         long result = ret == null ? 0 : ret.clone_ptr();
210                         return result;
211                 }
212                 public long sign_counterparty_htlc_transaction(long _htlc_tx, long _input, long _amount, long _per_commitment_point, long _htlc) {
213                         byte[] _htlc_tx_conv = InternalUtils.decodeUint8Array(_htlc_tx);
214                         byte[] _per_commitment_point_conv = InternalUtils.decodeUint8Array(_per_commitment_point);
215                         org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
216                         Result_ECDSASignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(_htlc_tx_conv, _input, _amount, _per_commitment_point_conv, _htlc_hu_conv);
217                                 GC.KeepAlive(arg);
218                         long result = ret == null ? 0 : ret.clone_ptr();
219                         return result;
220                 }
221                 public long sign_closing_transaction(long _closing_tx) {
222                         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); }
223                         Result_ECDSASignatureNoneZ ret = arg.sign_closing_transaction(_closing_tx_hu_conv);
224                                 GC.KeepAlive(arg);
225                         long result = ret == null ? 0 : ret.clone_ptr();
226                         return result;
227                 }
228                 public long sign_holder_anchor_input(long _anchor_tx, long _input) {
229                         byte[] _anchor_tx_conv = InternalUtils.decodeUint8Array(_anchor_tx);
230                         Result_ECDSASignatureNoneZ ret = arg.sign_holder_anchor_input(_anchor_tx_conv, _input);
231                                 GC.KeepAlive(arg);
232                         long result = ret == null ? 0 : ret.clone_ptr();
233                         return result;
234                 }
235                 public long sign_channel_announcement_with_funding_key(long _msg) {
236                         org.ldk.structs.UnsignedChannelAnnouncement _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, _msg); }
237                         Result_ECDSASignatureNoneZ ret = arg.sign_channel_announcement_with_funding_key(_msg_hu_conv);
238                                 GC.KeepAlive(arg);
239                         long result = ret == null ? 0 : ret.clone_ptr();
240                         return result;
241                 }
242         }
243
244         /** Creates a new instance of EcdsaChannelSigner from a given implementation */
245         public static EcdsaChannelSigner new_impl(EcdsaChannelSignerInterface arg, ChannelSignerInterface channelSigner_impl, ChannelPublicKeys pubkeys) {
246                 LDKEcdsaChannelSignerHolder impl_holder = new LDKEcdsaChannelSignerHolder();
247                 LDKEcdsaChannelSignerImpl impl = new LDKEcdsaChannelSignerImpl(arg, impl_holder);
248                 ChannelSigner channelSigner = ChannelSigner.new_impl(channelSigner_impl, pubkeys);
249                 long[] ptr_idx = bindings.LDKEcdsaChannelSigner_new(impl, channelSigner.instance_idx, pubkeys == null ? 0 : pubkeys.clone_ptr());
250
251                 impl_holder.held = new EcdsaChannelSigner(null, ptr_idx[0]);
252                 impl_holder.held.instance_idx = ptr_idx[1];
253                 impl_holder.held.bindings_instance = impl;
254                 impl_holder.held.ptrs_to.AddLast(channelSigner);
255                 return impl_holder.held;
256         }
257
258         /**
259          * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
260          * 
261          * Note that if signing fails or is rejected, the channel will be force-closed.
262          * 
263          * Policy checks should be implemented in this function, including checking the amount
264          * sent to us and checking the HTLCs.
265          * 
266          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
267          * A validating signer should ensure that an HTLC output is removed only when the matching
268          * preimage is provided, or when the value to holder is restored.
269          * 
270          * Note that all the relevant preimages will be provided, but there may also be additional
271          * irrelevant or duplicate preimages.
272          */
273         public Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] preimages) {
274                 long ret = bindings.EcdsaChannelSigner_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(preimages, preimages_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(preimages_conv_8, 32)))));
275                 GC.KeepAlive(this);
276                 GC.KeepAlive(commitment_tx);
277                 GC.KeepAlive(preimages);
278                 if (ret >= 0 && ret <= 4096) { return null; }
279                 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_hu_conv = Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.constr_from_ptr(ret);
280                 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
281                 return ret_hu_conv;
282         }
283
284         /**
285          * Validate the counterparty's revocation.
286          * 
287          * This is required in order for the signer to make sure that the state has moved
288          * forward and it is safe to sign the next counterparty commitment.
289          */
290         public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
291                 long ret = bindings.EcdsaChannelSigner_validate_counterparty_revocation(this.ptr, idx, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(secret, 32)));
292                 GC.KeepAlive(this);
293                 GC.KeepAlive(idx);
294                 GC.KeepAlive(secret);
295                 if (ret >= 0 && ret <= 4096) { return null; }
296                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
297                 return ret_hu_conv;
298         }
299
300         /**
301          * Creates a signature for a holder's commitment transaction.
302          * 
303          * This will be called
304          * - with a non-revoked `commitment_tx`.
305          * - with the latest `commitment_tx` when we initiate a force-close.
306          * 
307          * This may be called multiple times for the same transaction.
308          * 
309          * An external signer implementation should check that the commitment has not been revoked.
310          */
311         public Result_ECDSASignatureNoneZ sign_holder_commitment(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
312                 long ret = bindings.EcdsaChannelSigner_sign_holder_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr);
313                 GC.KeepAlive(this);
314                 GC.KeepAlive(commitment_tx);
315                 if (ret >= 0 && ret <= 4096) { return null; }
316                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
317                 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
318                 return ret_hu_conv;
319         }
320
321         /**
322          * Create a signature for the given input in a transaction spending an HTLC transaction output
323          * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
324          * 
325          * A justice transaction may claim multiple outputs at the same time if timelocks are
326          * similar, but only a signature for the input at index `input` should be signed for here.
327          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
328          * to an upcoming timelock expiration.
329          * 
330          * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
331          * 
332          * `per_commitment_key` is revocation secret which was provided by our counterparty when they
333          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
334          * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
335          * so).
336          */
337         public Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
338                 long ret = bindings.EcdsaChannelSigner_sign_justice_revoked_output(this.ptr, InternalUtils.encodeUint8Array(justice_tx), input, amount, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_key, 32)));
339                 GC.KeepAlive(this);
340                 GC.KeepAlive(justice_tx);
341                 GC.KeepAlive(input);
342                 GC.KeepAlive(amount);
343                 GC.KeepAlive(per_commitment_key);
344                 if (ret >= 0 && ret <= 4096) { return null; }
345                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
346                 return ret_hu_conv;
347         }
348
349         /**
350          * Create a signature for the given input in a transaction spending a commitment transaction
351          * HTLC output when our counterparty broadcasts an old state.
352          * 
353          * A justice transaction may claim multiple outputs at the same time if timelocks are
354          * similar, but only a signature for the input at index `input` should be signed for here.
355          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
356          * to an upcoming timelock expiration.
357          * 
358          * `amount` is the value of the output spent by this input, committed to in the BIP 143
359          * signature.
360          * 
361          * `per_commitment_key` is revocation secret which was provided by our counterparty when they
362          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
363          * not allow the spending of any funds by itself (you need our holder revocation_secret to do
364          * so).
365          * 
366          * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
367          * (which is committed to in the BIP 143 signatures).
368          */
369         public Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
370                 long ret = bindings.EcdsaChannelSigner_sign_justice_revoked_htlc(this.ptr, InternalUtils.encodeUint8Array(justice_tx), input, amount, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_key, 32)), htlc == null ? 0 : htlc.ptr);
371                 GC.KeepAlive(this);
372                 GC.KeepAlive(justice_tx);
373                 GC.KeepAlive(input);
374                 GC.KeepAlive(amount);
375                 GC.KeepAlive(per_commitment_key);
376                 GC.KeepAlive(htlc);
377                 if (ret >= 0 && ret <= 4096) { return null; }
378                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
379                 if (this != null) { this.ptrs_to.AddLast(htlc); };
380                 return ret_hu_conv;
381         }
382
383         /**
384          * Computes the signature for a commitment transaction's HTLC output used as an input within
385          * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
386          * must be be computed using [`EcdsaSighashType::All`].
387          * 
388          * Note that this may be called for HTLCs in the penultimate commitment transaction if a
389          * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
390          * broadcasts it before receiving the update for the latest commitment transaction.
391          * 
392          * [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
393          * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
394          */
395         public Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, org.ldk.structs.HTLCDescriptor htlc_descriptor) {
396                 long ret = bindings.EcdsaChannelSigner_sign_holder_htlc_transaction(this.ptr, InternalUtils.encodeUint8Array(htlc_tx), input, htlc_descriptor == null ? 0 : htlc_descriptor.ptr);
397                 GC.KeepAlive(this);
398                 GC.KeepAlive(htlc_tx);
399                 GC.KeepAlive(input);
400                 GC.KeepAlive(htlc_descriptor);
401                 if (ret >= 0 && ret <= 4096) { return null; }
402                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
403                 if (this != null) { this.ptrs_to.AddLast(htlc_descriptor); };
404                 return ret_hu_conv;
405         }
406
407         /**
408          * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
409          * transaction, either offered or received.
410          * 
411          * Such a transaction may claim multiples offered outputs at same time if we know the
412          * preimage for each when we create it, but only the input at index `input` should be
413          * signed for here. It may be called multiple times for same output(s) if a fee-bump is
414          * needed with regards to an upcoming timelock expiration.
415          * 
416          * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
417          * outputs.
418          * 
419          * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
420          * 
421          * `per_commitment_point` is the dynamic point corresponding to the channel state
422          * detected onchain. It has been generated by our counterparty and is used to derive
423          * channel state keys, which are then included in the witness script and committed to in the
424          * BIP 143 signature.
425          */
426         public Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
427                 long ret = bindings.EcdsaChannelSigner_sign_counterparty_htlc_transaction(this.ptr, InternalUtils.encodeUint8Array(htlc_tx), input, amount, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)), htlc == null ? 0 : htlc.ptr);
428                 GC.KeepAlive(this);
429                 GC.KeepAlive(htlc_tx);
430                 GC.KeepAlive(input);
431                 GC.KeepAlive(amount);
432                 GC.KeepAlive(per_commitment_point);
433                 GC.KeepAlive(htlc);
434                 if (ret >= 0 && ret <= 4096) { return null; }
435                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
436                 if (this != null) { this.ptrs_to.AddLast(htlc); };
437                 return ret_hu_conv;
438         }
439
440         /**
441          * Create a signature for a (proposed) closing transaction.
442          * 
443          * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
444          * chosen to forgo their output as dust.
445          */
446         public Result_ECDSASignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
447                 long ret = bindings.EcdsaChannelSigner_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr);
448                 GC.KeepAlive(this);
449                 GC.KeepAlive(closing_tx);
450                 if (ret >= 0 && ret <= 4096) { return null; }
451                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
452                 if (this != null) { this.ptrs_to.AddLast(closing_tx); };
453                 return ret_hu_conv;
454         }
455
456         /**
457          * Computes the signature for a commitment transaction's anchor output used as an
458          * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
459          */
460         public Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
461                 long ret = bindings.EcdsaChannelSigner_sign_holder_anchor_input(this.ptr, InternalUtils.encodeUint8Array(anchor_tx), input);
462                 GC.KeepAlive(this);
463                 GC.KeepAlive(anchor_tx);
464                 GC.KeepAlive(input);
465                 if (ret >= 0 && ret <= 4096) { return null; }
466                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
467                 return ret_hu_conv;
468         }
469
470         /**
471          * Signs a channel announcement message with our funding key proving it comes from one of the
472          * channel participants.
473          * 
474          * Channel announcements also require a signature from each node's network key. Our node
475          * signature is computed through [`NodeSigner::sign_gossip_message`].
476          * 
477          * Note that if this fails or is rejected, the channel will not be publicly announced and
478          * our counterparty may (though likely will not) close the channel on us for violating the
479          * protocol.
480          */
481         public Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(org.ldk.structs.UnsignedChannelAnnouncement msg) {
482                 long ret = bindings.EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this.ptr, msg == null ? 0 : msg.ptr);
483                 GC.KeepAlive(this);
484                 GC.KeepAlive(msg);
485                 if (ret >= 0 && ret <= 4096) { return null; }
486                 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
487                 if (this != null) { this.ptrs_to.AddLast(msg); };
488                 return ret_hu_conv;
489         }
490
491 }
492 } } }