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