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
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 ChannelMonitors.
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 same
20  * way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and
21  * ChannelMonitor::get_funding_txo().
22  * 4) Reconnect blocks on your ChannelMonitors.
23  * 5) Disconnect/connect blocks on the ChannelManager.
24  * 6) Move the ChannelMonitors into your local chain::Watch.
25  * 
26  * Note that the ordering of #4-6 is not of importance, however all three must occur before you
27  * call any other methods on the newly-deserialized ChannelManager.
28  * 
29  * Note that because some channels may be closed during deserialization, it is critical that you
30  * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
31  * you. If you deserialize an old ChannelManager (during which force-closure transactions may be
32  * broadcast), and then later deserialize a newer version of the same ChannelManager (which will
33  * not force-close the same channels but consider them live), you may end up revoking a state for
34  * which you've already broadcasted the transaction.
35  */
36 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
37 public class ChannelManagerReadArgs extends CommonBase {
38         ChannelManagerReadArgs(Object _dummy, long ptr) { super(ptr); }
39         @Override @SuppressWarnings("deprecation")
40         protected void finalize() throws Throwable {
41                 super.finalize();
42                 if (ptr != 0) { bindings.ChannelManagerReadArgs_free(ptr); }
43         }
44
45         /**
46          * The keys provider which will give us relevant keys. Some keys will be loaded during
47          * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
48          * signing data.
49          */
50         public KeysInterface get_keys_manager() {
51                 long ret = bindings.ChannelManagerReadArgs_get_keys_manager(this.ptr);
52                 KeysInterface ret_hu_conv = new KeysInterface(null, ret);
53                 ret_hu_conv.ptrs_to.add(this);
54                 return ret_hu_conv;
55         }
56
57         /**
58          * The keys provider which will give us relevant keys. Some keys will be loaded during
59          * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
60          * signing data.
61          */
62         public void set_keys_manager(KeysInterface val) {
63                 bindings.ChannelManagerReadArgs_set_keys_manager(this.ptr, val == null ? 0 : val.ptr);
64                 this.ptrs_to.add(val);
65         }
66
67         /**
68          * The fee_estimator for use in the ChannelManager in the future.
69          * 
70          * No calls to the FeeEstimator will be made during deserialization.
71          */
72         public FeeEstimator get_fee_estimator() {
73                 long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr);
74                 FeeEstimator ret_hu_conv = new FeeEstimator(null, ret);
75                 ret_hu_conv.ptrs_to.add(this);
76                 return ret_hu_conv;
77         }
78
79         /**
80          * The fee_estimator for use in the ChannelManager in the future.
81          * 
82          * No calls to the FeeEstimator will be made during deserialization.
83          */
84         public void set_fee_estimator(FeeEstimator val) {
85                 bindings.ChannelManagerReadArgs_set_fee_estimator(this.ptr, val == null ? 0 : val.ptr);
86                 this.ptrs_to.add(val);
87         }
88
89         /**
90          * The chain::Watch for use in the ChannelManager in the future.
91          * 
92          * No calls to the chain::Watch will be made during deserialization. It is assumed that
93          * you have deserialized ChannelMonitors separately and will add them to your
94          * chain::Watch after deserializing this ChannelManager.
95          */
96         public Watch get_chain_monitor() {
97                 long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr);
98                 Watch ret_hu_conv = new Watch(null, ret);
99                 ret_hu_conv.ptrs_to.add(this);
100                 return ret_hu_conv;
101         }
102
103         /**
104          * The chain::Watch for use in the ChannelManager in the future.
105          * 
106          * No calls to the chain::Watch will be made during deserialization. It is assumed that
107          * you have deserialized ChannelMonitors separately and will add them to your
108          * chain::Watch after deserializing this ChannelManager.
109          */
110         public void set_chain_monitor(Watch val) {
111                 bindings.ChannelManagerReadArgs_set_chain_monitor(this.ptr, val == null ? 0 : val.ptr);
112                 this.ptrs_to.add(val);
113         }
114
115         /**
116          * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
117          * used to broadcast the latest local commitment transactions of channels which must be
118          * force-closed during deserialization.
119          */
120         public BroadcasterInterface get_tx_broadcaster() {
121                 long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr);
122                 BroadcasterInterface ret_hu_conv = new BroadcasterInterface(null, ret);
123                 ret_hu_conv.ptrs_to.add(this);
124                 return ret_hu_conv;
125         }
126
127         /**
128          * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
129          * used to broadcast the latest local commitment transactions of channels which must be
130          * force-closed during deserialization.
131          */
132         public void set_tx_broadcaster(BroadcasterInterface val) {
133                 bindings.ChannelManagerReadArgs_set_tx_broadcaster(this.ptr, val == null ? 0 : val.ptr);
134                 this.ptrs_to.add(val);
135         }
136
137         /**
138          * The Logger for use in the ChannelManager and which may be used to log information during
139          * deserialization.
140          */
141         public Logger get_logger() {
142                 long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr);
143                 Logger ret_hu_conv = new Logger(null, ret);
144                 ret_hu_conv.ptrs_to.add(this);
145                 return ret_hu_conv;
146         }
147
148         /**
149          * The Logger for use in the ChannelManager and which may be used to log information during
150          * deserialization.
151          */
152         public void set_logger(Logger val) {
153                 bindings.ChannelManagerReadArgs_set_logger(this.ptr, val == null ? 0 : val.ptr);
154                 this.ptrs_to.add(val);
155         }
156
157         /**
158          * Default settings used for new channels. Any existing channels will continue to use the
159          * runtime settings which were stored when the ChannelManager was serialized.
160          */
161         public UserConfig get_default_config() {
162                 long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr);
163                 UserConfig ret_hu_conv = new UserConfig(null, ret);
164                 ret_hu_conv.ptrs_to.add(this);
165                 return ret_hu_conv;
166         }
167
168         /**
169          * Default settings used for new channels. Any existing channels will continue to use the
170          * runtime settings which were stored when the ChannelManager was serialized.
171          */
172         public void set_default_config(UserConfig val) {
173                 bindings.ChannelManagerReadArgs_set_default_config(this.ptr, val == null ? 0 : val.ptr & ~1);
174                 this.ptrs_to.add(val);
175         }
176
177         /**
178          * Simple utility function to create a ChannelManagerReadArgs which creates the monitor
179          * HashMap for you. This is primarily useful for C bindings where it is not practical to
180          * populate a HashMap directly from C.
181          */
182         public static ChannelManagerReadArgs of(KeysInterface keys_manager, FeeEstimator fee_estimator, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, UserConfig default_config, ChannelMonitor[] channel_monitors) {
183                 long ret = bindings.ChannelManagerReadArgs_new(keys_manager == null ? 0 : keys_manager.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, default_config == null ? 0 : default_config.ptr & ~1, Arrays.stream(channel_monitors).mapToLong(channel_monitors_conv_16 -> channel_monitors_conv_16 == null ? 0 : channel_monitors_conv_16.ptr & ~1).toArray());
184                 ChannelManagerReadArgs ret_hu_conv = new ChannelManagerReadArgs(null, ret);
185                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
186                 ret_hu_conv.ptrs_to.add(keys_manager);
187                 ret_hu_conv.ptrs_to.add(fee_estimator);
188                 ret_hu_conv.ptrs_to.add(chain_monitor);
189                 ret_hu_conv.ptrs_to.add(tx_broadcaster);
190                 ret_hu_conv.ptrs_to.add(logger);
191                 ret_hu_conv.ptrs_to.add(default_config);
192                 /* TODO 2 ChannelMonitor  */;
193                 return ret_hu_conv;
194         }
195
196 }