]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove KeysInterface trait.
authorArik Sosman <git@arik.io>
Tue, 20 Dec 2022 22:46:08 +0000 (14:46 -0800)
committerArik Sosman <git@arik.io>
Thu, 12 Jan 2023 17:18:08 +0000 (09:18 -0800)
30 files changed:
fuzz/src/chanmon_consistency.rs
fuzz/src/full_stack.rs
fuzz/src/onion_message.rs
lightning-background-processor/src/lib.rs
lightning-block-sync/src/init.rs
lightning-invoice/src/utils.rs
lightning-persister/src/lib.rs
lightning/src/chain/channelmonitor.rs
lightning/src/chain/keysinterface.rs
lightning/src/chain/onchaintx.rs
lightning/src/ln/chan_utils.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/inbound_payment.rs
lightning/src/ln/onion_route_tests.rs
lightning/src/ln/outbound_payment.rs
lightning/src/ln/payment_tests.rs
lightning/src/ln/priv_short_conf_tests.rs
lightning/src/ln/reload_tests.rs
lightning/src/ln/shutdown_tests.rs
lightning/src/onion_message/blinded_path.rs
lightning/src/onion_message/functional_tests.rs
lightning/src/onion_message/messenger.rs
lightning/src/routing/router.rs
lightning/src/routing/scoring.rs
lightning/src/util/enforcing_trait_impls.rs
lightning/src/util/persist.rs
lightning/src/util/scid_utils.rs
lightning/src/util/test_utils.rs

index e1bf9cb540d370972eab7ea9fc58732ef8f6b833..a181e1c28b70d40085e0262b8bb06039f8606d53 100644 (file)
@@ -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<Mutex<EnforcementState>> {
                let mut revoked_commitments = self.enforcement_states.lock().unwrap();
index 2d9be101ef89faf2fdd9901292becec1f013e26b..2af7009eb687d995641e40dadf5fd68f74f4f6fa 100644 (file)
@@ -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<dyn Logger>) {
        let input = Arc::new(InputData {
@@ -444,7 +442,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
                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);
index 4841f1c3014b58959bcc80c57158f5653751b683..3075a54b60de7a623d612351b3c815cd57cfc42f 100644 (file)
@@ -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};
index 199295b9f0c92e5dd1139480ebeed419ee44a701..585f62c869d977b37607d026a68ef5f0bcc3912b 100644 (file)
@@ -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<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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};
index 23e4435a6f513a6e58ba8c428d32d6c031c46d35..72a6ec4b0c429aa39f54e1a77a93ff0efbbc2523 100644 (file)
@@ -48,7 +48,7 @@ BlockSourceResult<ValidatedBlockHeader> 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<ValidatedBlockHeader> where B::Target: BlockSource {
 ///
 /// async fn init_sync<
 ///    B: BlockSource,
-///    K: KeysInterface,
+///    K: EntropySource + NodeSigner + SignerProvider,
 ///    T: BroadcasterInterface,
 ///    F: FeeEstimator,
 ///    R: Router,
index 1f6dc619a560b42b8f928cc8e6096605615e8f6c..91f0cfa18c424b58009e44a969fc9e7e8cd22cb1 100644 (file)
@@ -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<K: Deref, L: Deref>(
        logger: L, network: Currency,
 ) -> Result<Invoice, SignOrCreationError<()>>
 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<K: Deref, L: Deref>(
        logger: L, network: Currency
 ) -> Result<Invoice, SignOrCreationError<()>>
 where
-       K::Target: KeysInterface,
+       K::Target: EntropySource + NodeSigner,
        L::Target: Logger,
 {
        _create_phantom_invoice::<K, L>(
@@ -122,7 +122,7 @@ fn _create_phantom_invoice<K: Deref, L: Deref>(
        logger: L, network: Currency,
 ) -> Result<Invoice, SignOrCreationError<()>>
 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<M: Deref, T: Deref, K: Deref, F: Deref
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Der
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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<M: Deref, T:
                where
                        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Der
                where
                        M::Target: chain::Watch<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> Payer for Chann
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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;
 
index bf1c012218e7417f78e4c5c2d1947d0633718d5c..7eba088a15ed20df2f309082c33625dcf0a6beea 100644 (file)
@@ -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<K: Deref> (
                &self, keys_manager: K
        ) -> std::io::Result<Vec<(BlockHash, ChannelMonitor<<K::Target as SignerProvider>::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");
index db17810599d66e4d472d96ec96af76f1ced407f3..e16a533cb1d608102c91a0fce5e8d8792ab8493d 100644 (file)
@@ -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<K::Signer>) {
        fn read<R: io::Read>(reader: &mut R, keys_manager: &'a K) -> Result<Self, DecodeError> {
                macro_rules! unwrap_obj {
index 16075cdac4b2375b989abd28c7eec105af610c79..9fc00e25238dc8b375d247aec5c8114ce508f109 100644 (file)
@@ -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 `<Self::Signer as Writeable>::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<SecretKey> 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]
index 9bfe6fa9af21b1547e5aa8bf2183062cde66f4cd..8feaf6e6a302650711db3d78283bff3a4a127dfb 100644 (file)
@@ -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<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
        }
 }
 
-impl<'a, K: KeysInterface> ReadableArgs<(&'a K, u64, [u8; 32])> for OnchainTxHandler<K::Signer> {
+impl<'a, K: EntropySource + SignerProvider> ReadableArgs<(&'a K, u64, [u8; 32])> for OnchainTxHandler<K::Signer> {
        fn read<R: io::Read>(reader: &mut R, args: (&'a K, u64, [u8; 32])) -> Result<Self, DecodeError> {
                let keys_manager = args.0;
                let channel_value_satoshis = args.1;
index bbf0be78893d12e02d62595fb5936410e212ac3d..cd9f261b2283b40fb2efd5db45ef4a0fa2f255b7 100644 (file)
@@ -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;
index 76dc15065c05cd298b532247de377b757ce5491f..5e2e9d93b812c3a7788cb4685c5079135bb53753 100644 (file)
@@ -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<Signer: Sign> Channel<Signer> {
                channel_value_satoshis: u64, push_msat: u64, user_id: u128, config: &UserConfig, current_chain_height: u32,
                outbound_scid_alias: u64
        ) -> Result<Channel<Signer>, APIError>
-       where K::Target: KeysInterface<Signer = Signer>,
+       where K::Target: EntropySource + SignerProvider<Signer = Signer>,
              F::Target: FeeEstimator,
        {
                let opt_anchors = false; // TODO - should be based on features
@@ -1120,7 +1120,7 @@ impl<Signer: Sign> Channel<Signer> {
                msg: &msgs::OpenChannel, user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L,
                outbound_scid_alias: u64
        ) -> Result<Channel<Signer>, ChannelError>
-               where K::Target: KeysInterface<Signer = Signer>,
+               where K::Target: EntropySource + SignerProvider<Signer = Signer>,
                      F::Target: FeeEstimator,
                      L::Target: Logger,
        {
@@ -2225,7 +2225,7 @@ impl<Signer: Sign> Channel<Signer> {
                &mut self, msg: &msgs::FundingCreated, best_block: BestBlock, keys_source: &K, logger: &L
        ) -> Result<(msgs::FundingSigned, ChannelMonitor<<K::Target as SignerProvider>::Signer>, Option<msgs::ChannelReady>), ChannelError>
        where
-               K::Target: KeysInterface,
+               K::Target: SignerProvider,
                L::Target: Logger
        {
                if self.is_outbound() {
@@ -2313,7 +2313,7 @@ impl<Signer: Sign> Channel<Signer> {
                &mut self, msg: &msgs::FundingSigned, best_block: BestBlock, keys_source: &K, logger: &L
        ) -> Result<(ChannelMonitor<<K::Target as SignerProvider>::Signer>, Transaction, Option<msgs::ChannelReady>), ChannelError>
        where
-               K::Target: KeysInterface,
+               K::Target: SignerProvider,
                L::Target: Logger
        {
                if !self.is_outbound() {
@@ -4226,7 +4226,7 @@ impl<Signer: Sign> Channel<Signer> {
        pub fn shutdown<K: Deref>(
                &mut self, keys_provider: &K, their_features: &InitFeatures, msg: &msgs::Shutdown
        ) -> Result<(Option<msgs::Shutdown>, Option<ChannelMonitorUpdate>, 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<Signer: Sign> Channel<Signer> {
        /// holding cell HTLCs for payment failure.
        pub fn get_shutdown<K: Deref>(&mut self, keys_provider: &K, their_features: &InitFeatures, target_feerate_sats_per_kw: Option<u32>)
        -> Result<(msgs::Shutdown, Option<ChannelMonitorUpdate>, 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<Signer: Sign> Writeable for Channel<Signer> {
 
 const MAX_ALLOC_SIZE: usize = 64*1024;
 impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<<K::Target as SignerProvider>::Signer>
-               where K::Target: KeysInterface {
+               where K::Target: EntropySource + SignerProvider {
        fn read<R : io::Read>(reader: &mut R, args: (&'a K, u32)) -> Result<Self, DecodeError> {
                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<bitcoin::secp256k1::All>, hex: &str) -> PublicKey {
                PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode(hex).unwrap()[..]).unwrap())
index 7a9ed922746b43b97cf99a42bc8443b83a81bd15..77fb1de49422e0de0466f38abbed68f03b3e1886 100644 (file)
@@ -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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: D
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
        T::Target: BroadcasterInterface,
-       K::Target: KeysInterface,
+       K::Target: SignerProvider,
        F::Target: FeeEstimator,
        R::Target: Router,
        L::Target: Logger,
@@ -1410,7 +1410,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> ChannelManager<
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> MessageSendEven
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> EventsProvider
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> chain::Listen f
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> chain::Confirm
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> ChannelManager<
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref>
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref> Writeable for C
 where
        M::Target: chain::Watch<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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};
index c544c368073695a322fc98fd3ae9d504882cc806..c2e8158c768956f51ffdbdbff3d0286dcd831dfc 100644 (file)
@@ -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};
index ba1b1fe579a8cc52e30af7eb05f5ede4d6bf6a75..6e36cc1c0221dfbda1c424173d986cfa5b0f51db 100644 (file)
@@ -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<K: Deref>(keys: &ExpandedKey, min_value_msat: Option<u64>, 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)?;
 
index cad6952d36dbad9f9b7b9abf5a5c3330bfc713a0..121ce6f9c7a6281699f25a9f562a9405b00daa23 100644 (file)
@@ -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};
index 2f6431665b7ea5ec01bf4a7fe810d0ca9fc1b3c8..46b3f002f244250a1e4c7c5e606070178d0b9c7c 100644 (file)
@@ -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<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
                   u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
        {
@@ -289,7 +289,7 @@ impl OutboundPayments {
                keys_manager: &K, best_block_height: u32, send_payment_along_path: F
        ) -> Result<PaymentHash, PaymentSendFailure>
        where
-               K::Target: KeysInterface,
+               K::Target: EntropySource + NodeSigner,
                F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
                   u32, PaymentId, &Option<PaymentPreimage>, [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<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
                   u32, PaymentId, &Option<PaymentPreimage>, [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<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
                   u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
        {
@@ -414,7 +414,7 @@ impl OutboundPayments {
        fn add_new_pending_payment<K: Deref>(
                &self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
                route: &Route, keys_manager: &K, best_block_height: u32
-       ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where K::Target: KeysInterface {
+       ) -> Result<Vec<[u8; 32]>, 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<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
                   u32, PaymentId, &Option<PaymentPreimage>, [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<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
                   u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
        {
index 34f71047dc07f1a737bde291a66defa389ce4bdb..8ec265c3addfbb4c71ace2c4f4330b6b21383658 100644 (file)
@@ -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;
index bac542996e7e75df4dde7acceb9f224914047940..a7ee953213a3726028de8bc255bd6518af8508a7 100644 (file)
@@ -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};
index 486a5ee2df3e8dba3bf4037c3fe5f8fa0e744dcc..cac0c8e94d39a161404b763fce8ff82e4cb0b710 100644 (file)
@@ -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;
index 60d5dc85cd2742a8a81e0d8d44d95752e4c70bc1..c9c933ba091b081a0af156ec455a022676b09f51 100644 (file)
@@ -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};
index 49949bc0d5895fdf2b123f59e9f44e7c647c24b4..1268a8176e9f28ef626ac356491e03eae5c64a1f 100644 (file)
@@ -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<K: KeysInterface, T: secp256k1::Signing + secp256k1::Verification>
+       pub fn new<K: EntropySource, T: secp256k1::Signing + secp256k1::Verification>
                (node_pks: &[PublicKey], keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<Self, ()>
        {
                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<K: Deref, T: secp256k1::Signing + secp256k1::Verification>
                (&mut self, keys_manager: &K, secp_ctx: &Secp256k1<T>) -> 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());
index 7fc225cbc9c6fc30e25453ae3c0993af57ef4137..148b9caa16b2cc90ef6a6018b6a255b08df0d086 100644 (file)
@@ -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};
index d9d6070ae058c7f0041901b6e0e0eae4f89e3a6b..093c6d8a96f4c1d6194e644b109201b790fa1a7a 100644 (file)
@@ -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]: <https://github.com/lightning/bolts/pull/798>
 /// [`OnionMessenger`]: crate::onion_message::OnionMessenger
 pub struct OnionMessenger<K: Deref, L: Deref, CMH: Deref>
-       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<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
-       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<PublicKey, Ve
 }
 
 impl<K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for OnionMessenger<K, L, CMH>
-       where K::Target: KeysInterface,
+       where K::Target: NodeSigner,
              L::Target: Logger,
              CMH::Target: CustomOnionMessageHandler + Sized,
 {
@@ -440,7 +440,7 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for OnionMessenger<K, L
 }
 
 impl<K: Deref, L: Deref, CMH: Deref> OnionMessageProvider for OnionMessenger<K, L, CMH>
-       where K::Target: KeysInterface,
+       where K::Target: NodeSigner,
              L::Target: Logger,
              CMH::Target: CustomOnionMessageHandler,
 {
index 3f14b0c6a1128a366d8b80c9b59c216febe0b816..0a09ca81e3ffc6c13feca2c34391cac981128d62 100644 (file)
@@ -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;
index 860f3cb195418054322cd551f5e7487b84af8cad..f644e79d461bb819bc88111c2732840194c27461 100644 (file)
@@ -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;
 //! #
index 1a9038a2f5dc1c3c2122e71f8f6a5b0d4e945782..dfec1be7e91bc5896882560afa2939d46f0b0318 100644 (file)
@@ -239,7 +239,7 @@ impl Writeable for EnforcingSigner {
        fn write<W: Writer>(&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(())
index 3c8d93801ccdfec149601e4ec023b5514286f571..3b71ec757849cfaa4e88f977d6edf8132d89ffae 100644 (file)
@@ -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<<K::Target as SignerProvider>::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<<K::Target as SignerProvider>::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,
index 3db98553af547039ecc24c8ed2fa236aadbc7d18..128a70789ec126efa29febef9371319fe0b63db6 100644 (file)
@@ -68,7 +68,7 @@ pub fn scid_from_parts(block: u64, tx_index: u64, vout_index: u64) -> Result<u64
 pub(crate) mod fake_scid {
        use bitcoin::hash_types::BlockHash;
        use bitcoin::hashes::hex::FromHex;
-       use crate::chain::keysinterface::{KeysInterface, EntropySource};
+       use crate::chain::keysinterface::EntropySource;
        use crate::util::chacha20::ChaCha20;
        use crate::util::scid_utils;
 
@@ -102,7 +102,7 @@ pub(crate) mod fake_scid {
                /// index are also selected from a "reasonable" range. We add this logic because it makes it
                /// non-obvious at a glance that the scid is fake, e.g. if it appears in invoice route hints.
                pub(crate) fn get_fake_scid<K: Deref>(&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.
index 5b101e345e22aa8e889f67a8e700c2155305a21b..4c2e647141133fbd12ab177032ab2251e3daa246 100644 (file)
@@ -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<Vec<(OutPoint, channelmonitor::ChannelMonitor<EnforcingSigner>)>>,
        pub monitor_updates: Mutex<HashMap<[u8; 32], Vec<channelmonitor::ChannelMonitorUpdate>>>,
@@ -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);