1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
11 * A trait to sign Lightning channel transactions as described in
12 * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
14 * Signing services could be implemented on a hardware wallet and should implement signing
15 * policies in order to be secure. Please refer to the [VLS Policy
16 * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
17 * for an example of such policies.
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class EcdsaChannelSigner extends CommonBase {
21 final bindings.LDKEcdsaChannelSigner bindings_instance;
22 EcdsaChannelSigner(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
23 private EcdsaChannelSigner(bindings.LDKEcdsaChannelSigner arg, bindings.LDKChannelSigner ChannelSigner, ChannelPublicKeys pubkeys) {
24 super(bindings.LDKEcdsaChannelSigner_new(arg, ChannelSigner, pubkeys.clone_ptr()));
25 this.ptrs_to.add(arg);
26 this.ptrs_to.add(ChannelSigner);
27 this.bindings_instance = arg;
29 @Override @SuppressWarnings("deprecation")
30 protected void finalize() throws Throwable {
31 if (ptr != 0) { bindings.EcdsaChannelSigner_free(ptr); } super.finalize();
34 * Destroys the object, freeing associated resources. After this call, any access
35 * to this object may result in a SEGFAULT or worse.
37 * You should generally NEVER call this method. You should let the garbage collector
38 * do this for you when it finalizes objects. However, it may be useful for types
39 * which represent locks and should be closed immediately to avoid holding locks
42 public void destroy() {
43 if (ptr != 0) { bindings.EcdsaChannelSigner_free(ptr); }
46 public static interface EcdsaChannelSignerInterface {
48 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
50 * Note that if signing fails or is rejected, the channel will be force-closed.
52 * Policy checks should be implemented in this function, including checking the amount
53 * sent to us and checking the HTLCs.
55 * The preimages of outbound and inbound HTLCs that were fulfilled since the last commitment
56 * are provided. A validating signer should ensure that an outbound HTLC output is removed
57 * only when the matching preimage is provided and after the corresponding inbound HTLC has
58 * been removed for forwarded payments.
60 * Note that all the relevant preimages will be provided, but there may also be additional
61 * irrelevant or duplicate preimages.
63 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] inbound_htlc_preimages, byte[][] outbound_htlc_preimages);
65 * Creates a signature for a holder's commitment transaction.
68 * - with a non-revoked `commitment_tx`.
69 * - with the latest `commitment_tx` when we initiate a force-close.
71 * This may be called multiple times for the same transaction.
73 * An external signer implementation should check that the commitment has not been revoked.
75 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
76 * signature and should be retried later. Once the signer is ready to provide a signature after
77 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
80 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
82 Result_ECDSASignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction commitment_tx);
84 * Create a signature for the given input in a transaction spending an HTLC transaction output
85 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
87 * A justice transaction may claim multiple outputs at the same time if timelocks are
88 * similar, but only a signature for the input at index `input` should be signed for here.
89 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
90 * to an upcoming timelock expiration.
92 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
94 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
95 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
96 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
99 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
100 * signature and should be retried later. Once the signer is ready to provide a signature after
101 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
104 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
106 Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key);
108 * Create a signature for the given input in a transaction spending a commitment transaction
109 * HTLC output when our counterparty broadcasts an old state.
111 * A justice transaction may claim multiple outputs at the same time if timelocks are
112 * similar, but only a signature for the input at index `input` should be signed for here.
113 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
114 * to an upcoming timelock expiration.
116 * `amount` is the value of the output spent by this input, committed to in the BIP 143
119 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
120 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
121 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
124 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
125 * (which is committed to in the BIP 143 signatures).
127 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
128 * signature and should be retried later. Once the signer is ready to provide a signature after
129 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
132 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
134 Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc);
136 * Computes the signature for a commitment transaction's HTLC output used as an input within
137 * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
138 * must be be computed using [`EcdsaSighashType::All`].
140 * Note that this may be called for HTLCs in the penultimate commitment transaction if a
141 * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
142 * broadcasts it before receiving the update for the latest commitment transaction.
144 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
145 * signature and should be retried later. Once the signer is ready to provide a signature after
146 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
149 * [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
150 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
151 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
153 Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, HTLCDescriptor htlc_descriptor);
155 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
156 * transaction, either offered or received.
158 * Such a transaction may claim multiples offered outputs at same time if we know the
159 * preimage for each when we create it, but only the input at index `input` should be
160 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
161 * needed with regards to an upcoming timelock expiration.
163 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
166 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
168 * `per_commitment_point` is the dynamic point corresponding to the channel state
169 * detected onchain. It has been generated by our counterparty and is used to derive
170 * channel state keys, which are then included in the witness script and committed to in the
173 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
174 * signature and should be retried later. Once the signer is ready to provide a signature after
175 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
178 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
180 Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc);
182 * Create a signature for a (proposed) closing transaction.
184 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
185 * chosen to forgo their output as dust.
187 Result_ECDSASignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
189 * Computes the signature for a commitment transaction's anchor output used as an
190 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
192 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
193 * signature and should be retried later. Once the signer is ready to provide a signature after
194 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
197 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
199 Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input);
201 * Signs a channel announcement message with our funding key proving it comes from one of the
202 * channel participants.
204 * Channel announcements also require a signature from each node's network key. Our node
205 * signature is computed through [`NodeSigner::sign_gossip_message`].
207 * Note that if this fails or is rejected, the channel will not be publicly announced and
208 * our counterparty may (though likely will not) close the channel on us for violating the
211 * [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
213 Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg);
215 private static class LDKEcdsaChannelSignerHolder { EcdsaChannelSigner held; }
216 public static EcdsaChannelSigner new_impl(EcdsaChannelSignerInterface arg, ChannelSigner.ChannelSignerInterface ChannelSigner_impl, ChannelPublicKeys pubkeys) {
217 final LDKEcdsaChannelSignerHolder impl_holder = new LDKEcdsaChannelSignerHolder();
218 impl_holder.held = new EcdsaChannelSigner(new bindings.LDKEcdsaChannelSigner() {
219 @Override public long sign_counterparty_commitment(long commitment_tx, byte[][] inbound_htlc_preimages, byte[][] outbound_htlc_preimages) {
220 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); }
221 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv, inbound_htlc_preimages, outbound_htlc_preimages);
222 Reference.reachabilityFence(arg);
223 long result = ret.clone_ptr();
226 @Override public long sign_holder_commitment(long commitment_tx) {
227 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); }
228 Result_ECDSASignatureNoneZ ret = arg.sign_holder_commitment(commitment_tx_hu_conv);
229 Reference.reachabilityFence(arg);
230 long result = ret.clone_ptr();
233 @Override public long sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
234 Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_output(justice_tx, input, amount, per_commitment_key);
235 Reference.reachabilityFence(arg);
236 long result = ret.clone_ptr();
239 @Override public long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) {
240 org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); }
241 Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc_hu_conv);
242 Reference.reachabilityFence(arg);
243 long result = ret.clone_ptr();
246 @Override public long sign_holder_htlc_transaction(byte[] htlc_tx, long input, long htlc_descriptor) {
247 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); }
248 Result_ECDSASignatureNoneZ ret = arg.sign_holder_htlc_transaction(htlc_tx, input, htlc_descriptor_hu_conv);
249 Reference.reachabilityFence(arg);
250 long result = ret.clone_ptr();
253 @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) {
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, input, amount, per_commitment_point, htlc_hu_conv);
256 Reference.reachabilityFence(arg);
257 long result = ret.clone_ptr();
260 @Override 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);
263 Reference.reachabilityFence(arg);
264 long result = ret.clone_ptr();
267 @Override public long sign_holder_anchor_input(byte[] anchor_tx, long input) {
268 Result_ECDSASignatureNoneZ ret = arg.sign_holder_anchor_input(anchor_tx, input);
269 Reference.reachabilityFence(arg);
270 long result = ret.clone_ptr();
273 @Override public long sign_channel_announcement_with_funding_key(long msg) {
274 org.ldk.structs.UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, msg); }
275 Result_ECDSASignatureNoneZ ret = arg.sign_channel_announcement_with_funding_key(msg_hu_conv);
276 Reference.reachabilityFence(arg);
277 long result = ret.clone_ptr();
280 }, ChannelSigner.new_impl(ChannelSigner_impl, pubkeys).bindings_instance, pubkeys);
281 return impl_holder.held;
285 * Gets the underlying ChannelSigner.
287 public ChannelSigner get_channel_signer() {
288 ChannelSigner res = new ChannelSigner(null, bindings.LDKEcdsaChannelSigner_get_ChannelSigner(this.ptr));
289 res.ptrs_to.add(this);
294 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
296 * Note that if signing fails or is rejected, the channel will be force-closed.
298 * Policy checks should be implemented in this function, including checking the amount
299 * sent to us and checking the HTLCs.
301 * The preimages of outbound and inbound HTLCs that were fulfilled since the last commitment
302 * are provided. A validating signer should ensure that an outbound HTLC output is removed
303 * only when the matching preimage is provided and after the corresponding inbound HTLC has
304 * been removed for forwarded payments.
306 * Note that all the relevant preimages will be provided, but there may also be additional
307 * irrelevant or duplicate preimages.
309 public Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] inbound_htlc_preimages, byte[][] outbound_htlc_preimages) {
310 long ret = bindings.EcdsaChannelSigner_sign_counterparty_commitment(this.ptr, commitment_tx.ptr, inbound_htlc_preimages != null ? Arrays.stream(inbound_htlc_preimages).map(inbound_htlc_preimages_conv_8 -> InternalUtils.check_arr_len(inbound_htlc_preimages_conv_8, 32)).toArray(byte[][]::new) : null, outbound_htlc_preimages != null ? Arrays.stream(outbound_htlc_preimages).map(outbound_htlc_preimages_conv_8 -> InternalUtils.check_arr_len(outbound_htlc_preimages_conv_8, 32)).toArray(byte[][]::new) : null);
311 Reference.reachabilityFence(this);
312 Reference.reachabilityFence(commitment_tx);
313 Reference.reachabilityFence(inbound_htlc_preimages);
314 Reference.reachabilityFence(outbound_htlc_preimages);
315 if (ret >= 0 && ret <= 4096) { return null; }
316 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_hu_conv = Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.constr_from_ptr(ret);
317 if (this != null) { this.ptrs_to.add(commitment_tx); };
322 * Creates a signature for a holder's commitment transaction.
324 * This will be called
325 * - with a non-revoked `commitment_tx`.
326 * - with the latest `commitment_tx` when we initiate a force-close.
328 * This may be called multiple times for the same transaction.
330 * An external signer implementation should check that the commitment has not been revoked.
332 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
333 * signature and should be retried later. Once the signer is ready to provide a signature after
334 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
337 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
339 public Result_ECDSASignatureNoneZ sign_holder_commitment(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
340 long ret = bindings.EcdsaChannelSigner_sign_holder_commitment(this.ptr, commitment_tx.ptr);
341 Reference.reachabilityFence(this);
342 Reference.reachabilityFence(commitment_tx);
343 if (ret >= 0 && ret <= 4096) { return null; }
344 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
345 if (this != null) { this.ptrs_to.add(commitment_tx); };
350 * Create a signature for the given input in a transaction spending an HTLC transaction output
351 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
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.
358 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
360 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
361 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
362 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
365 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
366 * signature and should be retried later. Once the signer is ready to provide a signature after
367 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
370 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
372 public Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
373 long ret = bindings.EcdsaChannelSigner_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32));
374 Reference.reachabilityFence(this);
375 Reference.reachabilityFence(justice_tx);
376 Reference.reachabilityFence(input);
377 Reference.reachabilityFence(amount);
378 Reference.reachabilityFence(per_commitment_key);
379 if (ret >= 0 && ret <= 4096) { return null; }
380 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
385 * Create a signature for the given input in a transaction spending a commitment transaction
386 * HTLC output when our counterparty broadcasts an old state.
388 * A justice transaction may claim multiple outputs at the same time if timelocks are
389 * similar, but only a signature for the input at index `input` should be signed for here.
390 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
391 * to an upcoming timelock expiration.
393 * `amount` is the value of the output spent by this input, committed to in the BIP 143
396 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
397 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
398 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
401 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
402 * (which is committed to in the BIP 143 signatures).
404 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
405 * signature and should be retried later. Once the signer is ready to provide a signature after
406 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
409 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
411 public Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
412 long ret = bindings.EcdsaChannelSigner_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32), htlc.ptr);
413 Reference.reachabilityFence(this);
414 Reference.reachabilityFence(justice_tx);
415 Reference.reachabilityFence(input);
416 Reference.reachabilityFence(amount);
417 Reference.reachabilityFence(per_commitment_key);
418 Reference.reachabilityFence(htlc);
419 if (ret >= 0 && ret <= 4096) { return null; }
420 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
421 if (this != null) { this.ptrs_to.add(htlc); };
426 * Computes the signature for a commitment transaction's HTLC output used as an input within
427 * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
428 * must be be computed using [`EcdsaSighashType::All`].
430 * Note that this may be called for HTLCs in the penultimate commitment transaction if a
431 * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
432 * broadcasts it before receiving the update for the latest commitment transaction.
434 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
435 * signature and should be retried later. Once the signer is ready to provide a signature after
436 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
439 * [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
440 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
441 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
443 public Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, org.ldk.structs.HTLCDescriptor htlc_descriptor) {
444 long ret = bindings.EcdsaChannelSigner_sign_holder_htlc_transaction(this.ptr, htlc_tx, input, htlc_descriptor.ptr);
445 Reference.reachabilityFence(this);
446 Reference.reachabilityFence(htlc_tx);
447 Reference.reachabilityFence(input);
448 Reference.reachabilityFence(htlc_descriptor);
449 if (ret >= 0 && ret <= 4096) { return null; }
450 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
451 if (this != null) { this.ptrs_to.add(htlc_descriptor); };
456 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
457 * transaction, either offered or received.
459 * Such a transaction may claim multiples offered outputs at same time if we know the
460 * preimage for each when we create it, but only the input at index `input` should be
461 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
462 * needed with regards to an upcoming timelock expiration.
464 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
467 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
469 * `per_commitment_point` is the dynamic point corresponding to the channel state
470 * detected onchain. It has been generated by our counterparty and is used to derive
471 * channel state keys, which are then included in the witness script and committed to in the
474 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
475 * signature and should be retried later. Once the signer is ready to provide a signature after
476 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
479 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
481 public Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
482 long ret = bindings.EcdsaChannelSigner_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, InternalUtils.check_arr_len(per_commitment_point, 33), htlc.ptr);
483 Reference.reachabilityFence(this);
484 Reference.reachabilityFence(htlc_tx);
485 Reference.reachabilityFence(input);
486 Reference.reachabilityFence(amount);
487 Reference.reachabilityFence(per_commitment_point);
488 Reference.reachabilityFence(htlc);
489 if (ret >= 0 && ret <= 4096) { return null; }
490 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
491 if (this != null) { this.ptrs_to.add(htlc); };
496 * Create a signature for a (proposed) closing transaction.
498 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
499 * chosen to forgo their output as dust.
501 public Result_ECDSASignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
502 long ret = bindings.EcdsaChannelSigner_sign_closing_transaction(this.ptr, closing_tx.ptr);
503 Reference.reachabilityFence(this);
504 Reference.reachabilityFence(closing_tx);
505 if (ret >= 0 && ret <= 4096) { return null; }
506 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
507 if (this != null) { this.ptrs_to.add(closing_tx); };
512 * Computes the signature for a commitment transaction's anchor output used as an
513 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
515 * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
516 * signature and should be retried later. Once the signer is ready to provide a signature after
517 * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
520 * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
522 public Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
523 long ret = bindings.EcdsaChannelSigner_sign_holder_anchor_input(this.ptr, anchor_tx, input);
524 Reference.reachabilityFence(this);
525 Reference.reachabilityFence(anchor_tx);
526 Reference.reachabilityFence(input);
527 if (ret >= 0 && ret <= 4096) { return null; }
528 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
533 * Signs a channel announcement message with our funding key proving it comes from one of the
534 * channel participants.
536 * Channel announcements also require a signature from each node's network key. Our node
537 * signature is computed through [`NodeSigner::sign_gossip_message`].
539 * Note that if this fails or is rejected, the channel will not be publicly announced and
540 * our counterparty may (though likely will not) close the channel on us for violating the
543 * [`NodeSigner::sign_gossip_message`]: crate::sign::NodeSigner::sign_gossip_message
545 public Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(org.ldk.structs.UnsignedChannelAnnouncement msg) {
546 long ret = bindings.EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this.ptr, msg.ptr);
547 Reference.reachabilityFence(this);
548 Reference.reachabilityFence(msg);
549 if (ret >= 0 && ret <= 4096) { return null; }
550 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
551 if (this != null) { this.ptrs_to.add(msg); };