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                 if (ret < 1024) { return null; }
53                 KeysInterface ret_hu_conv = new KeysInterface(null, ret);
54                 ret_hu_conv.ptrs_to.add(this);
55                 return ret_hu_conv;
56         }
57
58         /**
59          * The keys provider which will give us relevant keys. Some keys will be loaded during
60          * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
61          * signing data.
62          */
63         public void set_keys_manager(KeysInterface val) {
64                 bindings.ChannelManagerReadArgs_set_keys_manager(this.ptr, val == null ? 0 : val.ptr);
65                 this.ptrs_to.add(val);
66         }
67
68         /**
69          * The fee_estimator for use in the ChannelManager in the future.
70          * 
71          * No calls to the FeeEstimator will be made during deserialization.
72          */
73         public FeeEstimator get_fee_estimator() {
74                 long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr);
75                 if (ret < 1024) { return null; }
76                 FeeEstimator ret_hu_conv = new FeeEstimator(null, ret);
77                 ret_hu_conv.ptrs_to.add(this);
78                 return ret_hu_conv;
79         }
80
81         /**
82          * The fee_estimator for use in the ChannelManager in the future.
83          * 
84          * No calls to the FeeEstimator will be made during deserialization.
85          */
86         public void set_fee_estimator(FeeEstimator val) {
87                 bindings.ChannelManagerReadArgs_set_fee_estimator(this.ptr, val == null ? 0 : val.ptr);
88                 this.ptrs_to.add(val);
89         }
90
91         /**
92          * The chain::Watch for use in the ChannelManager in the future.
93          * 
94          * No calls to the chain::Watch will be made during deserialization. It is assumed that
95          * you have deserialized ChannelMonitors separately and will add them to your
96          * chain::Watch after deserializing this ChannelManager.
97          */
98         public Watch get_chain_monitor() {
99                 long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr);
100                 if (ret < 1024) { return null; }
101                 Watch ret_hu_conv = new Watch(null, ret);
102                 ret_hu_conv.ptrs_to.add(this);
103                 return ret_hu_conv;
104         }
105
106         /**
107          * The chain::Watch for use in the ChannelManager in the future.
108          * 
109          * No calls to the chain::Watch will be made during deserialization. It is assumed that
110          * you have deserialized ChannelMonitors separately and will add them to your
111          * chain::Watch after deserializing this ChannelManager.
112          */
113         public void set_chain_monitor(Watch val) {
114                 bindings.ChannelManagerReadArgs_set_chain_monitor(this.ptr, val == null ? 0 : val.ptr);
115                 this.ptrs_to.add(val);
116         }
117
118         /**
119          * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
120          * used to broadcast the latest local commitment transactions of channels which must be
121          * force-closed during deserialization.
122          */
123         public BroadcasterInterface get_tx_broadcaster() {
124                 long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr);
125                 if (ret < 1024) { return null; }
126                 BroadcasterInterface ret_hu_conv = new BroadcasterInterface(null, ret);
127                 ret_hu_conv.ptrs_to.add(this);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
133          * used to broadcast the latest local commitment transactions of channels which must be
134          * force-closed during deserialization.
135          */
136         public void set_tx_broadcaster(BroadcasterInterface val) {
137                 bindings.ChannelManagerReadArgs_set_tx_broadcaster(this.ptr, val == null ? 0 : val.ptr);
138                 this.ptrs_to.add(val);
139         }
140
141         /**
142          * The Logger for use in the ChannelManager and which may be used to log information during
143          * deserialization.
144          */
145         public Logger get_logger() {
146                 long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr);
147                 if (ret < 1024) { return null; }
148                 Logger ret_hu_conv = new Logger(null, ret);
149                 ret_hu_conv.ptrs_to.add(this);
150                 return ret_hu_conv;
151         }
152
153         /**
154          * The Logger for use in the ChannelManager and which may be used to log information during
155          * deserialization.
156          */
157         public void set_logger(Logger val) {
158                 bindings.ChannelManagerReadArgs_set_logger(this.ptr, val == null ? 0 : val.ptr);
159                 this.ptrs_to.add(val);
160         }
161
162         /**
163          * Default settings used for new channels. Any existing channels will continue to use the
164          * runtime settings which were stored when the ChannelManager was serialized.
165          */
166         public UserConfig get_default_config() {
167                 long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr);
168                 if (ret < 1024) { return null; }
169                 UserConfig ret_hu_conv = new UserConfig(null, ret);
170                 ret_hu_conv.ptrs_to.add(this);
171                 return ret_hu_conv;
172         }
173
174         /**
175          * Default settings used for new channels. Any existing channels will continue to use the
176          * runtime settings which were stored when the ChannelManager was serialized.
177          */
178         public void set_default_config(UserConfig val) {
179                 bindings.ChannelManagerReadArgs_set_default_config(this.ptr, val == null ? 0 : val.ptr & ~1);
180                 this.ptrs_to.add(val);
181         }
182
183         /**
184          * Simple utility function to create a ChannelManagerReadArgs which creates the monitor
185          * HashMap for you. This is primarily useful for C bindings where it is not practical to
186          * populate a HashMap directly from C.
187          */
188         public static ChannelManagerReadArgs of(KeysInterface keys_manager, FeeEstimator fee_estimator, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, UserConfig default_config, ChannelMonitor[] channel_monitors) {
189                 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());
190                 if (ret < 1024) { return null; }
191                 ChannelManagerReadArgs ret_hu_conv = new ChannelManagerReadArgs(null, ret);
192                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
193                 ret_hu_conv.ptrs_to.add(keys_manager);
194                 ret_hu_conv.ptrs_to.add(fee_estimator);
195                 ret_hu_conv.ptrs_to.add(chain_monitor);
196                 ret_hu_conv.ptrs_to.add(tx_broadcaster);
197                 ret_hu_conv.ptrs_to.add(logger);
198                 ret_hu_conv.ptrs_to.add(default_config);
199                 /* TODO 2 ChannelMonitor  */;
200                 return ret_hu_conv;
201         }
202
203 }