[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / SignerProvider.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 that can return signer instances for individual channels.
10  */
11 public class SignerProvider : CommonBase {
12         internal readonly bindings.LDKSignerProvider bindings_instance;
13         internal SignerProvider(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
14         private SignerProvider(bindings.LDKSignerProvider arg) : base(bindings.LDKSignerProvider_new(arg)) {
15                 this.ptrs_to.AddLast(arg);
16                 this.bindings_instance = arg;
17         }
18         ~SignerProvider() {
19                 if (ptr != 0) { bindings.SignerProvider_free(ptr); }
20         }
21
22         public interface SignerProviderInterface {
23                 /**
24                  * Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through
25                  * [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow
26                  * implementations of [`SignerProvider`] to maintain a mapping between itself and the generated
27                  * `channel_keys_id`.
28                  * 
29                  * This method must return a different value each time it is called.
30                  */
31                 byte[] generate_channel_keys_id(bool _inbound, long _channel_value_satoshis, UInt128 _user_channel_id);
32                 /**
33                  * Derives the private key material backing a `Signer`.
34                  * 
35                  * To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through
36                  * [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be
37                  * re-derived from its `channel_keys_id`, which can be obtained through its trait method
38                  * [`ChannelSigner::channel_keys_id`].
39                  */
40                 WriteableEcdsaChannelSigner derive_channel_signer(long _channel_value_satoshis, byte[] _channel_keys_id);
41                 /**
42                  * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream.
43                  * This is only called during deserialization of other objects which contain
44                  * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s).
45                  * The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
46                  * contain no versioning scheme. You may wish to include your own version prefix and ensure
47                  * you've read all of the provided bytes to ensure no corruption occurred.
48                  * 
49                  * This method is slowly being phased out -- it will only be called when reading objects
50                  * written by LDK versions prior to 0.0.113.
51                  * 
52                  * [`Signer`]: Self::Signer
53                  * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
54                  * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
55                  */
56                 Result_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer(byte[] _reader);
57                 /**
58                  * Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
59                  * 
60                  * If this function returns an error, this will result in a channel failing to open.
61                  * 
62                  * This method should return a different value each time it is called, to avoid linking
63                  * on-chain funds across channels as controlled to the same user.
64                  */
65                 Result_ScriptNoneZ get_destination_script();
66                 /**
67                  * Get a script pubkey which we will send funds to when closing a channel.
68                  * 
69                  * If this function returns an error, this will result in a channel failing to open or close.
70                  * In the event of a failure when the counterparty is initiating a close, this can result in a
71                  * channel force close.
72                  * 
73                  * This method should return a different value each time it is called, to avoid linking
74                  * on-chain funds across channels as controlled to the same user.
75                  */
76                 Result_ShutdownScriptNoneZ get_shutdown_scriptpubkey();
77         }
78         private class LDKSignerProviderHolder { internal SignerProvider held; }
79         private class LDKSignerProviderImpl : bindings.LDKSignerProvider {
80                 internal LDKSignerProviderImpl(SignerProviderInterface arg, LDKSignerProviderHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
81                 private SignerProviderInterface arg;
82                 private LDKSignerProviderHolder impl_holder;
83                 public byte[] generate_channel_keys_id(bool _inbound, long _channel_value_satoshis, byte[] _user_channel_id) {
84                         org.ldk.util.UInt128 _user_channel_id_conv = new org.ldk.util.UInt128(_user_channel_id);
85                         byte[] ret = arg.generate_channel_keys_id(_inbound, _channel_value_satoshis, _user_channel_id_conv);
86                                 GC.KeepAlive(arg);
87                         byte[] result = InternalUtils.check_arr_len(ret, 32);
88                         return result;
89                 }
90                 public long derive_channel_signer(long _channel_value_satoshis, byte[] _channel_keys_id) {
91                         WriteableEcdsaChannelSigner ret = arg.derive_channel_signer(_channel_value_satoshis, _channel_keys_id);
92                                 GC.KeepAlive(arg);
93                         long result = ret.clone_ptr();
94                         if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
95                         return result;
96                 }
97                 public long read_chan_signer(byte[] _reader) {
98                         Result_WriteableEcdsaChannelSignerDecodeErrorZ ret = arg.read_chan_signer(_reader);
99                                 GC.KeepAlive(arg);
100                         long result = ret == null ? 0 : ret.clone_ptr();
101                         return result;
102                 }
103                 public long get_destination_script() {
104                         Result_ScriptNoneZ ret = arg.get_destination_script();
105                                 GC.KeepAlive(arg);
106                         long result = ret == null ? 0 : ret.clone_ptr();
107                         return result;
108                 }
109                 public long get_shutdown_scriptpubkey() {
110                         Result_ShutdownScriptNoneZ ret = arg.get_shutdown_scriptpubkey();
111                                 GC.KeepAlive(arg);
112                         long result = ret == null ? 0 : ret.clone_ptr();
113                         return result;
114                 }
115         }
116         public static SignerProvider new_impl(SignerProviderInterface arg) {
117                 LDKSignerProviderHolder impl_holder = new LDKSignerProviderHolder();
118                 impl_holder.held = new SignerProvider(new LDKSignerProviderImpl(arg, impl_holder));
119                 return impl_holder.held;
120         }
121         /**
122          * Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through
123          * [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow
124          * implementations of [`SignerProvider`] to maintain a mapping between itself and the generated
125          * `channel_keys_id`.
126          * 
127          * This method must return a different value each time it is called.
128          */
129         public byte[] generate_channel_keys_id(bool inbound, long channel_value_satoshis, org.ldk.util.UInt128 user_channel_id) {
130                 byte[] ret = bindings.SignerProvider_generate_channel_keys_id(this.ptr, inbound, channel_value_satoshis, user_channel_id.getLEBytes());
131                 GC.KeepAlive(this);
132                 GC.KeepAlive(inbound);
133                 GC.KeepAlive(channel_value_satoshis);
134                 GC.KeepAlive(user_channel_id);
135                 return ret;
136         }
137
138         /**
139          * Derives the private key material backing a `Signer`.
140          * 
141          * To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through
142          * [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be
143          * re-derived from its `channel_keys_id`, which can be obtained through its trait method
144          * [`ChannelSigner::channel_keys_id`].
145          */
146         public WriteableEcdsaChannelSigner derive_channel_signer(long channel_value_satoshis, byte[] channel_keys_id) {
147                 long ret = bindings.SignerProvider_derive_channel_signer(this.ptr, channel_value_satoshis, InternalUtils.check_arr_len(channel_keys_id, 32));
148                 GC.KeepAlive(this);
149                 GC.KeepAlive(channel_value_satoshis);
150                 GC.KeepAlive(channel_keys_id);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
153                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream.
159          * This is only called during deserialization of other objects which contain
160          * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s).
161          * The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
162          * contain no versioning scheme. You may wish to include your own version prefix and ensure
163          * you've read all of the provided bytes to ensure no corruption occurred.
164          * 
165          * This method is slowly being phased out -- it will only be called when reading objects
166          * written by LDK versions prior to 0.0.113.
167          * 
168          * [`Signer`]: Self::Signer
169          * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
170          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
171          */
172         public Result_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer(byte[] reader) {
173                 long ret = bindings.SignerProvider_read_chan_signer(this.ptr, reader);
174                 GC.KeepAlive(this);
175                 GC.KeepAlive(reader);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 Result_WriteableEcdsaChannelSignerDecodeErrorZ ret_hu_conv = Result_WriteableEcdsaChannelSignerDecodeErrorZ.constr_from_ptr(ret);
178                 return ret_hu_conv;
179         }
180
181         /**
182          * Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
183          * 
184          * If this function returns an error, this will result in a channel failing to open.
185          * 
186          * This method should return a different value each time it is called, to avoid linking
187          * on-chain funds across channels as controlled to the same user.
188          */
189         public Result_ScriptNoneZ get_destination_script() {
190                 long ret = bindings.SignerProvider_get_destination_script(this.ptr);
191                 GC.KeepAlive(this);
192                 if (ret >= 0 && ret <= 4096) { return null; }
193                 Result_ScriptNoneZ ret_hu_conv = Result_ScriptNoneZ.constr_from_ptr(ret);
194                 return ret_hu_conv;
195         }
196
197         /**
198          * Get a script pubkey which we will send funds to when closing a channel.
199          * 
200          * If this function returns an error, this will result in a channel failing to open or close.
201          * In the event of a failure when the counterparty is initiating a close, this can result in a
202          * channel force close.
203          * 
204          * This method should return a different value each time it is called, to avoid linking
205          * on-chain funds across channels as controlled to the same user.
206          */
207         public Result_ShutdownScriptNoneZ get_shutdown_scriptpubkey() {
208                 long ret = bindings.SignerProvider_get_shutdown_scriptpubkey(this.ptr);
209                 GC.KeepAlive(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 Result_ShutdownScriptNoneZ ret_hu_conv = Result_ShutdownScriptNoneZ.constr_from_ptr(ret);
212                 return ret_hu_conv;
213         }
214
215 }
216 } } }