6 namespace org { namespace ldk { namespace structs {
9 * A trait to sign Lightning channel transactions as described in
10 * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md).
12 * Signing services could be implemented on a hardware wallet and should implement signing
13 * policies in order to be secure. Please refer to the [VLS Policy
14 * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md)
15 * for an example of such policies.
17 public class BaseSign : CommonBase {
18 internal readonly bindings.LDKBaseSign bindings_instance;
19 internal BaseSign(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
20 private BaseSign(bindings.LDKBaseSign arg, ChannelPublicKeys pubkeys) : base(bindings.LDKBaseSign_new(arg, pubkeys == null ? 0 : pubkeys.clone_ptr())) {
21 this.ptrs_to.AddLast(arg);
22 this.bindings_instance = arg;
25 if (ptr != 0) { bindings.BaseSign_free(ptr); }
28 public interface BaseSignInterface {
30 * Gets the per-commitment point for a specific commitment number
32 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
34 byte[] get_per_commitment_point(long _idx);
36 * Gets the commitment secret for a specific commitment number as part of the revocation process
38 * An external signer implementation should error here if the commitment was already signed
39 * and should refuse to sign it in the future.
41 * May be called more than once for the same index.
43 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
45 byte[] release_commitment_secret(long _idx);
47 * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
49 * This is required in order for the signer to make sure that releasing a commitment
50 * secret won't leave us without a broadcastable holder transaction.
51 * Policy checks should be implemented in this function, including checking the amount
52 * sent to us and checking the HTLCs.
54 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
55 * A validating signer should ensure that an HTLC output is removed only when the matching
56 * preimage is provided, or when the value to holder is restored.
58 * Note that all the relevant preimages will be provided, but there may also be additional
59 * irrelevant or duplicate preimages.
61 Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction _holder_tx, byte[][] _preimages);
63 * Returns an arbitrary identifier describing the set of keys which are provided back to you in
64 * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
65 * [`BaseSign`] object uniquely and lookup or re-derive its keys.
67 byte[] channel_keys_id();
69 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
71 * Note that if signing fails or is rejected, the channel will be force-closed.
73 * Policy checks should be implemented in this function, including checking the amount
74 * sent to us and checking the HTLCs.
76 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
77 * A validating signer should ensure that an HTLC output is removed only when the matching
78 * preimage is provided, or when the value to holder is restored.
80 * Note that all the relevant preimages will be provided, but there may also be additional
81 * irrelevant or duplicate preimages.
83 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction _commitment_tx, byte[][] _preimages);
85 * Validate the counterparty's revocation.
87 * This is required in order for the signer to make sure that the state has moved
88 * forward and it is safe to sign the next counterparty commitment.
90 Result_NoneNoneZ validate_counterparty_revocation(long _idx, byte[] _secret);
92 * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
95 * - with a non-revoked `commitment_tx`.
96 * - with the latest `commitment_tx` when we initiate a force-close.
97 * - with the previous `commitment_tx`, just to get claiming HTLC
98 * signatures, if we are reacting to a [`ChannelMonitor`]
99 * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
100 * that decided to broadcast before it had been updated to the latest `commitment_tx`.
102 * This may be called multiple times for the same transaction.
104 * An external signer implementation should check that the commitment has not been revoked.
106 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
108 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction _commitment_tx);
110 * Create a signature for the given input in a transaction spending an HTLC transaction output
111 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
113 * A justice transaction may claim multiple outputs at the same time if timelocks are
114 * similar, but only a signature for the input at index `input` should be signed for here.
115 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
116 * to an upcoming timelock expiration.
118 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
120 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
121 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
122 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
125 Result_SignatureNoneZ sign_justice_revoked_output(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key);
127 * Create a signature for the given input in a transaction spending a commitment transaction
128 * HTLC output when our counterparty broadcasts an old state.
130 * A justice transaction may claim multiple outputs at the same time if timelocks are
131 * similar, but only a signature for the input at index `input` should be signed for here.
132 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
133 * to an upcoming timelock expiration.
135 * `amount` is the value of the output spent by this input, committed to in the BIP 143
138 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
139 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
140 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
143 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
144 * (which is committed to in the BIP 143 signatures).
146 Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key, HTLCOutputInCommitment _htlc);
148 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
149 * transaction, either offered or received.
151 * Such a transaction may claim multiples offered outputs at same time if we know the
152 * preimage for each when we create it, but only the input at index `input` should be
153 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
154 * needed with regards to an upcoming timelock expiration.
156 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
159 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
161 * `per_commitment_point` is the dynamic point corresponding to the channel state
162 * detected onchain. It has been generated by our counterparty and is used to derive
163 * channel state keys, which are then included in the witness script and committed to in the
166 Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] _htlc_tx, long _input, long _amount, byte[] _per_commitment_point, HTLCOutputInCommitment _htlc);
168 * Create a signature for a (proposed) closing transaction.
170 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
171 * chosen to forgo their output as dust.
173 Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction _closing_tx);
175 * Computes the signature for a commitment transaction's anchor output used as an
176 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
178 Result_SignatureNoneZ sign_holder_anchor_input(byte[] _anchor_tx, long _input);
180 * Signs a channel announcement message with our funding key and our node secret key (aka
181 * node_id or network_key), proving it comes from one of the channel participants.
183 * The first returned signature should be from our node secret key, the second from our
186 * Note that if this fails or is rejected, the channel will not be publicly announced and
187 * our counterparty may (though likely will not) close the channel on us for violating the
190 Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement _msg);
192 * Set the counterparty static channel data, including basepoints,
193 * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. Since these
194 * are static channel data, they MUST NOT be allowed to change to different values once set,
195 * as LDK may call this method more than once.
197 * channel_parameters.is_populated() MUST be true.
199 void provide_channel_parameters(ChannelTransactionParameters _channel_parameters);
201 private class LDKBaseSignHolder { internal BaseSign held; }
202 private class LDKBaseSignImpl : bindings.LDKBaseSign {
203 internal LDKBaseSignImpl(BaseSignInterface arg, LDKBaseSignHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
204 private BaseSignInterface arg;
205 private LDKBaseSignHolder impl_holder;
206 public byte[] get_per_commitment_point(long _idx) {
207 byte[] ret = arg.get_per_commitment_point(_idx);
209 byte[] result = InternalUtils.check_arr_len(ret, 33);
212 public byte[] release_commitment_secret(long _idx) {
213 byte[] ret = arg.release_commitment_secret(_idx);
215 byte[] result = InternalUtils.check_arr_len(ret, 32);
218 public long validate_holder_commitment(long _holder_tx, byte[][] _preimages) {
219 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); }
220 Result_NoneNoneZ ret = arg.validate_holder_commitment(_holder_tx_hu_conv, _preimages);
222 long result = ret == null ? 0 : ret.clone_ptr();
225 public byte[] channel_keys_id() {
226 byte[] ret = arg.channel_keys_id();
228 byte[] result = InternalUtils.check_arr_len(ret, 32);
231 public long sign_counterparty_commitment(long _commitment_tx, byte[][] _preimages) {
232 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); }
233 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(_commitment_tx_hu_conv, _preimages);
235 long result = ret == null ? 0 : ret.clone_ptr();
238 public long validate_counterparty_revocation(long _idx, byte[] _secret) {
239 Result_NoneNoneZ ret = arg.validate_counterparty_revocation(_idx, _secret);
241 long result = ret == null ? 0 : ret.clone_ptr();
244 public long sign_holder_commitment_and_htlcs(long _commitment_tx) {
245 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); }
246 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(_commitment_tx_hu_conv);
248 long result = ret == null ? 0 : ret.clone_ptr();
251 public long sign_justice_revoked_output(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key) {
252 Result_SignatureNoneZ ret = arg.sign_justice_revoked_output(_justice_tx, _input, _amount, _per_commitment_key);
254 long result = ret == null ? 0 : ret.clone_ptr();
257 public long sign_justice_revoked_htlc(byte[] _justice_tx, long _input, long _amount, byte[] _per_commitment_key, long _htlc) {
258 org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
259 Result_SignatureNoneZ ret = arg.sign_justice_revoked_htlc(_justice_tx, _input, _amount, _per_commitment_key, _htlc_hu_conv);
261 long result = ret == null ? 0 : ret.clone_ptr();
264 public long sign_counterparty_htlc_transaction(byte[] _htlc_tx, long _input, long _amount, byte[] _per_commitment_point, long _htlc) {
265 org.ldk.structs.HTLCOutputInCommitment _htlc_hu_conv = null; if (_htlc < 0 || _htlc > 4096) { _htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, _htlc); }
266 Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(_htlc_tx, _input, _amount, _per_commitment_point, _htlc_hu_conv);
268 long result = ret == null ? 0 : ret.clone_ptr();
271 public long sign_closing_transaction(long _closing_tx) {
272 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); }
273 Result_SignatureNoneZ ret = arg.sign_closing_transaction(_closing_tx_hu_conv);
275 long result = ret == null ? 0 : ret.clone_ptr();
278 public long sign_holder_anchor_input(byte[] _anchor_tx, long _input) {
279 Result_SignatureNoneZ ret = arg.sign_holder_anchor_input(_anchor_tx, _input);
281 long result = ret == null ? 0 : ret.clone_ptr();
284 public long sign_channel_announcement(long _msg) {
285 org.ldk.structs.UnsignedChannelAnnouncement _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, _msg); }
286 Result_C2Tuple_SignatureSignatureZNoneZ ret = arg.sign_channel_announcement(_msg_hu_conv);
288 long result = ret == null ? 0 : ret.clone_ptr();
291 public void provide_channel_parameters(long _channel_parameters) {
292 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); }
293 arg.provide_channel_parameters(_channel_parameters_hu_conv);
297 public static BaseSign new_impl(BaseSignInterface arg, ChannelPublicKeys pubkeys) {
298 LDKBaseSignHolder impl_holder = new LDKBaseSignHolder();
299 impl_holder.held = new BaseSign(new LDKBaseSignImpl(arg, impl_holder), pubkeys);
300 return impl_holder.held;
303 * Gets the per-commitment point for a specific commitment number
305 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
307 public byte[] get_per_commitment_point(long idx) {
308 byte[] ret = bindings.BaseSign_get_per_commitment_point(this.ptr, idx);
315 * Gets the commitment secret for a specific commitment number as part of the revocation process
317 * An external signer implementation should error here if the commitment was already signed
318 * and should refuse to sign it in the future.
320 * May be called more than once for the same index.
322 * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
324 public byte[] release_commitment_secret(long idx) {
325 byte[] ret = bindings.BaseSign_release_commitment_secret(this.ptr, idx);
332 * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
334 * This is required in order for the signer to make sure that releasing a commitment
335 * secret won't leave us without a broadcastable holder transaction.
336 * Policy checks should be implemented in this function, including checking the amount
337 * sent to us and checking the HTLCs.
339 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
340 * A validating signer should ensure that an HTLC output is removed only when the matching
341 * preimage is provided, or when the value to holder is restored.
343 * Note that all the relevant preimages will be provided, but there may also be additional
344 * irrelevant or duplicate preimages.
346 public Result_NoneNoneZ validate_holder_commitment(org.ldk.structs.HolderCommitmentTransaction holder_tx, byte[][] preimages) {
347 long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr, preimages != null ? InternalUtils.mapArray(preimages, preimages_conv_8 => InternalUtils.check_arr_len(preimages_conv_8, 32)) : null);
349 GC.KeepAlive(holder_tx);
350 GC.KeepAlive(preimages);
351 if (ret >= 0 && ret <= 4096) { return null; }
352 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
353 if (this != null) { this.ptrs_to.AddLast(holder_tx); };
358 * Returns an arbitrary identifier describing the set of keys which are provided back to you in
359 * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
360 * [`BaseSign`] object uniquely and lookup or re-derive its keys.
362 public byte[] channel_keys_id() {
363 byte[] ret = bindings.BaseSign_channel_keys_id(this.ptr);
369 * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
371 * Note that if signing fails or is rejected, the channel will be force-closed.
373 * Policy checks should be implemented in this function, including checking the amount
374 * sent to us and checking the HTLCs.
376 * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
377 * A validating signer should ensure that an HTLC output is removed only when the matching
378 * preimage is provided, or when the value to holder is restored.
380 * Note that all the relevant preimages will be provided, but there may also be additional
381 * irrelevant or duplicate preimages.
383 public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(org.ldk.structs.CommitmentTransaction commitment_tx, byte[][] preimages) {
384 long ret = bindings.BaseSign_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr, preimages != null ? InternalUtils.mapArray(preimages, preimages_conv_8 => InternalUtils.check_arr_len(preimages_conv_8, 32)) : null);
386 GC.KeepAlive(commitment_tx);
387 GC.KeepAlive(preimages);
388 if (ret >= 0 && ret <= 4096) { return null; }
389 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
390 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
395 * Validate the counterparty's revocation.
397 * This is required in order for the signer to make sure that the state has moved
398 * forward and it is safe to sign the next counterparty commitment.
400 public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
401 long ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, InternalUtils.check_arr_len(secret, 32));
404 GC.KeepAlive(secret);
405 if (ret >= 0 && ret <= 4096) { return null; }
406 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
411 * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.
413 * This will be called
414 * - with a non-revoked `commitment_tx`.
415 * - with the latest `commitment_tx` when we initiate a force-close.
416 * - with the previous `commitment_tx`, just to get claiming HTLC
417 * signatures, if we are reacting to a [`ChannelMonitor`]
418 * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
419 * that decided to broadcast before it had been updated to the latest `commitment_tx`.
421 * This may be called multiple times for the same transaction.
423 * An external signer implementation should check that the commitment has not been revoked.
425 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
427 public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(org.ldk.structs.HolderCommitmentTransaction commitment_tx) {
428 long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr);
430 GC.KeepAlive(commitment_tx);
431 if (ret >= 0 && ret <= 4096) { return null; }
432 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
433 if (this != null) { this.ptrs_to.AddLast(commitment_tx); };
438 * Create a signature for the given input in a transaction spending an HTLC transaction output
439 * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
441 * A justice transaction may claim multiple outputs at the same time if timelocks are
442 * similar, but only a signature for the input at index `input` should be signed for here.
443 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
444 * to an upcoming timelock expiration.
446 * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
448 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
449 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
450 * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
453 public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
454 long ret = bindings.BaseSign_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32));
456 GC.KeepAlive(justice_tx);
458 GC.KeepAlive(amount);
459 GC.KeepAlive(per_commitment_key);
460 if (ret >= 0 && ret <= 4096) { return null; }
461 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
466 * Create a signature for the given input in a transaction spending a commitment transaction
467 * HTLC output when our counterparty broadcasts an old state.
469 * A justice transaction may claim multiple outputs at the same time if timelocks are
470 * similar, but only a signature for the input at index `input` should be signed for here.
471 * It may be called multiple times for same output(s) if a fee-bump is needed with regards
472 * to an upcoming timelock expiration.
474 * `amount` is the value of the output spent by this input, committed to in the BIP 143
477 * `per_commitment_key` is revocation secret which was provided by our counterparty when they
478 * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
479 * not allow the spending of any funds by itself (you need our holder revocation_secret to do
482 * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
483 * (which is committed to in the BIP 143 signatures).
485 public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, org.ldk.structs.HTLCOutputInCommitment htlc) {
486 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 GC.KeepAlive(justice_tx);
490 GC.KeepAlive(amount);
491 GC.KeepAlive(per_commitment_key);
493 if (ret >= 0 && ret <= 4096) { return null; }
494 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
495 if (this != null) { this.ptrs_to.AddLast(htlc); };
500 * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
501 * transaction, either offered or received.
503 * Such a transaction may claim multiples offered outputs at same time if we know the
504 * preimage for each when we create it, but only the input at index `input` should be
505 * signed for here. It may be called multiple times for same output(s) if a fee-bump is
506 * needed with regards to an upcoming timelock expiration.
508 * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC
511 * `amount` is value of the output spent by this input, committed to in the BIP 143 signature.
513 * `per_commitment_point` is the dynamic point corresponding to the channel state
514 * detected onchain. It has been generated by our counterparty and is used to derive
515 * channel state keys, which are then included in the witness script and committed to in the
518 public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, org.ldk.structs.HTLCOutputInCommitment htlc) {
519 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 GC.KeepAlive(htlc_tx);
523 GC.KeepAlive(amount);
524 GC.KeepAlive(per_commitment_point);
526 if (ret >= 0 && ret <= 4096) { return null; }
527 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
528 if (this != null) { this.ptrs_to.AddLast(htlc); };
533 * Create a signature for a (proposed) closing transaction.
535 * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
536 * chosen to forgo their output as dust.
538 public Result_SignatureNoneZ sign_closing_transaction(org.ldk.structs.ClosingTransaction closing_tx) {
539 long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr);
541 GC.KeepAlive(closing_tx);
542 if (ret >= 0 && ret <= 4096) { return null; }
543 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
544 if (this != null) { this.ptrs_to.AddLast(closing_tx); };
549 * Computes the signature for a commitment transaction's anchor output used as an
550 * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
552 public Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
553 long ret = bindings.BaseSign_sign_holder_anchor_input(this.ptr, anchor_tx, input);
555 GC.KeepAlive(anchor_tx);
557 if (ret >= 0 && ret <= 4096) { return null; }
558 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
563 * Signs a channel announcement message with our funding key and our node secret key (aka
564 * node_id or network_key), proving it comes from one of the channel participants.
566 * The first returned signature should be from our node secret key, the second from our
569 * Note that if this fails or is rejected, the channel will not be publicly announced and
570 * our counterparty may (though likely will not) close the channel on us for violating the
573 public Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(org.ldk.structs.UnsignedChannelAnnouncement msg) {
574 long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr);
577 if (ret >= 0 && ret <= 4096) { return null; }
578 Result_C2Tuple_SignatureSignatureZNoneZ ret_hu_conv = Result_C2Tuple_SignatureSignatureZNoneZ.constr_from_ptr(ret);
579 if (this != null) { this.ptrs_to.AddLast(msg); };
584 * Set the counterparty static channel data, including basepoints,
585 * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. Since these
586 * are static channel data, they MUST NOT be allowed to change to different values once set,
587 * as LDK may call this method more than once.
589 * channel_parameters.is_populated() MUST be true.
591 public void provide_channel_parameters(org.ldk.structs.ChannelTransactionParameters channel_parameters) {
592 bindings.BaseSign_provide_channel_parameters(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr);
594 GC.KeepAlive(channel_parameters);
595 if (this != null) { this.ptrs_to.AddLast(channel_parameters); };
599 * Frees any resources associated with this object given its this_arg pointer.
600 * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
602 public ChannelPublicKeys get_pubkeys() {
603 long ret = bindings.BaseSign_get_pubkeys(this.ptr);
605 if (ret >= 0 && ret <= 4096) { return null; }
606 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
607 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };