Struct lightning::ln::channelmanager::ChannelManagerReadArgs
source · [−]pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,{
pub keys_manager: K,
pub fee_estimator: F,
pub chain_monitor: M,
pub tx_broadcaster: T,
pub logger: L,
pub default_config: UserConfig,
pub channel_monitors: HashMap<OutPoint, &'a mut ChannelMonitor<Signer>>,
}
Expand description
Arguments for the creation of a ChannelManager that are not deserialized.
At a high-level, the process for deserializing a ChannelManager and resuming normal operation is:
- Deserialize all stored
ChannelMonitor
s. - Deserialize the
ChannelManager
by filling in this struct and calling:<(BlockHash, ChannelManager)>::read(reader, args)
This may result in closing some channels if theChannelMonitor
is newer than the storedChannelManager
state to ensure no loss of funds. Thus, transactions may be broadcasted. - If you are not fetching full blocks, register all relevant
ChannelMonitor
outpoints the same way you would handle achain::Filter
call usingChannelMonitor::get_outputs_to_watch
andChannelMonitor::get_funding_txo
. - Reconnect blocks on your
ChannelMonitor
s. - Disconnect/connect blocks on the
ChannelManager
. - Re-persist the
ChannelMonitor
s to ensure the latest state is on disk. Note that if you’re using aChainMonitor
for yourchain::Watch
implementation, you will likely accomplish this as a side-effect of callingchain::Watch::watch_channel
in the next step. - Move the
ChannelMonitor
s into your localchain::Watch
. If you’re using aChainMonitor
, this is done by callingchain::Watch::watch_channel
.
Note that the ordering of #4-7 is not of importance, however all four must occur before you
call any other methods on the newly-deserialized ChannelManager
.
Note that because some channels may be closed during deserialization, it is critical that you always deserialize only the latest version of a ChannelManager and ChannelMonitors available to you. If you deserialize an old ChannelManager (during which force-closure transactions may be broadcast), and then later deserialize a newer version of the same ChannelManager (which will not force-close the same channels but consider them live), you may end up revoking a state for which you’ve already broadcasted the transaction.
Fields
keys_manager: K
The keys provider which will give us relevant keys. Some keys will be loaded during deserialization and KeysInterface::read_chan_signer will be used to read per-Channel signing data.
fee_estimator: F
The fee_estimator for use in the ChannelManager in the future.
No calls to the FeeEstimator will be made during deserialization.
chain_monitor: M
The chain::Watch for use in the ChannelManager in the future.
No calls to the chain::Watch will be made during deserialization. It is assumed that you have deserialized ChannelMonitors separately and will add them to your chain::Watch after deserializing this ChannelManager.
tx_broadcaster: T
The BroadcasterInterface which will be used in the ChannelManager in the future and may be used to broadcast the latest local commitment transactions of channels which must be force-closed during deserialization.
logger: L
The Logger for use in the ChannelManager and which may be used to log information during deserialization.
default_config: UserConfig
Default settings used for new channels. Any existing channels will continue to use the runtime settings which were stored when the ChannelManager was serialized.
channel_monitors: HashMap<OutPoint, &'a mut ChannelMonitor<Signer>>
A map from channel funding outpoints to ChannelMonitors for those channels (ie value.get_funding_txo() should be the key).
If a monitor is inconsistent with the channel state during deserialization the channel will be force-closed using the data in the ChannelMonitor and the channel will be dropped. This is true for missing channels as well. If there is a monitor missing for which we find channel data Err(DecodeError::InvalidValue) will be returned.
In such cases the latest local transactions will be sent to the tx_broadcaster included in this struct.
(C-not exported) because we have no HashMap bindings
Implementations
sourceimpl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
sourcepub fn new(
keys_manager: K,
fee_estimator: F,
chain_monitor: M,
tx_broadcaster: T,
logger: L,
default_config: UserConfig,
channel_monitors: Vec<&'a mut ChannelMonitor<Signer>>
) -> Self
pub fn new(
keys_manager: K,
fee_estimator: F,
chain_monitor: M,
tx_broadcaster: T,
logger: L,
default_config: UserConfig,
channel_monitors: Vec<&'a mut ChannelMonitor<Signer>>
) -> Self
Simple utility function to create a ChannelManagerReadArgs which creates the monitor HashMap for you. This is primarily useful for C bindings where it is not practical to populate a HashMap directly from C.
Trait Implementations
sourceimpl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ReadableArgs<ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>> for (BlockHash, Arc<ChannelManager<Signer, M, T, K, F, L>>)where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ReadableArgs<ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>> for (BlockHash, Arc<ChannelManager<Signer, M, T, K, F, L>>)where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
sourcefn read<R: Read>(
reader: &mut R,
args: ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>
) -> Result<Self, DecodeError>
fn read<R: Read>(
reader: &mut R,
args: ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>
) -> Result<Self, DecodeError>
Reads a Self in from the given Read
sourceimpl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ReadableArgs<ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>> for (BlockHash, ChannelManager<Signer, M, T, K, F, L>)where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ReadableArgs<ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>> for (BlockHash, ChannelManager<Signer, M, T, K, F, L>)where
M::Target: Watch<Signer>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
sourcefn read<R: Read>(
reader: &mut R,
args: ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>
) -> Result<Self, DecodeError>
fn read<R: Read>(
reader: &mut R,
args: ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>
) -> Result<Self, DecodeError>
Reads a Self in from the given Read
Auto Trait Implementations
impl<'a, Signer, M, T, K, F, L> RefUnwindSafe for ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>where
F: RefUnwindSafe,
K: RefUnwindSafe,
L: RefUnwindSafe,
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, Signer, M, T, K, F, L> Send for ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>where
F: Send,
K: Send,
L: Send,
M: Send,
Signer: Send,
T: Send,
impl<'a, Signer, M, T, K, F, L> Sync for ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>where
F: Sync,
K: Sync,
L: Sync,
M: Sync,
Signer: Send,
T: Sync,
impl<'a, Signer, M, T, K, F, L> Unpin for ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>where
F: Unpin,
K: Unpin,
L: Unpin,
M: Unpin,
T: Unpin,
impl<'a, Signer, M, T, K, F, L> !UnwindSafe for ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more