Struct lightning::chain::chainmonitor::ChainMonitor
source · [−]pub struct ChainMonitor<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,{ /* private fields */ }
Expand description
An implementation of chain::Watch
for monitoring channels.
Connected and disconnected blocks must be provided to ChainMonitor
as documented by
chain::Watch
. May be used in conjunction with ChannelManager
to monitor channels locally
or used independently to monitor channels remotely. See the module-level documentation for
details.
Implementations
sourceimpl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
sourcepub fn new(
chain_source: Option<C>,
broadcaster: T,
logger: L,
feeest: F,
persister: P
) -> Self
pub fn new(
chain_source: Option<C>,
broadcaster: T,
logger: L,
feeest: F,
persister: P
) -> Self
Creates a new ChainMonitor
used to watch on-chain activity pertaining to channels.
When an optional chain source implementing chain::Filter
is provided, the chain monitor
will call back to it indicating transactions and outputs of interest. This allows clients to
pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may
always need to fetch full blocks absent another means for determining which blocks contain
transactions relevant to the watched channels.
sourcepub fn get_claimable_balances(
&self,
ignored_channels: &[&ChannelDetails]
) -> Vec<Balance>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn get_claimable_balances(
&self,
ignored_channels: &[&ChannelDetails]
) -> Vec<Balance>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Gets the balances in the contained ChannelMonitor
s which are claimable on-chain or
claims which are awaiting confirmation.
Includes the balances from each ChannelMonitor
except those included in
ignored_channels
, allowing you to filter out balances from channels which are still open
(and whose balance should likely be pulled from the ChannelDetails
).
See ChannelMonitor::get_claimable_balances
for more details on the exact criteria for
inclusion in the return value.
sourcepub fn get_monitor(
&self,
funding_txo: OutPoint
) -> Result<LockedChannelMonitor<'_, ChannelSigner>, ()>
pub fn get_monitor(
&self,
funding_txo: OutPoint
) -> Result<LockedChannelMonitor<'_, ChannelSigner>, ()>
Gets the LockedChannelMonitor
for a given funding outpoint, returning an Err
if no
such ChannelMonitor
is currently being monitored for.
Note that the result holds a mutex over our monitor set, and should not be held indefinitely.
sourcepub fn list_monitors(&self) -> Vec<OutPoint>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn list_monitors(&self) -> Vec<OutPoint>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Lists the funding outpoint of each ChannelMonitor
being monitored.
Note that ChannelMonitor
s are not removed when a channel is closed as they are always
monitoring for on-chain state resolutions.
sourcepub fn channel_monitor_updated(
&self,
funding_txo: OutPoint,
completed_update_id: MonitorUpdateId
) -> Result<(), APIError>
pub fn channel_monitor_updated(
&self,
funding_txo: OutPoint,
completed_update_id: MonitorUpdateId
) -> Result<(), APIError>
Indicates the persistence of a ChannelMonitor
has completed after
ChannelMonitorUpdateStatus::InProgress
was returned from an update operation.
Thus, the anticipated use is, at a high level:
- This
ChainMonitor
callsPersist::update_persisted_channel
which stores the update to disk and begins updating any remote (e.g. watchtower/backup) copies, returningChannelMonitorUpdateStatus::InProgress
, - once all remote copies are updated, you call this function with the
completed_update_id
that completed, and once all pending updates have completed the channel will be re-enabled.
Returns an APIError::APIMisuseError
if funding_txo
does not match any currently
registered ChannelMonitor
s.
Trait Implementations
sourceimpl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> Confirm for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> Confirm for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
sourcefn transactions_confirmed(
&self,
header: &BlockHeader,
txdata: &TransactionData<'_>,
height: u32
)
fn transactions_confirmed(
&self,
header: &BlockHeader,
txdata: &TransactionData<'_>,
height: u32
)
sourcefn transaction_unconfirmed(&self, txid: &Txid)
fn transaction_unconfirmed(&self, txid: &Txid)
sourcefn best_block_updated(&self, header: &BlockHeader, height: u32)
fn best_block_updated(&self, header: &BlockHeader, height: u32)
sourceimpl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> EventsProvider for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> EventsProvider for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
sourcefn process_pending_events<H: Deref>(&self, handler: H)where
H::Target: EventHandler,
fn process_pending_events<H: Deref>(&self, handler: H)where
H::Target: EventHandler,
Processes SpendableOutputs
events produced from each ChannelMonitor
upon maturity.
An EventHandler
may safely call back to the provider, though this shouldn’t be needed in
order to handle these events.
sourceimpl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> Listen for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> Listen for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
sourcefn filtered_block_connected(
&self,
header: &BlockHeader,
txdata: &TransactionData<'_>,
height: u32
)
fn filtered_block_connected(
&self,
header: &BlockHeader,
txdata: &TransactionData<'_>,
height: u32
)
sourcefn block_disconnected(&self, header: &BlockHeader, height: u32)
fn block_disconnected(&self, header: &BlockHeader, height: u32)
sourcefn block_connected(&self, block: &Block, height: u32)
fn block_connected(&self, block: &Block, height: u32)
sourceimpl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> Watch<ChannelSigner> for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> Watch<ChannelSigner> for ChainMonitor<ChannelSigner, C, T, F, L, P>where
C::Target: Filter,
T::Target: BroadcasterInterface,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
sourcefn watch_channel(
&self,
funding_outpoint: OutPoint,
monitor: ChannelMonitor<ChannelSigner>
) -> ChannelMonitorUpdateStatus
fn watch_channel(
&self,
funding_outpoint: OutPoint,
monitor: ChannelMonitor<ChannelSigner>
) -> ChannelMonitorUpdateStatus
Adds the monitor that watches the channel referred to by the given outpoint.
Calls back to chain::Filter
with the funding transaction and outputs to watch.
Note that we persist the given ChannelMonitor
while holding the ChainMonitor
monitors lock.
sourcefn update_channel(
&self,
funding_txo: OutPoint,
update: ChannelMonitorUpdate
) -> ChannelMonitorUpdateStatus
fn update_channel(
&self,
funding_txo: OutPoint,
update: ChannelMonitorUpdate
) -> ChannelMonitorUpdateStatus
Note that we persist the given ChannelMonitor
update while holding the
ChainMonitor
monitors lock.