X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fchain%2Fmod.rs;h=33d4826fef210b849b61818fd9ba241aad2a9971;hb=eea56e967ff5f5fc903ce22c1b61415ccd48993e;hp=c54f9b1d7eba6814cb831bfd3c91c112fcc096cf;hpb=2fda791d5c36863ca69b290c9293db2fe0d35a25;p=rust-lightning diff --git a/lightning/src/chain/mod.rs b/lightning/src/chain/mod.rs index c54f9b1d..33d4826f 100644 --- a/lightning/src/chain/mod.rs +++ b/lightning/src/chain/mod.rs @@ -17,11 +17,11 @@ use bitcoin::hash_types::{BlockHash, Txid}; use bitcoin::network::constants::Network; use bitcoin::secp256k1::PublicKey; -use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent}; -use chain::keysinterface::Sign; -use chain::transaction::{OutPoint, TransactionData}; +use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent}; +use crate::chain::keysinterface::Sign; +use crate::chain::transaction::{OutPoint, TransactionData}; -use prelude::*; +use crate::prelude::*; pub mod chaininterface; pub mod chainmonitor; @@ -32,7 +32,7 @@ pub(crate) mod onchaintx; pub(crate) mod package; /// The best known block as identified by its hash and height. -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub struct BestBlock { block_hash: BlockHash, height: u32, @@ -171,7 +171,8 @@ pub trait Confirm { /// if they become available at the same time. fn best_block_updated(&self, header: &BlockHeader, height: u32); - /// Returns transactions that should be monitored for reorganization out of the chain. + /// Returns transactions that should be monitored for reorganization out of the chain along + /// with the hash of the block as part of which had been previously confirmed. /// /// Will include any transactions passed to [`transactions_confirmed`] that have insufficient /// confirmations to be safe from a chain reorganization. Will not include any transactions @@ -180,15 +181,17 @@ pub trait Confirm { /// May be called to determine the subset of transactions that must still be monitored for /// reorganization. Will be idempotent between calls but may change as a result of calls to the /// other interface methods. Thus, this is useful to determine which transactions may need to be - /// given to [`transaction_unconfirmed`]. + /// given to [`transaction_unconfirmed`]. If any of the returned transactions are confirmed in + /// a block other than the one with the given hash, they need to be unconfirmed and reconfirmed + /// via [`transaction_unconfirmed`] and [`transactions_confirmed`], respectively. /// /// [`transactions_confirmed`]: Self::transactions_confirmed /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed - fn get_relevant_txids(&self) -> Vec; + fn get_relevant_txids(&self) -> Vec<(Txid, Option)>; } /// An enum representing the status of a channel monitor update persistence. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ChannelMonitorUpdateStatus { /// The update has been durably persisted and all copies of the relevant [`ChannelMonitor`] /// have been updated. @@ -364,7 +367,7 @@ pub trait Filter { /// /// [`ChannelMonitor`]: channelmonitor::ChannelMonitor /// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected -#[derive(Clone, PartialEq, Hash)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct WatchedOutput { /// First block where the transaction output may have been spent. pub block_hash: Option,