You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lightning/src/chain/chainmonitor.rs
+58-8Lines changed: 58 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,7 @@ use bitcoin::hash_types::Txid;
29
29
use chain;
30
30
use chain::{Filter,WatchedOutput};
31
31
use chain::chaininterface::{BroadcasterInterface,FeeEstimator};
32
-
use chain::channelmonitor;
33
-
use chain::channelmonitor::{ChannelMonitor,ChannelMonitorUpdate,ChannelMonitorUpdateErr,Balance,MonitorEvent,MonitorUpdated,Persist,TransactionOutputs};
32
+
use chain::channelmonitor::{ChannelMonitor,ChannelMonitorUpdate,ChannelMonitorUpdateErr,Balance,MonitorEvent,MonitorUpdated,TransactionOutputs};
34
33
use chain::transaction::{OutPoint,TransactionData};
35
34
use chain::keysinterface::Sign;
36
35
use util::logger::Logger;
@@ -42,6 +41,57 @@ use prelude::*;
42
41
use sync::{RwLock,Mutex};
43
42
use core::ops::Deref;
44
43
44
+
/// `Persist` defines behavior for persisting channel monitors: this could mean
45
+
/// writing once to disk, and/or uploading to one or more backup services.
46
+
///
47
+
/// Note that for every new monitor, you **must** persist the new `ChannelMonitor`
48
+
/// to disk/backups. And, on every update, you **must** persist either the
49
+
/// `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk
50
+
/// of situations such as revoking a transaction, then crashing before this
51
+
/// revocation can be persisted, then unintentionally broadcasting a revoked
52
+
/// transaction and losing money. This is a risk because previous channel states
53
+
/// are toxic, so it's important that whatever channel state is persisted is
54
+
/// kept up-to-date.
55
+
pubtraitPersist<ChannelSigner:Sign>{
56
+
/// Persist a new channel's data. The data can be stored any way you want, but
57
+
/// the identifier provided by Rust-Lightning is the channel's outpoint (and
58
+
/// it is up to you to maintain a correct mapping between the outpoint and the
59
+
/// stored channel data). Note that you **must** persist every new monitor to
60
+
/// disk. See the `Persist` trait documentation for more details.
61
+
///
62
+
/// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`,
63
+
/// and [`ChannelMonitorUpdateErr`] for requirements when returning errors.
0 commit comments