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 == null ? 0 : 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 outgoing HTLCs that were fulfilled since the last commitment are provided.
56 * A validating signer should ensure that an HTLC output is removed only when the matching
57 * preimage is provided, or when the value to holder is restored.
59 * Note that all the relevant preimages will be provided, but there may also be additional
60 * irrelevant or duplicate preimages.
62 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages);
64 * Validate the counterparty's revocation.
66 * This is required in order for the signer to make sure that the state has moved
67 * forward and it is safe to sign the next counterparty commitment.
69 Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret);
71 * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
74 * - with a non-revoked `commitment_tx`.
75 * - with the latest `commitment_tx` when we initiate a force-close.
76 * - with the previous `commitment_tx`, just to get claiming HTLC
77 * signatures, if we are reacting to a [`ChannelMonitor`]
78 * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
79 * that decided to broadcast before it had been updated to the latest `commitment_tx`.
81 * This may be called multiple times for the same transaction.
83 * An external signer implementation should check that the commitment has not been revoked.
85 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
87 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx);
89 * Create a signature for the given input in a transaction spending an HTLC transaction output
90 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
92 * A justice transaction may claim multiple outputs at the same time if timelocks are
93 * similar, but only a signature for the input at index `input` should be signed for here.
94 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
95 * to an upcoming timelock expiration.
97 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
99 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
100 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
101 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
104 Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key);
106 * Create a signature for the given input in a transaction spending a commitment transaction
107 * HTLC output when our counterparty broadcasts an old state.
109 * A justice transaction may claim multiple outputs at the same time if timelocks are
110 * similar, but only a signature for the input at index `input` should be signed for here.
111 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
112 * to an upcoming timelock expiration.
114 * `amount` is the value of the output spent by this input, committed to in the BIP 143
117 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
118 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
119 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
122 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
123 * (which is committed to in the BIP 143 signatures).
125 Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc);
127 * Computes the signature for a commitment transaction's HTLC output used as an input within
128 * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
129 * must be be computed using [`EcdsaSighashType::All`]. Note that this should only be used to
130 * sign HTLC transactions from channels supporting anchor outputs after all additional
131 * inputs/outputs have been added to the transaction.
133 * [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
135 Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, HTLCDescriptor htlc_descriptor);
137 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
138 * transaction, either offered or received.
140 * Such a transaction may claim multiples offered outputs at same time if we know the
141 * preimage for each when we create it, but only the input at index `input` should be
142 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
143 * needed with regards to an upcoming timelock expiration.
145 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
148 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
150 * `per_commitment_point` is the dynamic point corresponding to the channel state
151 * detected onchain. It has been generated by our counterparty and is used to derive
152 * channel state keys, which are then included in the witness script and committed to in the
155 Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc);
157 * Create a signature for a (proposed) closing transaction.
159 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
160 * chosen to forgo their output as dust.
162 Result_ECDSASignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
164 * Computes the signature for a commitment transaction's anchor output used as an
165 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
167 Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input);
169 * Signs a channel announcement message with our funding key proving it comes from one of the
170 * channel participants.
172 * Channel announcements also require a signature from each node's network key. Our node
173 * signature is computed through [`NodeSigner::sign_gossip_message`].
175 * Note that if this fails or is rejected, the channel will not be publicly announced and
176 * our counterparty may (though likely will not) close the channel on us for violating the
179 Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg);
181 private static class LDKEcdsaChannelSignerHolder { EcdsaChannelSigner held; }
182 public static EcdsaChannelSigner new_impl(EcdsaChannelSignerInterface arg, ChannelSigner.ChannelSignerInterface ChannelSigner_impl, ChannelPublicKeys pubkeys) {
183 final LDKEcdsaChannelSignerHolder impl_holder = new LDKEcdsaChannelSignerHolder();
184 impl_holder.held = new EcdsaChannelSigner(new bindings.LDKEcdsaChannelSigner() {
185 @Override public long sign_counterparty_commitment(long commitment_tx, byte[][] preimages) {
186 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); }
187 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv, preimages);
188 Reference.reachabilityFence(arg);
189 long result = ret == null ? 0 : ret.clone_ptr();
192 @Override public long validate_counterparty_revocation(long idx, byte[] secret) {
193 Result_NoneNoneZ ret = arg.validate_counterparty_revocation(idx, secret);
194 Reference.reachabilityFence(arg);
195 long result = ret == null ? 0 : ret.clone_ptr();
198 @Override public long sign_holder_commitment_and_htlcs(long commitment_tx) {
199 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); }
200 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv);
201 Reference.reachabilityFence(arg);
202 long result = ret == null ? 0 : ret.clone_ptr();
205 @Override public long sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
206 Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_output(justice_tx, input, amount, per_commitment_key);
207 Reference.reachabilityFence(arg);
208 long result = ret == null ? 0 : ret.clone_ptr();
211 @Override public long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) {
212 org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); }
213 Result_ECDSASignatureNoneZ ret = arg.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc_hu_conv);
214 Reference.reachabilityFence(arg);
215 long result = ret == null ? 0 : ret.clone_ptr();
218 @Override public long sign_holder_htlc_transaction(byte[] htlc_tx, long input, long htlc_descriptor) {
219 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); }
220 Result_ECDSASignatureNoneZ ret = arg.sign_holder_htlc_transaction(htlc_tx, input, htlc_descriptor_hu_conv);
221 Reference.reachabilityFence(arg);
222 long result = ret == null ? 0 : ret.clone_ptr();
225 @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) {
226 org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); }
227 Result_ECDSASignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv);
228 Reference.reachabilityFence(arg);
229 long result = ret == null ? 0 : ret.clone_ptr();
232 @Override public long sign_closing_transaction(long closing_tx) {
233 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); }
234 Result_ECDSASignatureNoneZ ret = arg.sign_closing_transaction(closing_tx_hu_conv);
235 Reference.reachabilityFence(arg);
236 long result = ret == null ? 0 : ret.clone_ptr();
239 @Override public long sign_holder_anchor_input(byte[] anchor_tx, long input) {
240 Result_ECDSASignatureNoneZ ret = arg.sign_holder_anchor_input(anchor_tx, input);
241 Reference.reachabilityFence(arg);
242 long result = ret == null ? 0 : ret.clone_ptr();
245 @Override public long sign_channel_announcement_with_funding_key(long msg) {
246 org.ldk.structs.UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, msg); }
247 Result_ECDSASignatureNoneZ ret = arg.sign_channel_announcement_with_funding_key(msg_hu_conv);
248 Reference.reachabilityFence(arg);
249 long result = ret == null ? 0 : ret.clone_ptr();
252 }, ChannelSigner.new_impl(ChannelSigner_impl, pubkeys).bindings_instance, pubkeys);
253 return impl_holder.held;
257 * Gets the underlying ChannelSigner.
259 public ChannelSigner get_channel_signer() {
260 ChannelSigner res = new ChannelSigner(null, bindings.LDKEcdsaChannelSigner_get_ChannelSigner(this.ptr));
261 res.ptrs_to.add(this);
266 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
268 * Note that if signing fails or is rejected, the channel will be force-closed.
270 * Policy checks should be implemented in this function, including checking the amount
271 * sent to us and checking the HTLCs.
273 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
274 * A validating signer should ensure that an HTLC output is removed only when the matching
275 * preimage is provided, or when the value to holder is restored.
277 * Note that all the relevant preimages will be provided, but there may also be additional
278 * irrelevant or duplicate preimages.
280 public Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] preimages) {
281 long ret = bindings.EcdsaChannelSigner_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null);
282 Reference.reachabilityFence(this);
283 Reference.reachabilityFence(commitment_tx);
284 Reference.reachabilityFence(preimages);
285 if (ret >= 0 && ret <= 4096) { return null; }
286 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_hu_conv = Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.constr_from_ptr(ret);
287 if (this != null) { this.ptrs_to.add(commitment_tx); };
292 * Validate the counterparty's revocation.
294 * This is required in order for the signer to make sure that the state has moved
295 * forward and it is safe to sign the next counterparty commitment.
297 public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
298 long ret = bindings.EcdsaChannelSigner_validate_counterparty_revocation(this.ptr, idx, InternalUtils.check_arr_len(secret, 32));
299 Reference.reachabilityFence(this);
300 Reference.reachabilityFence(idx);
301 Reference.reachabilityFence(secret);
302 if (ret >= 0 && ret <= 4096) { return null; }
303 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
308 * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
310 * This will be called
311 * - with a non-revoked `commitment_tx`.
312 * - with the latest `commitment_tx` when we initiate a force-close.
313 * - with the previous `commitment_tx`, just to get claiming HTLC
314 * signatures, if we are reacting to a [`ChannelMonitor`]
315 * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
316 * that decided to broadcast before it had been updated to the latest `commitment_tx`.
318 * This may be called multiple times for the same transaction.
320 * An external signer implementation should check that the commitment has not been revoked.
322 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
324 public Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_holder_commitment_and_htlcs(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
325 long ret = bindings.EcdsaChannelSigner_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr);
326 Reference.reachabilityFence(this);
327 Reference.reachabilityFence(commitment_tx);
328 if (ret >= 0 && ret <= 4096) { return null; }
329 Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_hu_conv = Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.constr_from_ptr(ret);
330 if (this != null) { this.ptrs_to.add(commitment_tx); };
335 * Create a signature for the given input in a transaction spending an HTLC transaction output
336 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
338 * A justice transaction may claim multiple outputs at the same time if timelocks are
339 * similar, but only a signature for the input at index `input` should be signed for here.
340 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
341 * to an upcoming timelock expiration.
343 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
345 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
346 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
347 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
350 public Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
351 long ret = bindings.EcdsaChannelSigner_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32));
352 Reference.reachabilityFence(this);
353 Reference.reachabilityFence(justice_tx);
354 Reference.reachabilityFence(input);
355 Reference.reachabilityFence(amount);
356 Reference.reachabilityFence(per_commitment_key);
357 if (ret >= 0 && ret <= 4096) { return null; }
358 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
363 * Create a signature for the given input in a transaction spending a commitment transaction
364 * HTLC output when our counterparty broadcasts an old state.
366 * A justice transaction may claim multiple outputs at the same time if timelocks are
367 * similar, but only a signature for the input at index `input` should be signed for here.
368 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
369 * to an upcoming timelock expiration.
371 * `amount` is the value of the output spent by this input, committed to in the BIP 143
374 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
375 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
376 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
379 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
380 * (which is committed to in the BIP 143 signatures).
382 public Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
383 long ret = bindings.EcdsaChannelSigner_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32), htlc == null ? 0 : htlc.ptr);
384 Reference.reachabilityFence(this);
385 Reference.reachabilityFence(justice_tx);
386 Reference.reachabilityFence(input);
387 Reference.reachabilityFence(amount);
388 Reference.reachabilityFence(per_commitment_key);
389 Reference.reachabilityFence(htlc);
390 if (ret >= 0 && ret <= 4096) { return null; }
391 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
392 if (this != null) { this.ptrs_to.add(htlc); };
397 * Computes the signature for a commitment transaction's HTLC output used as an input within
398 * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned
399 * must be be computed using [`EcdsaSighashType::All`]. Note that this should only be used to
400 * sign HTLC transactions from channels supporting anchor outputs after all additional
401 * inputs/outputs have been added to the transaction.
403 * [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All
405 public Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, org.ldk.structs.HTLCDescriptor htlc_descriptor) {
406 long ret = bindings.EcdsaChannelSigner_sign_holder_htlc_transaction(this.ptr, htlc_tx, input, htlc_descriptor == null ? 0 : htlc_descriptor.ptr);
407 Reference.reachabilityFence(this);
408 Reference.reachabilityFence(htlc_tx);
409 Reference.reachabilityFence(input);
410 Reference.reachabilityFence(htlc_descriptor);
411 if (ret >= 0 && ret <= 4096) { return null; }
412 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
413 if (this != null) { this.ptrs_to.add(htlc_descriptor); };
418 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
419 * transaction, either offered or received.
421 * Such a transaction may claim multiples offered outputs at same time if we know the
422 * preimage for each when we create it, but only the input at index `input` should be
423 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
424 * needed with regards to an upcoming timelock expiration.
426 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
429 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
431 * `per_commitment_point` is the dynamic point corresponding to the channel state
432 * detected onchain. It has been generated by our counterparty and is used to derive
433 * channel state keys, which are then included in the witness script and committed to in the
436 public Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
437 long ret = bindings.EcdsaChannelSigner_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, InternalUtils.check_arr_len(per_commitment_point, 33), htlc == null ? 0 : htlc.ptr);
438 Reference.reachabilityFence(this);
439 Reference.reachabilityFence(htlc_tx);
440 Reference.reachabilityFence(input);
441 Reference.reachabilityFence(amount);
442 Reference.reachabilityFence(per_commitment_point);
443 Reference.reachabilityFence(htlc);
444 if (ret >= 0 && ret <= 4096) { return null; }
445 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
446 if (this != null) { this.ptrs_to.add(htlc); };
451 * Create a signature for a (proposed) closing transaction.
453 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
454 * chosen to forgo their output as dust.
456 public Result_ECDSASignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
457 long ret = bindings.EcdsaChannelSigner_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr);
458 Reference.reachabilityFence(this);
459 Reference.reachabilityFence(closing_tx);
460 if (ret >= 0 && ret <= 4096) { return null; }
461 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
462 if (this != null) { this.ptrs_to.add(closing_tx); };
467 * Computes the signature for a commitment transaction's anchor output used as an
468 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
470 public Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
471 long ret = bindings.EcdsaChannelSigner_sign_holder_anchor_input(this.ptr, anchor_tx, input);
472 Reference.reachabilityFence(this);
473 Reference.reachabilityFence(anchor_tx);
474 Reference.reachabilityFence(input);
475 if (ret >= 0 && ret <= 4096) { return null; }
476 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
481 * Signs a channel announcement message with our funding key proving it comes from one of the
482 * channel participants.
484 * Channel announcements also require a signature from each node's network key. Our node
485 * signature is computed through [`NodeSigner::sign_gossip_message`].
487 * Note that if this fails or is rejected, the channel will not be publicly announced and
488 * our counterparty may (though likely will not) close the channel on us for violating the
491 public Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(org.ldk.structs.UnsignedChannelAnnouncement msg) {
492 long ret = bindings.EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this.ptr, msg == null ? 0 : msg.ptr);
493 Reference.reachabilityFence(this);
494 Reference.reachabilityFence(msg);
495 if (ret >= 0 && ret <= 4096) { return null; }
496 Result_ECDSASignatureNoneZ ret_hu_conv = Result_ECDSASignatureNoneZ.constr_from_ptr(ret);
497 if (this != null) { this.ptrs_to.add(msg); };