Struct lightning_signer::monitor::ChainMonitor
source · pub struct ChainMonitor {
pub funding_outpoint: OutPoint,
pub state: Arc<Mutex<State>>,
}
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
impl ChainMonitor
sourcepub fn new(funding_outpoint: OutPoint, height: u32) -> Self
pub fn new(funding_outpoint: OutPoint, height: u32) -> Self
Create a new chain monitor. Use add_funding to really start monitoring.
sourcepub fn new_from_persistence(funding_outpoint: OutPoint, state: State) -> Self
pub fn new_from_persistence(funding_outpoint: OutPoint, state: State) -> Self
recreate this monitor after restoring from persistence
sourcepub fn get_state(&self) -> MutexGuard<'_, State>
pub fn get_state(&self) -> MutexGuard<'_, State>
Get the locked state
sourcepub fn add_funding_outpoint(&self, outpoint: &OutPoint)
pub fn add_funding_outpoint(&self, outpoint: &OutPoint)
Add a funding transaction to keep track of For single-funding
sourcepub fn add_funding(&self, tx: &Transaction, vout: u32)
pub fn add_funding(&self, tx: &Transaction, vout: u32)
Add a funding transaction to keep track of For dual-funding
sourcepub fn funding_depth(&self) -> u32
pub fn funding_depth(&self) -> u32
Returns the number of confirmations of the funding transaction, or zero if it wasn’t confirmed yet.
sourcepub fn funding_double_spent_depth(&self) -> u32
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.
sourcepub fn as_chain_state(&self) -> ChainState
pub fn as_chain_state(&self) -> ChainState
Convert to a ChainState, to be used for validation
Trait Implementations§
source§impl ChainListener for ChainMonitor
impl ChainListener for ChainMonitor
source§fn on_add_block(&self, txs: Vec<&Transaction>) -> Vec<OutPoint> ⓘ
fn on_add_block(&self, txs: Vec<&Transaction>) -> Vec<OutPoint> ⓘ
A block was added, and zero or more transactions consume watched outpoints.
The listener returns zero or more new outpoints to watch.
source§fn on_remove_block(&self, txs: Vec<&Transaction>)
fn on_remove_block(&self, txs: Vec<&Transaction>)
A block was deleted.
The tracker will revert any changes to the watched outpoints set.
source§impl Clone for ChainMonitor
impl Clone for ChainMonitor
source§fn clone(&self) -> ChainMonitor
fn clone(&self) -> ChainMonitor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Ord for ChainMonitor
impl Ord for ChainMonitor
source§impl PartialEq<ChainMonitor> for ChainMonitor
impl PartialEq<ChainMonitor> for ChainMonitor
source§impl PartialOrd<ChainMonitor> for ChainMonitor
impl PartialOrd<ChainMonitor> for ChainMonitor
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for ChainMonitor
impl SendSync for ChainMonitor
Auto Trait Implementations§
impl RefUnwindSafe for ChainMonitor
impl Send for ChainMonitor
impl Sync for ChainMonitor
impl Unpin for ChainMonitor
impl UnwindSafe for ChainMonitor
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.