[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelManagerReadArgs.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  * Arguments for the creation of a ChannelManager that are not deserialized.
11  * 
12  * At a high-level, the process for deserializing a ChannelManager and resuming normal operation
13  * is:
14  * 1) Deserialize all stored [`ChannelMonitor`]s.
15  * 2) Deserialize the [`ChannelManager`] by filling in this struct and calling:
16  * `<(BlockHash, ChannelManager)>::read(reader, args)`
17  * This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored
18  * [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted.
19  * 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the
20  * same way you would handle a [`chain::Filter`] call using
21  * [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`].
22  * 4) Reconnect blocks on your [`ChannelMonitor`]s.
23  * 5) Disconnect/connect blocks on the [`ChannelManager`].
24  * 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk.
25  * Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you
26  * will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in
27  * the next step.
28  * 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a
29  * [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`].
30  * 
31  * Note that the ordering of #4-7 is not of importance, however all four must occur before you
32  * call any other methods on the newly-deserialized [`ChannelManager`].
33  * 
34  * Note that because some channels may be closed during deserialization, it is critical that you
35  * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
36  * you. If you deserialize an old ChannelManager (during which force-closure transactions may be
37  * broadcast), and then later deserialize a newer version of the same ChannelManager (which will
38  * not force-close the same channels but consider them live), you may end up revoking a state for
39  * which you've already broadcasted the transaction.
40  * 
41  * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
42  */
43 public class ChannelManagerReadArgs : CommonBase {
44         internal ChannelManagerReadArgs(object _dummy, long ptr) : base(ptr) { }
45         ~ChannelManagerReadArgs() {
46                 if (ptr != 0) { bindings.ChannelManagerReadArgs_free(ptr); }
47         }
48
49         /**
50          * A cryptographically secure source of entropy.
51          */
52         public EntropySource get_entropy_source() {
53                 long ret = bindings.ChannelManagerReadArgs_get_entropy_source(this.ptr);
54                 GC.KeepAlive(this);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 EntropySource ret_hu_conv = new EntropySource(null, ret);
57                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
58                 return ret_hu_conv;
59         }
60
61         /**
62          * A cryptographically secure source of entropy.
63          */
64         public void set_entropy_source(org.ldk.structs.EntropySource val) {
65                 bindings.ChannelManagerReadArgs_set_entropy_source(this.ptr, val.ptr);
66                 GC.KeepAlive(this);
67                 GC.KeepAlive(val);
68                 if (this != null) { this.ptrs_to.AddLast(val); };
69         }
70
71         /**
72          * A signer that is able to perform node-scoped cryptographic operations.
73          */
74         public NodeSigner get_node_signer() {
75                 long ret = bindings.ChannelManagerReadArgs_get_node_signer(this.ptr);
76                 GC.KeepAlive(this);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 NodeSigner ret_hu_conv = new NodeSigner(null, ret);
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
80                 return ret_hu_conv;
81         }
82
83         /**
84          * A signer that is able to perform node-scoped cryptographic operations.
85          */
86         public void set_node_signer(org.ldk.structs.NodeSigner val) {
87                 bindings.ChannelManagerReadArgs_set_node_signer(this.ptr, val.ptr);
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(val);
90                 if (this != null) { this.ptrs_to.AddLast(val); };
91         }
92
93         /**
94          * The keys provider which will give us relevant keys. Some keys will be loaded during
95          * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
96          * signing data.
97          */
98         public SignerProvider get_signer_provider() {
99                 long ret = bindings.ChannelManagerReadArgs_get_signer_provider(this.ptr);
100                 GC.KeepAlive(this);
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 SignerProvider ret_hu_conv = new SignerProvider(null, ret);
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
104                 return ret_hu_conv;
105         }
106
107         /**
108          * The keys provider which will give us relevant keys. Some keys will be loaded during
109          * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
110          * signing data.
111          */
112         public void set_signer_provider(org.ldk.structs.SignerProvider val) {
113                 bindings.ChannelManagerReadArgs_set_signer_provider(this.ptr, val.ptr);
114                 GC.KeepAlive(this);
115                 GC.KeepAlive(val);
116                 if (this != null) { this.ptrs_to.AddLast(val); };
117         }
118
119         /**
120          * The fee_estimator for use in the ChannelManager in the future.
121          * 
122          * No calls to the FeeEstimator will be made during deserialization.
123          */
124         public FeeEstimator get_fee_estimator() {
125                 long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr);
126                 GC.KeepAlive(this);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 FeeEstimator ret_hu_conv = new FeeEstimator(null, ret);
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
130                 return ret_hu_conv;
131         }
132
133         /**
134          * The fee_estimator for use in the ChannelManager in the future.
135          * 
136          * No calls to the FeeEstimator will be made during deserialization.
137          */
138         public void set_fee_estimator(org.ldk.structs.FeeEstimator val) {
139                 bindings.ChannelManagerReadArgs_set_fee_estimator(this.ptr, val.ptr);
140                 GC.KeepAlive(this);
141                 GC.KeepAlive(val);
142                 if (this != null) { this.ptrs_to.AddLast(val); };
143         }
144
145         /**
146          * The chain::Watch for use in the ChannelManager in the future.
147          * 
148          * No calls to the chain::Watch will be made during deserialization. It is assumed that
149          * you have deserialized ChannelMonitors separately and will add them to your
150          * chain::Watch after deserializing this ChannelManager.
151          */
152         public Watch get_chain_monitor() {
153                 long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr);
154                 GC.KeepAlive(this);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 Watch ret_hu_conv = new Watch(null, ret);
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
158                 return ret_hu_conv;
159         }
160
161         /**
162          * The chain::Watch for use in the ChannelManager in the future.
163          * 
164          * No calls to the chain::Watch will be made during deserialization. It is assumed that
165          * you have deserialized ChannelMonitors separately and will add them to your
166          * chain::Watch after deserializing this ChannelManager.
167          */
168         public void set_chain_monitor(org.ldk.structs.Watch val) {
169                 bindings.ChannelManagerReadArgs_set_chain_monitor(this.ptr, val.ptr);
170                 GC.KeepAlive(this);
171                 GC.KeepAlive(val);
172                 if (this != null) { this.ptrs_to.AddLast(val); };
173         }
174
175         /**
176          * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
177          * used to broadcast the latest local commitment transactions of channels which must be
178          * force-closed during deserialization.
179          */
180         public BroadcasterInterface get_tx_broadcaster() {
181                 long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr);
182                 GC.KeepAlive(this);
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 BroadcasterInterface ret_hu_conv = new BroadcasterInterface(null, ret);
185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
186                 return ret_hu_conv;
187         }
188
189         /**
190          * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
191          * used to broadcast the latest local commitment transactions of channels which must be
192          * force-closed during deserialization.
193          */
194         public void set_tx_broadcaster(org.ldk.structs.BroadcasterInterface val) {
195                 bindings.ChannelManagerReadArgs_set_tx_broadcaster(this.ptr, val.ptr);
196                 GC.KeepAlive(this);
197                 GC.KeepAlive(val);
198                 if (this != null) { this.ptrs_to.AddLast(val); };
199         }
200
201         /**
202          * The router which will be used in the ChannelManager in the future for finding routes
203          * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding.
204          * 
205          * No calls to the router will be made during deserialization.
206          */
207         public Router get_router() {
208                 long ret = bindings.ChannelManagerReadArgs_get_router(this.ptr);
209                 GC.KeepAlive(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 Router ret_hu_conv = new Router(null, ret);
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
213                 return ret_hu_conv;
214         }
215
216         /**
217          * The router which will be used in the ChannelManager in the future for finding routes
218          * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding.
219          * 
220          * No calls to the router will be made during deserialization.
221          */
222         public void set_router(org.ldk.structs.Router val) {
223                 bindings.ChannelManagerReadArgs_set_router(this.ptr, val.ptr);
224                 GC.KeepAlive(this);
225                 GC.KeepAlive(val);
226                 if (this != null) { this.ptrs_to.AddLast(val); };
227         }
228
229         /**
230          * The Logger for use in the ChannelManager and which may be used to log information during
231          * deserialization.
232          */
233         public Logger get_logger() {
234                 long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr);
235                 GC.KeepAlive(this);
236                 if (ret >= 0 && ret <= 4096) { return null; }
237                 Logger ret_hu_conv = new Logger(null, ret);
238                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
239                 return ret_hu_conv;
240         }
241
242         /**
243          * The Logger for use in the ChannelManager and which may be used to log information during
244          * deserialization.
245          */
246         public void set_logger(org.ldk.structs.Logger val) {
247                 bindings.ChannelManagerReadArgs_set_logger(this.ptr, val.ptr);
248                 GC.KeepAlive(this);
249                 GC.KeepAlive(val);
250                 if (this != null) { this.ptrs_to.AddLast(val); };
251         }
252
253         /**
254          * Default settings used for new channels. Any existing channels will continue to use the
255          * runtime settings which were stored when the ChannelManager was serialized.
256          */
257         public UserConfig get_default_config() {
258                 long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr);
259                 GC.KeepAlive(this);
260                 if (ret >= 0 && ret <= 4096) { return null; }
261                 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
262                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
263                 return ret_hu_conv;
264         }
265
266         /**
267          * Default settings used for new channels. Any existing channels will continue to use the
268          * runtime settings which were stored when the ChannelManager was serialized.
269          */
270         public void set_default_config(org.ldk.structs.UserConfig val) {
271                 bindings.ChannelManagerReadArgs_set_default_config(this.ptr, val == null ? 0 : val.ptr);
272                 GC.KeepAlive(this);
273                 GC.KeepAlive(val);
274                 if (this != null) { this.ptrs_to.AddLast(val); };
275         }
276
277         /**
278          * Simple utility function to create a ChannelManagerReadArgs which creates the monitor
279          * HashMap for you. This is primarily useful for C bindings where it is not practical to
280          * populate a HashMap directly from C.
281          */
282         public static ChannelManagerReadArgs of(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.SignerProvider signer_provider, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Watch chain_monitor, org.ldk.structs.BroadcasterInterface tx_broadcaster, org.ldk.structs.Router router, org.ldk.structs.Logger logger, org.ldk.structs.UserConfig default_config, ChannelMonitor[] channel_monitors) {
283                 long ret = bindings.ChannelManagerReadArgs_new(entropy_source.ptr, node_signer.ptr, signer_provider.ptr, fee_estimator.ptr, chain_monitor.ptr, tx_broadcaster.ptr, router.ptr, logger.ptr, default_config == null ? 0 : default_config.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(channel_monitors, channel_monitors_conv_16 => channel_monitors_conv_16 == null ? 0 : channel_monitors_conv_16.ptr)));
284                 GC.KeepAlive(entropy_source);
285                 GC.KeepAlive(node_signer);
286                 GC.KeepAlive(signer_provider);
287                 GC.KeepAlive(fee_estimator);
288                 GC.KeepAlive(chain_monitor);
289                 GC.KeepAlive(tx_broadcaster);
290                 GC.KeepAlive(router);
291                 GC.KeepAlive(logger);
292                 GC.KeepAlive(default_config);
293                 GC.KeepAlive(channel_monitors);
294                 if (ret >= 0 && ret <= 4096) { return null; }
295                 org.ldk.structs.ChannelManagerReadArgs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManagerReadArgs(null, ret); }
296                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
297                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
298                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
299                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(signer_provider); };
300                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_estimator); };
301                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(chain_monitor); };
302                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(tx_broadcaster); };
303                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(router); };
304                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
305                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(default_config); };
306                 foreach (ChannelMonitor channel_monitors_conv_16 in channel_monitors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_monitors_conv_16); }; };
307                 return ret_hu_conv;
308         }
309
310 }
311 } } }