//! Structs and traits which allow other parts of rust-lightning to interact with the blockchain.
-use bitcoin::blockdata::block::{Block, BlockHeader};
+use bitcoin::blockdata::block::{Block, Header};
use bitcoin::blockdata::constants::genesis_block;
-use bitcoin::blockdata::script::Script;
+use bitcoin::blockdata::script::{Script, ScriptBuf};
use bitcoin::hash_types::{BlockHash, Txid};
use bitcoin::network::constants::Network;
use bitcoin::secp256k1::PublicKey;
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent};
-use crate::sign::WriteableEcdsaChannelSigner;
+use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
use crate::chain::transaction::{OutPoint, TransactionData};
use crate::prelude::*;
pub trait Listen {
/// Notifies the listener that a block was added at the given height, with the transaction data
/// possibly filtered.
- fn filtered_block_connected(&self, header: &BlockHeader, txdata: &TransactionData, height: u32);
+ fn filtered_block_connected(&self, header: &Header, txdata: &TransactionData, height: u32);
/// Notifies the listener that a block was added at the given height.
fn block_connected(&self, block: &Block, height: u32) {
}
/// Notifies the listener that a block was removed at the given height.
- fn block_disconnected(&self, header: &BlockHeader, height: u32);
+ fn block_disconnected(&self, header: &Header, height: u32);
}
/// The `Confirm` trait is used to notify LDK when relevant transactions have been confirmed on
///
/// [chain order]: Confirm#order
/// [`best_block_updated`]: Self::best_block_updated
- fn transactions_confirmed(&self, header: &BlockHeader, txdata: &TransactionData, height: u32);
+ fn transactions_confirmed(&self, header: &Header, txdata: &TransactionData, height: u32);
/// Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization.
///
/// Must be called for any transaction returned by [`get_relevant_txids`] if it has been
///
/// Must be called whenever a new chain tip becomes available. May be skipped for intermediary
/// blocks.
- fn best_block_updated(&self, header: &BlockHeader, height: u32);
+ fn best_block_updated(&self, header: &Header, height: u32);
/// Returns transactions that must be monitored for reorganization out of the chain along
- /// with the hash of the block as part of which it had been previously confirmed.
+ /// with the height and the hash of the block as part of which it had been previously confirmed.
///
/// Note that the returned `Option<BlockHash>` might be `None` for channels created with LDK
/// 0.0.112 and prior, in which case you need to manually track previous confirmations.
/// 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.
+ /// given hash at the given height, 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<(Txid, Option<BlockHash>)>;
+ fn get_relevant_txids(&self) -> Vec<(Txid, u32, Option<BlockHash>)>;
}
/// An enum representing the status of a channel monitor update persistence.
pub outpoint: OutPoint,
/// Spending condition of the transaction output.
- pub script_pubkey: Script,
+ pub script_pubkey: ScriptBuf,
}
-impl<T: Listen> Listen for core::ops::Deref<Target = T> {
- fn filtered_block_connected(&self, header: &BlockHeader, txdata: &TransactionData, height: u32) {
+impl<T: Listen> Listen for dyn core::ops::Deref<Target = T> {
+ fn filtered_block_connected(&self, header: &Header, txdata: &TransactionData, height: u32) {
(**self).filtered_block_connected(header, txdata, height);
}
- fn block_disconnected(&self, header: &BlockHeader, height: u32) {
+ fn block_disconnected(&self, header: &Header, height: u32) {
(**self).block_disconnected(header, height);
}
}
T::Target: Listen,
U::Target: Listen,
{
- fn filtered_block_connected(&self, header: &BlockHeader, txdata: &TransactionData, height: u32) {
+ fn filtered_block_connected(&self, header: &Header, txdata: &TransactionData, height: u32) {
self.0.filtered_block_connected(header, txdata, height);
self.1.filtered_block_connected(header, txdata, height);
}
- fn block_disconnected(&self, header: &BlockHeader, height: u32) {
+ fn block_disconnected(&self, header: &Header, height: u32) {
self.0.block_disconnected(header, height);
self.1.block_disconnected(header, height);
}