From: Arik Sosman Date: Tue, 20 Dec 2022 22:46:08 +0000 (-0800) Subject: Remove KeysInterface trait. X-Git-Tag: v0.0.114-beta~65^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=5824e226cad67e32d5e8be71ebbb6f91a3fc2116;p=rust-lightning Remove KeysInterface trait. --- diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index e1bf9cb54..a181e1c28 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -36,7 +36,7 @@ use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, chainmonitor, chan use lightning::chain::channelmonitor::{ChannelMonitor, MonitorEvent}; use lightning::chain::transaction::OutPoint; use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator}; -use lightning::chain::keysinterface::{KeyMaterial, KeysInterface, InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider}; +use lightning::chain::keysinterface::{KeyMaterial, InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider}; use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use lightning::ln::channelmanager::{self, ChainParameters, ChannelDetails, ChannelManager, PaymentSendFailure, ChannelManagerReadArgs, PaymentId}; use lightning::ln::channel::FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE; @@ -270,8 +270,6 @@ impl SignerProvider for KeyProvider { } } -impl KeysInterface for KeyProvider {} - impl KeyProvider { fn make_enforcement_state_cell(&self, commitment_seed: [u8; 32]) -> Arc> { let mut revoked_commitments = self.enforcement_states.lock().unwrap(); diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index 2d9be101e..2af7009eb 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -33,7 +33,7 @@ use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen}; use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator}; use lightning::chain::chainmonitor; use lightning::chain::transaction::OutPoint; -use lightning::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, KeysInterface, EntropySource, NodeSigner, SignerProvider}; +use lightning::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider}; use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentId}; use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler}; @@ -387,8 +387,6 @@ impl SignerProvider for KeyProvider { } } -impl KeysInterface for KeyProvider {} - #[inline] pub fn do_test(data: &[u8], logger: &Arc) { let input = Arc::new(InputData { @@ -444,7 +442,7 @@ pub fn do_test(data: &[u8], logger: &Arc) { best_block: BestBlock::from_genesis(network), }; let channelmanager = Arc::new(ChannelManager::new(fee_est.clone(), monitor.clone(), broadcast.clone(), &router, Arc::clone(&logger), keys_manager.clone(), config, params)); - // Adding new calls to `KeysInterface::get_secure_random_bytes` during startup can change all the + // Adding new calls to `EntropySource::get_secure_random_bytes` during startup can change all the // keys subsequently generated in this test. Rather than regenerating all the messages manually, // it's easier to just increment the counter here so the keys don't change. keys_manager.counter.fetch_sub(3, Ordering::AcqRel); diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index 4841f1c30..3075a54b6 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -5,7 +5,7 @@ use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey}; use bitcoin::secp256k1::ecdh::SharedSecret; use bitcoin::secp256k1::ecdsa::RecoverableSignature; -use lightning::chain::keysinterface::{Recipient, KeyMaterial, KeysInterface, EntropySource, NodeSigner, SignerProvider}; +use lightning::chain::keysinterface::{Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider}; use lightning::ln::msgs::{self, DecodeError, OnionMessageHandler}; use lightning::ln::script::ShutdownScript; use lightning::util::enforcing_trait_impls::EnforcingSigner; @@ -140,8 +140,6 @@ impl SignerProvider for KeyProvider { fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!() } } -impl KeysInterface for KeyProvider {} - #[cfg(test)] mod tests { use lightning::util::logger::{Logger, Record}; diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 199295b9f..585f62c86 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -17,7 +17,7 @@ extern crate lightning_rapid_gossip_sync; use lightning::chain; use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator}; use lightning::chain::chainmonitor::{ChainMonitor, Persist}; -use lightning::chain::keysinterface::{KeysInterface, SignerProvider}; +use lightning::chain::keysinterface::{EntropySource, NodeSigner, SignerProvider}; use lightning::ln::channelmanager::ChannelManager; use lightning::ln::msgs::{ChannelMessageHandler, OnionMessageHandler, RoutingMessageHandler}; use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor}; @@ -374,7 +374,7 @@ where CF::Target: 'static + chain::Filter, CW::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + EntropySource + NodeSigner + SignerProvider, F::Target: 'static + FeeEstimator, R::Target: 'static + Router, L::Target: 'static + Logger, @@ -490,7 +490,7 @@ impl BackgroundProcessor { CF::Target: 'static + chain::Filter, CW::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + EntropySource + NodeSigner + SignerProvider, F::Target: 'static + FeeEstimator, R::Target: 'static + Router, L::Target: 'static + Logger, @@ -575,7 +575,7 @@ mod tests { use bitcoin::network::constants::Network; use lightning::chain::{BestBlock, Confirm, chainmonitor}; use lightning::chain::channelmonitor::ANTI_REORG_DELAY; - use lightning::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, KeysInterface, KeysManager, NodeSigner}; + use lightning::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, KeysManager, NodeSigner}; use lightning::chain::transaction::OutPoint; use lightning::get_event_msg; use lightning::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChainParameters, ChannelManager, SimpleArcChannelManager}; diff --git a/lightning-block-sync/src/init.rs b/lightning-block-sync/src/init.rs index 23e4435a6..72a6ec4b0 100644 --- a/lightning-block-sync/src/init.rs +++ b/lightning-block-sync/src/init.rs @@ -48,7 +48,7 @@ BlockSourceResult where B::Target: BlockSource { /// use lightning::chain::chaininterface::BroadcasterInterface; /// use lightning::chain::chaininterface::FeeEstimator; /// use lightning::chain::keysinterface; -/// use lightning::chain::keysinterface::KeysInterface; +/// use lightning::chain::keysinterface::{EntropySource, NodeSigner, SignerProvider}; /// use lightning::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs}; /// use lightning::routing::router::Router; /// use lightning::util::config::UserConfig; @@ -61,7 +61,7 @@ BlockSourceResult where B::Target: BlockSource { /// /// async fn init_sync< /// B: BlockSource, -/// K: KeysInterface, +/// K: EntropySource + NodeSigner + SignerProvider, /// T: BroadcasterInterface, /// F: FeeEstimator, /// R: Router, diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs index 1f6dc619a..91f0cfa18 100644 --- a/lightning-invoice/src/utils.rs +++ b/lightning-invoice/src/utils.rs @@ -8,7 +8,7 @@ use bech32::ToBase32; use bitcoin_hashes::Hash; use lightning::chain; use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator}; -use lightning::chain::keysinterface::{Recipient, KeysInterface, NodeSigner, SignerProvider}; +use lightning::chain::keysinterface::{Recipient, NodeSigner, SignerProvider, EntropySource}; use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY}; #[cfg(feature = "std")] @@ -42,7 +42,7 @@ use core::time::Duration; /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for /// in excess of the current time. /// -/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom +/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this /// requirement). /// @@ -57,7 +57,7 @@ pub fn create_phantom_invoice( logger: L, network: Currency, ) -> Result> where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, L::Target: Logger, { let description = Description::new(description).map_err(SignOrCreationError::CreationError)?; @@ -91,7 +91,7 @@ where /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for /// in excess of the current time. /// -/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom +/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this /// requirement). /// @@ -106,7 +106,7 @@ pub fn create_phantom_invoice_with_description_hash( logger: L, network: Currency ) -> Result> where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, L::Target: Logger, { _create_phantom_invoice::( @@ -122,7 +122,7 @@ fn _create_phantom_invoice( logger: L, network: Currency, ) -> Result> where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, L::Target: Logger, { use std::time::{SystemTime, UNIX_EPOCH}; @@ -239,7 +239,7 @@ pub fn create_invoice_from_channelmanager::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -271,7 +271,7 @@ pub fn create_invoice_from_channelmanager_with_description_hash::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -299,7 +299,7 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -322,7 +322,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -344,7 +344,7 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -370,7 +370,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_ where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -395,7 +395,7 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_has where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -576,7 +576,7 @@ impl Payer for Chann where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -630,7 +630,6 @@ mod test { use lightning::util::events::{MessageSendEvent, MessageSendEventsProvider, Event}; use lightning::util::test_utils; use lightning::util::config::UserConfig; - use lightning::chain::keysinterface::KeysInterface; use crate::utils::create_invoice_from_channelmanager_and_duration_since_epoch; use std::collections::HashSet; diff --git a/lightning-persister/src/lib.rs b/lightning-persister/src/lib.rs index bf1c01221..7eba088a1 100644 --- a/lightning-persister/src/lib.rs +++ b/lightning-persister/src/lib.rs @@ -20,7 +20,7 @@ extern crate libc; use bitcoin::hash_types::{BlockHash, Txid}; use bitcoin::hashes::hex::FromHex; use lightning::chain::channelmonitor::ChannelMonitor; -use lightning::chain::keysinterface::{KeysInterface, SignerProvider}; +use lightning::chain::keysinterface::{EntropySource, SignerProvider}; use lightning::util::ser::{ReadableArgs, Writeable}; use lightning::util::persist::KVStorePersister; use std::fs; @@ -62,7 +62,7 @@ impl FilesystemPersister { pub fn read_channelmonitors ( &self, keys_manager: K ) -> std::io::Result::Signer>)>> - where K::Target: KeysInterface + Sized, + where K::Target: EntropySource + SignerProvider + Sized, { let mut path = PathBuf::from(&self.path_to_channel_data); path.push("monitors"); diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index db1781059..e16a533cb 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -42,7 +42,7 @@ use crate::chain; use crate::chain::{BestBlock, WatchedOutput}; use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator, LowerBoundedFeeEstimator}; use crate::chain::transaction::{OutPoint, TransactionData}; -use crate::chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, Sign, KeysInterface}; +use crate::chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, Sign, SignerProvider, EntropySource}; #[cfg(anchors)] use crate::chain::onchaintx::ClaimEvent; use crate::chain::onchaintx::OnchainTxHandler; @@ -3704,7 +3704,7 @@ where const MAX_ALLOC_SIZE: usize = 64*1024; -impl<'a, K: KeysInterface> ReadableArgs<&'a K> +impl<'a, K: EntropySource + SignerProvider> ReadableArgs<&'a K> for (BlockHash, ChannelMonitor) { fn read(reader: &mut R, keys_manager: &'a K) -> Result { macro_rules! unwrap_obj { diff --git a/lightning/src/chain/keysinterface.rs b/lightning/src/chain/keysinterface.rs index 16075cdac..9fc00e252 100644 --- a/lightning/src/chain/keysinterface.rs +++ b/lightning/src/chain/keysinterface.rs @@ -137,7 +137,7 @@ impl_writeable_tlv_based!(StaticPaymentOutputDescriptor, { /// [`SpendableOutputs`]: crate::util::events::Event::SpendableOutputs #[derive(Clone, Debug, PartialEq, Eq)] pub enum SpendableOutputDescriptor { - /// An output to a script which was provided via [`KeysInterface`] directly, either from + /// An output to a script which was provided via [`SignerProvider`] directly, either from /// [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already /// know how to spend it. No secret keys are provided as LDK was never given any key. /// These may include outputs from a transaction punishing our counterparty or claiming an HTLC @@ -517,7 +517,7 @@ pub trait SignerProvider { /// [`BaseSign::channel_keys_id`]. fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer; - /// Reads a [`Signer`] for this [`KeysInterface`] from the given input stream. + /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. /// This is only called during deserialization of other objects which contain /// [`Sign`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). /// The bytes are exactly those which `::write()` writes, and @@ -545,9 +545,6 @@ pub trait SignerProvider { fn get_shutdown_scriptpubkey(&self) -> ShutdownScript; } -/// A trait to describe an object which can get user secrets and key material. -pub trait KeysInterface: EntropySource + NodeSigner + SignerProvider {} - #[derive(Clone)] /// A simple implementation of [`Sign`] that just keeps the private keys in memory. /// @@ -954,8 +951,8 @@ impl ReadableArgs for InMemorySigner { } } -/// Simple [`KeysInterface`] implementation that takes a 32-byte seed for use as a BIP 32 extended -/// key and derives keys from that. +/// Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a +/// 32-byte seed for use as a BIP 32 extended key and derives keys from that. /// /// Your `node_id` is seed/0'. /// Unilateral closes may use seed/1'. @@ -1331,8 +1328,6 @@ impl SignerProvider for KeysManager { } } -impl KeysInterface for KeysManager {} - /// Similar to [`KeysManager`], but allows the node using this struct to receive phantom node /// payments. /// @@ -1425,8 +1420,6 @@ impl SignerProvider for PhantomKeysManager { } } -impl KeysInterface for PhantomKeysManager {} - impl PhantomKeysManager { /// Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` /// that is shared across all nodes that intend to participate in [phantom node payments] diff --git a/lightning/src/chain/onchaintx.rs b/lightning/src/chain/onchaintx.rs index 9bfe6fa9a..8feaf6e6a 100644 --- a/lightning/src/chain/onchaintx.rs +++ b/lightning/src/chain/onchaintx.rs @@ -21,7 +21,7 @@ use bitcoin::hash_types::{Txid, BlockHash}; use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature}; use bitcoin::secp256k1; -use crate::chain::keysinterface::BaseSign; +use crate::chain::keysinterface::{BaseSign, EntropySource, SignerProvider}; use crate::ln::msgs::DecodeError; use crate::ln::PaymentPreimage; #[cfg(anchors)] @@ -31,7 +31,7 @@ use crate::ln::chan_utils::{ChannelTransactionParameters, HolderCommitmentTransa use crate::chain::chaininterface::ConfirmationTarget; use crate::chain::chaininterface::{FeeEstimator, BroadcasterInterface, LowerBoundedFeeEstimator}; use crate::chain::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER}; -use crate::chain::keysinterface::{Sign, KeysInterface}; +use crate::chain::keysinterface::Sign; #[cfg(anchors)] use crate::chain::package::PackageSolvingData; use crate::chain::package::PackageTemplate; @@ -322,7 +322,7 @@ impl OnchainTxHandler { } } -impl<'a, K: KeysInterface> ReadableArgs<(&'a K, u64, [u8; 32])> for OnchainTxHandler { +impl<'a, K: EntropySource + SignerProvider> ReadableArgs<(&'a K, u64, [u8; 32])> for OnchainTxHandler { fn read(reader: &mut R, args: (&'a K, u64, [u8; 32])) -> Result { let keys_manager = args.0; let channel_value_satoshis = args.1; diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index bbf0be788..cd9f261b2 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -1635,7 +1635,7 @@ mod tests { use crate::ln::chan_utils::{get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment}; use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1}; use crate::util::test_utils; - use crate::chain::keysinterface::{KeysInterface, BaseSign, SignerProvider}; + use crate::chain::keysinterface::{BaseSign, SignerProvider}; use bitcoin::{Network, Txid}; use bitcoin::hashes::Hash; use crate::ln::PaymentHash; diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 76dc15065..5e2e9d93b 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -35,7 +35,7 @@ use crate::chain::BestBlock; use crate::chain::chaininterface::{FeeEstimator, ConfirmationTarget, LowerBoundedFeeEstimator}; use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS}; use crate::chain::transaction::{OutPoint, TransactionData}; -use crate::chain::keysinterface::{Sign, EntropySource, KeysInterface, BaseSign, SignerProvider}; +use crate::chain::keysinterface::{Sign, EntropySource, BaseSign, SignerProvider}; use crate::util::events::ClosureReason; use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter}; use crate::util::logger::Logger; @@ -908,7 +908,7 @@ impl Channel { channel_value_satoshis: u64, push_msat: u64, user_id: u128, config: &UserConfig, current_chain_height: u32, outbound_scid_alias: u64 ) -> Result, APIError> - where K::Target: KeysInterface, + where K::Target: EntropySource + SignerProvider, F::Target: FeeEstimator, { let opt_anchors = false; // TODO - should be based on features @@ -1120,7 +1120,7 @@ impl Channel { msg: &msgs::OpenChannel, user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L, outbound_scid_alias: u64 ) -> Result, ChannelError> - where K::Target: KeysInterface, + where K::Target: EntropySource + SignerProvider, F::Target: FeeEstimator, L::Target: Logger, { @@ -2225,7 +2225,7 @@ impl Channel { &mut self, msg: &msgs::FundingCreated, best_block: BestBlock, keys_source: &K, logger: &L ) -> Result<(msgs::FundingSigned, ChannelMonitor<::Signer>, Option), ChannelError> where - K::Target: KeysInterface, + K::Target: SignerProvider, L::Target: Logger { if self.is_outbound() { @@ -2313,7 +2313,7 @@ impl Channel { &mut self, msg: &msgs::FundingSigned, best_block: BestBlock, keys_source: &K, logger: &L ) -> Result<(ChannelMonitor<::Signer>, Transaction, Option), ChannelError> where - K::Target: KeysInterface, + K::Target: SignerProvider, L::Target: Logger { if !self.is_outbound() { @@ -4226,7 +4226,7 @@ impl Channel { pub fn shutdown( &mut self, keys_provider: &K, their_features: &InitFeatures, msg: &msgs::Shutdown ) -> Result<(Option, Option, Vec<(HTLCSource, PaymentHash)>), ChannelError> - where K::Target: KeysInterface + where K::Target: SignerProvider { if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 { return Err(ChannelError::Close("Peer sent shutdown when we needed a channel_reestablish".to_owned())); @@ -5847,7 +5847,7 @@ impl Channel { /// holding cell HTLCs for payment failure. pub fn get_shutdown(&mut self, keys_provider: &K, their_features: &InitFeatures, target_feerate_sats_per_kw: Option) -> Result<(msgs::Shutdown, Option, Vec<(HTLCSource, PaymentHash)>), APIError> - where K::Target: KeysInterface { + where K::Target: SignerProvider { for htlc in self.pending_outbound_htlcs.iter() { if let OutboundHTLCState::LocalAnnounced(_) = htlc.state { return Err(APIError::APIMisuseError{err: "Cannot begin shutdown with pending HTLCs. Process pending events first".to_owned()}); @@ -6330,7 +6330,7 @@ impl Writeable for Channel { const MAX_ALLOC_SIZE: usize = 64*1024; impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<::Signer> - where K::Target: KeysInterface { + where K::Target: EntropySource + SignerProvider { fn read(reader: &mut R, args: (&'a K, u32)) -> Result { let (keys_source, serialized_height) = args; let ver = read_ver_prefix!(reader, SERIALIZATION_VERSION); @@ -6802,7 +6802,7 @@ mod tests { use crate::ln::chan_utils::{htlc_success_tx_weight, htlc_timeout_tx_weight}; use crate::chain::BestBlock; use crate::chain::chaininterface::{FeeEstimator, LowerBoundedFeeEstimator, ConfirmationTarget}; - use crate::chain::keysinterface::{BaseSign, InMemorySigner, Recipient, KeyMaterial, KeysInterface, EntropySource, NodeSigner, SignerProvider}; + use crate::chain::keysinterface::{BaseSign, InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider}; use crate::chain::transaction::OutPoint; use crate::util::config::UserConfig; use crate::util::enforcing_trait_impls::EnforcingSigner; @@ -6898,8 +6898,6 @@ mod tests { } } - impl KeysInterface for Keys {} - #[cfg(not(feature = "grind_signatures"))] fn public_from_secret_hex(secp_ctx: &Secp256k1, hex: &str) -> PublicKey { PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode(hex).unwrap()[..]).unwrap()) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 7a9ed9227..77fb1de49 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -57,7 +57,7 @@ use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VA use crate::ln::outbound_payment; use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment}; use crate::ln::wire::Encode; -use crate::chain::keysinterface::{EntropySource, KeysInterface, KeysManager, NodeSigner, Recipient, Sign, SignerProvider}; +use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient, Sign, SignerProvider}; use crate::util::config::{UserConfig, ChannelConfig}; use crate::util::events::{Event, EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination}; use crate::util::events; @@ -601,7 +601,7 @@ pub struct ChannelManager::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -1410,7 +1410,7 @@ impl ChannelManager< where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -5480,7 +5480,7 @@ impl MessageSendEven where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -5542,7 +5542,7 @@ impl EventsProvider where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -5579,7 +5579,7 @@ impl chain::Listen f where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -5617,7 +5617,7 @@ impl chain::Confirm where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -5708,7 +5708,7 @@ impl ChannelManager< where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -5913,7 +5913,7 @@ impl where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -6616,7 +6616,7 @@ impl Writeable for C where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -6825,7 +6825,7 @@ pub struct ChannelManagerReadArgs<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -6882,7 +6882,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -6906,7 +6906,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -6922,7 +6922,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner + SignerProvider, F::Target: FeeEstimator, R::Target: Router, L::Target: Logger, @@ -7476,7 +7476,7 @@ mod tests { use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, ClosureReason}; use crate::util::test_utils; use crate::util::config::ChannelConfig; - use crate::chain::keysinterface::{EntropySource, KeysInterface}; + use crate::chain::keysinterface::EntropySource; #[test] fn test_notify_limits() { @@ -8230,7 +8230,7 @@ mod tests { pub mod bench { use crate::chain::Listen; use crate::chain::chainmonitor::{ChainMonitor, Persist}; - use crate::chain::keysinterface::{EntropySource, KeysManager, KeysInterface, InMemorySigner}; + use crate::chain::keysinterface::{EntropySource, KeysManager, InMemorySigner}; use crate::ln::channelmanager::{self, BestBlock, ChainParameters, ChannelManager, PaymentHash, PaymentPreimage, PaymentId}; use crate::ln::functional_test_utils::*; use crate::ln::msgs::{ChannelMessageHandler, Init}; diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index c544c3680..c2e8158c7 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -17,7 +17,7 @@ use crate::chain::chaininterface::LowerBoundedFeeEstimator; use crate::chain::channelmonitor; use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY}; use crate::chain::transaction::OutPoint; -use crate::chain::keysinterface::{BaseSign, EntropySource, KeysInterface}; +use crate::chain::keysinterface::{BaseSign, EntropySource}; use crate::ln::{PaymentPreimage, PaymentSecret, PaymentHash}; use crate::ln::channel::{commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC, CONCURRENT_INBOUND_HTLC_FEE_BUFFER, FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE, MIN_AFFORDABLE_HTLC_COUNT}; use crate::ln::channelmanager::{self, PaymentId, RAACommitmentOrder, PaymentSendFailure, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA}; diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs index ba1b1fe57..6e36cc1c0 100644 --- a/lightning/src/ln/inbound_payment.rs +++ b/lightning/src/ln/inbound_payment.rs @@ -14,7 +14,7 @@ use bitcoin::hashes::{Hash, HashEngine}; use bitcoin::hashes::cmp::fixed_time_eq; use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; -use crate::chain::keysinterface::{KeyMaterial, KeysInterface, EntropySource}; +use crate::chain::keysinterface::{KeyMaterial, EntropySource}; use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use crate::ln::msgs; use crate::ln::msgs::MAX_VALUE_MSAT; @@ -93,7 +93,7 @@ impl Method { /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager /// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material pub fn create(keys: &ExpandedKey, min_value_msat: Option, invoice_expiry_delta_secs: u32, keys_manager: &K, current_time: u64) -> Result<(PaymentHash, PaymentSecret), ()> - where K::Target: KeysInterface + where K::Target: EntropySource { let metadata_bytes = construct_metadata_bytes(min_value_msat, Method::LdkPaymentHash, invoice_expiry_delta_secs, current_time)?; diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index cad6952d3..121ce6f9c 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -12,7 +12,7 @@ //! returned errors decode to the correct thing. use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS}; -use crate::chain::keysinterface::{EntropySource, KeysInterface, NodeSigner, Recipient}; +use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient}; use crate::ln::{PaymentHash, PaymentSecret}; use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS; use crate::ln::channelmanager::{self, HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingAddHTLCInfo, PendingHTLCInfo, PendingHTLCRouting, PaymentId}; diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index 2f6431665..46b3f002f 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -13,7 +13,7 @@ use bitcoin::hashes::Hash; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, Secp256k1, SecretKey}; -use crate::chain::keysinterface::{EntropySource, KeysInterface, NodeSigner, Recipient}; +use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient}; use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use crate::ln::channelmanager::{HTLCSource, IDEMPOTENCY_TIMEOUT_TICKS, PaymentId}; use crate::ln::msgs::DecodeError; @@ -276,7 +276,7 @@ impl OutboundPayments { payment_id: PaymentId, keys_manager: &K, best_block_height: u32, send_payment_along_path: F ) -> Result<(), PaymentSendFailure> where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, F: Fn(&Vec, &Option, &PaymentHash, &Option, u64, u32, PaymentId, &Option, [u8; 32]) -> Result<(), APIError> { @@ -289,7 +289,7 @@ impl OutboundPayments { keys_manager: &K, best_block_height: u32, send_payment_along_path: F ) -> Result where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, F: Fn(&Vec, &Option, &PaymentHash, &Option, u64, u32, PaymentId, &Option, [u8; 32]) -> Result<(), APIError> { @@ -311,7 +311,7 @@ impl OutboundPayments { send_payment_along_path: F ) -> Result<(), PaymentSendFailure> where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, F: Fn(&Vec, &Option, &PaymentHash, &Option, u64, u32, PaymentId, &Option, [u8; 32]) -> Result<(), APIError> { @@ -380,7 +380,7 @@ impl OutboundPayments { best_block_height: u32, send_payment_along_path: F ) -> Result<(PaymentHash, PaymentId), PaymentSendFailure> where - K::Target: KeysInterface, + K::Target: EntropySource + NodeSigner, F: Fn(&Vec, &Option, &PaymentHash, &Option, u64, u32, PaymentId, &Option, [u8; 32]) -> Result<(), APIError> { @@ -414,7 +414,7 @@ impl OutboundPayments { fn add_new_pending_payment( &self, payment_hash: PaymentHash, payment_secret: Option, payment_id: PaymentId, route: &Route, keys_manager: &K, best_block_height: u32 - ) -> Result, PaymentSendFailure> where K::Target: KeysInterface { + ) -> Result, PaymentSendFailure> where K::Target: EntropySource + NodeSigner { let mut onion_session_privs = Vec::with_capacity(route.paths.len()); for _ in 0..route.paths.len() { onion_session_privs.push(keys_manager.get_secure_random_bytes()); @@ -450,7 +450,7 @@ impl OutboundPayments { send_payment_along_path: F ) -> Result<(), PaymentSendFailure> where - K::Target: KeysInterface, + K::Target: NodeSigner, F: Fn(&Vec, &Option, &PaymentHash, &Option, u64, u32, PaymentId, &Option, [u8; 32]) -> Result<(), APIError> { @@ -560,7 +560,7 @@ impl OutboundPayments { send_payment_along_path: F ) -> Result<(), PaymentSendFailure> where - K::Target: KeysInterface, + K::Target: NodeSigner, F: Fn(&Vec, &Option, &PaymentHash, &Option, u64, u32, PaymentId, &Option, [u8; 32]) -> Result<(), APIError> { diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs index 34f71047d..8ec265c3a 100644 --- a/lightning/src/ln/payment_tests.rs +++ b/lightning/src/ln/payment_tests.rs @@ -13,8 +13,8 @@ use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Listen, Watch}; use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS}; +use crate::chain::keysinterface::EntropySource; use crate::chain::transaction::OutPoint; -use crate::chain::keysinterface::{EntropySource, KeysInterface}; use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS; use crate::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS}; use crate::ln::msgs; diff --git a/lightning/src/ln/priv_short_conf_tests.rs b/lightning/src/ln/priv_short_conf_tests.rs index bac542996..a7ee95321 100644 --- a/lightning/src/ln/priv_short_conf_tests.rs +++ b/lightning/src/ln/priv_short_conf_tests.rs @@ -12,7 +12,7 @@ //! LSP). use crate::chain::ChannelMonitorUpdateStatus; -use crate::chain::keysinterface::{Recipient, KeysInterface, NodeSigner}; +use crate::chain::keysinterface::{Recipient, NodeSigner}; use crate::ln::channelmanager::{self, ChannelManager, MIN_CLTV_EXPIRY_DELTA, PaymentId}; use crate::routing::gossip::RoutingFees; use crate::routing::router::{PaymentParameters, RouteHint, RouteHintHop}; diff --git a/lightning/src/ln/reload_tests.rs b/lightning/src/ln/reload_tests.rs index 486a5ee2d..cac0c8e94 100644 --- a/lightning/src/ln/reload_tests.rs +++ b/lightning/src/ln/reload_tests.rs @@ -12,7 +12,7 @@ use crate::chain::{ChannelMonitorUpdateStatus, Watch}; use crate::chain::chaininterface::LowerBoundedFeeEstimator; use crate::chain::channelmonitor::ChannelMonitor; -use crate::chain::keysinterface::{EntropySource, KeysInterface}; +use crate::chain::keysinterface::EntropySource; use crate::chain::transaction::OutPoint; use crate::ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs, PaymentId}; use crate::ln::msgs; diff --git a/lightning/src/ln/shutdown_tests.rs b/lightning/src/ln/shutdown_tests.rs index 60d5dc85c..c9c933ba0 100644 --- a/lightning/src/ln/shutdown_tests.rs +++ b/lightning/src/ln/shutdown_tests.rs @@ -9,7 +9,7 @@ //! Tests of our shutdown and closing_signed negotiation logic. -use crate::chain::keysinterface::{EntropySource, KeysInterface, SignerProvider}; +use crate::chain::keysinterface::{EntropySource, SignerProvider}; use crate::chain::transaction::OutPoint; use crate::ln::channelmanager::{self, PaymentSendFailure, PaymentId}; use crate::routing::router::{PaymentParameters, get_route}; diff --git a/lightning/src/onion_message/blinded_path.rs b/lightning/src/onion_message/blinded_path.rs index 49949bc0d..1268a8176 100644 --- a/lightning/src/onion_message/blinded_path.rs +++ b/lightning/src/onion_message/blinded_path.rs @@ -13,7 +13,7 @@ use bitcoin::hashes::{Hash, HashEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; -use crate::chain::keysinterface::{KeysInterface, NodeSigner, Recipient}; +use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient}; use super::packet::ControlTlvs; use super::utils; use crate::ln::msgs::DecodeError; @@ -63,7 +63,7 @@ impl BlindedPath { /// /// Errors if less than two hops are provided or if `node_pk`(s) are invalid. // TODO: make all payloads the same size with padding + add dummy hops - pub fn new + pub fn new (node_pks: &[PublicKey], keys_manager: &K, secp_ctx: &Secp256k1) -> Result { if node_pks.len() < 2 { return Err(()) } @@ -81,7 +81,7 @@ impl BlindedPath { // Advance the blinded path by one hop, so make the second hop into the new introduction node. pub(super) fn advance_by_one (&mut self, keys_manager: &K, secp_ctx: &Secp256k1) -> Result<(), ()> - where K::Target: KeysInterface + where K::Target: NodeSigner { let control_tlvs_ss = keys_manager.ecdh(Recipient::Node, &self.blinding_point, None)?; let rho = onion_utils::gen_rho_from_shared_secret(&control_tlvs_ss.secret_bytes()); diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 7fc225cbc..148b9caa1 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -9,7 +9,7 @@ //! Onion message testing and test utilities live here. -use crate::chain::keysinterface::{KeysInterface, NodeSigner, Recipient}; +use crate::chain::keysinterface::{NodeSigner, Recipient}; use crate::ln::features::InitFeatures; use crate::ln::msgs::{self, DecodeError, OnionMessageHandler}; use super::{BlindedPath, CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError}; diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index d9d6070ae..093c6d8a9 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -15,7 +15,7 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; -use crate::chain::keysinterface::{EntropySource, KeysInterface, KeysManager, NodeSigner, Recipient}; +use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient}; use crate::ln::features::{InitFeatures, NodeFeatures}; use crate::ln::msgs::{self, OnionMessageHandler}; use crate::ln::onion_utils; @@ -43,7 +43,7 @@ use crate::prelude::*; /// # extern crate bitcoin; /// # use bitcoin::hashes::_export::_core::time::Duration; /// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; -/// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface}; +/// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager}; /// # use lightning::ln::msgs::DecodeError; /// # use lightning::ln::peer_handler::IgnoringMessageHandler; /// # use lightning::onion_message::{BlindedPath, CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger}; @@ -105,7 +105,7 @@ use crate::prelude::*; /// [offers]: /// [`OnionMessenger`]: crate::onion_message::OnionMessenger pub struct OnionMessenger - where K::Target: KeysInterface, + where K::Target: NodeSigner, L::Target: Logger, CMH:: Target: CustomOnionMessageHandler, { @@ -154,9 +154,9 @@ pub enum SendError { InvalidMessage, /// Our next-hop peer's buffer was full or our total outbound buffer was full. BufferFull, - /// Failed to retrieve our node id from the provided [`KeysInterface`]. + /// Failed to retrieve our node id from the provided [`NodeSigner`]. /// - /// [`KeysInterface`]: crate::chain::keysinterface::KeysInterface + /// [`NodeSigner`]: crate::chain::keysinterface::NodeSigner GetNodeIdFailed, /// We attempted to send to a blinded path where we are the introduction node, and failed to /// advance the blinded path to make the second hop the new introduction node. Either @@ -187,7 +187,7 @@ pub trait CustomOnionMessageHandler { } impl OnionMessenger - where K::Target: KeysInterface, + where K::Target: EntropySource + NodeSigner, L::Target: Logger, CMH::Target: CustomOnionMessageHandler, { @@ -296,7 +296,7 @@ fn outbound_buffer_full(peer_node_id: &PublicKey, buffer: &HashMap OnionMessageHandler for OnionMessenger - where K::Target: KeysInterface, + where K::Target: NodeSigner, L::Target: Logger, CMH::Target: CustomOnionMessageHandler + Sized, { @@ -440,7 +440,7 @@ impl OnionMessageHandler for OnionMessenger OnionMessageProvider for OnionMessenger - where K::Target: KeysInterface, + where K::Target: NodeSigner, L::Target: Logger, CMH::Target: CustomOnionMessageHandler, { diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 3f14b0c6a..0a09ca81e 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -2139,7 +2139,7 @@ mod tests { use crate::routing::scoring::{ChannelUsage, Score, ProbabilisticScorer, ProbabilisticScoringParameters}; use crate::routing::test_utils::{add_channel, add_or_update_node, build_graph, build_line_graph, id_to_feature_flags, get_nodes, update_channel}; use crate::chain::transaction::OutPoint; - use crate::chain::keysinterface::{EntropySource, KeysInterface}; + use crate::chain::keysinterface::EntropySource; use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures}; use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT}; use crate::ln::channelmanager; @@ -5653,7 +5653,7 @@ mod benches { use bitcoin::hashes::Hash; use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; use crate::chain::transaction::OutPoint; - use crate::chain::keysinterface::{EntropySource, KeysManager,KeysInterface}; + use crate::chain::keysinterface::{EntropySource, KeysManager}; use crate::ln::channelmanager::{self, ChannelCounterparty, ChannelDetails}; use crate::ln::features::InvoiceFeatures; use crate::routing::gossip::NetworkGraph; diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 860f3cb19..f644e79d4 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -20,7 +20,7 @@ //! # use lightning::routing::gossip::NetworkGraph; //! # use lightning::routing::router::{RouteParameters, find_route}; //! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters}; -//! # use lightning::chain::keysinterface::{KeysManager, KeysInterface}; +//! # use lightning::chain::keysinterface::KeysManager; //! # use lightning::util::logger::{Logger, Record}; //! # use bitcoin::secp256k1::PublicKey; //! # diff --git a/lightning/src/util/enforcing_trait_impls.rs b/lightning/src/util/enforcing_trait_impls.rs index 1a9038a2f..dfec1be7e 100644 --- a/lightning/src/util/enforcing_trait_impls.rs +++ b/lightning/src/util/enforcing_trait_impls.rs @@ -239,7 +239,7 @@ impl Writeable for EnforcingSigner { fn write(&self, writer: &mut W) -> Result<(), Error> { // EnforcingSigner has two fields - `inner` ([`InMemorySigner`]) and `state` // ([`EnforcementState`]). `inner` is serialized here and deserialized by - // [`KeysInterface::read_chan_signer`]. `state` is managed by [`KeysInterface`] + // [`SignerProvider::read_chan_signer`]. `state` is managed by [`SignerProvider`] // and will be serialized as needed by the implementation of that trait. self.inner.write(writer)?; Ok(()) diff --git a/lightning/src/util/persist.rs b/lightning/src/util/persist.rs index 3c8d93801..3b71ec757 100644 --- a/lightning/src/util/persist.rs +++ b/lightning/src/util/persist.rs @@ -16,7 +16,7 @@ use crate::routing::scoring::WriteableScore; use crate::chain; use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator}; use crate::chain::chainmonitor::{Persist, MonitorUpdateId}; -use crate::chain::keysinterface::{Sign, KeysInterface, SignerProvider}; +use crate::chain::keysinterface::{Sign, SignerProvider}; use crate::chain::transaction::OutPoint; use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate}; use crate::ln::channelmanager::ChannelManager; @@ -37,7 +37,7 @@ pub trait KVStorePersister { pub trait Persister<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref, S: WriteableScore<'a>> where M::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + SignerProvider, F::Target: 'static + FeeEstimator, R::Target: 'static + Router, L::Target: 'static + Logger, @@ -55,7 +55,7 @@ pub trait Persister<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Der impl<'a, A: KVStorePersister, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, M, T, K, F, R, L, S> for A where M::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + SignerProvider, F::Target: 'static + FeeEstimator, R::Target: 'static + Router, L::Target: 'static + Logger, diff --git a/lightning/src/util/scid_utils.rs b/lightning/src/util/scid_utils.rs index 3db98553a..128a70789 100644 --- a/lightning/src/util/scid_utils.rs +++ b/lightning/src/util/scid_utils.rs @@ -68,7 +68,7 @@ pub fn scid_from_parts(block: u64, tx_index: u64, vout_index: u64) -> Result(&self, highest_seen_blockheight: u32, genesis_hash: &BlockHash, fake_scid_rand_bytes: &[u8; 32], keys_manager: &K) -> u64 - where K::Target: KeysInterface, + where K::Target: EntropySource, { // Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for // namespaces. diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 5b101e345..4c2e64714 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -140,9 +140,6 @@ impl SignerProvider for OnlyReadsKeysInterface { fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!(); } } -impl keysinterface::KeysInterface for OnlyReadsKeysInterface { -} - pub struct TestChainMonitor<'a> { pub added_monitors: Mutex)>>, pub monitor_updates: Mutex>>, @@ -713,8 +710,6 @@ impl SignerProvider for TestKeysInterface { } } -impl keysinterface::KeysInterface for TestKeysInterface {} - impl TestKeysInterface { pub fn new(seed: &[u8; 32], network: Network) -> Self { let now = Duration::from_secs(genesis_block(network).header.time as u64);