Struct ChannelManagerReadArgs
pub struct ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,{
pub entropy_source: ES,
pub node_signer: NS,
pub signer_provider: SP,
pub fee_estimator: F,
pub chain_monitor: M,
pub tx_broadcaster: T,
pub router: R,
pub message_router: MR,
pub logger: L,
pub default_config: UserConfig,
pub channel_monitors: HashMap<OutPoint, &'a ChannelMonitor<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>, RandomState>,
}
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
. - Disconnect/connect blocks on your
ChannelMonitor
s to get them in sync with the chain. - Disconnect/connect blocks on the
ChannelManager
to get it in sync with the chain. - Optionally re-persist the
ChannelMonitor
s to ensure the latest state is on disk. This is important if you have replayed a nontrivial number of blocks in step (4), allowing you to avoid having to replay the same blocks if you shut down quickly after startup. It is otherwise not required. 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§
§entropy_source: ES
A cryptographically secure source of entropy.
node_signer: NS
A signer that is able to perform node-scoped cryptographic operations.
signer_provider: SP
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.
router: R
The router which will be used in the ChannelManager in the future for finding routes on-the-fly for trampoline payments. Absent in private nodes that don’t support forwarding.
No calls to the router will be made during deserialization.
message_router: MR
The MessageRouter
used for constructing BlindedMessagePath
s for Offer
s,
Refund
s, and any reply paths.
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 ChannelMonitor<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>, RandomState>
A map from channel funding outpoints to ChannelMonitors for those channels (ie value.context.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.
This is not exported to bindings users because we have no HashMap bindings
Implementations§
§impl<'a, M, T, ES, NS, SP, F, R, MR, L> ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,
impl<'a, M, T, ES, NS, SP, F, R, MR, L> ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,
pub fn new(
entropy_source: ES,
node_signer: NS,
signer_provider: SP,
fee_estimator: F,
chain_monitor: M,
tx_broadcaster: T,
router: R,
message_router: MR,
logger: L,
default_config: UserConfig,
channel_monitors: Vec<&'a ChannelMonitor<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>>,
) -> ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
pub fn new( entropy_source: ES, node_signer: NS, signer_provider: SP, fee_estimator: F, chain_monitor: M, tx_broadcaster: T, router: R, message_router: MR, logger: L, default_config: UserConfig, channel_monitors: Vec<&'a ChannelMonitor<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>>, ) -> ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
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§
§impl<'a, M, T, ES, NS, SP, F, R, MR, L> ReadableArgs<ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>> for (BlockHash, Arc<ChannelManager<M, T, ES, NS, SP, F, R, MR, L>>)where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,
impl<'a, M, T, ES, NS, SP, F, R, MR, L> ReadableArgs<ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>> for (BlockHash, Arc<ChannelManager<M, T, ES, NS, SP, F, R, MR, L>>)where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,
§fn read<Reader>(
reader: &mut Reader,
args: ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>,
) -> Result<(BlockHash, Arc<ChannelManager<M, T, ES, NS, SP, F, R, MR, L>>), DecodeError>where
Reader: Read,
fn read<Reader>(
reader: &mut Reader,
args: ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>,
) -> Result<(BlockHash, Arc<ChannelManager<M, T, ES, NS, SP, F, R, MR, L>>), DecodeError>where
Reader: Read,
Self
in from the given Read
.§impl<'a, M, T, ES, NS, SP, F, R, MR, L> ReadableArgs<ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>> for (BlockHash, ChannelManager<M, T, ES, NS, SP, F, R, MR, L>)where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,
impl<'a, M, T, ES, NS, SP, F, R, MR, L> ReadableArgs<ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>> for (BlockHash, ChannelManager<M, T, ES, NS, SP, F, R, MR, L>)where
M: Deref,
T: Deref,
ES: Deref,
NS: Deref,
SP: Deref,
F: Deref,
R: Deref,
MR: Deref,
L: Deref,
<M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::EcdsaSigner>,
<T as Deref>::Target: BroadcasterInterface,
<ES as Deref>::Target: EntropySource,
<NS as Deref>::Target: NodeSigner,
<SP as Deref>::Target: SignerProvider,
<F as Deref>::Target: FeeEstimator,
<R as Deref>::Target: Router,
<MR as Deref>::Target: MessageRouter,
<L as Deref>::Target: Logger,
§fn read<Reader>(
reader: &mut Reader,
args: ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>,
) -> Result<(BlockHash, ChannelManager<M, T, ES, NS, SP, F, R, MR, L>), DecodeError>where
Reader: Read,
fn read<Reader>(
reader: &mut Reader,
args: ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>,
) -> Result<(BlockHash, ChannelManager<M, T, ES, NS, SP, F, R, MR, L>), DecodeError>where
Reader: Read,
Self
in from the given Read
.Auto Trait Implementations§
impl<'a, M, T, ES, NS, SP, F, R, MR, L> Freeze for ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
impl<'a, M, T, ES, NS, SP, F, R, MR, L> Send for ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
impl<'a, M, T, ES, NS, SP, F, R, MR, L> Sync for ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
impl<'a, M, T, ES, NS, SP, F, R, MR, L> RefUnwindSafe for ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>where
ES: RefUnwindSafe,
NS: RefUnwindSafe,
SP: RefUnwindSafe,
F: RefUnwindSafe,
M: RefUnwindSafe,
T: RefUnwindSafe,
R: RefUnwindSafe,
MR: RefUnwindSafe,
L: RefUnwindSafe,
impl<'a, M, T, ES, NS, SP, F, R, MR, L> Unpin for ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
impl<'a, M, T, ES, NS, SP, F, R, MR, L> UnwindSafe for ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>where
ES: UnwindSafe,
NS: UnwindSafe,
SP: UnwindSafe,
F: UnwindSafe,
M: UnwindSafe,
T: UnwindSafe,
R: UnwindSafe,
MR: UnwindSafe,
L: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request