[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / TrustedCommitmentTransaction.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 /**
12  * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin
13  * transaction and the transaction creation keys) are trusted.
14  * 
15  * See trust() and verify() functions on CommitmentTransaction.
16  * 
17  * This structure implements Deref.
18  */
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class TrustedCommitmentTransaction extends CommonBase {
21         TrustedCommitmentTransaction(Object _dummy, long ptr) { super(ptr); }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 super.finalize();
25                 if (ptr != 0) { bindings.TrustedCommitmentTransaction_free(ptr); }
26         }
27
28         /**
29          * The transaction ID of the built Bitcoin transaction
30          */
31         public byte[] txid() {
32                 byte[] ret = bindings.TrustedCommitmentTransaction_txid(this.ptr);
33                 Reference.reachabilityFence(this);
34                 return ret;
35         }
36
37         /**
38          * The pre-built Bitcoin commitment transaction
39          */
40         public BuiltCommitmentTransaction built_transaction() {
41                 long ret = bindings.TrustedCommitmentTransaction_built_transaction(this.ptr);
42                 Reference.reachabilityFence(this);
43                 if (ret >= 0 && ret <= 4096) { return null; }
44                 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
45                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
46                 return ret_hu_conv;
47         }
48
49         /**
50          * The pre-calculated transaction creation public keys.
51          */
52         public TxCreationKeys keys() {
53                 long ret = bindings.TrustedCommitmentTransaction_keys(this.ptr);
54                 Reference.reachabilityFence(this);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
57                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Should anchors be used.
63          */
64         public ChannelTypeFeatures channel_type_features() {
65                 long ret = bindings.TrustedCommitmentTransaction_channel_type_features(this.ptr);
66                 Reference.reachabilityFence(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Get a signature for each HTLC which was included in the commitment transaction (ie for
75          * which HTLCOutputInCommitment::transaction_output_index.is_some()).
76          * 
77          * The returned Vec has one entry for each HTLC, and in the same order.
78          * 
79          * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All.
80          */
81         public Result_CVec_ECDSASignatureZNoneZ get_htlc_sigs(byte[] htlc_base_key, org.ldk.structs.DirectedChannelTransactionParameters channel_parameters, org.ldk.structs.EntropySource entropy_source) {
82                 long ret = bindings.TrustedCommitmentTransaction_get_htlc_sigs(this.ptr, InternalUtils.check_arr_len(htlc_base_key, 32), channel_parameters == null ? 0 : channel_parameters.ptr, entropy_source.ptr);
83                 Reference.reachabilityFence(this);
84                 Reference.reachabilityFence(htlc_base_key);
85                 Reference.reachabilityFence(channel_parameters);
86                 Reference.reachabilityFence(entropy_source);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 Result_CVec_ECDSASignatureZNoneZ ret_hu_conv = Result_CVec_ECDSASignatureZNoneZ.constr_from_ptr(ret);
89                 if (this != null) { this.ptrs_to.add(channel_parameters); };
90                 if (this != null) { this.ptrs_to.add(entropy_source); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Returns the index of the revokeable output, i.e. the `to_local` output sending funds to
96          * the broadcaster, in the built transaction, if any exists.
97          * 
98          * There are two cases where this may return `None`:
99          * - The balance of the revokeable output is below the dust limit (only found on commitments
100          * early in the channel's lifetime, i.e. before the channel reserve is met).
101          * - This commitment was created before LDK 0.0.117. In this case, the
102          * commitment transaction previously didn't contain enough information to locate the
103          * revokeable output.
104          */
105         public Option_usizeZ revokeable_output_index() {
106                 long ret = bindings.TrustedCommitmentTransaction_revokeable_output_index(this.ptr);
107                 Reference.reachabilityFence(this);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.Option_usizeZ ret_hu_conv = org.ldk.structs.Option_usizeZ.constr_from_ptr(ret);
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Helper method to build an unsigned justice transaction spending the revokeable
116          * `to_local` output to a destination script. Fee estimation accounts for the expected
117          * revocation witness data that will be added when signed.
118          * 
119          * This method will error if the given fee rate results in a fee greater than the value
120          * of the output being spent, or if there exists no revokeable `to_local` output on this
121          * commitment transaction. See [`Self::revokeable_output_index`] for more details.
122          * 
123          * The built transaction will allow fee bumping with RBF, and this method takes
124          * `feerate_per_kw` as an input such that multiple copies of a justice transaction at different
125          * fee rates may be built.
126          */
127         public Result_TransactionNoneZ build_to_local_justice_tx(long feerate_per_kw, byte[] destination_script) {
128                 long ret = bindings.TrustedCommitmentTransaction_build_to_local_justice_tx(this.ptr, feerate_per_kw, destination_script);
129                 Reference.reachabilityFence(this);
130                 Reference.reachabilityFence(feerate_per_kw);
131                 Reference.reachabilityFence(destination_script);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
134                 return ret_hu_conv;
135         }
136
137 }