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