Struct lightning_signer::monitor::ChainMonitor

source ·
pub struct ChainMonitor {
    pub funding_outpoint: OutPoint,
    pub state: Arc<Mutex<State>>,
    /* private fields */
}
Expand description

Keep track of channel on-chain events. Note that this object has refcounted state, so is lightweight to clone.

Fields§

§funding_outpoint: OutPoint

the first funding outpoint, used to identify the channel / channel monitor

§state: Arc<Mutex<State>>

the monitor state

Implementations§

source§

impl ChainMonitor

source

pub fn as_base(&self) -> ChainMonitorBase

Get the base

source

pub fn get_state(&self) -> MutexGuard<'_, State>

Get the locked state

source

pub fn add_funding(&self, tx: &Transaction, vout: u32)

Add a funding transaction to keep track of For dual-funding

source

pub fn funding_depth(&self) -> u32

Returns the number of confirmations of the funding transaction, or zero if it wasn’t confirmed yet.

source

pub fn funding_double_spent_depth(&self) -> u32

Returns the number of confirmations of a double-spend of the funding transaction or zero if it wasn’t double-spent.

source

pub fn closing_depth(&self) -> u32

Returns the number of confirmations of the closing transaction, or zero

source

pub fn is_done(&self) -> bool

Whether this channel can be forgotten:

  • mutual close is confirmed
  • unilateral close is swept
  • funding transaction is double-spent and enough confirmations have passed

Trait Implementations§

source§

impl ChainListener for ChainMonitor

§

type Key = OutPoint

The key type
source§

fn key(&self) -> &Self::Key

The key
source§

fn on_add_block( &self, txs: &[Transaction], block_hash: &BlockHash ) -> (Vec<OutPoint>, Vec<OutPoint>)

A block was added via a compact proof. The listener returns outpoints to watch in the future, and outpoints to stop watching.
source§

fn on_add_streamed_block_end( &self, block_hash: &BlockHash ) -> (Vec<OutPoint>, Vec<OutPoint>)

A block was added via streaming (see on_block_chunk). The listener returns outpoints to watch in the future, and outpoints to stop watching. The decoded block hash is also returned.
source§

fn on_remove_block( &self, txs: &[Transaction], block_hash: &BlockHash ) -> (Vec<OutPoint>, Vec<OutPoint>)

A block was deleted via a compact proof. The listener returns the same thing as on_add_block, so that the changes can be reverted. The decoded block hash is also returned.
source§

fn on_remove_streamed_block_end( &self, block_hash: &BlockHash ) -> (Vec<OutPoint>, Vec<OutPoint>)

A block was deleted via streaming (see on_block_chunk). The listener returns the same thing as on_add_block, so that the changes can be reverted.
source§

fn on_push<F>(&self, f: F)
where F: FnOnce(&mut dyn Listener),

Get the block push decoder listener
source§

impl Clone for ChainMonitor

source§

fn clone(&self) -> ChainMonitor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl SendSync for ChainMonitor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V