+ }
+
+ /// Updates channel state to take note of transactions which were confirmed in the given block
+ /// at the given height.
+ ///
+ /// Note that you must still call (or have called) [`update_best_block`] with the block
+ /// information which is included here.
+ ///
+ /// This method may be called before or after [`update_best_block`] for a given block's
+ /// transaction data and may be called multiple times with additional transaction data for a
+ /// given block.
+ ///
+ /// This method may be called for a previous block after an [`update_best_block`] call has
+ /// been made for a later block, however it must *not* be called with transaction data from a
+ /// block which is no longer in the best chain (ie where [`update_best_block`] has already
+ /// been informed about a blockchain reorganization which no longer includes the block which
+ /// corresponds to `header`).
+ ///
+ /// [`update_best_block`]: `Self::update_best_block`
+ pub fn transactions_confirmed(&self, header: &BlockHeader, height: u32, txdata: &TransactionData) {
+ // Note that we MUST NOT end up calling methods on self.chain_monitor here - we're called
+ // during initialization prior to the chain_monitor being fully configured in some cases.
+ // See the docs for `ChannelManagerReadArgs` for more.
+
+ let block_hash = header.block_hash();
+ log_trace!(self.logger, "{} transactions included in block {} at height {} provided", txdata.len(), block_hash, height);
+
+ let _persistence_guard = PersistenceNotifierGuard::new(&self.total_consistency_lock, &self.persistence_notifier);
+ self.do_chain_event(height, |channel| channel.transactions_confirmed(&block_hash, height, txdata, &self.logger).map(|_| (None, Vec::new())));
+ }
+
+ /// Updates channel state with the current best blockchain tip. You should attempt to call this
+ /// quickly after a new block becomes available, however if multiple new blocks become
+ /// available at the same time, only a single `update_best_block()` call needs to be made.
+ ///
+ /// This method should also be called immediately after any block disconnections, once at the
+ /// reorganization fork point, and once with the new chain tip. Calling this method at the
+ /// blockchain reorganization fork point ensures we learn when a funding transaction which was
+ /// previously confirmed is reorganized out of the blockchain, ensuring we do not continue to
+ /// accept payments which cannot be enforced on-chain.
+ ///
+ /// In both the block-connection and block-disconnection case, this method may be called either
+ /// once per block connected or disconnected, or simply at the fork point and new tip(s),
+ /// skipping any intermediary blocks.
+ pub fn update_best_block(&self, header: &BlockHeader, height: u32) {
+ // Note that we MUST NOT end up calling methods on self.chain_monitor here - we're called
+ // during initialization prior to the chain_monitor being fully configured in some cases.
+ // See the docs for `ChannelManagerReadArgs` for more.
+
+ let block_hash = header.block_hash();
+ log_trace!(self.logger, "New best block: {} at height {}", block_hash, height);
+
+ let _persistence_guard = PersistenceNotifierGuard::new(&self.total_consistency_lock, &self.persistence_notifier);
+