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