use bitcoin::blockdata::block::BlockHeader;
use bitcoin::blockdata::constants::genesis_block;
-use bitcoin::blockdata::transaction::Transaction;
use bitcoin::network::constants::Network;
use bitcoin::hashes::{Hash, HashEngine};
use chain;
use chain::Watch;
-use chain::chaininterface::{BroadcasterInterface,ChainListener,FeeEstimator};
-use chain::transaction::OutPoint;
+use chain::chaininterface::{BroadcasterInterface, FeeEstimator};
+use chain::chainmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, HTLC_FAIL_BACK_BUFFER, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY, MonitorEvent};
+use chain::transaction::{OutPoint, TransactionData};
use ln::channel::{Channel, ChannelError};
-use ln::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, HTLC_FAIL_BACK_BUFFER, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY, MonitorEvent};
use ln::features::{InitFeatures, NodeFeatures};
use routing::router::{Route, RouteHop};
use ln::msgs;
/// Tracks the inbound corresponding to an outbound HTLC
#[derive(Clone, PartialEq)]
-pub(super) struct HTLCPreviousHopData {
+pub(crate) struct HTLCPreviousHopData {
short_channel_id: u64,
htlc_id: u64,
incoming_packet_shared_secret: [u8; 32],
/// Tracks the inbound corresponding to an outbound HTLC
#[derive(Clone, PartialEq)]
-pub(super) enum HTLCSource {
+pub(crate) enum HTLCSource {
PreviousHopData(HTLCPreviousHopData),
OutboundRoute {
path: Vec<RouteHop>,
///
/// Users need to notify the new ChannelManager when a new block is connected or
/// disconnected using its `block_connected` and `block_disconnected` methods.
- /// However, rather than calling these methods directly, the user should register
- /// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
- /// `block_(dis)connected` methods, which will notify all registered listeners in one
- /// go.
pub fn new(network: Network, fee_est: F, chain_monitor: M, tx_broadcaster: T, logger: L, keys_manager: K, config: UserConfig, current_blockchain_height: usize) -> Self {
let secp_ctx = Secp256k1::new();
}
}
-impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K: Deref + Sync + Send, F: Deref + Sync + Send, L: Deref + Sync + Send>
- ChainListener for ChannelManager<ChanSigner, M, T, K, F, L>
+impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<ChanSigner, M, T, K, F, L>
where M::Target: chain::Watch<Keys=ChanSigner>,
T::Target: BroadcasterInterface,
K::Target: KeysInterface<ChanKeySigner = ChanSigner>,
F::Target: FeeEstimator,
- L::Target: Logger,
+ L::Target: Logger,
{
- fn block_connected(&self, header: &BlockHeader, txdata: &[(usize, &Transaction)], height: u32) {
+ /// Updates channel state based on transactions seen in a connected block.
+ pub fn block_connected(&self, header: &BlockHeader, txdata: &TransactionData, height: u32) {
let header_hash = header.block_hash();
log_trace!(self.logger, "Block {} at height {} connected", header_hash, height);
let _ = self.total_consistency_lock.read().unwrap();
}
}
- /// We force-close the channel without letting our counterparty participate in the shutdown
- fn block_disconnected(&self, header: &BlockHeader, _: u32) {
+ /// Updates channel state based on a disconnected block.
+ ///
+ /// If necessary, the channel may be force-closed without letting the counterparty participate
+ /// in the shutdown.
+ pub fn block_disconnected(&self, header: &BlockHeader) {
let _ = self.total_consistency_lock.read().unwrap();
let mut failed_channels = Vec::new();
{