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