[][src]Struct lightning::ln::channelmonitor::ChannelMonitor

pub struct ChannelMonitor { /* fields omitted */ }

A ChannelMonitor handles chain events (blocks connected and disconnected) and generates on-chain transactions to ensure no loss of funds occurs.

You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date information and are actively monitoring the chain.

Methods

impl ChannelMonitor[src]

pub fn insert_combine(
    &mut self,
    other: ChannelMonitor
) -> Result<(), MonitorUpdateError>
[src]

Combines this ChannelMonitor with the information contained in the other ChannelMonitor. After a successful call this ChannelMonitor is up-to-date and is safe to use to monitor the chain for new blocks/transactions.

pub fn get_funding_txo(&self) -> Option<OutPoint>[src]

Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.

pub fn get_monitored_outpoints(&self) -> Vec<(Sha256dHash, u32, &Script)>[src]

Gets the sets of all outpoints which this ChannelMonitor expects to hear about spends of. Generally useful when deserializing as during normal operation the return values of block_connected are sufficient to ensure all relevant outpoints are being monitored (note that the get_funding_txo outpoint and transaction must also be monitored for!).

pub fn write_for_disk<W: Writer>(&self, writer: &mut W) -> Result<(), Error>[src]

Writes this monitor into the given writer, suitable for writing to disk.

Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along the "reorg path" (ie not just starting at the same height but starting at the highest common block that appears on your best chain as well as on the chain which contains the last block hash returned) upon deserializing the object!

pub fn write_for_watchtower<W: Writer>(
    &self,
    writer: &mut W
) -> Result<(), Error>
[src]

Encodes this monitor into the given writer, suitable for sending to a remote watchtower

Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along the "reorg path" (ie not just starting at the same height but starting at the highest common block that appears on your best chain as well as on the chain which contains the last block hash returned) upon deserializing the object!

pub fn get_latest_local_commitment_txn(&self) -> Vec<Transaction>[src]

Used by ChannelManager deserialization to broadcast the latest local state if its copy of the Channel was out-of-date. You may use it to get a broadcastable local toxic tx in case of fallen-behind, i.e when receiving a channel_reestablish with a proof that our remote side knows a higher revocation secret than the local commitment number we are aware of. Broadcasting these transactions are UNSAFE, as they allow remote side to punish you. Nevertheless you may want to broadcast them if remote don't close channel with his higher commitment transaction after a substantial amount of time (a month or even a year) to get back funds. Best may be to contact out-of-band the other node operator to coordinate with him if option is available to you. In any-case, choice is up to the user.

Trait Implementations

impl Clone for ChannelMonitor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.