1 namespace org { namespace ldk { namespace enums {/**
2 * An enum representing the status of a channel monitor update persistence.
4 * These are generally used as the return value for an implementation of [`Persist`] which is used
5 * as the storage layer for a [`ChainMonitor`]. See the docs on [`Persist`] for a high-level
6 * explanation of how to handle different cases.
8 * While `UnrecoverableError` is provided as a failure variant, it is not truly \"handled\" on the
9 * calling side, and generally results in an immediate panic. For those who prefer to avoid
10 * panics, `InProgress` can be used and you can retry the update operation in the background or
13 * Note that channels should generally *not* be force-closed after a persistence failure.
14 * Force-closing with the latest [`ChannelMonitorUpdate`] applied may result in a transaction
15 * being broadcast which can only be spent by the latest [`ChannelMonitor`]! Thus, if the
16 * latest [`ChannelMonitor`] is not durably persisted anywhere and exists only in memory, naively
17 * calling [`ChannelManager::force_close_broadcasting_latest_txn`] *may result in loss of funds*!
19 * [`Persist`]: chainmonitor::Persist
20 * [`ChainMonitor`]: chainmonitor::ChainMonitor
21 * [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn
23 public enum ChannelMonitorUpdateStatus {
25 * The update has been durably persisted and all copies of the relevant [`ChannelMonitor`]
28 * This includes performing any `fsync()` calls required to ensure the update is guaranteed to
29 * be available on restart even if the application crashes.
31 LDKChannelMonitorUpdateStatus_Completed,
33 * Indicates that the update will happen asynchronously in the background or that a transient
34 * failure occurred which is being retried in the background and will eventually complete.
36 * This will \"freeze\" a channel, preventing us from revoking old states or submitting a new
37 * commitment transaction to the counterparty. Once the update(s) which are `InProgress` have
38 * been completed, a [`MonitorEvent::Completed`] can be used to restore the channel to an
41 * Even when a channel has been \"frozen\", updates to the [`ChannelMonitor`] can continue to
42 * occur (e.g. if an inbound HTLC which we forwarded was claimed upstream, resulting in us
43 * attempting to claim it on this channel) and those updates must still be persisted.
45 * No updates to the channel will be made which could invalidate other [`ChannelMonitor`]s
46 * until a [`MonitorEvent::Completed`] is provided, even if you return no error on a later
47 * monitor update for the same channel.
49 * For deployments where a copy of [`ChannelMonitor`]s and other local state are backed up in
50 * a remote location (with local copies persisted immediately), it is anticipated that all
51 * updates will return [`InProgress`] until the remote copies could be updated.
53 * Note that while fully asynchronous persistence of [`ChannelMonitor`] data is generally
54 * reliable, this feature is considered beta, and a handful of edge-cases remain. Until the
55 * remaining cases are fixed, in rare cases, *using this feature may lead to funds loss*.
57 * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress
59 LDKChannelMonitorUpdateStatus_InProgress,
61 * Indicates that an update has failed and will not complete at any point in the future.
63 * Currently returning this variant will cause LDK to immediately panic to encourage immediate
64 * shutdown. In the future this may be updated to disconnect peers and refuse to continue
65 * normal operation without a panic.
67 * Applications which wish to perform an orderly shutdown after failure should consider
68 * returning [`InProgress`] instead and simply shut down without ever marking the update
71 * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress
73 LDKChannelMonitorUpdateStatus_UnrecoverableError,