[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / BaseSign.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * A trait to sign lightning channel transactions as described in BOLT 3.
12  * 
13  * Signing services could be implemented on a hardware wallet. In this case,
14  * the current Sign would be a front-end on top of a communication
15  * channel connected to your secure device and lightning key material wouldn't
16  * reside on a hot server. Nevertheless, a this deployment would still need
17  * to trust the ChannelManager to avoid loss of funds as this latest component
18  * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
19  * 
20  * A more secure iteration would be to use hashlock (or payment points) to pair
21  * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
22  * at the price of more state and computation on the hardware wallet side. In the future,
23  * we are looking forward to design such interface.
24  * 
25  * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
26  * to act, as liveness and breach reply correctness are always going to be hard requirements
27  * of LN security model, orthogonal of key management issues.
28  */
29 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
30 public class BaseSign extends CommonBase {
31         final bindings.LDKBaseSign bindings_instance;
32         BaseSign(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
33         private BaseSign(bindings.LDKBaseSign arg, ChannelPublicKeys pubkeys) {
34                 super(bindings.LDKBaseSign_new(arg, pubkeys == null ? 0 : pubkeys.clone_ptr()));
35                 this.ptrs_to.add(arg);
36                 this.bindings_instance = arg;
37         }
38         @Override @SuppressWarnings("deprecation")
39         protected void finalize() throws Throwable {
40                 if (ptr != 0) { bindings.BaseSign_free(ptr); } super.finalize();
41         }
42
43         public static interface BaseSignInterface {
44                 /**
45                  * Gets the per-commitment point for a specific commitment number
46                  * 
47                  * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
48                  */
49                 byte[] get_per_commitment_point(long idx);
50                 /**
51                  * Gets the commitment secret for a specific commitment number as part of the revocation process
52                  * 
53                  * An external signer implementation should error here if the commitment was already signed
54                  * and should refuse to sign it in the future.
55                  * 
56                  * May be called more than once for the same index.
57                  * 
58                  * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
59                  */
60                 byte[] release_commitment_secret(long idx);
61                 /**
62                  * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
63                  * 
64                  * This is required in order for the signer to make sure that releasing a commitment
65                  * secret won't leave us without a broadcastable holder transaction.
66                  * Policy checks should be implemented in this function, including checking the amount
67                  * sent to us and checking the HTLCs.
68                  * 
69                  * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
70                  * A validating signer should ensure that an HTLC output is removed only when the matching
71                  * preimage is provided, or when the value to holder is restored.
72                  * 
73                  * NOTE: all the relevant preimages will be provided, but there may also be additional
74                  * irrelevant or duplicate preimages.
75                  */
76                 Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages);
77                 /**
78                  * Gets an arbitrary identifier describing the set of keys which are provided back to you in
79                  * some SpendableOutputDescriptor types. This should be sufficient to identify this
80                  * Sign object uniquely and lookup or re-derive its keys.
81                  */
82                 byte[] channel_keys_id();
83                 /**
84                  * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
85                  * 
86                  * Note that if signing fails or is rejected, the channel will be force-closed.
87                  * 
88                  * Policy checks should be implemented in this function, including checking the amount
89                  * sent to us and checking the HTLCs.
90                  * 
91                  * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
92                  * A validating signer should ensure that an HTLC output is removed only when the matching
93                  * preimage is provided, or when the value to holder is restored.
94                  * 
95                  * NOTE: all the relevant preimages will be provided, but there may also be additional
96                  * irrelevant or duplicate preimages.
97                  */
98                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages);
99                 /**
100                  * Validate the counterparty's revocation.
101                  * 
102                  * This is required in order for the signer to make sure that the state has moved
103                  * forward and it is safe to sign the next counterparty commitment.
104                  */
105                 Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret);
106                 /**
107                  * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
108                  * This will only ever be called with a non-revoked commitment_tx.  This will be called with the
109                  * latest commitment_tx when we initiate a force-close.
110                  * This will be called with the previous latest, just to get claiming HTLC signatures, if we are
111                  * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to
112                  * the latest.
113                  * This may be called multiple times for the same transaction.
114                  * 
115                  * An external signer implementation should check that the commitment has not been revoked.
116                  * 
117                  * May return Err if key derivation fails.  Callers, such as ChannelMonitor, will panic in such a case.
118                  */
119                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx);
120                 /**
121                  * Create a signature for the given input in a transaction spending an HTLC transaction output
122                  * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
123                  * 
124                  * A justice transaction may claim multiple outputs at the same time if timelocks are
125                  * similar, but only a signature for the input at index `input` should be signed for here.
126                  * It may be called multiple times for same output(s) if a fee-bump is needed with regards
127                  * to an upcoming timelock expiration.
128                  * 
129                  * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
130                  * 
131                  * per_commitment_key is revocation secret which was provided by our counterparty when they
132                  * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
133                  * not allow the spending of any funds by itself (you need our holder revocation_secret to do
134                  * so).
135                  */
136                 Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key);
137                 /**
138                  * Create a signature for the given input in a transaction spending a commitment transaction
139                  * HTLC output when our counterparty broadcasts an old state.
140                  * 
141                  * A justice transaction may claim multiple outputs at the same time if timelocks are
142                  * similar, but only a signature for the input at index `input` should be signed for here.
143                  * It may be called multiple times for same output(s) if a fee-bump is needed with regards
144                  * to an upcoming timelock expiration.
145                  * 
146                  * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
147                  * 
148                  * per_commitment_key is revocation secret which was provided by our counterparty when they
149                  * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
150                  * not allow the spending of any funds by itself (you need our holder revocation_secret to do
151                  * so).
152                  * 
153                  * htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script
154                  * (which is committed to in the BIP 143 signatures).
155                  */
156                 Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc);
157                 /**
158                  * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
159                  * transaction, either offered or received.
160                  * 
161                  * Such a transaction may claim multiples offered outputs at same time if we know the
162                  * preimage for each when we create it, but only the input at index `input` should be
163                  * signed for here. It may be called multiple times for same output(s) if a fee-bump is
164                  * needed with regards to an upcoming timelock expiration.
165                  * 
166                  * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
167                  * outputs.
168                  * 
169                  * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
170                  * 
171                  * Per_commitment_point is the dynamic point corresponding to the channel state
172                  * detected onchain. It has been generated by our counterparty and is used to derive
173                  * channel state keys, which are then included in the witness script and committed to in the
174                  * BIP 143 signature.
175                  */
176                 Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc);
177                 /**
178                  * Create a signature for a (proposed) closing transaction.
179                  * 
180                  * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
181                  * chosen to forgo their output as dust.
182                  */
183                 Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
184                 /**
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.
187                  * 
188                  * The first returned signature should be from our node secret key, the second from our
189                  * funding key.
190                  * 
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
193                  * protocol.
194                  */
195                 Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg);
196                 /**
197                  * Set the counterparty static channel data, including basepoints,
198                  * counterparty_selected/holder_selected_contest_delay and funding outpoint.
199                  * This is done as soon as the funding outpoint is known.  Since these are static channel data,
200                  * they MUST NOT be allowed to change to different values once set.
201                  * 
202                  * channel_parameters.is_populated() MUST be true.
203                  * 
204                  * We bind holder_selected_contest_delay late here for API convenience.
205                  * 
206                  * Will be called before any signatures are applied.
207                  */
208                 void ready_channel(ChannelTransactionParameters channel_parameters);
209         }
210         private static class LDKBaseSignHolder { BaseSign held; }
211         public static BaseSign new_impl(BaseSignInterface arg, ChannelPublicKeys pubkeys) {
212                 final LDKBaseSignHolder impl_holder = new LDKBaseSignHolder();
213                 impl_holder.held = new BaseSign(new bindings.LDKBaseSign() {
214                         @Override public byte[] get_per_commitment_point(long idx) {
215                                 byte[] ret = arg.get_per_commitment_point(idx);
216                                 Reference.reachabilityFence(arg);
217                                 byte[] result = InternalUtils.check_arr_len(ret, 33);
218                                 return result;
219                         }
220                         @Override public byte[] release_commitment_secret(long idx) {
221                                 byte[] ret = arg.release_commitment_secret(idx);
222                                 Reference.reachabilityFence(arg);
223                                 byte[] result = InternalUtils.check_arr_len(ret, 32);
224                                 return result;
225                         }
226                         @Override public long validate_holder_commitment(long holder_tx, byte[][] preimages) {
227                                 HolderCommitmentTransaction holder_tx_hu_conv = null; if (holder_tx < 0 || holder_tx > 4096) { holder_tx_hu_conv = new HolderCommitmentTransaction(null, holder_tx); }
228                                 Result_NoneNoneZ ret = arg.validate_holder_commitment(holder_tx_hu_conv, preimages);
229                                 Reference.reachabilityFence(arg);
230                                 long result = ret == null ? 0 : ret.clone_ptr();
231                                 return result;
232                         }
233                         @Override public byte[] channel_keys_id() {
234                                 byte[] ret = arg.channel_keys_id();
235                                 Reference.reachabilityFence(arg);
236                                 byte[] result = InternalUtils.check_arr_len(ret, 32);
237                                 return result;
238                         }
239                         @Override public long sign_counterparty_commitment(long commitment_tx, byte[][] preimages) {
240                                 CommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new CommitmentTransaction(null, commitment_tx); }
241                                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv, preimages);
242                                 Reference.reachabilityFence(arg);
243                                 long result = ret == null ? 0 : ret.clone_ptr();
244                                 return result;
245                         }
246                         @Override public long validate_counterparty_revocation(long idx, byte[] secret) {
247                                 Result_NoneNoneZ ret = arg.validate_counterparty_revocation(idx, secret);
248                                 Reference.reachabilityFence(arg);
249                                 long result = ret == null ? 0 : ret.clone_ptr();
250                                 return result;
251                         }
252                         @Override public long sign_holder_commitment_and_htlcs(long commitment_tx) {
253                                 HolderCommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); }
254                                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv);
255                                 Reference.reachabilityFence(arg);
256                                 long result = ret == null ? 0 : ret.clone_ptr();
257                                 return result;
258                         }
259                         @Override public long sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
260                                 Result_SignatureNoneZ ret = arg.sign_justice_revoked_output(justice_tx, input, amount, per_commitment_key);
261                                 Reference.reachabilityFence(arg);
262                                 long result = ret == null ? 0 : ret.clone_ptr();
263                                 return result;
264                         }
265                         @Override public long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) {
266                                 HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); }
267                                 Result_SignatureNoneZ ret = arg.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc_hu_conv);
268                                 Reference.reachabilityFence(arg);
269                                 long result = ret == null ? 0 : ret.clone_ptr();
270                                 return result;
271                         }
272                         @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) {
273                                 HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); }
274                                 Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv);
275                                 Reference.reachabilityFence(arg);
276                                 long result = ret == null ? 0 : ret.clone_ptr();
277                                 return result;
278                         }
279                         @Override public long sign_closing_transaction(long closing_tx) {
280                                 ClosingTransaction closing_tx_hu_conv = null; if (closing_tx < 0 || closing_tx > 4096) { closing_tx_hu_conv = new ClosingTransaction(null, closing_tx); }
281                                 Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx_hu_conv);
282                                 Reference.reachabilityFence(arg);
283                                 long result = ret == null ? 0 : ret.clone_ptr();
284                                 return result;
285                         }
286                         @Override public long sign_channel_announcement(long msg) {
287                                 UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UnsignedChannelAnnouncement(null, msg); }
288                                 Result_C2Tuple_SignatureSignatureZNoneZ ret = arg.sign_channel_announcement(msg_hu_conv);
289                                 Reference.reachabilityFence(arg);
290                                 long result = ret == null ? 0 : ret.clone_ptr();
291                                 return result;
292                         }
293                         @Override public void ready_channel(long channel_parameters) {
294                                 ChannelTransactionParameters channel_parameters_hu_conv = null; if (channel_parameters < 0 || channel_parameters > 4096) { channel_parameters_hu_conv = new ChannelTransactionParameters(null, channel_parameters); }
295                                 arg.ready_channel(channel_parameters_hu_conv);
296                                 Reference.reachabilityFence(arg);
297                         }
298                 }, pubkeys);
299                 return impl_holder.held;
300         }
301         /**
302          * Gets the per-commitment point for a specific commitment number
303          * 
304          * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
305          */
306         public byte[] get_per_commitment_point(long idx) {
307                 byte[] ret = bindings.BaseSign_get_per_commitment_point(this.ptr, idx);
308                 Reference.reachabilityFence(this);
309                 Reference.reachabilityFence(idx);
310                 return ret;
311         }
312
313         /**
314          * Gets the commitment secret for a specific commitment number as part of the revocation process
315          * 
316          * An external signer implementation should error here if the commitment was already signed
317          * and should refuse to sign it in the future.
318          * 
319          * May be called more than once for the same index.
320          * 
321          * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
322          */
323         public byte[] release_commitment_secret(long idx) {
324                 byte[] ret = bindings.BaseSign_release_commitment_secret(this.ptr, idx);
325                 Reference.reachabilityFence(this);
326                 Reference.reachabilityFence(idx);
327                 return ret;
328         }
329
330         /**
331          * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
332          * 
333          * This is required in order for the signer to make sure that releasing a commitment
334          * secret won't leave us without a broadcastable holder transaction.
335          * Policy checks should be implemented in this function, including checking the amount
336          * sent to us and checking the HTLCs.
337          * 
338          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
339          * A validating signer should ensure that an HTLC output is removed only when the matching
340          * preimage is provided, or when the value to holder is restored.
341          * 
342          * NOTE: all the relevant preimages will be provided, but there may also be additional
343          * irrelevant or duplicate preimages.
344          */
345         public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages) {
346                 long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr & ~1, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null);
347                 Reference.reachabilityFence(this);
348                 Reference.reachabilityFence(holder_tx);
349                 Reference.reachabilityFence(preimages);
350                 if (ret >= 0 && ret <= 4096) { return null; }
351                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
352                 this.ptrs_to.add(holder_tx);
353                 return ret_hu_conv;
354         }
355
356         /**
357          * Gets an arbitrary identifier describing the set of keys which are provided back to you in
358          * some SpendableOutputDescriptor types. This should be sufficient to identify this
359          * Sign object uniquely and lookup or re-derive its keys.
360          */
361         public byte[] channel_keys_id() {
362                 byte[] ret = bindings.BaseSign_channel_keys_id(this.ptr);
363                 Reference.reachabilityFence(this);
364                 return ret;
365         }
366
367         /**
368          * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
369          * 
370          * Note that if signing fails or is rejected, the channel will be force-closed.
371          * 
372          * Policy checks should be implemented in this function, including checking the amount
373          * sent to us and checking the HTLCs.
374          * 
375          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
376          * A validating signer should ensure that an HTLC output is removed only when the matching
377          * preimage is provided, or when the value to holder is restored.
378          * 
379          * NOTE: all the relevant preimages will be provided, but there may also be additional
380          * irrelevant or duplicate preimages.
381          */
382         public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages) {
383                 long ret = bindings.BaseSign_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null);
384                 Reference.reachabilityFence(this);
385                 Reference.reachabilityFence(commitment_tx);
386                 Reference.reachabilityFence(preimages);
387                 if (ret >= 0 && ret <= 4096) { return null; }
388                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
389                 this.ptrs_to.add(commitment_tx);
390                 return ret_hu_conv;
391         }
392
393         /**
394          * Validate the counterparty's revocation.
395          * 
396          * This is required in order for the signer to make sure that the state has moved
397          * forward and it is safe to sign the next counterparty commitment.
398          */
399         public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
400                 long ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, InternalUtils.check_arr_len(secret, 32));
401                 Reference.reachabilityFence(this);
402                 Reference.reachabilityFence(idx);
403                 Reference.reachabilityFence(secret);
404                 if (ret >= 0 && ret <= 4096) { return null; }
405                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
406                 return ret_hu_conv;
407         }
408
409         /**
410          * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
411          * This will only ever be called with a non-revoked commitment_tx.  This will be called with the
412          * latest commitment_tx when we initiate a force-close.
413          * This will be called with the previous latest, just to get claiming HTLC signatures, if we are
414          * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to
415          * the latest.
416          * This may be called multiple times for the same transaction.
417          * 
418          * An external signer implementation should check that the commitment has not been revoked.
419          * 
420          * May return Err if key derivation fails.  Callers, such as ChannelMonitor, will panic in such a case.
421          */
422         public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx) {
423                 long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1);
424                 Reference.reachabilityFence(this);
425                 Reference.reachabilityFence(commitment_tx);
426                 if (ret >= 0 && ret <= 4096) { return null; }
427                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
428                 this.ptrs_to.add(commitment_tx);
429                 return ret_hu_conv;
430         }
431
432         /**
433          * Create a signature for the given input in a transaction spending an HTLC transaction output
434          * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
435          * 
436          * A justice transaction may claim multiple outputs at the same time if timelocks are
437          * similar, but only a signature for the input at index `input` should be signed for here.
438          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
439          * to an upcoming timelock expiration.
440          * 
441          * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
442          * 
443          * per_commitment_key is revocation secret which was provided by our counterparty when they
444          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
445          * not allow the spending of any funds by itself (you need our holder revocation_secret to do
446          * so).
447          */
448         public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
449                 long ret = bindings.BaseSign_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32));
450                 Reference.reachabilityFence(this);
451                 Reference.reachabilityFence(justice_tx);
452                 Reference.reachabilityFence(input);
453                 Reference.reachabilityFence(amount);
454                 Reference.reachabilityFence(per_commitment_key);
455                 if (ret >= 0 && ret <= 4096) { return null; }
456                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
457                 return ret_hu_conv;
458         }
459
460         /**
461          * Create a signature for the given input in a transaction spending a commitment transaction
462          * HTLC output when our counterparty broadcasts an old state.
463          * 
464          * A justice transaction may claim multiple outputs at the same time if timelocks are
465          * similar, but only a signature for the input at index `input` should be signed for here.
466          * It may be called multiple times for same output(s) if a fee-bump is needed with regards
467          * to an upcoming timelock expiration.
468          * 
469          * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
470          * 
471          * per_commitment_key is revocation secret which was provided by our counterparty when they
472          * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
473          * not allow the spending of any funds by itself (you need our holder revocation_secret to do
474          * so).
475          * 
476          * htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script
477          * (which is committed to in the BIP 143 signatures).
478          */
479         public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc) {
480                 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 & ~1);
481                 Reference.reachabilityFence(this);
482                 Reference.reachabilityFence(justice_tx);
483                 Reference.reachabilityFence(input);
484                 Reference.reachabilityFence(amount);
485                 Reference.reachabilityFence(per_commitment_key);
486                 Reference.reachabilityFence(htlc);
487                 if (ret >= 0 && ret <= 4096) { return null; }
488                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
489                 this.ptrs_to.add(htlc);
490                 return ret_hu_conv;
491         }
492
493         /**
494          * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
495          * transaction, either offered or received.
496          * 
497          * Such a transaction may claim multiples offered outputs at same time if we know the
498          * preimage for each when we create it, but only the input at index `input` should be
499          * signed for here. It may be called multiple times for same output(s) if a fee-bump is
500          * needed with regards to an upcoming timelock expiration.
501          * 
502          * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
503          * outputs.
504          * 
505          * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
506          * 
507          * Per_commitment_point is the dynamic point corresponding to the channel state
508          * detected onchain. It has been generated by our counterparty and is used to derive
509          * channel state keys, which are then included in the witness script and committed to in the
510          * BIP 143 signature.
511          */
512         public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc) {
513                 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 & ~1);
514                 Reference.reachabilityFence(this);
515                 Reference.reachabilityFence(htlc_tx);
516                 Reference.reachabilityFence(input);
517                 Reference.reachabilityFence(amount);
518                 Reference.reachabilityFence(per_commitment_point);
519                 Reference.reachabilityFence(htlc);
520                 if (ret >= 0 && ret <= 4096) { return null; }
521                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
522                 this.ptrs_to.add(htlc);
523                 return ret_hu_conv;
524         }
525
526         /**
527          * Create a signature for a (proposed) closing transaction.
528          * 
529          * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
530          * chosen to forgo their output as dust.
531          */
532         public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) {
533                 long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr & ~1);
534                 Reference.reachabilityFence(this);
535                 Reference.reachabilityFence(closing_tx);
536                 if (ret >= 0 && ret <= 4096) { return null; }
537                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
538                 this.ptrs_to.add(closing_tx);
539                 return ret_hu_conv;
540         }
541
542         /**
543          * Signs a channel announcement message with our funding key and our node secret key (aka
544          * node_id or network_key), proving it comes from one of the channel participants.
545          * 
546          * The first returned signature should be from our node secret key, the second from our
547          * funding key.
548          * 
549          * Note that if this fails or is rejected, the channel will not be publicly announced and
550          * our counterparty may (though likely will not) close the channel on us for violating the
551          * protocol.
552          */
553         public Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
554                 long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
555                 Reference.reachabilityFence(this);
556                 Reference.reachabilityFence(msg);
557                 if (ret >= 0 && ret <= 4096) { return null; }
558                 Result_C2Tuple_SignatureSignatureZNoneZ ret_hu_conv = Result_C2Tuple_SignatureSignatureZNoneZ.constr_from_ptr(ret);
559                 this.ptrs_to.add(msg);
560                 return ret_hu_conv;
561         }
562
563         /**
564          * Set the counterparty static channel data, including basepoints,
565          * counterparty_selected/holder_selected_contest_delay and funding outpoint.
566          * This is done as soon as the funding outpoint is known.  Since these are static channel data,
567          * they MUST NOT be allowed to change to different values once set.
568          * 
569          * channel_parameters.is_populated() MUST be true.
570          * 
571          * We bind holder_selected_contest_delay late here for API convenience.
572          * 
573          * Will be called before any signatures are applied.
574          */
575         public void ready_channel(ChannelTransactionParameters channel_parameters) {
576                 bindings.BaseSign_ready_channel(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr & ~1);
577                 Reference.reachabilityFence(this);
578                 Reference.reachabilityFence(channel_parameters);
579                 this.ptrs_to.add(channel_parameters);
580         }
581
582         /**
583          * Frees any resources associated with this object given its this_arg pointer.
584          * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
585          */
586         public ChannelPublicKeys get_pubkeys() {
587                 long ret = bindings.BaseSign_get_pubkeys(this.ptr);
588                 Reference.reachabilityFence(this);
589                 if (ret >= 0 && ret <= 4096) { return null; }
590                 ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
591                 ret_hu_conv.ptrs_to.add(this);
592                 return ret_hu_conv;
593         }
594
595 }