7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of EcdsaChannelSigner */
12 public interface EcdsaChannelSignerInterface {
13 /**Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
15 * Note that if signing fails or is rejected, the channel will be force-closed.
17 * Policy checks should be implemented in this function, including checking the amount
18 * sent to us and checking the HTLCs.
20 * The preimages of outbound and inbound HTLCs that were fulfilled since the last commitment
21 * are provided. A validating signer should ensure that an outbound HTLC output is removed
22 * only when the matching preimage is provided and after the corresponding inbound HTLC has
23 * been removed for forwarded payments.
25 * Note that all the relevant preimages will be provided, but there may also be additional
26 * irrelevant or duplicate preimages.
28 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] inbound_htlc_preimages, byte[][] outbound_htlc_preimages);
29 /**Creates a signature for a holder's commitment transaction.
32 * - with a non-revoked `commitment_tx`.
33 * - with the latest `commitment_tx` when we initiate a force-close.
35 * This may be called multiple times for the same transaction.
37 * An external signer implementation should check that the commitment has not been revoked.
39 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
40 * signature and should be retried later. Once the signer is ready to provide a signature after
41 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
44 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
46 Result_ECDSASignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction commitment_tx);
47 /**Create a signature for the given input in a transaction spending an HTLC transaction output
48 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
50 * A justice transaction may claim multiple outputs at the same time if timelocks are
51 * similar, but only a signature for the input at index `input` should be signed for here.
52 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
53 * to an upcoming timelock expiration.
55 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
57 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
58 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
59 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
62 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
63 * signature and should be retried later. Once the signer is ready to provide a signature after
64 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
67 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
69 Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key);
70 /**Create a signature for the given input in a transaction spending a commitment transaction
71 * HTLC output when our counterparty broadcasts an old state.
73 * A justice transaction may claim multiple outputs at the same time if timelocks are
74 * similar, but only a signature for the input at index `input` should be signed for here.
75 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
76 * to an upcoming timelock expiration.
78 * `amount` is the value of the output spent by this input, committed to in the BIP 143
81 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
82 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
83 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
86 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
87 * (which is committed to in the BIP 143 signatures).
89 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
90 * signature and should be retried later. Once the signer is ready to provide a signature after
91 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
94 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
96 Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc);
97 /**Computes the signature for a commitment transaction's HTLC output used as an input within
98 * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
99 * must be be computed using [`EcdsaSighashType::All`].
101 * Note that this may be called for HTLCs in the penultimate commitment transaction if a
102 * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
103 * broadcasts it before receiving the update for the latest commitment transaction.
105 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
106 * signature and should be retried later. Once the signer is ready to provide a signature after
107 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
110 * [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
111 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
112 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
114 Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, HTLCDescriptor htlc_descriptor);
115 /**Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
116 * transaction, either offered or received.
118 * Such a transaction may claim multiples offered outputs at same time if we know the
119 * preimage for each when we create it, but only the input at index `input` should be
120 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
121 * needed with regards to an upcoming timelock expiration.
123 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
126 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
128 * `per_commitment_point` is the dynamic point corresponding to the channel state
129 * detected onchain. It has been generated by our counterparty and is used to derive
130 * channel state keys, which are then included in the witness script and committed to in the
133 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
134 * signature and should be retried later. Once the signer is ready to provide a signature after
135 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
138 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
140 Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc);
141 /**Create a signature for a (proposed) closing transaction.
143 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
144 * chosen to forgo their output as dust.
146 Result_ECDSASignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
147 /**Computes the signature for a commitment transaction's anchor output used as an
148 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
150 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
151 * signature and should be retried later. Once the signer is ready to provide a signature after
152 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
155 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
157 Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input);
158 /**Signs a channel announcement message with our funding key proving it comes from one of the
159 * channel participants.
161 * Channel announcements also require a signature from each node's network key. Our node
162 * signature is computed through [`NodeSigner::sign_gossip_message`].
164 * Note that if this fails or is rejected, the channel will not be publicly announced and
165 * our counterparty may (though likely will not) close the channel on us for violating the
168 * [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
170 Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg);
174 * A trait to sign Lightning channel transactions as described in
175 * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
177 * Signing services could be implemented on a hardware wallet and should implement signing
178 * policies in order to be secure. Please refer to the [VLS Policy
179 * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
180 * for an example of such policies.
182 public class EcdsaChannelSigner : CommonBase {
183 internal bindings.LDKEcdsaChannelSigner bindings_instance;
184 internal long instance_idx;
186 internal EcdsaChannelSigner(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
187 ~EcdsaChannelSigner() {
188 if (ptr != 0) { bindings.EcdsaChannelSigner_free(ptr); }
191 private class LDKEcdsaChannelSignerHolder { internal EcdsaChannelSigner held; }
192 private class LDKEcdsaChannelSignerImpl : bindings.LDKEcdsaChannelSigner {
193 internal LDKEcdsaChannelSignerImpl(EcdsaChannelSignerInterface arg, LDKEcdsaChannelSignerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
194 private EcdsaChannelSignerInterface arg;
195 private LDKEcdsaChannelSignerHolder impl_holder;
196 public long sign_counterparty_commitment(long _commitment_tx, long _inbound_htlc_preimages, long _outbound_htlc_preimages) {
197 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); }
198 int _inbound_htlc_preimages_conv_8_len = InternalUtils.getArrayLength(_inbound_htlc_preimages);
199 byte[][] _inbound_htlc_preimages_conv_8_arr = new byte[_inbound_htlc_preimages_conv_8_len][];
200 for (int i = 0; i < _inbound_htlc_preimages_conv_8_len; i++) {
201 long _inbound_htlc_preimages_conv_8 = InternalUtils.getU64ArrayElem(_inbound_htlc_preimages, i);
202 byte[] _inbound_htlc_preimages_conv_8_conv = InternalUtils.decodeUint8Array(_inbound_htlc_preimages_conv_8);
203 _inbound_htlc_preimages_conv_8_arr[i] = _inbound_htlc_preimages_conv_8_conv;
205 bindings.free_buffer(_inbound_htlc_preimages);
206 int _outbound_htlc_preimages_conv_8_len = InternalUtils.getArrayLength(_outbound_htlc_preimages);
207 byte[][] _outbound_htlc_preimages_conv_8_arr = new byte[_outbound_htlc_preimages_conv_8_len][];
208 for (int i = 0; i < _outbound_htlc_preimages_conv_8_len; i++) {
209 long _outbound_htlc_preimages_conv_8 = InternalUtils.getU64ArrayElem(_outbound_htlc_preimages, i);
210 byte[] _outbound_htlc_preimages_conv_8_conv = InternalUtils.decodeUint8Array(_outbound_htlc_preimages_conv_8);
211 _outbound_htlc_preimages_conv_8_arr[i] = _outbound_htlc_preimages_conv_8_conv;
213 bindings.free_buffer(_outbound_htlc_preimages);
214 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret = arg.sign_counterparty_commitment(_commitment_tx_hu_conv, _inbound_htlc_preimages_conv_8_arr, _outbound_htlc_preimages_conv_8_arr);
216 long result = ret.clone_ptr();
219 public long sign_holder_commitment(long _commitment_tx) {
220 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); }
221 Result_ECDSASignatureNoneZ ret = arg.sign_holder_commitment(_commitment_tx_hu_conv);
223 long result = ret.clone_ptr();
226 public long sign_justice_revoked_output(long _justice_tx, long _input, long _amount, long _per_commitment_key) {
227 byte[] _justice_tx_conv = InternalUtils.decodeUint8Array(_justice_tx);
228 byte[] _per_commitment_key_conv = InternalUtils.decodeUint8Array(_per_commitment_key);
229 Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_output(_justice_tx_conv, _input, _amount, _per_commitment_key_conv);
231 long result = ret.clone_ptr();
234 public long sign_justice_revoked_htlc(long _justice_tx, long _input, long _amount, long _per_commitment_key, long _htlc) {
235 byte[] _justice_tx_conv = InternalUtils.decodeUint8Array(_justice_tx);
236 byte[] _per_commitment_key_conv = InternalUtils.decodeUint8Array(_per_commitment_key);
237 org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
238 Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_htlc(_justice_tx_conv, _input, _amount, _per_commitment_key_conv, _htlc_hu_conv);
240 long result = ret.clone_ptr();
243 public long sign_holder_htlc_transaction(long _htlc_tx, long _input, long _htlc_descriptor) {
244 byte[] _htlc_tx_conv = InternalUtils.decodeUint8Array(_htlc_tx);
245 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); }
246 Result_ECDSASignatureNoneZ ret = arg.sign_holder_htlc_transaction(_htlc_tx_conv, _input, _htlc_descriptor_hu_conv);
248 long result = ret.clone_ptr();
251 public long sign_counterparty_htlc_transaction(long _htlc_tx, long _input, long _amount, long _per_commitment_point, long _htlc) {
252 byte[] _htlc_tx_conv = InternalUtils.decodeUint8Array(_htlc_tx);
253 byte[] _per_commitment_point_conv = InternalUtils.decodeUint8Array(_per_commitment_point);
254 org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
255 Result_ECDSASignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(_htlc_tx_conv, _input, _amount, _per_commitment_point_conv, _htlc_hu_conv);
257 long result = ret.clone_ptr();
260 public long sign_closing_transaction(long _closing_tx) {
261 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); }
262 Result_ECDSASignatureNoneZ ret = arg.sign_closing_transaction(_closing_tx_hu_conv);
264 long result = ret.clone_ptr();
267 public long sign_holder_anchor_input(long _anchor_tx, long _input) {
268 byte[] _anchor_tx_conv = InternalUtils.decodeUint8Array(_anchor_tx);
269 Result_ECDSASignatureNoneZ ret = arg.sign_holder_anchor_input(_anchor_tx_conv, _input);
271 long result = ret.clone_ptr();
274 public long sign_channel_announcement_with_funding_key(long _msg) {
275 org.ldk.structs.UnsignedChannelAnnouncement _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, _msg); }
276 Result_ECDSASignatureNoneZ ret = arg.sign_channel_announcement_with_funding_key(_msg_hu_conv);
278 long result = ret.clone_ptr();
283 /** Creates a new instance of EcdsaChannelSigner from a given implementation */
284 public static EcdsaChannelSigner new_impl(EcdsaChannelSignerInterface arg, ChannelSignerInterface channelSigner_impl, ChannelPublicKeys pubkeys) {
285 LDKEcdsaChannelSignerHolder impl_holder = new LDKEcdsaChannelSignerHolder();
286 LDKEcdsaChannelSignerImpl impl = new LDKEcdsaChannelSignerImpl(arg, impl_holder);
287 ChannelSigner channelSigner = ChannelSigner.new_impl(channelSigner_impl, pubkeys);
288 long[] ptr_idx = bindings.LDKEcdsaChannelSigner_new(impl, channelSigner.instance_idx, pubkeys.clone_ptr());
290 impl_holder.held = new EcdsaChannelSigner(null, ptr_idx[0]);
291 impl_holder.held.instance_idx = ptr_idx[1];
292 impl_holder.held.bindings_instance = impl;
293 impl_holder.held.ptrs_to.AddLast(channelSigner);
294 return impl_holder.held;
298 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
300 * Note that if signing fails or is rejected, the channel will be force-closed.
302 * Policy checks should be implemented in this function, including checking the amount
303 * sent to us and checking the HTLCs.
305 * The preimages of outbound and inbound HTLCs that were fulfilled since the last commitment
306 * are provided. A validating signer should ensure that an outbound HTLC output is removed
307 * only when the matching preimage is provided and after the corresponding inbound HTLC has
308 * been removed for forwarded payments.
310 * Note that all the relevant preimages will be provided, but there may also be additional
311 * irrelevant or duplicate preimages.
313 public Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] inbound_htlc_preimages, byte[][] outbound_htlc_preimages) {
314 long ret = bindings.EcdsaChannelSigner_sign_counterparty_commitment(this.ptr, commitment_tx.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(inbound_htlc_preimages, inbound_htlc_preimages_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(inbound_htlc_preimages_conv_8, 32)))), InternalUtils.encodeUint64Array(InternalUtils.mapArray(outbound_htlc_preimages, outbound_htlc_preimages_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(outbound_htlc_preimages_conv_8, 32)))));
316 GC.KeepAlive(commitment_tx);
317 GC.KeepAlive(inbound_htlc_preimages);
318 GC.KeepAlive(outbound_htlc_preimages);
319 if (ret >= 0 && ret <= 4096) { return null; }
320 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_hu_conv = Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.constr_from_ptr(ret);
321 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
326 * Creates a signature for a holder's commitment transaction.
328 * This will be called
329 * - with a non-revoked `commitment_tx`.
330 * - with the latest `commitment_tx` when we initiate a force-close.
332 * This may be called multiple times for the same transaction.
334 * An external signer implementation should check that the commitment has not been revoked.
336 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
337 * signature and should be retried later. Once the signer is ready to provide a signature after
338 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
341 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
343 public Result_ECDSASignatureNoneZ sign_holder_commitment(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
344 long ret = bindings.EcdsaChannelSigner_sign_holder_commitment(this.ptr, commitment_tx.ptr);
346 GC.KeepAlive(commitment_tx);
347 if (ret >= 0 && ret <= 4096) { return null; }
348 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
349 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
354 * Create a signature for the given input in a transaction spending an HTLC transaction output
355 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
357 * A justice transaction may claim multiple outputs at the same time if timelocks are
358 * similar, but only a signature for the input at index `input` should be signed for here.
359 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
360 * to an upcoming timelock expiration.
362 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
364 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
365 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
366 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
369 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
370 * signature and should be retried later. Once the signer is ready to provide a signature after
371 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
374 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
376 public Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
377 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)));
379 GC.KeepAlive(justice_tx);
381 GC.KeepAlive(amount);
382 GC.KeepAlive(per_commitment_key);
383 if (ret >= 0 && ret <= 4096) { return null; }
384 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
389 * Create a signature for the given input in a transaction spending a commitment transaction
390 * HTLC output when our counterparty broadcasts an old state.
392 * A justice transaction may claim multiple outputs at the same time if timelocks are
393 * similar, but only a signature for the input at index `input` should be signed for here.
394 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
395 * to an upcoming timelock expiration.
397 * `amount` is the value of the output spent by this input, committed to in the BIP 143
400 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
401 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
402 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
405 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
406 * (which is committed to in the BIP 143 signatures).
408 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
409 * signature and should be retried later. Once the signer is ready to provide a signature after
410 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
413 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
415 public Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
416 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.ptr);
418 GC.KeepAlive(justice_tx);
420 GC.KeepAlive(amount);
421 GC.KeepAlive(per_commitment_key);
423 if (ret >= 0 && ret <= 4096) { return null; }
424 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
425 if (this != null) { this.ptrs_to.AddLast(htlc); };
430 * Computes the signature for a commitment transaction's HTLC output used as an input within
431 * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
432 * must be be computed using [`EcdsaSighashType::All`].
434 * Note that this may be called for HTLCs in the penultimate commitment transaction if a
435 * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
436 * broadcasts it before receiving the update for the latest commitment transaction.
438 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
439 * signature and should be retried later. Once the signer is ready to provide a signature after
440 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
443 * [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
444 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
445 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
447 public Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, org.ldk.structs.HTLCDescriptor htlc_descriptor) {
448 long ret = bindings.EcdsaChannelSigner_sign_holder_htlc_transaction(this.ptr, InternalUtils.encodeUint8Array(htlc_tx), input, htlc_descriptor.ptr);
450 GC.KeepAlive(htlc_tx);
452 GC.KeepAlive(htlc_descriptor);
453 if (ret >= 0 && ret <= 4096) { return null; }
454 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
455 if (this != null) { this.ptrs_to.AddLast(htlc_descriptor); };
460 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
461 * transaction, either offered or received.
463 * Such a transaction may claim multiples offered outputs at same time if we know the
464 * preimage for each when we create it, but only the input at index `input` should be
465 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
466 * needed with regards to an upcoming timelock expiration.
468 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
471 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
473 * `per_commitment_point` is the dynamic point corresponding to the channel state
474 * detected onchain. It has been generated by our counterparty and is used to derive
475 * channel state keys, which are then included in the witness script and committed to in the
478 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
479 * signature and should be retried later. Once the signer is ready to provide a signature after
480 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
483 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
485 public Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
486 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.ptr);
488 GC.KeepAlive(htlc_tx);
490 GC.KeepAlive(amount);
491 GC.KeepAlive(per_commitment_point);
493 if (ret >= 0 && ret <= 4096) { return null; }
494 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
495 if (this != null) { this.ptrs_to.AddLast(htlc); };
500 * Create a signature for a (proposed) closing transaction.
502 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
503 * chosen to forgo their output as dust.
505 public Result_ECDSASignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
506 long ret = bindings.EcdsaChannelSigner_sign_closing_transaction(this.ptr, closing_tx.ptr);
508 GC.KeepAlive(closing_tx);
509 if (ret >= 0 && ret <= 4096) { return null; }
510 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
511 if (this != null) { this.ptrs_to.AddLast(closing_tx); };
516 * Computes the signature for a commitment transaction's anchor output used as an
517 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
519 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
520 * signature and should be retried later. Once the signer is ready to provide a signature after
521 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
524 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
526 public Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
527 long ret = bindings.EcdsaChannelSigner_sign_holder_anchor_input(this.ptr, InternalUtils.encodeUint8Array(anchor_tx), input);
529 GC.KeepAlive(anchor_tx);
531 if (ret >= 0 && ret <= 4096) { return null; }
532 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
537 * Signs a channel announcement message with our funding key proving it comes from one of the
538 * channel participants.
540 * Channel announcements also require a signature from each node's network key. Our node
541 * signature is computed through [`NodeSigner::sign_gossip_message`].
543 * Note that if this fails or is rejected, the channel will not be publicly announced and
544 * our counterparty may (though likely will not) close the channel on us for violating the
547 * [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
549 public Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(org.ldk.structs.UnsignedChannelAnnouncement msg) {
550 long ret = bindings.EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this.ptr, msg.ptr);
553 if (ret >= 0 && ret <= 4096) { return null; }
554 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
555 if (this != null) { this.ptrs_to.AddLast(msg); };