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 BaseSign extends CommonBase {
21 final bindings.LDKBaseSign bindings_instance;
22 BaseSign(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
23 private BaseSign(bindings.LDKBaseSign arg, ChannelPublicKeys pubkeys) {
24 super(bindings.LDKBaseSign_new(arg, pubkeys == null ? 0 : pubkeys.clone_ptr()));
25 this.ptrs_to.add(arg);
26 this.bindings_instance = arg;
28 @Override @SuppressWarnings("deprecation")
29 protected void finalize() throws Throwable {
30 if (ptr != 0) { bindings.BaseSign_free(ptr); } super.finalize();
33 public static interface BaseSignInterface {
35 * Gets the per-commitment point for a specific commitment number
37 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
39 byte[] get_per_commitment_point(long idx);
41 * Gets the commitment secret for a specific commitment number as part of the revocation process
43 * An external signer implementation should error here if the commitment was already signed
44 * and should refuse to sign it in the future.
46 * May be called more than once for the same index.
48 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
50 byte[] release_commitment_secret(long idx);
52 * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
54 * This is required in order for the signer to make sure that releasing a commitment
55 * secret won't leave us without a broadcastable holder transaction.
56 * Policy checks should be implemented in this function, including checking the amount
57 * sent to us and checking the HTLCs.
59 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
60 * A validating signer should ensure that an HTLC output is removed only when the matching
61 * preimage is provided, or when the value to holder is restored.
63 * Note that all the relevant preimages will be provided, but there may also be additional
64 * irrelevant or duplicate preimages.
66 Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages);
68 * Returns an arbitrary identifier describing the set of keys which are provided back to you in
69 * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
70 * [`BaseSign`] object uniquely and lookup or re-derive its keys.
72 byte[] channel_keys_id();
74 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
76 * Note that if signing fails or is rejected, the channel will be force-closed.
78 * Policy checks should be implemented in this function, including checking the amount
79 * sent to us and checking the HTLCs.
81 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
82 * A validating signer should ensure that an HTLC output is removed only when the matching
83 * preimage is provided, or when the value to holder is restored.
85 * Note that all the relevant preimages will be provided, but there may also be additional
86 * irrelevant or duplicate preimages.
88 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages);
90 * Validate the counterparty's revocation.
92 * This is required in order for the signer to make sure that the state has moved
93 * forward and it is safe to sign the next counterparty commitment.
95 Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret);
97 * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
100 * - with a non-revoked `commitment_tx`.
101 * - with the latest `commitment_tx` when we initiate a force-close.
102 * - with the previous `commitment_tx`, just to get claiming HTLC
103 * signatures, if we are reacting to a [`ChannelMonitor`]
104 * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
105 * that decided to broadcast before it had been updated to the latest `commitment_tx`.
107 * This may be called multiple times for the same transaction.
109 * An external signer implementation should check that the commitment has not been revoked.
111 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
113 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx);
115 * Create a signature for the given input in a transaction spending an HTLC transaction output
116 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
118 * A justice transaction may claim multiple outputs at the same time if timelocks are
119 * similar, but only a signature for the input at index `input` should be signed for here.
120 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
121 * to an upcoming timelock expiration.
123 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
125 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
126 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
127 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
130 Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key);
132 * Create a signature for the given input in a transaction spending a commitment transaction
133 * HTLC output when our counterparty broadcasts an old state.
135 * A justice transaction may claim multiple outputs at the same time if timelocks are
136 * similar, but only a signature for the input at index `input` should be signed for here.
137 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
138 * to an upcoming timelock expiration.
140 * `amount` is the value of the output spent by this input, committed to in the BIP 143
143 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
144 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
145 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
148 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
149 * (which is committed to in the BIP 143 signatures).
151 Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc);
153 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
154 * transaction, either offered or received.
156 * Such a transaction may claim multiples offered outputs at same time if we know the
157 * preimage for each when we create it, but only the input at index `input` should be
158 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
159 * needed with regards to an upcoming timelock expiration.
161 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
164 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
166 * `per_commitment_point` is the dynamic point corresponding to the channel state
167 * detected onchain. It has been generated by our counterparty and is used to derive
168 * channel state keys, which are then included in the witness script and committed to in the
171 Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc);
173 * Create a signature for a (proposed) closing transaction.
175 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
176 * chosen to forgo their output as dust.
178 Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
180 * Computes the signature for a commitment transaction's anchor output used as an
181 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
183 Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input);
185 * Signs a channel announcement message with our funding key and our node secret key (aka
186 * node_id or network_key), proving it comes from one of the channel participants.
188 * The first returned signature should be from our node secret key, the second from our
191 * Note that if this fails or is rejected, the channel will not be publicly announced and
192 * our counterparty may (though likely will not) close the channel on us for violating the
195 Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg);
197 * Set the counterparty static channel data, including basepoints,
198 * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. Since these
199 * are static channel data, they MUST NOT be allowed to change to different values once set,
200 * as LDK may call this method more than once.
202 * channel_parameters.is_populated() MUST be true.
204 void provide_channel_parameters(ChannelTransactionParameters channel_parameters);
206 private static class LDKBaseSignHolder { BaseSign held; }
207 public static BaseSign new_impl(BaseSignInterface arg, ChannelPublicKeys pubkeys) {
208 final LDKBaseSignHolder impl_holder = new LDKBaseSignHolder();
209 impl_holder.held = new BaseSign(new bindings.LDKBaseSign() {
210 @Override public byte[] get_per_commitment_point(long idx) {
211 byte[] ret = arg.get_per_commitment_point(idx);
212 Reference.reachabilityFence(arg);
213 byte[] result = InternalUtils.check_arr_len(ret, 33);
216 @Override public byte[] release_commitment_secret(long idx) {
217 byte[] ret = arg.release_commitment_secret(idx);
218 Reference.reachabilityFence(arg);
219 byte[] result = InternalUtils.check_arr_len(ret, 32);
222 @Override public long validate_holder_commitment(long holder_tx, byte[][] preimages) {
223 org.ldk.structs.HolderCommitmentTransaction holder_tx_hu_conv = null; if (holder_tx < 0 || holder_tx > 4096) { holder_tx_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, holder_tx); }
224 Result_NoneNoneZ ret = arg.validate_holder_commitment(holder_tx_hu_conv, preimages);
225 Reference.reachabilityFence(arg);
226 long result = ret == null ? 0 : ret.clone_ptr();
229 @Override public byte[] channel_keys_id() {
230 byte[] ret = arg.channel_keys_id();
231 Reference.reachabilityFence(arg);
232 byte[] result = InternalUtils.check_arr_len(ret, 32);
235 @Override public long sign_counterparty_commitment(long commitment_tx, byte[][] preimages) {
236 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); }
237 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv, preimages);
238 Reference.reachabilityFence(arg);
239 long result = ret == null ? 0 : ret.clone_ptr();
242 @Override public long validate_counterparty_revocation(long idx, byte[] secret) {
243 Result_NoneNoneZ ret = arg.validate_counterparty_revocation(idx, secret);
244 Reference.reachabilityFence(arg);
245 long result = ret == null ? 0 : ret.clone_ptr();
248 @Override public long sign_holder_commitment_and_htlcs(long commitment_tx) {
249 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); }
250 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv);
251 Reference.reachabilityFence(arg);
252 long result = ret == null ? 0 : ret.clone_ptr();
255 @Override public long sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
256 Result_SignatureNoneZ ret = arg.sign_justice_revoked_output(justice_tx, input, amount, per_commitment_key);
257 Reference.reachabilityFence(arg);
258 long result = ret == null ? 0 : ret.clone_ptr();
261 @Override public long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) {
262 org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); }
263 Result_SignatureNoneZ ret = arg.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc_hu_conv);
264 Reference.reachabilityFence(arg);
265 long result = ret == null ? 0 : ret.clone_ptr();
268 @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) {
269 org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); }
270 Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv);
271 Reference.reachabilityFence(arg);
272 long result = ret == null ? 0 : ret.clone_ptr();
275 @Override public long sign_closing_transaction(long closing_tx) {
276 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); }
277 Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx_hu_conv);
278 Reference.reachabilityFence(arg);
279 long result = ret == null ? 0 : ret.clone_ptr();
282 @Override public long sign_holder_anchor_input(byte[] anchor_tx, long input) {
283 Result_SignatureNoneZ ret = arg.sign_holder_anchor_input(anchor_tx, input);
284 Reference.reachabilityFence(arg);
285 long result = ret == null ? 0 : ret.clone_ptr();
288 @Override public long sign_channel_announcement(long msg) {
289 org.ldk.structs.UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, msg); }
290 Result_C2Tuple_SignatureSignatureZNoneZ ret = arg.sign_channel_announcement(msg_hu_conv);
291 Reference.reachabilityFence(arg);
292 long result = ret == null ? 0 : ret.clone_ptr();
295 @Override public void provide_channel_parameters(long channel_parameters) {
296 org.ldk.structs.ChannelTransactionParameters channel_parameters_hu_conv = null; if (channel_parameters < 0 || channel_parameters > 4096) { channel_parameters_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, channel_parameters); }
297 arg.provide_channel_parameters(channel_parameters_hu_conv);
298 Reference.reachabilityFence(arg);
301 return impl_holder.held;
304 * Gets the per-commitment point for a specific commitment number
306 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
308 public byte[] get_per_commitment_point(long idx) {
309 byte[] ret = bindings.BaseSign_get_per_commitment_point(this.ptr, idx);
310 Reference.reachabilityFence(this);
311 Reference.reachabilityFence(idx);
316 * Gets the commitment secret for a specific commitment number as part of the revocation process
318 * An external signer implementation should error here if the commitment was already signed
319 * and should refuse to sign it in the future.
321 * May be called more than once for the same index.
323 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
325 public byte[] release_commitment_secret(long idx) {
326 byte[] ret = bindings.BaseSign_release_commitment_secret(this.ptr, idx);
327 Reference.reachabilityFence(this);
328 Reference.reachabilityFence(idx);
333 * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
335 * This is required in order for the signer to make sure that releasing a commitment
336 * secret won't leave us without a broadcastable holder transaction.
337 * Policy checks should be implemented in this function, including checking the amount
338 * sent to us and checking the HTLCs.
340 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
341 * A validating signer should ensure that an HTLC output is removed only when the matching
342 * preimage is provided, or when the value to holder is restored.
344 * Note that all the relevant preimages will be provided, but there may also be additional
345 * irrelevant or duplicate preimages.
347 public Result_NoneNoneZ validate_holder_commitment(org.ldk.structs.HolderCommitmentTransaction holder_tx, byte[][] preimages) {
348 long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null);
349 Reference.reachabilityFence(this);
350 Reference.reachabilityFence(holder_tx);
351 Reference.reachabilityFence(preimages);
352 if (ret >= 0 && ret <= 4096) { return null; }
353 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
354 if (this != null) { this.ptrs_to.add(holder_tx); };
359 * Returns an arbitrary identifier describing the set of keys which are provided back to you in
360 * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
361 * [`BaseSign`] object uniquely and lookup or re-derive its keys.
363 public byte[] channel_keys_id() {
364 byte[] ret = bindings.BaseSign_channel_keys_id(this.ptr);
365 Reference.reachabilityFence(this);
370 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
372 * Note that if signing fails or is rejected, the channel will be force-closed.
374 * Policy checks should be implemented in this function, including checking the amount
375 * sent to us and checking the HTLCs.
377 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
378 * A validating signer should ensure that an HTLC output is removed only when the matching
379 * preimage is provided, or when the value to holder is restored.
381 * Note that all the relevant preimages will be provided, but there may also be additional
382 * irrelevant or duplicate preimages.
384 public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] preimages) {
385 long ret = bindings.BaseSign_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);
386 Reference.reachabilityFence(this);
387 Reference.reachabilityFence(commitment_tx);
388 Reference.reachabilityFence(preimages);
389 if (ret >= 0 && ret <= 4096) { return null; }
390 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
391 if (this != null) { this.ptrs_to.add(commitment_tx); };
396 * Validate the counterparty's revocation.
398 * This is required in order for the signer to make sure that the state has moved
399 * forward and it is safe to sign the next counterparty commitment.
401 public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
402 long ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, InternalUtils.check_arr_len(secret, 32));
403 Reference.reachabilityFence(this);
404 Reference.reachabilityFence(idx);
405 Reference.reachabilityFence(secret);
406 if (ret >= 0 && ret <= 4096) { return null; }
407 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
412 * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
414 * This will be called
415 * - with a non-revoked `commitment_tx`.
416 * - with the latest `commitment_tx` when we initiate a force-close.
417 * - with the previous `commitment_tx`, just to get claiming HTLC
418 * signatures, if we are reacting to a [`ChannelMonitor`]
419 * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
420 * that decided to broadcast before it had been updated to the latest `commitment_tx`.
422 * This may be called multiple times for the same transaction.
424 * An external signer implementation should check that the commitment has not been revoked.
426 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
428 public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
429 long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr);
430 Reference.reachabilityFence(this);
431 Reference.reachabilityFence(commitment_tx);
432 if (ret >= 0 && ret <= 4096) { return null; }
433 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
434 if (this != null) { this.ptrs_to.add(commitment_tx); };
439 * Create a signature for the given input in a transaction spending an HTLC transaction output
440 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
442 * A justice transaction may claim multiple outputs at the same time if timelocks are
443 * similar, but only a signature for the input at index `input` should be signed for here.
444 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
445 * to an upcoming timelock expiration.
447 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
449 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
450 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
451 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
454 public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
455 long ret = bindings.BaseSign_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32));
456 Reference.reachabilityFence(this);
457 Reference.reachabilityFence(justice_tx);
458 Reference.reachabilityFence(input);
459 Reference.reachabilityFence(amount);
460 Reference.reachabilityFence(per_commitment_key);
461 if (ret >= 0 && ret <= 4096) { return null; }
462 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
467 * Create a signature for the given input in a transaction spending a commitment transaction
468 * HTLC output when our counterparty broadcasts an old state.
470 * A justice transaction may claim multiple outputs at the same time if timelocks are
471 * similar, but only a signature for the input at index `input` should be signed for here.
472 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
473 * to an upcoming timelock expiration.
475 * `amount` is the value of the output spent by this input, committed to in the BIP 143
478 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
479 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
480 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
483 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
484 * (which is committed to in the BIP 143 signatures).
486 public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
487 long ret = bindings.BaseSign_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32), htlc == null ? 0 : htlc.ptr);
488 Reference.reachabilityFence(this);
489 Reference.reachabilityFence(justice_tx);
490 Reference.reachabilityFence(input);
491 Reference.reachabilityFence(amount);
492 Reference.reachabilityFence(per_commitment_key);
493 Reference.reachabilityFence(htlc);
494 if (ret >= 0 && ret <= 4096) { return null; }
495 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
496 if (this != null) { this.ptrs_to.add(htlc); };
501 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
502 * transaction, either offered or received.
504 * Such a transaction may claim multiples offered outputs at same time if we know the
505 * preimage for each when we create it, but only the input at index `input` should be
506 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
507 * needed with regards to an upcoming timelock expiration.
509 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
512 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
514 * `per_commitment_point` is the dynamic point corresponding to the channel state
515 * detected onchain. It has been generated by our counterparty and is used to derive
516 * channel state keys, which are then included in the witness script and committed to in the
519 public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
520 long ret = bindings.BaseSign_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, InternalUtils.check_arr_len(per_commitment_point, 33), htlc == null ? 0 : htlc.ptr);
521 Reference.reachabilityFence(this);
522 Reference.reachabilityFence(htlc_tx);
523 Reference.reachabilityFence(input);
524 Reference.reachabilityFence(amount);
525 Reference.reachabilityFence(per_commitment_point);
526 Reference.reachabilityFence(htlc);
527 if (ret >= 0 && ret <= 4096) { return null; }
528 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
529 if (this != null) { this.ptrs_to.add(htlc); };
534 * Create a signature for a (proposed) closing transaction.
536 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
537 * chosen to forgo their output as dust.
539 public Result_SignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
540 long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr);
541 Reference.reachabilityFence(this);
542 Reference.reachabilityFence(closing_tx);
543 if (ret >= 0 && ret <= 4096) { return null; }
544 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
545 if (this != null) { this.ptrs_to.add(closing_tx); };
550 * Computes the signature for a commitment transaction's anchor output used as an
551 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
553 public Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
554 long ret = bindings.BaseSign_sign_holder_anchor_input(this.ptr, anchor_tx, input);
555 Reference.reachabilityFence(this);
556 Reference.reachabilityFence(anchor_tx);
557 Reference.reachabilityFence(input);
558 if (ret >= 0 && ret <= 4096) { return null; }
559 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
564 * Signs a channel announcement message with our funding key and our node secret key (aka
565 * node_id or network_key), proving it comes from one of the channel participants.
567 * The first returned signature should be from our node secret key, the second from our
570 * Note that if this fails or is rejected, the channel will not be publicly announced and
571 * our counterparty may (though likely will not) close the channel on us for violating the
574 public Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(org.ldk.structs.UnsignedChannelAnnouncement msg) {
575 long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr);
576 Reference.reachabilityFence(this);
577 Reference.reachabilityFence(msg);
578 if (ret >= 0 && ret <= 4096) { return null; }
579 Result_C2Tuple_SignatureSignatureZNoneZ ret_hu_conv = Result_C2Tuple_SignatureSignatureZNoneZ.constr_from_ptr(ret);
580 if (this != null) { this.ptrs_to.add(msg); };
585 * Set the counterparty static channel data, including basepoints,
586 * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. Since these
587 * are static channel data, they MUST NOT be allowed to change to different values once set,
588 * as LDK may call this method more than once.
590 * channel_parameters.is_populated() MUST be true.
592 public void provide_channel_parameters(org.ldk.structs.ChannelTransactionParameters channel_parameters) {
593 bindings.BaseSign_provide_channel_parameters(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr);
594 Reference.reachabilityFence(this);
595 Reference.reachabilityFence(channel_parameters);
596 if (this != null) { this.ptrs_to.add(channel_parameters); };
600 * Frees any resources associated with this object given its this_arg pointer.
601 * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
603 public ChannelPublicKeys get_pubkeys() {
604 long ret = bindings.BaseSign_get_pubkeys(this.ptr);
605 Reference.reachabilityFence(this);
606 if (ret >= 0 && ret <= 4096) { return null; }
607 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
608 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };