X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fchain%2Fmod.rs;h=1d51f262216d3620fb068908864db0c545f0f734;hb=aa127f55edc4439b03426644d178e402397329e8;hp=f7ddedef3a3e99b45f3fe8d35399fdce49b6c976;hpb=6cd6816cd7efce593ef487d07adfff66cee0daa2;p=rust-lightning diff --git a/lightning/src/chain/mod.rs b/lightning/src/chain/mod.rs index f7ddedef..1d51f262 100644 --- a/lightning/src/chain/mod.rs +++ b/lightning/src/chain/mod.rs @@ -14,7 +14,7 @@ use bitcoin::blockdata::transaction::TxOut; use bitcoin::hash_types::{BlockHash, Txid}; use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, MonitorEvent}; -use chain::keysinterface::ChannelKeys; +use chain::keysinterface::Sign; use chain::transaction::OutPoint; pub mod chaininterface; @@ -23,17 +23,6 @@ pub mod channelmonitor; pub mod transaction; pub mod keysinterface; -/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and -/// UTXOs. -pub trait Access: Send + Sync { - /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. - /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output - /// is unknown. - /// - /// [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id - fn get_utxo(&self, genesis_hash: &BlockHash, short_channel_id: u64) -> Result; -} - /// An error when accessing the chain via [`Access`]. /// /// [`Access`]: trait.Access.html @@ -46,6 +35,17 @@ pub enum AccessError { UnknownTx, } +/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and +/// UTXOs. +pub trait Access: Send + Sync { + /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. + /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output + /// is unknown. + /// + /// [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id + fn get_utxo(&self, genesis_hash: &BlockHash, short_channel_id: u64) -> Result; +} + /// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as /// blocks are connected and disconnected. /// @@ -67,10 +67,7 @@ pub enum AccessError { /// [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html /// [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html /// [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure -pub trait Watch: Send + Sync { - /// Keys needed by monitors for creating and signing transactions. - type Keys: ChannelKeys; - +pub trait Watch: Send + Sync { /// Watches a channel identified by `funding_txo` using `monitor`. /// /// Implementations are responsible for watching the chain for the funding transaction along @@ -80,7 +77,7 @@ pub trait Watch: Send + Sync { /// [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch /// [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected /// [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected - fn watch_channel(&self, funding_txo: OutPoint, monitor: ChannelMonitor) -> Result<(), ChannelMonitorUpdateErr>; + fn watch_channel(&self, funding_txo: OutPoint, monitor: ChannelMonitor) -> Result<(), ChannelMonitorUpdateErr>; /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. ///