From 1c8a06cf61921b5edd637c066ca8bd001183042d Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Wed, 26 Oct 2022 13:57:11 -0700 Subject: [PATCH] Remove generic `Signer` parameter where it can be inferred from `KeysInterface` --- lightning-background-processor/src/lib.rs | 24 ++++++++--------- lightning-block-sync/src/init.rs | 11 ++++---- lightning-invoice/src/utils.rs | 21 +++++++-------- lightning-persister/src/lib.rs | 10 +++---- lightning/src/chain/channelmonitor.rs | 6 ++--- lightning/src/ln/channel.rs | 8 +++--- lightning/src/ln/channelmanager.rs | 26 +++++++++---------- lightning/src/ln/inbound_payment.rs | 6 ++--- .../src/onion_message/functional_tests.rs | 2 +- lightning/src/onion_message/messenger.rs | 22 ++++++++-------- lightning/src/util/persist.rs | 12 ++++----- lightning/src/util/scid_utils.rs | 6 ++--- 12 files changed, 75 insertions(+), 79 deletions(-) diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 76b17ffdd..5fb8499b6 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::{Sign, KeysInterface}; +use lightning::chain::keysinterface::KeysInterface; use lightning::ln::channelmanager::ChannelManager; use lightning::ln::msgs::{ChannelMessageHandler, OnionMessageHandler, RoutingMessageHandler}; use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor}; @@ -365,7 +365,6 @@ macro_rules! define_run_body { #[cfg(feature = "futures")] pub async fn process_events_async< 'a, - Signer: 'static + Sign, CA: 'static + Deref + Send + Sync, CF: 'static + Deref + Send + Sync, CW: 'static + Deref + Send + Sync, @@ -381,7 +380,7 @@ pub async fn process_events_async< OMH: 'static + Deref + Send + Sync, EH: 'static + EventHandler + Send, PS: 'static + Deref + Send, - M: 'static + Deref> + Send + Sync, + M: 'static + Deref::Signer, CF, T, F, L, P>> + Send + Sync, CM: 'static + Deref> + Send + Sync, PGS: 'static + Deref> + Send + Sync, RGS: 'static + Deref> + Send, @@ -399,17 +398,17 @@ pub async fn process_events_async< where CA::Target: 'static + chain::Access, CF::Target: 'static + chain::Filter, - CW::Target: 'static + chain::Watch, + CW::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + KeysInterface, F::Target: 'static + FeeEstimator, L::Target: 'static + Logger, - P::Target: 'static + Persist, + P::Target: 'static + Persist<::Signer>, CMH::Target: 'static + ChannelMessageHandler, OMH::Target: 'static + OnionMessageHandler, RMH::Target: 'static + RoutingMessageHandler, UMH::Target: 'static + CustomMessageHandler, - PS::Target: 'static + Persister<'a, Signer, CW, T, K, F, L, SC>, + PS::Target: 'static + Persister<'a, CW, T, K, F, L, SC>, { let mut should_continue = true; define_run_body!(persister, event_handler, chain_monitor, channel_manager, @@ -471,7 +470,6 @@ impl BackgroundProcessor { /// [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable pub fn start< 'a, - Signer: 'static + Sign, CA: 'static + Deref + Send + Sync, CF: 'static + Deref + Send + Sync, CW: 'static + Deref + Send + Sync, @@ -487,7 +485,7 @@ impl BackgroundProcessor { RMH: 'static + Deref + Send + Sync, EH: 'static + EventHandler + Send, PS: 'static + Deref + Send, - M: 'static + Deref> + Send + Sync, + M: 'static + Deref::Signer, CF, T, F, L, P>> + Send + Sync, CM: 'static + Deref> + Send + Sync, PGS: 'static + Deref> + Send + Sync, RGS: 'static + Deref> + Send, @@ -502,17 +500,17 @@ impl BackgroundProcessor { where CA::Target: 'static + chain::Access, CF::Target: 'static + chain::Filter, - CW::Target: 'static + chain::Watch, + CW::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + KeysInterface, F::Target: 'static + FeeEstimator, L::Target: 'static + Logger, - P::Target: 'static + Persist, + P::Target: 'static + Persist<::Signer>, CMH::Target: 'static + ChannelMessageHandler, OMH::Target: 'static + OnionMessageHandler, RMH::Target: 'static + RoutingMessageHandler, UMH::Target: 'static + CustomMessageHandler, - PS::Target: 'static + Persister<'a, Signer, CW, T, K, F, L, SC>, + PS::Target: 'static + Persister<'a, CW, T, K, F, L, SC>, { let stop_thread = Arc::new(AtomicBool::new(false)); let stop_thread_clone = stop_thread.clone(); diff --git a/lightning-block-sync/src/init.rs b/lightning-block-sync/src/init.rs index 7e1cb3fb6..893f4b5d4 100644 --- a/lightning-block-sync/src/init.rs +++ b/lightning-block-sync/src/init.rs @@ -61,16 +61,15 @@ BlockSourceResult where B::Target: BlockSource { /// /// async fn init_sync< /// B: BlockSource, -/// K: KeysInterface, -/// S: keysinterface::Sign, +/// K: KeysInterface, /// T: BroadcasterInterface, /// F: FeeEstimator, /// L: Logger, /// C: chain::Filter, -/// P: chainmonitor::Persist, +/// P: chainmonitor::Persist, /// >( /// block_source: &B, -/// chain_monitor: &ChainMonitor, +/// chain_monitor: &ChainMonitor, /// config: UserConfig, /// keys_manager: &K, /// tx_broadcaster: &T, @@ -80,7 +79,7 @@ BlockSourceResult where B::Target: BlockSource { /// ) { /// // Read a serialized channel monitor paired with the block hash when it was persisted. /// let serialized_monitor = "..."; -/// let (monitor_block_hash, mut monitor) = <(BlockHash, ChannelMonitor)>::read( +/// let (monitor_block_hash, mut monitor) = <(BlockHash, ChannelMonitor)>::read( /// &mut Cursor::new(&serialized_monitor), keys_manager).unwrap(); /// /// // Read the channel manager paired with the block hash when it was persisted. @@ -95,7 +94,7 @@ BlockSourceResult where B::Target: BlockSource { /// config, /// vec![&mut monitor], /// ); -/// <(BlockHash, ChannelManager<&ChainMonitor, &T, &K, &F, &L>)>::read( +/// <(BlockHash, ChannelManager<&ChainMonitor, &T, &K, &F, &L>)>::read( /// &mut Cursor::new(&serialized_manager), read_args).unwrap() /// }; /// diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs index 65bf4fb80..b6442934d 100644 --- a/lightning-invoice/src/utils.rs +++ b/lightning-invoice/src/utils.rs @@ -8,7 +8,7 @@ use bech32::ToBase32; use bitcoin_hashes::{Hash, sha256}; use lightning::chain; use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator}; -use lightning::chain::keysinterface::{Recipient, KeysInterface, Sign}; +use lightning::chain::keysinterface::{Recipient, KeysInterface}; use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY}; #[cfg(feature = "std")] @@ -54,7 +54,7 @@ use crate::sync::Mutex; /// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash /// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels -pub fn create_phantom_invoice( +pub fn create_phantom_invoice( amt_msat: Option, payment_hash: Option, description: String, invoice_expiry_delta_secs: u32, phantom_route_hints: Vec, keys_manager: K, logger: L, network: Currency, @@ -65,7 +65,7 @@ where { let description = Description::new(description).map_err(SignOrCreationError::CreationError)?; let description = InvoiceDescription::Direct(&description,); - _create_phantom_invoice::( + _create_phantom_invoice::( amt_msat, payment_hash, description, invoice_expiry_delta_secs, phantom_route_hints, keys_manager, logger, network, ) @@ -103,7 +103,7 @@ where /// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash /// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels -pub fn create_phantom_invoice_with_description_hash( +pub fn create_phantom_invoice_with_description_hash( amt_msat: Option, payment_hash: Option, invoice_expiry_delta_secs: u32, description_hash: Sha256, phantom_route_hints: Vec, keys_manager: K, logger: L, network: Currency @@ -112,14 +112,14 @@ where K::Target: KeysInterface, L::Target: Logger, { - _create_phantom_invoice::( + _create_phantom_invoice::( amt_msat, payment_hash, InvoiceDescription::Hash(&description_hash), invoice_expiry_delta_secs, phantom_route_hints, keys_manager, logger, network, ) } #[cfg(feature = "std")] -fn _create_phantom_invoice( +fn _create_phantom_invoice( amt_msat: Option, payment_hash: Option, description: InvoiceDescription, invoice_expiry_delta_secs: u32, phantom_route_hints: Vec, keys_manager: K, logger: L, network: Currency, @@ -690,7 +690,6 @@ mod test { use lightning::ln::functional_test_utils::*; use lightning::ln::msgs::ChannelMessageHandler; use lightning::routing::router::{PaymentParameters, RouteParameters, find_route}; - use lightning::util::enforcing_trait_impls::EnforcingSigner; use lightning::util::events::{MessageSendEvent, MessageSendEventsProvider, Event}; use lightning::util::test_utils; use lightning::util::config::UserConfig; @@ -1016,7 +1015,7 @@ mod test { let non_default_invoice_expiry_secs = 4200; let invoice = - crate::utils::create_phantom_invoice::( + crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>( Some(payment_amt), payment_hash, "test".to_string(), non_default_invoice_expiry_secs, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet ).unwrap(); @@ -1125,7 +1124,7 @@ mod test { nodes[2].node.get_phantom_route_hints(), ]; - let invoice = crate::utils::create_phantom_invoice::(Some(payment_amt), Some(payment_hash), "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet).unwrap(); + let invoice = crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(Some(payment_amt), Some(payment_hash), "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet).unwrap(); let chan_0_1 = &nodes[1].node.list_usable_channels()[0]; assert_eq!(invoice.route_hints()[0].0[0].htlc_minimum_msat, chan_0_1.inbound_htlc_minimum_msat); @@ -1153,7 +1152,7 @@ mod test { let description_hash = crate::Sha256(Hash::hash("Description hash phantom invoice".as_bytes())); let non_default_invoice_expiry_secs = 4200; let invoice = crate::utils::create_phantom_invoice_with_description_hash::< - EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger, + &test_utils::TestKeysInterface, &test_utils::TestLogger, >( Some(payment_amt), None, non_default_invoice_expiry_secs, description_hash, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet @@ -1470,7 +1469,7 @@ mod test { .map(|route_hint| route_hint.phantom_scid) .collect::>(); - let invoice = crate::utils::create_phantom_invoice::(invoice_amt, None, "test".to_string(), 3600, phantom_route_hints, &invoice_node.keys_manager, &invoice_node.logger, Currency::BitcoinTestnet).unwrap(); + let invoice = crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(invoice_amt, None, "test".to_string(), 3600, phantom_route_hints, &invoice_node.keys_manager, &invoice_node.logger, Currency::BitcoinTestnet).unwrap(); let invoice_hints = invoice.private_routes(); diff --git a/lightning-persister/src/lib.rs b/lightning-persister/src/lib.rs index c36609351..a949584a6 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::{Sign, KeysInterface}; +use lightning::chain::keysinterface::KeysInterface; use lightning::util::ser::{ReadableArgs, Writeable}; use lightning::util::persist::KVStorePersister; use std::fs; @@ -59,10 +59,10 @@ impl FilesystemPersister { } /// Read `ChannelMonitor`s from disk. - pub fn read_channelmonitors ( + pub fn read_channelmonitors ( &self, keys_manager: K - ) -> Result)>, std::io::Error> - where K::Target: KeysInterface + Sized, + ) -> Result::Signer>)>, std::io::Error> + where K::Target: KeysInterface + Sized, { let mut path = PathBuf::from(&self.path_to_channel_data); path.push("monitors"); @@ -105,7 +105,7 @@ impl FilesystemPersister { let contents = fs::read(&file.path())?; let mut buffer = Cursor::new(&contents); - match <(BlockHash, ChannelMonitor)>::read(&mut buffer, &*keys_manager) { + match <(BlockHash, ChannelMonitor<::Signer>)>::read(&mut buffer, &*keys_manager) { Ok((blockhash, channel_monitor)) => { if channel_monitor.get_funding_txo().0.txid != txid.unwrap() || channel_monitor.get_funding_txo().0.index != index.unwrap() { return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "ChannelMonitor was stored in the wrong file")); diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 0bfd94445..c0d0affcc 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -3551,8 +3551,8 @@ where const MAX_ALLOC_SIZE: usize = 64*1024; -impl<'a, Signer: Sign, K: KeysInterface> ReadableArgs<&'a K> - for (BlockHash, ChannelMonitor) { +impl<'a, K: KeysInterface> ReadableArgs<&'a K> + for (BlockHash, ChannelMonitor) { fn read(reader: &mut R, keys_manager: &'a K) -> Result { macro_rules! unwrap_obj { ($key: expr) => { @@ -3736,7 +3736,7 @@ impl<'a, Signer: Sign, K: KeysInterface> ReadableArgs<&'a K> return Err(DecodeError::InvalidValue); } } - let onchain_tx_handler: OnchainTxHandler = ReadableArgs::read(reader, keys_manager)?; + let onchain_tx_handler: OnchainTxHandler = ReadableArgs::read(reader, keys_manager)?; let lockdown_from_offchain = Readable::read(reader)?; let holder_tx_signed = Readable::read(reader)?; diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 9b1bf2e45..0e304f307 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -4205,7 +4205,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: KeysInterface { 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())); @@ -5825,7 +5825,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: KeysInterface { 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()}); @@ -6284,8 +6284,8 @@ impl Writeable for Channel { } const MAX_ALLOC_SIZE: usize = 64*1024; -impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel - where K::Target: KeysInterface { +impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<::Signer> + where K::Target: KeysInterface { fn read(reader: &mut R, args: (&'a K, u32)) -> Result { let (keys_source, serialized_height) = args; let ver = read_ver_prefix!(reader, SERIALIZATION_VERSION); diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 91a853132..46cb0e079 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -6921,10 +6921,10 @@ impl Writeable for ChannelMana /// which you've already broadcasted the transaction. /// /// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor -pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> - where M::Target: chain::Watch, +pub struct ChannelManagerReadArgs<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> + where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: KeysInterface, F::Target: FeeEstimator, L::Target: Logger, { @@ -6967,14 +6967,14 @@ pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: /// this struct. /// /// (C-not exported) because we have no HashMap bindings - pub channel_monitors: HashMap>, + pub channel_monitors: HashMap::Signer>>, } -impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> - ChannelManagerReadArgs<'a, Signer, M, T, K, F, L> - where M::Target: chain::Watch, +impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> + ChannelManagerReadArgs<'a, M, T, K, F, L> + where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, - K::Target: KeysInterface, + K::Target: KeysInterface, F::Target: FeeEstimator, L::Target: Logger, { @@ -6982,7 +6982,7 @@ impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> /// HashMap for you. This is primarily useful for C bindings where it is not practical to /// populate a HashMap directly from C. pub fn new(keys_manager: K, fee_estimator: F, chain_monitor: M, tx_broadcaster: T, logger: L, default_config: UserConfig, - mut channel_monitors: Vec<&'a mut ChannelMonitor>) -> Self { + mut channel_monitors: Vec<&'a mut ChannelMonitor<::Signer>>) -> Self { Self { keys_manager, fee_estimator, chain_monitor, tx_broadcaster, logger, default_config, channel_monitors: channel_monitors.drain(..).map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect() @@ -6993,28 +6993,28 @@ impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> // Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the // SipmleArcChannelManager type: impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> - ReadableArgs::Signer, M, T, K, F, L>> for (BlockHash, Arc>) + ReadableArgs> for (BlockHash, Arc>) where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, L::Target: Logger, { - fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, ::Signer, M, T, K, F, L>) -> Result { + fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, M, T, K, F, L>) -> Result { let (blockhash, chan_manager) = <(BlockHash, ChannelManager)>::read(reader, args)?; Ok((blockhash, Arc::new(chan_manager))) } } impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> - ReadableArgs::Signer, M, T, K, F, L>> for (BlockHash, ChannelManager) + ReadableArgs> for (BlockHash, ChannelManager) where M::Target: chain::Watch<::Signer>, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, L::Target: Logger, { - fn read(reader: &mut R, mut args: ChannelManagerReadArgs<'a, ::Signer, M, T, K, F, L>) -> Result { + fn read(reader: &mut R, mut args: ChannelManagerReadArgs<'a, M, T, K, F, L>) -> Result { let _ver = read_ver_prefix!(reader, SERIALIZATION_VERSION); let genesis_hash: BlockHash = Readable::read(reader)?; diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs index c9ef10051..731b68ce4 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, Sign}; +use crate::chain::keysinterface::{KeyMaterial, KeysInterface}; use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use crate::ln::msgs; use crate::ln::msgs::MAX_VALUE_MSAT; @@ -91,8 +91,8 @@ impl Method { /// `current_time` is a Unix timestamp representing the current time. /// /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager -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 +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 { let metadata_bytes = construct_metadata_bytes(min_value_msat, Method::LdkPaymentHash, invoice_expiry_delta_secs, current_time)?; diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index bd0a884a8..200570861 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -25,7 +25,7 @@ use crate::sync::Arc; struct MessengerNode { keys_manager: Arc, - messenger: OnionMessenger, Arc, Arc>, + messenger: OnionMessenger, Arc, Arc>, logger: Arc, } diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index a09c942be..b884c2ffe 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::{InMemorySigner, KeysInterface, KeysManager, Recipient, Sign}; +use crate::chain::keysinterface::{KeysInterface, KeysManager, Recipient}; use crate::ln::features::{InitFeatures, NodeFeatures}; use crate::ln::msgs::{self, OnionMessageHandler}; use crate::ln::onion_utils; @@ -104,8 +104,8 @@ use crate::prelude::*; /// /// [offers]: /// [`OnionMessenger`]: crate::onion_message::OnionMessenger -pub struct OnionMessenger - where K::Target: KeysInterface, +pub struct OnionMessenger + where K::Target: KeysInterface, L::Target: Logger, CMH:: Target: CustomOnionMessageHandler, { @@ -186,8 +186,8 @@ pub trait CustomOnionMessageHandler { fn read_custom_message(&self, message_type: u64, buffer: &mut R) -> Result, msgs::DecodeError>; } -impl OnionMessenger - where K::Target: KeysInterface, +impl OnionMessenger + where K::Target: KeysInterface, L::Target: Logger, CMH::Target: CustomOnionMessageHandler, { @@ -295,8 +295,8 @@ fn outbound_buffer_full(peer_node_id: &PublicKey, buffer: &HashMap OnionMessageHandler for OnionMessenger - where K::Target: KeysInterface, +impl OnionMessageHandler for OnionMessenger + where K::Target: KeysInterface, L::Target: Logger, CMH::Target: CustomOnionMessageHandler + Sized, { @@ -439,8 +439,8 @@ impl OnionMessageHandler for Onion } } -impl OnionMessageProvider for OnionMessenger - where K::Target: KeysInterface, +impl OnionMessageProvider for OnionMessenger + where K::Target: KeysInterface, L::Target: Logger, CMH::Target: CustomOnionMessageHandler, { @@ -462,7 +462,7 @@ impl OnionMessageProvider for Onio /// /// [`SimpleArcChannelManager`]: crate::ln::channelmanager::SimpleArcChannelManager /// [`SimpleArcPeerManager`]: crate::ln::peer_handler::SimpleArcPeerManager -pub type SimpleArcOnionMessenger = OnionMessenger, Arc, IgnoringMessageHandler>; +pub type SimpleArcOnionMessenger = OnionMessenger, Arc, IgnoringMessageHandler>; /// Useful for simplifying the parameters of [`SimpleRefChannelManager`] and /// [`SimpleRefPeerManager`]. See their docs for more details. /// @@ -470,7 +470,7 @@ pub type SimpleArcOnionMessenger = OnionMessenger = OnionMessenger; +pub type SimpleRefOnionMessenger<'a, 'b, L> = OnionMessenger<&'a KeysManager, &'b L, IgnoringMessageHandler>; /// Construct onion packet payloads and keys for sending an onion message along the given /// `unblinded_path` to the given `destination`. diff --git a/lightning/src/util/persist.rs b/lightning/src/util/persist.rs index bccdb629a..40c042a27 100644 --- a/lightning/src/util/persist.rs +++ b/lightning/src/util/persist.rs @@ -26,10 +26,10 @@ pub trait KVStorePersister { } /// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. -pub trait Persister<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>> - where M::Target: 'static + chain::Watch, +pub trait Persister<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>> + where M::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + KeysInterface, F::Target: 'static + FeeEstimator, L::Target: 'static + Logger, { @@ -43,10 +43,10 @@ pub trait Persister<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: fn persist_scorer(&self, scorer: &S) -> Result<(), io::Error>; } -impl<'a, A: KVStorePersister, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, Signer, M, T, K, F, L, S> for A - where M::Target: 'static + chain::Watch, +impl<'a, A: KVStorePersister, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, M, T, K, F, L, S> for A + where M::Target: 'static + chain::Watch<::Signer>, T::Target: 'static + BroadcasterInterface, - K::Target: 'static + KeysInterface, + K::Target: 'static + KeysInterface, F::Target: 'static + FeeEstimator, L::Target: 'static + Logger, { diff --git a/lightning/src/util/scid_utils.rs b/lightning/src/util/scid_utils.rs index c3529a6cb..651b36ef3 100644 --- a/lightning/src/util/scid_utils.rs +++ b/lightning/src/util/scid_utils.rs @@ -66,7 +66,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, + pub(crate) fn get_fake_scid(&self, highest_seen_blockheight: u32, genesis_hash: &BlockHash, fake_scid_rand_bytes: &[u8; 32], keys_manager: &K) -> u64 + where K::Target: KeysInterface, { // Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for // namespaces. -- 2.39.5