[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelSigner.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  * A trait to handle Lightning channel key material without concretizing the channel type or
10  * the signature mechanism.
11  */
12 public class ChannelSigner : CommonBase {
13         internal readonly bindings.LDKChannelSigner bindings_instance;
14         internal ChannelSigner(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
15         private ChannelSigner(bindings.LDKChannelSigner arg, ChannelPublicKeys pubkeys) : base(bindings.LDKChannelSigner_new(arg, pubkeys == null ? 0 : pubkeys.clone_ptr())) {
16                 this.ptrs_to.AddLast(arg);
17                 this.bindings_instance = arg;
18         }
19         ~ChannelSigner() {
20                 if (ptr != 0) { bindings.ChannelSigner_free(ptr); }
21         }
22
23         public interface ChannelSignerInterface {
24                 /**
25                  * Gets the per-commitment point for a specific commitment number
26                  * 
27                  * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
28                  */
29                 byte[] get_per_commitment_point(long _idx);
30                 /**
31                  * Gets the commitment secret for a specific commitment number as part of the revocation process
32                  * 
33                  * An external signer implementation should error here if the commitment was already signed
34                  * and should refuse to sign it in the future.
35                  * 
36                  * May be called more than once for the same index.
37                  * 
38                  * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
39                  */
40                 byte[] release_commitment_secret(long _idx);
41                 /**
42                  * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
43                  * 
44                  * This is required in order for the signer to make sure that releasing a commitment
45                  * secret won't leave us without a broadcastable holder transaction.
46                  * Policy checks should be implemented in this function, including checking the amount
47                  * sent to us and checking the HTLCs.
48                  * 
49                  * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
50                  * A validating signer should ensure that an HTLC output is removed only when the matching
51                  * preimage is provided, or when the value to holder is restored.
52                  * 
53                  * Note that all the relevant preimages will be provided, but there may also be additional
54                  * irrelevant or duplicate preimages.
55                  */
56                 Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction _holder_tx, byte[][] _preimages);
57                 /**
58                  * Returns an arbitrary identifier describing the set of keys which are provided back to you in
59                  * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
60                  * [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys.
61                  */
62                 byte[] channel_keys_id();
63                 /**
64                  * Set the counterparty static channel data, including basepoints,
65                  * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
66                  * 
67                  * This data is static, and will never change for a channel once set. For a given [`ChannelSigner`]
68                  * instance, LDK will call this method exactly once - either immediately after construction
69                  * (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding
70                  * information has been generated.
71                  * 
72                  * channel_parameters.is_populated() MUST be true.
73                  */
74                 void provide_channel_parameters(ChannelTransactionParameters _channel_parameters);
75         }
76         private class LDKChannelSignerHolder { internal ChannelSigner held; }
77         private class LDKChannelSignerImpl : bindings.LDKChannelSigner {
78                 internal LDKChannelSignerImpl(ChannelSignerInterface arg, LDKChannelSignerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
79                 private ChannelSignerInterface arg;
80                 private LDKChannelSignerHolder impl_holder;
81                 public byte[] get_per_commitment_point(long _idx) {
82                         byte[] ret = arg.get_per_commitment_point(_idx);
83                                 GC.KeepAlive(arg);
84                         byte[] result = InternalUtils.check_arr_len(ret, 33);
85                         return result;
86                 }
87                 public byte[] release_commitment_secret(long _idx) {
88                         byte[] ret = arg.release_commitment_secret(_idx);
89                                 GC.KeepAlive(arg);
90                         byte[] result = InternalUtils.check_arr_len(ret, 32);
91                         return result;
92                 }
93                 public long validate_holder_commitment(long _holder_tx, byte[][] _preimages) {
94                         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); }
95                         Result_NoneNoneZ ret = arg.validate_holder_commitment(_holder_tx_hu_conv, _preimages);
96                                 GC.KeepAlive(arg);
97                         long result = ret == null ? 0 : ret.clone_ptr();
98                         return result;
99                 }
100                 public byte[] channel_keys_id() {
101                         byte[] ret = arg.channel_keys_id();
102                                 GC.KeepAlive(arg);
103                         byte[] result = InternalUtils.check_arr_len(ret, 32);
104                         return result;
105                 }
106                 public void provide_channel_parameters(long _channel_parameters) {
107                         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); }
108                         arg.provide_channel_parameters(_channel_parameters_hu_conv);
109                                 GC.KeepAlive(arg);
110                 }
111         }
112         public static ChannelSigner new_impl(ChannelSignerInterface arg, ChannelPublicKeys pubkeys) {
113                 LDKChannelSignerHolder impl_holder = new LDKChannelSignerHolder();
114                 impl_holder.held = new ChannelSigner(new LDKChannelSignerImpl(arg, impl_holder), pubkeys);
115                 return impl_holder.held;
116         }
117         /**
118          * Gets the per-commitment point for a specific commitment number
119          * 
120          * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
121          */
122         public byte[] get_per_commitment_point(long idx) {
123                 byte[] ret = bindings.ChannelSigner_get_per_commitment_point(this.ptr, idx);
124                 GC.KeepAlive(this);
125                 GC.KeepAlive(idx);
126                 return ret;
127         }
128
129         /**
130          * Gets the commitment secret for a specific commitment number as part of the revocation process
131          * 
132          * An external signer implementation should error here if the commitment was already signed
133          * and should refuse to sign it in the future.
134          * 
135          * May be called more than once for the same index.
136          * 
137          * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
138          */
139         public byte[] release_commitment_secret(long idx) {
140                 byte[] ret = bindings.ChannelSigner_release_commitment_secret(this.ptr, idx);
141                 GC.KeepAlive(this);
142                 GC.KeepAlive(idx);
143                 return ret;
144         }
145
146         /**
147          * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
148          * 
149          * This is required in order for the signer to make sure that releasing a commitment
150          * secret won't leave us without a broadcastable holder transaction.
151          * Policy checks should be implemented in this function, including checking the amount
152          * sent to us and checking the HTLCs.
153          * 
154          * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided.
155          * A validating signer should ensure that an HTLC output is removed only when the matching
156          * preimage is provided, or when the value to holder is restored.
157          * 
158          * Note that all the relevant preimages will be provided, but there may also be additional
159          * irrelevant or duplicate preimages.
160          */
161         public Result_NoneNoneZ validate_holder_commitment(org.ldk.structs.HolderCommitmentTransaction holder_tx, byte[][] preimages) {
162                 long ret = bindings.ChannelSigner_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);
163                 GC.KeepAlive(this);
164                 GC.KeepAlive(holder_tx);
165                 GC.KeepAlive(preimages);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
168                 if (this != null) { this.ptrs_to.AddLast(holder_tx); };
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Returns an arbitrary identifier describing the set of keys which are provided back to you in
174          * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this
175          * [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys.
176          */
177         public byte[] channel_keys_id() {
178                 byte[] ret = bindings.ChannelSigner_channel_keys_id(this.ptr);
179                 GC.KeepAlive(this);
180                 return ret;
181         }
182
183         /**
184          * Set the counterparty static channel data, including basepoints,
185          * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
186          * 
187          * This data is static, and will never change for a channel once set. For a given [`ChannelSigner`]
188          * instance, LDK will call this method exactly once - either immediately after construction
189          * (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding
190          * information has been generated.
191          * 
192          * channel_parameters.is_populated() MUST be true.
193          */
194         public void provide_channel_parameters(org.ldk.structs.ChannelTransactionParameters channel_parameters) {
195                 bindings.ChannelSigner_provide_channel_parameters(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr);
196                 GC.KeepAlive(this);
197                 GC.KeepAlive(channel_parameters);
198                 if (this != null) { this.ptrs_to.AddLast(channel_parameters); };
199         }
200
201         /**
202          * Frees any resources associated with this object given its this_arg pointer.
203          * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
204          */
205         public ChannelPublicKeys get_pubkeys() {
206                 long ret = bindings.ChannelSigner_get_pubkeys(this.ptr);
207                 GC.KeepAlive(this);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
211                 return ret_hu_conv;
212         }
213
214 }
215 } } }