6 namespace org { namespace ldk { namespace structs {
10 * Arguments for the creation of a ChannelManager that are not deserialized.
12 * At a high-level, the process for deserializing a ChannelManager and resuming normal operation
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
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`].
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`].
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.
41 * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
43 public class ChannelManagerReadArgs : CommonBase {
44 internal ChannelManagerReadArgs(object _dummy, long ptr) : base(ptr) { }
45 ~ChannelManagerReadArgs() {
46 if (ptr != 0) { bindings.ChannelManagerReadArgs_free(ptr); }
50 * The keys provider which will give us relevant keys. Some keys will be loaded during
51 * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
54 public KeysInterface get_keys_manager() {
55 long ret = bindings.ChannelManagerReadArgs_get_keys_manager(this.ptr);
57 if (ret >= 0 && ret <= 4096) { return null; }
58 KeysInterface ret_hu_conv = new KeysInterface(null, ret);
59 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
64 * The keys provider which will give us relevant keys. Some keys will be loaded during
65 * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
68 public void set_keys_manager(org.ldk.structs.KeysInterface val) {
69 bindings.ChannelManagerReadArgs_set_keys_manager(this.ptr, val == null ? 0 : val.ptr);
72 if (this != null) { this.ptrs_to.AddLast(val); };
76 * The fee_estimator for use in the ChannelManager in the future.
78 * No calls to the FeeEstimator will be made during deserialization.
80 public FeeEstimator get_fee_estimator() {
81 long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 FeeEstimator ret_hu_conv = new FeeEstimator(null, ret);
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
90 * The fee_estimator for use in the ChannelManager in the future.
92 * No calls to the FeeEstimator will be made during deserialization.
94 public void set_fee_estimator(org.ldk.structs.FeeEstimator val) {
95 bindings.ChannelManagerReadArgs_set_fee_estimator(this.ptr, val == null ? 0 : val.ptr);
98 if (this != null) { this.ptrs_to.AddLast(val); };
102 * The chain::Watch for use in the ChannelManager in the future.
104 * No calls to the chain::Watch will be made during deserialization. It is assumed that
105 * you have deserialized ChannelMonitors separately and will add them to your
106 * chain::Watch after deserializing this ChannelManager.
108 public Watch get_chain_monitor() {
109 long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr);
111 if (ret >= 0 && ret <= 4096) { return null; }
112 Watch ret_hu_conv = new Watch(null, ret);
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
118 * The chain::Watch for use in the ChannelManager in the future.
120 * No calls to the chain::Watch will be made during deserialization. It is assumed that
121 * you have deserialized ChannelMonitors separately and will add them to your
122 * chain::Watch after deserializing this ChannelManager.
124 public void set_chain_monitor(org.ldk.structs.Watch val) {
125 bindings.ChannelManagerReadArgs_set_chain_monitor(this.ptr, val == null ? 0 : val.ptr);
128 if (this != null) { this.ptrs_to.AddLast(val); };
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.
136 public BroadcasterInterface get_tx_broadcaster() {
137 long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr);
139 if (ret >= 0 && ret <= 4096) { return null; }
140 BroadcasterInterface ret_hu_conv = new BroadcasterInterface(null, ret);
141 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
146 * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
147 * used to broadcast the latest local commitment transactions of channels which must be
148 * force-closed during deserialization.
150 public void set_tx_broadcaster(org.ldk.structs.BroadcasterInterface val) {
151 bindings.ChannelManagerReadArgs_set_tx_broadcaster(this.ptr, val == null ? 0 : val.ptr);
154 if (this != null) { this.ptrs_to.AddLast(val); };
158 * The Logger for use in the ChannelManager and which may be used to log information during
161 public Logger get_logger() {
162 long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr);
164 if (ret >= 0 && ret <= 4096) { return null; }
165 Logger ret_hu_conv = new Logger(null, ret);
166 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
171 * The Logger for use in the ChannelManager and which may be used to log information during
174 public void set_logger(org.ldk.structs.Logger val) {
175 bindings.ChannelManagerReadArgs_set_logger(this.ptr, val == null ? 0 : val.ptr);
178 if (this != null) { this.ptrs_to.AddLast(val); };
182 * Default settings used for new channels. Any existing channels will continue to use the
183 * runtime settings which were stored when the ChannelManager was serialized.
185 public UserConfig get_default_config() {
186 long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr);
188 if (ret >= 0 && ret <= 4096) { return null; }
189 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
190 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
195 * Default settings used for new channels. Any existing channels will continue to use the
196 * runtime settings which were stored when the ChannelManager was serialized.
198 public void set_default_config(org.ldk.structs.UserConfig val) {
199 bindings.ChannelManagerReadArgs_set_default_config(this.ptr, val == null ? 0 : val.ptr);
202 if (this != null) { this.ptrs_to.AddLast(val); };
206 * Simple utility function to create a ChannelManagerReadArgs which creates the monitor
207 * HashMap for you. This is primarily useful for C bindings where it is not practical to
208 * populate a HashMap directly from C.
210 public static ChannelManagerReadArgs of(org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Watch chain_monitor, org.ldk.structs.BroadcasterInterface tx_broadcaster, org.ldk.structs.Logger logger, org.ldk.structs.UserConfig default_config, ChannelMonitor[] channel_monitors) {
211 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, channel_monitors != null ? InternalUtils.mapArray(channel_monitors, channel_monitors_conv_16 => channel_monitors_conv_16 == null ? 0 : channel_monitors_conv_16.ptr) : null);
212 GC.KeepAlive(keys_manager);
213 GC.KeepAlive(fee_estimator);
214 GC.KeepAlive(chain_monitor);
215 GC.KeepAlive(tx_broadcaster);
216 GC.KeepAlive(logger);
217 GC.KeepAlive(default_config);
218 GC.KeepAlive(channel_monitors);
219 if (ret >= 0 && ret <= 4096) { return null; }
220 org.ldk.structs.ChannelManagerReadArgs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManagerReadArgs(null, ret); }
221 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
222 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
223 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_estimator); };
224 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(chain_monitor); };
225 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(tx_broadcaster); };
226 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
227 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(default_config); };
228 foreach (ChannelMonitor channel_monitors_conv_16 in channel_monitors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_monitors_conv_16); }; };