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 * A cryptographically secure source of entropy.
52 public EntropySource get_entropy_source() {
53 long ret = bindings.ChannelManagerReadArgs_get_entropy_source(this.ptr);
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); };
62 * A cryptographically secure source of entropy.
64 public void set_entropy_source(org.ldk.structs.EntropySource val) {
65 bindings.ChannelManagerReadArgs_set_entropy_source(this.ptr, val.ptr);
68 if (this != null) { this.ptrs_to.AddLast(val); };
72 * A signer that is able to perform node-scoped cryptographic operations.
74 public NodeSigner get_node_signer() {
75 long ret = bindings.ChannelManagerReadArgs_get_node_signer(this.ptr);
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); };
84 * A signer that is able to perform node-scoped cryptographic operations.
86 public void set_node_signer(org.ldk.structs.NodeSigner val) {
87 bindings.ChannelManagerReadArgs_set_node_signer(this.ptr, val.ptr);
90 if (this != null) { this.ptrs_to.AddLast(val); };
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
98 public SignerProvider get_signer_provider() {
99 long ret = bindings.ChannelManagerReadArgs_get_signer_provider(this.ptr);
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); };
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
112 public void set_signer_provider(org.ldk.structs.SignerProvider val) {
113 bindings.ChannelManagerReadArgs_set_signer_provider(this.ptr, val.ptr);
116 if (this != null) { this.ptrs_to.AddLast(val); };
120 * The fee_estimator for use in the ChannelManager in the future.
122 * No calls to the FeeEstimator will be made during deserialization.
124 public FeeEstimator get_fee_estimator() {
125 long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr);
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); };
134 * The fee_estimator for use in the ChannelManager in the future.
136 * No calls to the FeeEstimator will be made during deserialization.
138 public void set_fee_estimator(org.ldk.structs.FeeEstimator val) {
139 bindings.ChannelManagerReadArgs_set_fee_estimator(this.ptr, val.ptr);
142 if (this != null) { this.ptrs_to.AddLast(val); };
146 * The chain::Watch for use in the ChannelManager in the future.
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.
152 public Watch get_chain_monitor() {
153 long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr);
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); };
162 * The chain::Watch for use in the ChannelManager in the future.
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.
168 public void set_chain_monitor(org.ldk.structs.Watch val) {
169 bindings.ChannelManagerReadArgs_set_chain_monitor(this.ptr, val.ptr);
172 if (this != null) { this.ptrs_to.AddLast(val); };
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.
180 public BroadcasterInterface get_tx_broadcaster() {
181 long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr);
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); };
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.
194 public void set_tx_broadcaster(org.ldk.structs.BroadcasterInterface val) {
195 bindings.ChannelManagerReadArgs_set_tx_broadcaster(this.ptr, val.ptr);
198 if (this != null) { this.ptrs_to.AddLast(val); };
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.
205 * No calls to the router will be made during deserialization.
207 public Router get_router() {
208 long ret = bindings.ChannelManagerReadArgs_get_router(this.ptr);
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); };
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.
220 * No calls to the router will be made during deserialization.
222 public void set_router(org.ldk.structs.Router val) {
223 bindings.ChannelManagerReadArgs_set_router(this.ptr, val.ptr);
226 if (this != null) { this.ptrs_to.AddLast(val); };
230 * The Logger for use in the ChannelManager and which may be used to log information during
233 public Logger get_logger() {
234 long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr);
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); };
243 * The Logger for use in the ChannelManager and which may be used to log information during
246 public void set_logger(org.ldk.structs.Logger val) {
247 bindings.ChannelManagerReadArgs_set_logger(this.ptr, val.ptr);
250 if (this != null) { this.ptrs_to.AddLast(val); };
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.
257 public UserConfig get_default_config() {
258 long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr);
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); };
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.
270 public void set_default_config(org.ldk.structs.UserConfig val) {
271 bindings.ChannelManagerReadArgs_set_default_config(this.ptr, val.ptr);
274 if (this != null) { this.ptrs_to.AddLast(val); };
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.
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.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(channel_monitors, channel_monitors_conv_16 => 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); }; };