Drop Deref indirection for EntropySource
What changed, and why it matters
This commit is a large internal cleanup in the rust-lightning codebase. It removes an extra layer of pointer indirection (the Deref trait) from how randomness sources are passed around, replacing it with a direct EntropySource trait bound. The change simplifies type signatures and reduces boilerplate but does not appear to fix a security bug or introduce a new vulnerability. A blanket implementation of EntropySource for any type that dereferences to an EntropySource is added to preserve backward compatibility with existing callers.
No immediate security action required. Treat as a normal refactoring commit. Reviewers may want to verify that the blanket `EntropySource for E: Deref<Target = T>` impl does not create coherence issues with downstream crates, but it is a standard pattern and unlikely to introduce security-relevant behavior changes.
Security signals we found
Large refactor touching entropy/randomness interfaces across many modules
Addition of a blanket trait impl for EntropySource over Deref targets
No changes to randomness generation, signing, or secret handling logic
No mention of security fixes, CVEs, or vulnerability reports in commit message or diff
Evidence from the diff
The patch refactors generic constraints across ~30 files from ES: Deref where ES::Target: EntropySource to ES: EntropySource. To keep existing Arc<dyn EntropySource> and &dyn EntropySource callers working, a blanket impl is added: impl<T: EntropySource + ?Sized, E: Deref<Target = T>> EntropySource for E. This is a type-system simplification. Call sites that previously dereferenced the source explicitly (e.g., &*self.entropy_source) now pass &self.entropy_source directly. No cryptographic logic, randomness generation, or protocol behavior is changed. The commit message explicitly states the goal is to reduce generics and verbosity while preserving equivalent behavior.
Changed components
lightning/src/sign/mod.rs (EntropySource trait)lightning/src/ln/channelmanager.rslightning/src/ln/channel.rslightning/src/ln/outbound_payment.rslightning/src/chain/chainmonitor.rslightning/src/onion_message/messenger.rslightning/src/routing/router.rslightning/src/util/persist.rslightning-liquidity/src/manager.rslightning-background-processor/src/lib.rsInspect captured patch +254 / −467
diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs
index 0cefcca..c8898b0 100644
--- a/lightning-background-processor/src/lib.rs
+++ b/lightning-background-processor/src/lib.rs
@@ -420,8 +420,7 @@ type DynChannelManager = lightning::ln::channelmanager::ChannelManager<
pub const NO_ONION_MESSENGER: Option<
Arc<
dyn AOnionMessenger<
- EntropySource = dyn EntropySource + Send + Sync,
- ES = &(dyn EntropySource + Send + Sync),
+ EntropySource = &(dyn EntropySource + Send + Sync),
NodeSigner = dyn lightning::sign::NodeSigner + Send + Sync,
NS = &(dyn lightning::sign::NodeSigner + Send + Sync),
Logger = dyn Logger + Send + Sync,
@@ -480,8 +479,7 @@ impl KVStore for DummyKVStore {
pub const NO_LIQUIDITY_MANAGER: Option<
Arc<
dyn ALiquidityManager<
- EntropySource = dyn EntropySource + Send + Sync,
- ES = &(dyn EntropySource + Send + Sync),
+ EntropySource = &(dyn EntropySource + Send + Sync),
NodeSigner = dyn lightning::sign::NodeSigner + Send + Sync,
NS = &(dyn lightning::sign::NodeSigner + Send + Sync),
AChannelManager = DynChannelManager,
@@ -506,8 +504,7 @@ pub const NO_LIQUIDITY_MANAGER: Option<
pub const NO_LIQUIDITY_MANAGER_SYNC: Option<
Arc<
dyn ALiquidityManagerSync<
- EntropySource = dyn EntropySource + Send + Sync,
- ES = &(dyn EntropySource + Send + Sync),
+ EntropySource = &(dyn EntropySource + Send + Sync),
NodeSigner = dyn lightning::sign::NodeSigner + Send + Sync,
NS = &(dyn lightning::sign::NodeSigner + Send + Sync),
AChannelManager = DynChannelManager,
@@ -961,7 +958,7 @@ pub async fn process_events_async<
P: Deref,
EventHandlerFuture: core::future::Future<Output = Result<(), ReplayEvent>>,
EventHandler: Fn(Event) -> EventHandlerFuture,
- ES: Deref,
+ ES: EntropySource,
M: Deref<Target = ChainMonitor<<CM::Target as AChannelManager>::Signer, CF, T, F, L, P, ES>>,
CM: Deref,
OM: Deref,
@@ -990,7 +987,6 @@ where
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<<CM::Target as AChannelManager>::Signer>,
- ES::Target: EntropySource,
CM::Target: AChannelManager,
OM::Target: AOnionMessenger,
PM::Target: APeerManager,
@@ -1461,7 +1457,7 @@ pub async fn process_events_async_with_kv_store_sync<
P: Deref,
EventHandlerFuture: core::future::Future<Output = Result<(), ReplayEvent>>,
EventHandler: Fn(Event) -> EventHandlerFuture,
- ES: Deref,
+ ES: EntropySource,
M: Deref<Target = ChainMonitor<<CM::Target as AChannelManager>::Signer, CF, T, F, L, P, ES>>,
CM: Deref,
OM: Deref,
@@ -1490,7 +1486,6 @@ where
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<<CM::Target as AChannelManager>::Signer>,
- ES::Target: EntropySource,
CM::Target: AChannelManager,
OM::Target: AOnionMessenger,
PM::Target: APeerManager,
@@ -1573,7 +1568,7 @@ impl BackgroundProcessor {
L: 'static + Deref + Send,
P: 'static + Deref,
EH: 'static + EventHandler + Send,
- ES: 'static + Deref + Send,
+ ES: 'static + EntropySource + Send,
M: 'static
+ Deref<
Target = ChainMonitor<<CM::Target as AChannelManager>::Signer, CF, T, F, L, P, ES>,
@@ -1603,7 +1598,6 @@ impl BackgroundProcessor {
F::Target: 'static + FeeEstimator,
L::Target: 'static + Logger,
P::Target: 'static + Persist<<CM::Target as AChannelManager>::Signer>,
- ES::Target: 'static + EntropySource,
CM::Target: AChannelManager,
OM::Target: AOnionMessenger,
PM::Target: APeerManager,
diff --git a/lightning-liquidity/src/lsps0/client.rs b/lightning-liquidity/src/lsps0/client.rs
index d300936..776e9d3 100644
--- a/lightning-liquidity/src/lsps0/client.rs
+++ b/lightning-liquidity/src/lsps0/client.rs
@@ -25,9 +25,8 @@ use bitcoin::secp256k1::PublicKey;
use core::ops::Deref;
/// A message handler capable of sending and handling bLIP-50 / LSPS0 messages.
-pub struct LSPS0ClientHandler<ES: Deref, K: Deref + Clone>
+pub struct LSPS0ClientHandler<ES: EntropySource, K: Deref + Clone>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
entropy_source: ES,
@@ -35,9 +34,8 @@ where
pending_events: Arc<EventQueue<K>>,
}
-impl<ES: Deref, K: Deref + Clone> LSPS0ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPS0ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
/// Returns a new instance of [`LSPS0ClientHandler`].
@@ -89,9 +87,8 @@ where
}
}
-impl<ES: Deref, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS0ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS0ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
type ProtocolMessage = LSPS0Message;
diff --git a/lightning-liquidity/src/lsps1/client.rs b/lightning-liquidity/src/lsps1/client.rs
index 4a79fb6..1e5b2e3 100644
--- a/lightning-liquidity/src/lsps1/client.rs
+++ b/lightning-liquidity/src/lsps1/client.rs
@@ -47,9 +47,8 @@ struct PeerState {
}
/// The main object allowing to send and receive bLIP-51 / LSPS1 messages.
-pub struct LSPS1ClientHandler<ES: Deref, K: Deref + Clone>
+pub struct LSPS1ClientHandler<ES: EntropySource, K: Deref + Clone>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
entropy_source: ES,
@@ -59,9 +58,8 @@ where
config: LSPS1ClientConfig,
}
-impl<ES: Deref, K: Deref + Clone> LSPS1ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPS1ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
/// Constructs an `LSPS1ClientHandler`.
@@ -432,9 +430,8 @@ where
}
}
-impl<ES: Deref, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS1ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS1ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
type ProtocolMessage = LSPS1Message;
diff --git a/lightning-liquidity/src/lsps1/service.rs b/lightning-liquidity/src/lsps1/service.rs
index 8afea1b..76a9a43 100644
--- a/lightning-liquidity/src/lsps1/service.rs
+++ b/lightning-liquidity/src/lsps1/service.rs
@@ -132,9 +132,8 @@ impl PeerState {
}
/// The main object allowing to send and receive bLIP-51 / LSPS1 messages.
-pub struct LSPS1ServiceHandler<ES: Deref, CM: Deref + Clone, C: Deref, K: Deref + Clone>
+pub struct LSPS1ServiceHandler<ES: EntropySource, CM: Deref + Clone, C: Deref, K: Deref + Clone>
where
- ES::Target: EntropySource,
CM::Target: AChannelManager,
C::Target: Filter,
K::Target: KVStore,
@@ -148,12 +147,11 @@ where
config: LSPS1ServiceConfig,
}
-impl<ES: Deref, CM: Deref + Clone, C: Deref, K: Deref + Clone> LSPS1ServiceHandler<ES, CM, C, K>
+impl<ES: EntropySource, CM: Deref + Clone, C: Deref, K: Deref + Clone>
+ LSPS1ServiceHandler<ES, CM, C, K>
where
- ES::Target: EntropySource,
CM::Target: AChannelManager,
C::Target: Filter,
- ES::Target: EntropySource,
K::Target: KVStore,
{
/// Constructs a `LSPS1ServiceHandler`.
@@ -421,10 +419,9 @@ where
}
}
-impl<ES: Deref, CM: Deref + Clone, C: Deref, K: Deref + Clone> LSPSProtocolMessageHandler
+impl<ES: EntropySource, CM: Deref + Clone, C: Deref, K: Deref + Clone> LSPSProtocolMessageHandler
for LSPS1ServiceHandler<ES, CM, C, K>
where
- ES::Target: EntropySource,
CM::Target: AChannelManager,
C::Target: Filter,
K::Target: KVStore,
diff --git a/lightning-liquidity/src/lsps2/client.rs b/lightning-liquidity/src/lsps2/client.rs
index 83aa7e3..2e9fca2 100644
--- a/lightning-liquidity/src/lsps2/client.rs
+++ b/lightning-liquidity/src/lsps2/client.rs
@@ -68,9 +68,8 @@ impl PeerState {
/// opened. Please refer to the [`bLIP-52 / LSPS2 specification`] for more information.
///
/// [`bLIP-52 / LSPS2 specification`]: https://github.com/lightning/blips/blob/master/blip-0052.md#trust-models
-pub struct LSPS2ClientHandler<ES: Deref, K: Deref + Clone>
+pub struct LSPS2ClientHandler<ES: EntropySource, K: Deref + Clone>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
entropy_source: ES,
@@ -80,9 +79,8 @@ where
config: LSPS2ClientConfig,
}
-impl<ES: Deref, K: Deref + Clone> LSPS2ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPS2ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
/// Constructs an `LSPS2ClientHandler`.
@@ -375,9 +373,8 @@ where
}
}
-impl<ES: Deref, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS2ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS2ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
type ProtocolMessage = LSPS2Message;
diff --git a/lightning-liquidity/src/lsps5/client.rs b/lightning-liquidity/src/lsps5/client.rs
index 1c6f8b8..df10522 100644
--- a/lightning-liquidity/src/lsps5/client.rs
+++ b/lightning-liquidity/src/lsps5/client.rs
@@ -125,9 +125,8 @@ impl PeerState {
/// [`lsps5.list_webhooks`]: super::msgs::LSPS5Request::ListWebhooks
/// [`lsps5.remove_webhook`]: super::msgs::LSPS5Request::RemoveWebhook
/// [`LSPS5Validator`]: super::validator::LSPS5Validator
-pub struct LSPS5ClientHandler<ES: Deref, K: Deref + Clone>
+pub struct LSPS5ClientHandler<ES: EntropySource, K: Deref + Clone>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
pending_messages: Arc<MessageQueue>,
@@ -137,9 +136,8 @@ where
_config: LSPS5ClientConfig,
}
-impl<ES: Deref, K: Deref + Clone> LSPS5ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPS5ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
/// Constructs an `LSPS5ClientHandler`.
@@ -426,9 +424,8 @@ where
}
}
-impl<ES: Deref, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS5ClientHandler<ES, K>
+impl<ES: EntropySource, K: Deref + Clone> LSPSProtocolMessageHandler for LSPS5ClientHandler<ES, K>
where
- ES::Target: EntropySource,
K::Target: KVStore,
{
type ProtocolMessage = LSPS5Message;
diff --git a/lightning-liquidity/src/manager.rs b/lightning-liquidity/src/manager.rs
index 84a52e2..14b0fa5 100644
--- a/lightning-liquidity/src/manager.rs
+++ b/lightning-liquidity/src/manager.rs
@@ -104,9 +104,7 @@ pub struct LiquidityClientConfig {
/// languages.
pub trait ALiquidityManager {
/// A type implementing [`EntropySource`]
- type EntropySource: EntropySource + ?Sized;
- /// A type that may be dereferenced to [`Self::EntropySource`].
- type ES: Deref<Target = Self::EntropySource> + Clone;
+ type EntropySource: EntropySource + Clone;
/// A type implementing [`NodeSigner`]
type NodeSigner: NodeSigner + ?Sized;
/// A type that may be dereferenced to [`Self::NodeSigner`].
@@ -133,7 +131,7 @@ pub trait ALiquidityManager {
fn get_lm(
&self,
) -> &LiquidityManager<
- Self::ES,
+ Self::EntropySource,
Self::NS,
Self::CM,
Self::C,
@@ -144,7 +142,7 @@ pub trait ALiquidityManager {
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -153,15 +151,13 @@ impl<
T: BroadcasterInterface + Clone,
> ALiquidityManager for LiquidityManager<ES, NS, CM, C, K, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
K::Target: KVStore,
TP::Target: TimeProvider,
{
- type EntropySource = ES::Target;
- type ES = ES;
+ type EntropySource = ES;
type NodeSigner = NS::Target;
type NS = NS;
type AChannelManager = CM::Target;
@@ -184,9 +180,7 @@ where
/// languages.
pub trait ALiquidityManagerSync {
/// A type implementing [`EntropySource`]
- type EntropySource: EntropySource + ?Sized;
- /// A type that may be dereferenced to [`Self::EntropySource`].
- type ES: Deref<Target = Self::EntropySource> + Clone;
+ type EntropySource: EntropySource + Clone;
/// A type implementing [`NodeSigner`]
type NodeSigner: NodeSigner + ?Sized;
/// A type that may be dereferenced to [`Self::NodeSigner`].
@@ -214,7 +208,7 @@ pub trait ALiquidityManagerSync {
fn get_lm_async(
&self,
) -> &LiquidityManager<
- Self::ES,
+ Self::EntropySource,
Self::NS,
Self::CM,
Self::C,
@@ -226,7 +220,7 @@ pub trait ALiquidityManagerSync {
fn get_lm(
&self,
) -> &LiquidityManagerSync<
- Self::ES,
+ Self::EntropySource,
Self::NS,
Self::CM,
Self::C,
@@ -237,7 +231,7 @@ pub trait ALiquidityManagerSync {
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -246,15 +240,13 @@ impl<
T: BroadcasterInterface + Clone,
> ALiquidityManagerSync for LiquidityManagerSync<ES, NS, CM, C, KS, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
KS::Target: KVStoreSync,
TP::Target: TimeProvider,
{
- type EntropySource = ES::Target;
- type ES = ES;
+ type EntropySource = ES;
type NodeSigner = NS::Target;
type NS = NS;
type AChannelManager = CM::Target;
@@ -271,7 +263,7 @@ where
fn get_lm_async(
&self,
) -> &LiquidityManager<
- Self::ES,
+ Self::EntropySource,
Self::NS,
Self::CM,
Self::C,
@@ -306,7 +298,7 @@ where
/// [`Event::HTLCHandlingFailed`]: lightning::events::Event::HTLCHandlingFailed
/// [`Event::PaymentForwarded`]: lightning::events::Event::PaymentForwarded
pub struct LiquidityManager<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -314,7 +306,6 @@ pub struct LiquidityManager<
TP: Deref + Clone,
T: BroadcasterInterface + Clone,
> where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -344,7 +335,7 @@ pub struct LiquidityManager<
#[cfg(feature = "time")]
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -352,7 +343,6 @@ impl<
T: BroadcasterInterface + Clone,
> LiquidityManager<ES, NS, CM, C, K, DefaultTimeProvider, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -384,7 +374,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -393,7 +383,6 @@ impl<
T: BroadcasterInterface + Clone,
> LiquidityManager<ES, NS, CM, C, K, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -810,7 +799,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -819,7 +808,6 @@ impl<
T: BroadcasterInterface + Clone,
> CustomMessageReader for LiquidityManager<ES, NS, CM, C, K, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -841,7 +829,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -850,7 +838,6 @@ impl<
T: BroadcasterInterface + Clone,
> CustomMessageHandler for LiquidityManager<ES, NS, CM, C, K, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -974,7 +961,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -983,7 +970,6 @@ impl<
T: BroadcasterInterface + Clone,
> Listen for LiquidityManager<ES, NS, CM, C, K, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1019,7 +1005,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1028,7 +1014,6 @@ impl<
T: BroadcasterInterface + Clone,
> Confirm for LiquidityManager<ES, NS, CM, C, K, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1064,7 +1049,7 @@ where
/// A synchroneous wrapper around [`LiquidityManager`] to be used in contexts where async is not
/// available.
pub struct LiquidityManagerSync<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1072,7 +1057,6 @@ pub struct LiquidityManagerSync<
TP: Deref + Clone,
T: BroadcasterInterface + Clone,
> where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1084,7 +1068,7 @@ pub struct LiquidityManagerSync<
#[cfg(feature = "time")]
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1092,7 +1076,6 @@ impl<
T: BroadcasterInterface + Clone,
> LiquidityManagerSync<ES, NS, CM, C, KS, DefaultTimeProvider, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
KS::Target: KVStoreSync,
@@ -1135,7 +1118,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1144,7 +1127,6 @@ impl<
T: BroadcasterInterface + Clone,
> LiquidityManagerSync<ES, NS, CM, C, KS, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1304,7 +1286,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1313,7 +1295,6 @@ impl<
T: BroadcasterInterface + Clone,
> CustomMessageReader for LiquidityManagerSync<ES, NS, CM, C, KS, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1330,7 +1311,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1339,7 +1320,6 @@ impl<
T: BroadcasterInterface + Clone,
> CustomMessageHandler for LiquidityManagerSync<ES, NS, CM, C, KS, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1376,7 +1356,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1385,7 +1365,6 @@ impl<
T: BroadcasterInterface + Clone,
> Listen for LiquidityManagerSync<ES, NS, CM, C, KS, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
@@ -1405,7 +1384,7 @@ where
}
impl<
- ES: Deref + Clone,
+ ES: EntropySource + Clone,
NS: Deref + Clone,
CM: Deref + Clone,
C: Deref + Clone,
@@ -1414,7 +1393,6 @@ impl<
T: BroadcasterInterface + Clone,
> Confirm for LiquidityManagerSync<ES, NS, CM, C, KS, TP, T>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
CM::Target: AChannelManager,
C::Target: Filter,
diff --git a/lightning-liquidity/src/utils/mod.rs b/lightning-liquidity/src/utils/mod.rs
index b66d3eb..32b5044 100644
--- a/lightning-liquidity/src/utils/mod.rs
+++ b/lightning-liquidity/src/utils/mod.rs
@@ -1,7 +1,7 @@
//! Utilities for LSPS5 service.
use alloc::string::String;
-use core::{fmt::Write, ops::Deref};
+use core::fmt::Write;
use lightning::sign::EntropySource;
@@ -23,10 +23,7 @@ pub fn scid_from_human_readable_string(human_readable_scid: &str) -> Result<u64,
Ok((block << 40) | (tx_index << 16) | vout_index)
}
-pub(crate) fn generate_request_id<ES: Deref>(entropy_source: &ES) -> LSPSRequestId
-where
- ES::Target: EntropySource,
-{
+pub(crate) fn generate_request_id<ES: EntropySource>(entropy_source: &ES) -> LSPSRequestId {
let bytes = entropy_source.get_secure_random_bytes();
LSPSRequestId(hex_str(&bytes[0..16]))
}
diff --git a/lightning-net-tokio/src/lib.rs b/lightning-net-tokio/src/lib.rs
index 27d309f..eec0e42 100644
--- a/lightning-net-tokio/src/lib.rs
+++ b/lightning-net-tokio/src/lib.rs
@@ -480,13 +480,12 @@ where
///
/// Returns a future (as the fn is async) that yields another future, see [`connect_outbound`] for
/// details on this return value.
-pub async fn tor_connect_outbound<PM: Deref + 'static + Send + Sync + Clone, ES: Deref>(
+pub async fn tor_connect_outbound<PM: Deref + 'static + Send + Sync + Clone, ES: EntropySource>(
peer_manager: PM, their_node_id: PublicKey, addr: SocketAddress, tor_proxy_addr: SocketAddr,
entropy_source: ES,
) -> Option<impl std::future::Future<Output = ()>>
where
PM::Target: APeerManager<Descriptor = SocketDescriptor>,
- ES::Target: EntropySource,
{
let connect_fut = async {
tor_connect(addr, tor_proxy_addr, entropy_source).await.map(|s| s.into_std().unwrap())
@@ -500,12 +499,9 @@ where
}
}
-async fn tor_connect<ES: Deref>(
+async fn tor_connect<ES: EntropySource>(
addr: SocketAddress, tor_proxy_addr: SocketAddr, entropy_source: ES,
-) -> Result<TcpStream, ()>
-where
- ES::Target: EntropySource,
-{
+) -> Result<TcpStream, ()> {
use std::io::Write;
use tokio::io::AsyncReadExt;
diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs
index 84a42ff..c914458 100644
--- a/lightning/src/blinded_path/message.rs
+++ b/lightning/src/blinded_path/message.rs
@@ -58,14 +58,11 @@ impl BlindedMessagePath {
/// `compact_padding` selects between space-inefficient padding which better hides contents and
/// a space-constrained padding which does very little to hide the contents, especially for the
/// last hop. It should only be set when the blinded path needs to be as compact as possible.
- pub fn one_hop<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ pub fn one_hop<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
recipient_node_id: PublicKey, local_node_receive_key: ReceiveAuthKey,
context: MessageContext, compact_padding: bool, entropy_source: ES,
secp_ctx: &Secp256k1<T>,
- ) -> Self
- where
- ES::Target: EntropySource,
- {
+ ) -> Self {
Self::new(
&[],
recipient_node_id,
@@ -82,14 +79,11 @@ impl BlindedMessagePath {
/// `compact_padding` selects between space-inefficient padding which better hides contents and
/// a space-constrained padding which does very little to hide the contents, especially for the
/// last hop. It should only be set when the blinded path needs to be as compact as possible.
- pub fn new<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ pub fn new<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
intermediate_nodes: &[MessageForwardNode], recipient_node_id: PublicKey,
local_node_receive_key: ReceiveAuthKey, context: MessageContext, compact_padding: bool,
entropy_source: ES, secp_ctx: &Secp256k1<T>,
- ) -> Self
- where
- ES::Target: EntropySource,
- {
+ ) -> Self {
BlindedMessagePath::new_with_dummy_hops(
intermediate_nodes,
recipient_node_id,
@@ -109,14 +103,14 @@ impl BlindedMessagePath {
/// last hop. It should only be set when the blinded path needs to be as compact as possible.
///
/// Note: At most [`MAX_DUMMY_HOPS_COUNT`] dummy hops can be added to the blinded path.
- pub fn new_with_dummy_hops<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ pub fn new_with_dummy_hops<
+ ES: EntropySource,
+ T: secp256k1::Signing + secp256k1::Verification,
+ >(
intermediate_nodes: &[MessageForwardNode], recipient_node_id: PublicKey,
dummy_hop_count: usize, local_node_receive_key: ReceiveAuthKey, context: MessageContext,
compact_padding: bool, entropy_source: ES, secp_ctx: &Secp256k1<T>,
- ) -> Self
- where
- ES::Target: EntropySource,
- {
+ ) -> Self {
let introduction_node = IntroductionNode::NodeId(
intermediate_nodes.first().map_or(recipient_node_id, |n| n.node_id),
);
diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs
index b68be81..e195f5a 100644
--- a/lightning/src/blinded_path/payment.rs
+++ b/lightning/src/blinded_path/payment.rs
@@ -87,13 +87,10 @@ pub struct BlindedPaymentPath {
impl BlindedPaymentPath {
/// Create a one-hop blinded path for a payment.
- pub fn one_hop<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ pub fn one_hop<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
payee_node_id: PublicKey, local_node_receive_key: ReceiveAuthKey, payee_tlvs: ReceiveTlvs,
min_final_cltv_expiry_delta: u16, entropy_source: ES, secp_ctx: &Secp256k1<T>,
- ) -> Result<Self, ()>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<Self, ()> {
// This value is not considered in pathfinding for 1-hop blinded paths, because it's intended to
// be in relation to a specific channel.
let htlc_maximum_msat = u64::max_value();
@@ -115,14 +112,11 @@ impl BlindedPaymentPath {
/// * [`BlindedPayInfo`] calculation results in an integer overflow
/// * any unknown features are required in the provided [`ForwardTlvs`]
// TODO: make all payloads the same size with padding + add dummy hops
- pub fn new<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ pub fn new<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
intermediate_nodes: &[PaymentForwardNode], payee_node_id: PublicKey,
local_node_receive_key: ReceiveAuthKey, payee_tlvs: ReceiveTlvs, htlc_maximum_msat: u64,
min_final_cltv_expiry_delta: u16, entropy_source: ES, secp_ctx: &Secp256k1<T>,
- ) -> Result<Self, ()>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<Self, ()> {
BlindedPaymentPath::new_inner(
intermediate_nodes,
payee_node_id,
@@ -147,15 +141,15 @@ impl BlindedPaymentPath {
///
/// TODO: Add end-to-end tests validating fee aggregation, CLTV deltas, and
/// HTLC bounds when dummy hops are present, before exposing this API publicly.
- pub(crate) fn new_with_dummy_hops<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ pub(crate) fn new_with_dummy_hops<
+ ES: EntropySource,
+ T: secp256k1::Signing + secp256k1::Verification,
+ >(
intermediate_nodes: &[PaymentForwardNode], payee_node_id: PublicKey,
dummy_tlvs: &[DummyTlvs], local_node_receive_key: ReceiveAuthKey, payee_tlvs: ReceiveTlvs,
htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16, entropy_source: ES,
secp_ctx: &Secp256k1<T>,
- ) -> Result<Self, ()>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<Self, ()> {
BlindedPaymentPath::new_inner(
intermediate_nodes,
payee_node_id,
@@ -169,15 +163,12 @@ impl BlindedPaymentPath {
)
}
- fn new_inner<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
+ fn new_inner<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>(
intermediate_nodes: &[PaymentForwardNode], payee_node_id: PublicKey,
local_node_receive_key: ReceiveAuthKey, dummy_tlvs: &[DummyTlvs], payee_tlvs: ReceiveTlvs,
htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16, entropy_source: ES,
secp_ctx: &Secp256k1<T>,
- ) -> Result<Self, ()>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<Self, ()> {
let introduction_node = IntroductionNode::NodeId(
intermediate_nodes.first().map_or(payee_node_id, |n| n.node_id),
);
diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs
index 678c7b6..e4a9ca9 100644
--- a/lightning/src/chain/chainmonitor.rs
+++ b/lightning/src/chain/chainmonitor.rs
@@ -259,14 +259,13 @@ pub struct AsyncPersister<
K: Deref + MaybeSend + MaybeSync + 'static,
S: FutureSpawner,
L: Deref + MaybeSend + MaybeSync + 'static,
- ES: Deref + MaybeSend + MaybeSync + 'static,
+ ES: EntropySource + MaybeSend + MaybeSync + 'static,
SP: Deref + MaybeSend + MaybeSync + 'static,
BI: BroadcasterInterface + MaybeSend + MaybeSync + 'static,
FE: Deref + MaybeSend + MaybeSync + 'static,
> where
K::Target: KVStore + MaybeSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -278,7 +277,7 @@ impl<
K: Deref + MaybeSend + MaybeSync + 'static,
S: FutureSpawner,
L: Deref + MaybeSend + MaybeSync + 'static,
- ES: Deref + MaybeSend + MaybeSync + 'static,
+ ES: EntropySource + MaybeSend + MaybeSync + 'static,
SP: Deref + MaybeSend + MaybeSync + 'static,
BI: BroadcasterInterface + MaybeSend + MaybeSync + 'static,
FE: Deref + MaybeSend + MaybeSync + 'static,
@@ -286,7 +285,6 @@ impl<
where
K::Target: KVStore + MaybeSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -300,7 +298,7 @@ impl<
K: Deref + MaybeSend + MaybeSync + 'static,
S: FutureSpawner,
L: Deref + MaybeSend + MaybeSync + 'static,
- ES: Deref + MaybeSend + MaybeSync + 'static,
+ ES: EntropySource + MaybeSend + MaybeSync + 'static,
SP: Deref + MaybeSend + MaybeSync + 'static,
BI: BroadcasterInterface + MaybeSend + MaybeSync + 'static,
FE: Deref + MaybeSend + MaybeSync + 'static,
@@ -308,7 +306,6 @@ impl<
where
K::Target: KVStore + MaybeSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
<SP::Target as SignerProvider>::EcdsaSigner: MaybeSend + 'static,
@@ -363,13 +360,12 @@ pub struct ChainMonitor<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
monitors: RwLock<HashMap<ChannelId, MonitorHolder<ChannelSigner>>>,
chain_source: Option<C>,
@@ -403,7 +399,7 @@ impl<
T: BroadcasterInterface + MaybeSend + MaybeSync + 'static,
F: Deref + MaybeSend + MaybeSync + 'static,
L: Deref + MaybeSend + MaybeSync + 'static,
- ES: Deref + MaybeSend + MaybeSync + 'static,
+ ES: EntropySource + MaybeSend + MaybeSync + 'static,
>
ChainMonitor<
<SP::Target as SignerProvider>::EcdsaSigner,
@@ -419,7 +415,6 @@ impl<
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
<SP::Target as SignerProvider>::EcdsaSigner: MaybeSend + 'static,
{
/// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels.
@@ -461,14 +456,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view
/// of a channel and reacting accordingly based on transactions in the given chain data. See
@@ -1107,14 +1101,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> BaseMessageHandler for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent> {
let mut pending_events = self.pending_send_only_events.lock().unwrap();
@@ -1145,14 +1138,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> SendOnlyMessageHandler for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
}
@@ -1163,14 +1155,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> chain::Listen for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
fn filtered_block_connected(&self, header: &Header, txdata: &TransactionData, height: u32) {
log_debug!(
@@ -1226,14 +1217,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> chain::Confirm for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
fn transactions_confirmed(&self, header: &Header, txdata: &TransactionData, height: u32) {
log_debug!(
@@ -1320,14 +1310,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> chain::Watch<ChannelSigner> for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
fn watch_channel(
&self, channel_id: ChannelId, monitor: ChannelMonitor<ChannelSigner>,
@@ -1515,14 +1504,13 @@ impl<
F: Deref,
L: Deref,
P: Deref,
- ES: Deref,
+ ES: EntropySource,
> events::EventsProvider for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>
where
C::Target: chain::Filter,
F::Target: FeeEstimator,
L::Target: Logger,
P::Target: Persist<ChannelSigner>,
- ES::Target: EntropySource,
{
/// Processes [`SpendableOutputs`] events produced from each [`ChannelMonitor`] upon maturity.
///
diff --git a/lightning/src/crypto/utils.rs b/lightning/src/crypto/utils.rs
index b59cc60..1570b3a 100644
--- a/lightning/src/crypto/utils.rs
+++ b/lightning/src/crypto/utils.rs
@@ -5,8 +5,6 @@ use bitcoin::secp256k1::{ecdsa::Signature, Message, Secp256k1, SecretKey, Signin
use crate::sign::EntropySource;
-use core::ops::Deref;
-
macro_rules! hkdf_extract_expand {
($salt: expr, $ikm: expr) => {{
let mut hmac = HmacEngine::<Sha256>::new($salt);
@@ -72,12 +70,9 @@ pub fn sign<C: Signing>(ctx: &Secp256k1<C>, msg: &Message, sk: &SecretKey) -> Si
#[inline]
#[allow(unused_variables)]
-pub fn sign_with_aux_rand<C: Signing, ES: Deref>(
+pub fn sign_with_aux_rand<C: Signing, ES: EntropySource>(
ctx: &Secp256k1<C>, msg: &Message, sk: &SecretKey, entropy_source: &ES,
-) -> Signature
-where
- ES::Target: EntropySource,
-{
+) -> Signature {
#[cfg(feature = "grind_signatures")]
let sig = loop {
let sig = ctx.sign_ecdsa_with_noncedata(msg, sk, &entropy_source.get_secure_random_bytes());
diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs
index 431fdd2..46afa05 100644
--- a/lightning/src/ln/chan_utils.rs
+++ b/lightning/src/ln/chan_utils.rs
@@ -1452,13 +1452,10 @@ impl BuiltCommitmentTransaction {
}
/// Signs the holder commitment transaction because we are about to broadcast it.
- pub fn sign_holder_commitment<T: secp256k1::Signing, ES: Deref>(
+ pub fn sign_holder_commitment<T: secp256k1::Signing, ES: EntropySource>(
&self, funding_key: &SecretKey, funding_redeemscript: &Script, channel_value_satoshis: u64,
entropy_source: &ES, secp_ctx: &Secp256k1<T>,
- ) -> Signature
- where
- ES::Target: EntropySource,
- {
+ ) -> Signature {
let sighash = self.get_sighash_all(funding_redeemscript, channel_value_satoshis);
sign_with_aux_rand(secp_ctx, &sighash, funding_key, entropy_source)
}
@@ -2139,10 +2136,10 @@ impl<'a> TrustedCommitmentTransaction<'a> {
///
/// This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All.
#[rustfmt::skip]
- pub fn get_htlc_sigs<T: secp256k1::Signing, ES: Deref>(
+ pub fn get_htlc_sigs<T: secp256k1::Signing, ES: EntropySource>(
&self, htlc_base_key: &SecretKey, channel_parameters: &DirectedChannelTransactionParameters,
entropy_source: &ES, secp_ctx: &Secp256k1<T>,
- ) -> Result<Vec<Signature>, ()> where ES::Target: EntropySource {
+ ) -> Result<Vec<Signature>, ()> {
let inner = self.inner;
let keys = &inner.keys;
let txid = inner.built.txid;
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 65a627f..38502c9 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -3567,7 +3567,7 @@ where
SP::Target: SignerProvider,
{
#[rustfmt::skip]
- fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
+ fn new_for_inbound_channel<'a, ES: EntropySource, F: Deref, L: Deref>(
fee_estimator: &'a LowerBoundedFeeEstimator<F>,
entropy_source: &'a ES,
signer_provider: &'a SP,
@@ -3587,7 +3587,6 @@ where
open_channel_fields: msgs::CommonOpenChannelFields,
) -> Result<(FundingScope, ChannelContext<SP>), ChannelError>
where
- ES::Target: EntropySource,
F::Target: FeeEstimator,
L::Target: Logger,
SP::Target: SignerProvider,
@@ -3912,7 +3911,7 @@ where
}
#[rustfmt::skip]
- fn new_for_outbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
+ fn new_for_outbound_channel<'a, ES: EntropySource, F: Deref, L: Deref>(
fee_estimator: &'a LowerBoundedFeeEstimator<F>,
entropy_source: &'a ES,
signer_provider: &'a SP,
@@ -3931,7 +3930,6 @@ where
_logger: L,
) -> Result<(FundingScope, ChannelContext<SP>), APIError>
where
- ES::Target: EntropySource,
F::Target: FeeEstimator,
SP::Target: SignerProvider,
L::Target: Logger,
@@ -6846,13 +6844,12 @@ pub(super) struct FundingNegotiationContext {
impl FundingNegotiationContext {
/// Prepare and start interactive transaction negotiation.
/// If error occurs, it is caused by our side, not the counterparty.
- fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
+ fn into_interactive_tx_constructor<SP: Deref, ES: EntropySource>(
mut self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
entropy_source: &ES, holder_node_id: PublicKey,
) -> Result<InteractiveTxConstructor, NegotiationError>
where
SP::Target: SignerProvider,
- ES::Target: EntropySource,
{
debug_assert_eq!(
self.shared_funding_input.is_some(),
@@ -12521,12 +12518,11 @@ where
Ok(())
}
- pub(crate) fn splice_init<ES: Deref, L: Deref>(
+ pub(crate) fn splice_init<ES: EntropySource, L: Deref>(
&mut self, msg: &msgs::SpliceInit, our_funding_contribution_satoshis: i64,
signer_provider: &SP, entropy_source: &ES, holder_node_id: &PublicKey, logger: &L,
) -> Result<msgs::SpliceAck, ChannelError>
where
- ES::Target: EntropySource,
L::Target: Logger,
{
let our_funding_contribution = SignedAmount::from_sat(our_funding_contribution_satoshis);
@@ -12592,12 +12588,11 @@ where
})
}
- pub(crate) fn splice_ack<ES: Deref, L: Deref>(
+ pub(crate) fn splice_ack<ES: EntropySource, L: Deref>(
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
holder_node_id: &PublicKey, logger: &L,
) -> Result<Option<InteractiveTxMessageSend>, ChannelError>
where
- ES::Target: EntropySource,
L::Target: Logger,
{
let splice_funding = self.validate_splice_ack(msg)?;
@@ -13704,13 +13699,12 @@ where
#[allow(dead_code)] // TODO(dual_funding): Remove once opending V2 channels is enabled.
#[rustfmt::skip]
- pub fn new<ES: Deref, F: Deref, L: Deref>(
+ pub fn new<ES: EntropySource, F: Deref, L: Deref>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP, counterparty_node_id: PublicKey, their_features: &InitFeatures,
channel_value_satoshis: u64, push_msat: u64, user_id: u128, config: &UserConfig, current_chain_height: u32,
outbound_scid_alias: u64, temporary_channel_id: Option<ChannelId>, logger: L
) -> Result<OutboundV1Channel<SP>, APIError>
- where ES::Target: EntropySource,
- F::Target: FeeEstimator,
+ where F::Target: FeeEstimator,
L::Target: Logger,
{
let holder_selected_channel_reserve_satoshis = get_holder_selected_channel_reserve_satoshis(channel_value_satoshis, config);
@@ -14096,14 +14090,13 @@ where
/// Creates a new channel from a remote sides' request for one.
/// Assumes chain_hash has already been checked and corresponds with what we expect!
#[rustfmt::skip]
- pub fn new<ES: Deref, F: Deref, L: Deref>(
+ pub fn new<ES: EntropySource, F: Deref, L: Deref>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
their_features: &InitFeatures, msg: &msgs::OpenChannel, user_id: u128, config: &UserConfig,
current_chain_height: u32, logger: &L, is_0conf: bool,
) -> Result<InboundV1Channel<SP>, ChannelError>
- where ES::Target: EntropySource,
- F::Target: FeeEstimator,
+ where F::Target: FeeEstimator,
L::Target: Logger,
{
let logger = WithContext::from(logger, Some(counterparty_node_id), Some(msg.common_fields.temporary_channel_id), None);
@@ -14370,15 +14363,14 @@ where
{
#[allow(dead_code)] // TODO(dual_funding): Remove once creating V2 channels is enabled.
#[rustfmt::skip]
- pub fn new_outbound<ES: Deref, F: Deref, L: Deref>(
+ pub fn new_outbound<ES: EntropySource, F: Deref, L: Deref>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L,
) -> Result<Self, APIError>
- where ES::Target: EntropySource,
- F::Target: FeeEstimator,
+ where F::Target: FeeEstimator,
L::Target: Logger,
{
let channel_keys_id = signer_provider.generate_channel_keys_id(false, user_id);
@@ -14519,14 +14511,13 @@ where
/// TODO(dual_funding): Allow contributions, pass intended amount and inputs
#[allow(dead_code)] // TODO(dual_funding): Remove once V2 channels is enabled.
#[rustfmt::skip]
- pub fn new_inbound<ES: Deref, F: Deref, L: Deref>(
+ pub fn new_inbound<ES: EntropySource, F: Deref, L: Deref>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
holder_node_id: PublicKey, counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
their_features: &InitFeatures, msg: &msgs::OpenChannelV2,
user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L,
) -> Result<Self, ChannelError>
- where ES::Target: EntropySource,
- F::Target: FeeEstimator,
+ where F::Target: FeeEstimator,
L::Target: Logger,
{
// TODO(dual_funding): Take these as input once supported
@@ -15277,10 +15268,9 @@ where
}
}
-impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c ChannelTypeFeatures)>
- for FundedChannel<SP>
+impl<'a, 'b, 'c, ES: EntropySource, SP: Deref>
+ ReadableArgs<(&'a ES, &'b SP, &'c ChannelTypeFeatures)> for FundedChannel<SP>
where
- ES::Target: EntropySource,
SP::Target: SignerProvider,
{
fn read<R: io::Read>(
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 7191e84..bcb5b2a 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -1791,9 +1791,7 @@ pub trait AChannelManager {
/// A type implementing [`BroadcasterInterface`].
type Broadcaster: BroadcasterInterface;
/// A type implementing [`EntropySource`].
- type EntropySource: EntropySource + ?Sized;
- /// A type that may be dereferenced to [`Self::EntropySource`].
- type ES: Deref<Target = Self::EntropySource>;
+ type EntropySource: EntropySource;
/// A type implementing [`NodeSigner`].
type NodeSigner: NodeSigner + ?Sized;
/// A type that may be dereferenced to [`Self::NodeSigner`].
@@ -1826,7 +1824,7 @@ pub trait AChannelManager {
) -> &ChannelManager<
Self::M,
Self::Broadcaster,
- Self::ES,
+ Self::EntropySource,
Self::NS,
Self::SP,
Self::F,
@@ -1839,7 +1837,7 @@ pub trait AChannelManager {
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -1849,7 +1847,6 @@ impl<
> AChannelManager for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -1860,8 +1857,7 @@ where
type Watch = M::Target;
type M = M;
type Broadcaster = T;
- type EntropySource = ES::Target;
- type ES = ES;
+ type EntropySource = ES;
type NodeSigner = NS::Target;
type NS = NS;
type Signer = <SP::Target as SignerProvider>::EcdsaSigner;
@@ -2622,7 +2618,7 @@ where
pub struct ChannelManager<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -2631,7 +2627,6 @@ pub struct ChannelManager<
L: Deref,
> where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -3411,7 +3406,7 @@ fn create_htlc_intercepted_event(
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -3421,7 +3416,6 @@ impl<
> ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -5627,7 +5621,7 @@ where
features,
best_block_height,
self.duration_since_epoch(),
- &*self.entropy_source,
+ &self.entropy_source,
&self.pending_events,
);
match outbound_pmts_res {
@@ -5761,7 +5755,7 @@ where
intercept_id,
prev_outbound_scid_alias,
htlc_id,
- &*self.entropy_source,
+ &self.entropy_source,
)
}
@@ -13407,7 +13401,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
pub fn create_offer_builder(&$self) -> Result<$builder, Bolt12SemanticError> {
let builder = $self.flow.create_offer_builder(
- &*$self.entropy_source, $self.get_peers_for_blinded_path()
+ &$self.entropy_source, $self.get_peers_for_blinded_path()
)?;
Ok(builder.into())
@@ -13432,7 +13426,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
ME::Target: MessageRouter,
{
let builder = $self.flow.create_offer_builder_using_router(
- router, &*$self.entropy_source, $self.get_peers_for_blinded_path()
+ router, &$self.entropy_source, $self.get_peers_for_blinded_path()
)?;
Ok(builder.into())
@@ -13484,7 +13478,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
&$self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId,
retry_strategy: Retry, route_params_config: RouteParametersConfig
) -> Result<$builder, Bolt12SemanticError> {
- let entropy = &*$self.entropy_source;
+ let entropy = &$self.entropy_source;
let builder = $self.flow.create_refund_builder(
entropy, amount_msats, absolute_expiry,
@@ -13528,7 +13522,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
where
ME::Target: MessageRouter,
{
- let entropy = &*$self.entropy_source;
+ let entropy = &$self.entropy_source;
let builder = $self.flow.create_refund_builder_using_router(
router, entropy, amount_msats, absolute_expiry,
@@ -13551,7 +13545,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -13561,7 +13555,6 @@ impl<
> ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -13757,7 +13750,7 @@ where
payer_note: Option<String>, payment_id: PaymentId,
human_readable_name: Option<HumanReadableName>, create_pending_payment: CPP,
) -> Result<(), Bolt12SemanticError> {
- let entropy = &*self.entropy_source;
+ let entropy = &self.entropy_source;
let nonce = Nonce::from_entropy_source(entropy);
let builder = self.flow.create_invoice_request_builder(
@@ -13825,7 +13818,7 @@ where
&self, refund: &Refund,
) -> Result<Bolt12Invoice, Bolt12SemanticError> {
let secp_ctx = &self.secp_ctx;
- let entropy = &*self.entropy_source;
+ let entropy = &self.entropy_source;
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
@@ -13890,7 +13883,7 @@ where
optional_params: OptionalOfferPaymentParams, dns_resolvers: Vec<Destination>,
) -> Result<(), ()> {
let (onion_message, context) =
- self.flow.hrn_resolver.resolve_name(payment_id, name, &*self.entropy_source)?;
+ self.flow.hrn_resolver.resolve_name(payment_id, name, &self.entropy_source)?;
let expiration = StaleExpiration::TimerTicks(1);
self.pending_outbound_payments.add_new_awaiting_offer(
@@ -14427,7 +14420,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -14437,7 +14430,6 @@ impl<
> BaseMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -14797,7 +14789,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -14807,7 +14799,6 @@ impl<
> EventsProvider for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -14831,7 +14822,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -14841,7 +14832,6 @@ impl<
> chain::Listen for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -14891,7 +14881,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -14901,7 +14891,6 @@ impl<
> chain::Confirm for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -15063,7 +15052,7 @@ pub(super) enum FundingConfirmedMessage {
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -15073,7 +15062,6 @@ impl<
> ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -15424,7 +15412,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -15434,7 +15422,6 @@ impl<
> ChannelMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -15998,7 +15985,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -16008,7 +15995,6 @@ impl<
> OffersMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -16215,7 +16201,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -16225,7 +16211,6 @@ impl<
> AsyncPaymentsMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -16259,7 +16244,7 @@ where
responder.clone(),
self.get_peers_for_blinded_path(),
self.list_usable_channels(),
- &*self.entropy_source,
+ &self.entropy_source,
&*self.router,
) {
Some((msg, ctx)) => (msg, ctx),
@@ -16459,7 +16444,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -16469,7 +16454,6 @@ impl<
> DNSResolverMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -16526,7 +16510,7 @@ where
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -16536,7 +16520,6 @@ impl<
> NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -17041,7 +17024,7 @@ impl_writeable_tlv_based!(PendingInboundPayment, {
impl<
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -17051,7 +17034,6 @@ impl<
> Writeable for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -17407,7 +17389,7 @@ pub struct ChannelManagerReadArgs<
'a,
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -17416,7 +17398,6 @@ pub struct ChannelManagerReadArgs<
L: Deref + Clone,
> where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -17486,7 +17467,7 @@ impl<
'a,
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -17496,7 +17477,6 @@ impl<
> ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, MR, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -17573,7 +17553,7 @@ impl<
'a,
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -17584,7 +17564,6 @@ impl<
for (BlockHash, Arc<ChannelManager<M, T, ES, NS, SP, F, R, MR, L>>)
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
@@ -17605,7 +17584,7 @@ impl<
'a,
M: Deref,
T: BroadcasterInterface,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
SP: Deref,
F: Deref,
@@ -17616,7 +17595,6 @@ impl<
for (BlockHash, ChannelManager<M, T, ES, NS, SP, F, R, MR, L>)
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
F::Target: FeeEstimator,
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 69c18d9..c68a2c7 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -734,7 +734,7 @@ pub trait NodeHolder {
) -> &ChannelManager<
<Self::CM as AChannelManager>::M,
<Self::CM as AChannelManager>::Broadcaster,
- <Self::CM as AChannelManager>::ES,
+ <Self::CM as AChannelManager>::EntropySource,
<Self::CM as AChannelManager>::NS,
<Self::CM as AChannelManager>::SP,
<Self::CM as AChannelManager>::F,
@@ -751,7 +751,7 @@ impl<H: NodeHolder> NodeHolder for &H {
) -> &ChannelManager<
<Self::CM as AChannelManager>::M,
<Self::CM as AChannelManager>::Broadcaster,
- <Self::CM as AChannelManager>::ES,
+ <Self::CM as AChannelManager>::EntropySource,
<Self::CM as AChannelManager>::NS,
<Self::CM as AChannelManager>::SP,
<Self::CM as AChannelManager>::F,
diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs
index 17c2526..03e271d 100644
--- a/lightning/src/ln/inbound_payment.rs
+++ b/lightning/src/ln/inbound_payment.rs
@@ -143,13 +143,10 @@ fn min_final_cltv_expiry_delta_from_metadata(bytes: [u8; METADATA_LEN]) -> u16 {
///
/// [phantom node payments]: crate::sign::PhantomKeysManager
/// [`NodeSigner::get_expanded_key`]: crate::sign::NodeSigner::get_expanded_key
-pub fn create<ES: Deref>(
+pub fn create<ES: EntropySource>(
keys: &ExpandedKey, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32,
entropy_source: &ES, current_time: u64, min_final_cltv_expiry_delta: Option<u16>,
-) -> Result<(PaymentHash, PaymentSecret), ()>
-where
- ES::Target: EntropySource,
-{
+) -> Result<(PaymentHash, PaymentSecret), ()> {
let metadata_bytes = construct_metadata_bytes(
min_value_msat,
if min_final_cltv_expiry_delta.is_some() {
diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs
index f402ac5..a004f6e 100644
--- a/lightning/src/ln/interactivetxs.rs
+++ b/lightning/src/ln/interactivetxs.rs
@@ -39,7 +39,6 @@ use crate::ln::types::ChannelId;
use crate::sign::{EntropySource, P2TR_KEY_PATH_WITNESS_WEIGHT, P2WPKH_WITNESS_WEIGHT};
use core::fmt::Display;
-use core::ops::Deref;
/// The number of received `tx_add_input` messages during a negotiation at which point the
/// negotiation MUST be failed.
@@ -1989,10 +1988,9 @@ macro_rules! do_state_transition {
}};
}
-fn generate_holder_serial_id<ES: Deref>(entropy_source: &ES, is_initiator: bool) -> SerialId
-where
- ES::Target: EntropySource,
-{
+fn generate_holder_serial_id<ES: EntropySource>(
+ entropy_source: &ES, is_initiator: bool,
+) -> SerialId {
let rand_bytes = entropy_source.get_secure_random_bytes();
let mut serial_id_bytes = [0u8; 8];
serial_id_bytes.copy_from_slice(&rand_bytes[..8]);
@@ -2008,10 +2006,7 @@ pub(super) enum HandleTxCompleteValue {
NegotiationComplete(Option<InteractiveTxMessageSend>, OutPoint),
}
-pub(super) struct InteractiveTxConstructorArgs<'a, ES: Deref>
-where
- ES::Target: EntropySource,
-{
+pub(super) struct InteractiveTxConstructorArgs<'a, ES: EntropySource> {
pub entropy_source: &'a ES,
pub holder_node_id: PublicKey,
pub counterparty_node_id: PublicKey,
@@ -2030,10 +2025,9 @@ impl InteractiveTxConstructor {
///
/// If the holder is the initiator, they need to send the first message which is a `TxAddInput`
/// message.
- pub fn new<ES: Deref>(args: InteractiveTxConstructorArgs<ES>) -> Result<Self, NegotiationError>
- where
- ES::Target: EntropySource,
- {
+ pub fn new<ES: EntropySource>(
+ args: InteractiveTxConstructorArgs<ES>,
+ ) -> Result<Self, NegotiationError> {
let InteractiveTxConstructorArgs {
entropy_source,
holder_node_id,
@@ -2428,7 +2422,6 @@ mod tests {
OutPoint, PubkeyHash, ScriptBuf, Sequence, SignedAmount, Transaction, TxIn, TxOut,
WPubkeyHash,
};
- use core::ops::Deref;
use super::{
get_output_weight, ConstructedTransaction, InteractiveTxSigningSession, TxInMetadata,
@@ -2498,19 +2491,15 @@ mod tests {
do_test_interactive_tx_constructor_internal(session, &&entropy_source);
}
- fn do_test_interactive_tx_constructor_with_entropy_source<ES: Deref>(
+ fn do_test_interactive_tx_constructor_with_entropy_source<ES: EntropySource>(
session: TestSession, entropy_source: ES,
- ) where
- ES::Target: EntropySource,
- {
+ ) {
do_test_interactive_tx_constructor_internal(session, &entropy_source);
}
- fn do_test_interactive_tx_constructor_internal<ES: Deref>(
+ fn do_test_interactive_tx_constructor_internal<ES: EntropySource>(
session: TestSession, entropy_source: &ES,
- ) where
- ES::Target: EntropySource,
- {
+ ) {
let channel_id = ChannelId(entropy_source.get_secure_random_bytes());
let funding_tx_locktime = AbsoluteLockTime::from_height(1337).unwrap();
let holder_node_id = PublicKey::from_secret_key(
diff --git a/lightning/src/ln/invoice_utils.rs b/lightning/src/ln/invoice_utils.rs
index e72ea45..5e4036b 100644
--- a/lightning/src/ln/invoice_utils.rs
+++ b/lightning/src/ln/invoice_utils.rs
@@ -67,14 +67,13 @@ use core::time::Duration;
feature = "std",
doc = "This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller."
)]
-pub fn create_phantom_invoice<ES: Deref, NS: Deref, L: Deref>(
+pub fn create_phantom_invoice<ES: EntropySource, NS: Deref, L: Deref>(
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: String,
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>,
entropy_source: ES, node_signer: NS, logger: L, network: Currency,
min_final_cltv_expiry_delta: Option<u16>, duration_since_epoch: Duration,
) -> Result<Bolt11Invoice, SignOrCreationError<()>>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
{
@@ -135,14 +134,13 @@ where
feature = "std",
doc = "This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller."
)]
-pub fn create_phantom_invoice_with_description_hash<ES: Deref, NS: Deref, L: Deref>(
+pub fn create_phantom_invoice_with_description_hash<ES: EntropySource, NS: Deref, L: Deref>(
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, invoice_expiry_delta_secs: u32,
description_hash: Sha256, phantom_route_hints: Vec<PhantomRouteHints>, entropy_source: ES,
node_signer: NS, logger: L, network: Currency, min_final_cltv_expiry_delta: Option<u16>,
duration_since_epoch: Duration,
) -> Result<Bolt11Invoice, SignOrCreationError<()>>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
{
@@ -163,14 +161,13 @@ where
const MAX_CHANNEL_HINTS: usize = 3;
-fn _create_phantom_invoice<ES: Deref, NS: Deref, L: Deref>(
+fn _create_phantom_invoice<ES: EntropySource, NS: Deref, L: Deref>(
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>,
description: Bolt11InvoiceDescription, invoice_expiry_delta_secs: u32,
phantom_route_hints: Vec<PhantomRouteHints>, entropy_source: ES, node_signer: NS, logger: L,
network: Currency, min_final_cltv_expiry_delta: Option<u16>, duration_since_epoch: Duration,
) -> Result<Bolt11Invoice, SignOrCreationError<()>>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
{
diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs
index b255dcd..caf31a7 100644
--- a/lightning/src/ln/outbound_payment.rs
+++ b/lightning/src/ln/outbound_payment.rs
@@ -866,7 +866,7 @@ impl OutboundPayments {
impl OutboundPayments {
#[rustfmt::skip]
- pub(super) fn send_payment<R: Deref, ES: Deref, NS: Deref, IH, SP, L: Deref>(
+ pub(super) fn send_payment<R: Deref, ES: EntropySource, NS: Deref, IH, SP, L: Deref>(
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId,
retry_strategy: Retry, route_params: RouteParameters, router: &R,
first_hops: Vec<ChannelDetails>, compute_inflight_htlcs: IH, entropy_source: &ES,
@@ -876,7 +876,6 @@ impl OutboundPayments {
) -> Result<(), RetryableSendFailure>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
IH: Fn() -> InFlightHtlcs,
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
@@ -888,7 +887,7 @@ impl OutboundPayments {
}
#[rustfmt::skip]
- pub(super) fn send_spontaneous_payment<R: Deref, ES: Deref, NS: Deref, IH, SP, L: Deref>(
+ pub(super) fn send_spontaneous_payment<R: Deref, ES: EntropySource, NS: Deref, IH, SP, L: Deref>(
&self, payment_preimage: Option<PaymentPreimage>, recipient_onion: RecipientOnionFields,
payment_id: PaymentId, retry_strategy: Retry, route_params: RouteParameters, router: &R,
first_hops: Vec<ChannelDetails>, inflight_htlcs: IH, entropy_source: &ES,
@@ -898,7 +897,6 @@ impl OutboundPayments {
) -> Result<PaymentHash, RetryableSendFailure>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
IH: Fn() -> InFlightHtlcs,
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
@@ -915,7 +913,7 @@ impl OutboundPayments {
}
#[rustfmt::skip]
- pub(super) fn pay_for_bolt11_invoice<R: Deref, ES: Deref, NS: Deref, IH, SP, L: Deref>(
+ pub(super) fn pay_for_bolt11_invoice<R: Deref, ES: EntropySource, NS: Deref, IH, SP, L: Deref>(
&self, invoice: &Bolt11Invoice, payment_id: PaymentId,
amount_msats: Option<u64>,
route_params_config: RouteParametersConfig,
@@ -928,7 +926,6 @@ impl OutboundPayments {
) -> Result<(), Bolt11PaymentError>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
IH: Fn() -> InFlightHtlcs,
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
@@ -964,7 +961,7 @@ impl OutboundPayments {
#[rustfmt::skip]
pub(super) fn send_payment_for_bolt12_invoice<
- R: Deref, ES: Deref, NS: Deref, NL: Deref, IH, SP, L: Deref,
+ R: Deref, ES: EntropySource, NS: Deref, NL: Deref, IH, SP, L: Deref,
>(
&self, invoice: &Bolt12Invoice, payment_id: PaymentId, router: &R,
first_hops: Vec<ChannelDetails>, features: Bolt12InvoiceFeatures, inflight_htlcs: IH,
@@ -975,7 +972,6 @@ impl OutboundPayments {
) -> Result<(), Bolt12PaymentError>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
NL::Target: NodeIdLookUp,
IH: Fn() -> InFlightHtlcs,
@@ -1010,7 +1006,7 @@ impl OutboundPayments {
#[rustfmt::skip]
fn send_payment_for_bolt12_invoice_internal<
- R: Deref, ES: Deref, NS: Deref, NL: Deref, IH, SP, L: Deref,
+ R: Deref, ES: EntropySource, NS: Deref, NL: Deref, IH, SP, L: Deref,
>(
&self, payment_id: PaymentId, payment_hash: PaymentHash,
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
@@ -1023,7 +1019,6 @@ impl OutboundPayments {
) -> Result<(), Bolt12PaymentError>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
NL::Target: NodeIdLookUp,
IH: Fn() -> InFlightHtlcs,
@@ -1119,14 +1114,11 @@ impl OutboundPayments {
Ok(())
}
- pub(super) fn static_invoice_received<ES: Deref>(
+ pub(super) fn static_invoice_received<ES: EntropySource>(
&self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures,
best_block_height: u32, duration_since_epoch: Duration, entropy_source: ES,
pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>>,
- ) -> Result<(), Bolt12PaymentError>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<(), Bolt12PaymentError> {
macro_rules! abandon_with_entry {
($payment: expr, $reason: expr) => {
assert!(
@@ -1230,7 +1222,7 @@ impl OutboundPayments {
pub(super) fn send_payment_for_static_invoice<
R: Deref,
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
NL: Deref,
IH,
@@ -1245,7 +1237,6 @@ impl OutboundPayments {
) -> Result<(), Bolt12PaymentError>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
NL::Target: NodeIdLookUp,
IH: Fn() -> InFlightHtlcs,
@@ -1314,7 +1305,15 @@ impl OutboundPayments {
}
// Returns whether the data changed and needs to be repersisted.
- pub(super) fn check_retry_payments<R: Deref, ES: Deref, NS: Deref, SP, IH, FH, L: Deref>(
+ pub(super) fn check_retry_payments<
+ R: Deref,
+ ES: EntropySource,
+ NS: Deref,
+ SP,
+ IH,
+ FH,
+ L: Deref,
+ >(
&self, router: &R, first_hops: FH, inflight_htlcs: IH, entropy_source: &ES,
node_signer: &NS, best_block_height: u32,
pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>>,
@@ -1322,7 +1321,6 @@ impl OutboundPayments {
) -> bool
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
IH: Fn() -> InFlightHtlcs,
@@ -1481,7 +1479,7 @@ impl OutboundPayments {
/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
/// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
#[rustfmt::skip]
- fn send_payment_for_non_bolt12_invoice<R: Deref, NS: Deref, ES: Deref, IH, SP, L: Deref>(
+ fn send_payment_for_non_bolt12_invoice<R: Deref, NS: Deref, ES: EntropySource, IH, SP, L: Deref>(
&self, payment_id: PaymentId, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
keysend_preimage: Option<PaymentPreimage>, retry_strategy: Retry, mut route_params: RouteParameters,
router: &R, first_hops: Vec<ChannelDetails>, inflight_htlcs: IH, entropy_source: &ES,
@@ -1491,7 +1489,6 @@ impl OutboundPayments {
) -> Result<(), RetryableSendFailure>
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
IH: Fn() -> InFlightHtlcs,
@@ -1527,7 +1524,7 @@ impl OutboundPayments {
}
#[rustfmt::skip]
- fn find_route_and_send_payment<R: Deref, NS: Deref, ES: Deref, IH, SP, L: Deref>(
+ fn find_route_and_send_payment<R: Deref, NS: Deref, ES: EntropySource, IH, SP, L: Deref>(
&self, payment_hash: PaymentHash, payment_id: PaymentId, route_params: RouteParameters,
router: &R, first_hops: Vec<ChannelDetails>, inflight_htlcs: &IH, entropy_source: &ES,
node_signer: &NS, best_block_height: u32,
@@ -1536,7 +1533,6 @@ impl OutboundPayments {
)
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
IH: Fn() -> InFlightHtlcs,
@@ -1689,7 +1685,7 @@ impl OutboundPayments {
}
#[rustfmt::skip]
- fn handle_pay_route_err<R: Deref, NS: Deref, ES: Deref, IH, SP, L: Deref>(
+ fn handle_pay_route_err<R: Deref, NS: Deref, ES: EntropySource, IH, SP, L: Deref>(
&self, err: PaymentSendFailure, payment_id: PaymentId, payment_hash: PaymentHash, route: Route,
mut route_params: RouteParameters, onion_session_privs: Vec<[u8; 32]>, router: &R,
first_hops: Vec<ChannelDetails>, inflight_htlcs: &IH, entropy_source: &ES, node_signer: &NS,
@@ -1699,7 +1695,6 @@ impl OutboundPayments {
)
where
R::Target: Router,
- ES::Target: EntropySource,
NS::Target: NodeSigner,
IH: Fn() -> InFlightHtlcs,
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
@@ -1811,12 +1806,11 @@ impl OutboundPayments {
}
#[rustfmt::skip]
- pub(super) fn send_probe<ES: Deref, NS: Deref, F>(
+ pub(super) fn send_probe<ES: EntropySource, NS: Deref, F>(
&self, path: Path, probing_cookie_secret: [u8; 32], entropy_source: &ES, node_signer: &NS,
best_block_height: u32, send_payment_along_path: F,
) -> Result<(PaymentHash, PaymentId), ProbeSendFailure>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
F: Fn(SendAlongPathArgs) -> Result<(), APIError>,
{
@@ -1886,20 +1880,20 @@ impl OutboundPayments {
#[cfg(any(test, feature = "_externalize_tests"))]
#[rustfmt::skip]
- pub(super) fn test_add_new_pending_payment<ES: Deref>(
+ pub(super) fn test_add_new_pending_payment<ES: EntropySource>(
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId,
route: &Route, retry_strategy: Option<Retry>, entropy_source: &ES, best_block_height: u32
- ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where ES::Target: EntropySource {
+ ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> {
self.add_new_pending_payment(payment_hash, recipient_onion, payment_id, None, route, retry_strategy, None, entropy_source, best_block_height, None)
}
#[rustfmt::skip]
- pub(super) fn add_new_pending_payment<ES: Deref>(
+ pub(super) fn add_new_pending_payment<ES: EntropySource>(
&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId,
keysend_preimage: Option<PaymentPreimage>, route: &Route, retry_strategy: Option<Retry>,
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32,
bolt12_invoice: Option<PaidBolt12Invoice>
- ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where ES::Target: EntropySource {
+ ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> {
let mut pending_outbounds = self.pending_outbound_payments.lock().unwrap();
match pending_outbounds.entry(payment_id) {
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment),
@@ -1915,15 +1909,12 @@ impl OutboundPayments {
}
#[rustfmt::skip]
- fn create_pending_payment<ES: Deref>(
+ fn create_pending_payment<ES: EntropySource>(
payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<InvoiceRequest>,
bolt12_invoice: Option<PaidBolt12Invoice>, route: &Route, retry_strategy: Option<Retry>,
payment_params: Option<PaymentParameters>, entropy_source: &ES, best_block_height: u32
- ) -> (PendingOutboundPayment, Vec<[u8; 32]>)
- where
- ES::Target: EntropySource,
- {
+ ) -> (PendingOutboundPayment, Vec<[u8; 32]>) {
let mut onion_session_privs = Vec::with_capacity(route.paths.len());
for _ in 0..route.paths.len() {
onion_session_privs.push(entropy_source.get_secure_random_bytes());
diff --git a/lightning/src/ln/types.rs b/lightning/src/ln/types.rs
index 5d72ba6..fd8ccba 100644
--- a/lightning/src/ln/types.rs
+++ b/lightning/src/ln/types.rs
@@ -24,7 +24,6 @@ use bitcoin::hashes::{sha256::Hash as Sha256, Hash as _, HashEngine as _};
use bitcoin::hex::display::impl_fmt_traits;
use core::borrow::Borrow;
-use core::ops::Deref;
/// A unique 32-byte identifier for a channel.
/// Depending on how the ID is generated, several varieties are distinguished
@@ -53,10 +52,7 @@ impl ChannelId {
}
/// Create a _temporary_ channel ID randomly, based on an entropy source.
- pub fn temporary_from_entropy_source<ES: Deref>(entropy_source: &ES) -> Self
- where
- ES::Target: EntropySource,
- {
+ pub fn temporary_from_entropy_source<ES: EntropySource>(entropy_source: &ES) -> Self {
Self(entropy_source.get_secure_random_bytes())
}
diff --git a/lightning/src/offers/flow.rs b/lightning/src/offers/flow.rs
index 8b03f0e..97e92fd 100644
--- a/lightning/src/offers/flow.rs
+++ b/lightning/src/offers/flow.rs
@@ -550,11 +550,10 @@ where
}
}
- fn create_offer_builder_intern<ES: Deref, PF, I>(
+ fn create_offer_builder_intern<ES: EntropySource, PF, I>(
&self, entropy_source: ES, make_paths: PF,
) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
where
- ES::Target: EntropySource,
PF: FnOnce(
PublicKey,
MessageContext,
@@ -607,13 +606,10 @@ where
/// This is not exported to bindings users as builder patterns don't map outside of move semantics.
///
/// [`DefaultMessageRouter`]: crate::onion_message::messenger::DefaultMessageRouter
- pub fn create_offer_builder<ES: Deref>(
+ pub fn create_offer_builder<ES: EntropySource>(
&self, entropy_source: ES, peers: Vec<MessageForwardNode>,
- ) -> Result<OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Bolt12SemanticError>
- where
- ES::Target: EntropySource,
- {
- self.create_offer_builder_intern(&*entropy_source, |_, context, _| {
+ ) -> Result<OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Bolt12SemanticError> {
+ self.create_offer_builder_intern(&entropy_source, |_, context, _| {
self.create_blinded_paths(peers, context)
.map(|paths| paths.into_iter().take(1))
.map_err(|_| Bolt12SemanticError::MissingPaths)
@@ -630,15 +626,14 @@ where
/// This is not exported to bindings users as builder patterns don't map outside of move semantics.
///
/// See [`Self::create_offer_builder`] for more details on usage.
- pub fn create_offer_builder_using_router<ME: Deref, ES: Deref>(
+ pub fn create_offer_builder_using_router<ME: Deref, ES: EntropySource>(
&self, router: ME, entropy_source: ES, peers: Vec<MessageForwardNode>,
) -> Result<OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Bolt12SemanticError>
where
ME::Target: MessageRouter,
- ES::Target: EntropySource,
{
let receive_key = self.get_receive_auth_key();
- self.create_offer_builder_intern(&*entropy_source, |node_id, context, secp_ctx| {
+ self.create_offer_builder_intern(&entropy_source, |node_id, context, secp_ctx| {
router
.create_blinded_paths(node_id, receive_key, context, peers, secp_ctx)
.map(|paths| paths.into_iter().take(1))
@@ -657,23 +652,19 @@ where
/// aforementioned always-online node.
///
/// This is not exported to bindings users as builder patterns don't map outside of move semantics.
- pub fn create_async_receive_offer_builder<ES: Deref>(
+ pub fn create_async_receive_offer_builder<ES: EntropySource>(
&self, entropy_source: ES, message_paths_to_always_online_node: Vec<BlindedMessagePath>,
- ) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
- where
- ES::Target: EntropySource,
- {
- self.create_offer_builder_intern(&*entropy_source, |_, _, _| {
+ ) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError> {
+ self.create_offer_builder_intern(&entropy_source, |_, _, _| {
Ok(message_paths_to_always_online_node)
})
}
- fn create_refund_builder_intern<ES: Deref, PF, I>(
+ fn create_refund_builder_intern<ES: EntropySource, PF, I>(
&self, entropy_source: ES, make_paths: PF, amount_msats: u64, absolute_expiry: Duration,
payment_id: PaymentId,
) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError>
where
- ES::Target: EntropySource,
PF: FnOnce(
PublicKey,
MessageContext,
@@ -683,7 +674,7 @@ where
{
let node_id = self.get_our_node_id();
let expanded_key = &self.inbound_payment_key;
- let entropy = &*entropy_source;
+ let entropy = &entropy_source;
let secp_ctx = &self.secp_ctx;
let nonce = Nonce::from_entropy_source(entropy);
@@ -744,15 +735,12 @@ where
///
/// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
/// [`RouteParameters::from_payment_params_and_value`]: crate::routing::router::RouteParameters::from_payment_params_and_value
- pub fn create_refund_builder<ES: Deref>(
+ pub fn create_refund_builder<ES: EntropySource>(
&self, entropy_source: ES, amount_msats: u64, absolute_expiry: Duration,
payment_id: PaymentId, peers: Vec<MessageForwardNode>,
- ) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError> {
self.create_refund_builder_intern(
- &*entropy_source,
+ &entropy_source,
|_, context, _| {
self.create_blinded_paths(peers, context)
.map(|paths| paths.into_iter().take(1))
@@ -785,17 +773,16 @@ where
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
/// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
/// [`RouteParameters::from_payment_params_and_value`]: crate::routing::router::RouteParameters::from_payment_params_and_value
- pub fn create_refund_builder_using_router<ES: Deref, ME: Deref>(
+ pub fn create_refund_builder_using_router<ES: EntropySource, ME: Deref>(
&self, router: ME, entropy_source: ES, amount_msats: u64, absolute_expiry: Duration,
payment_id: PaymentId, peers: Vec<MessageForwardNode>,
) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError>
where
ME::Target: MessageRouter,
- ES::Target: EntropySource,
{
let receive_key = self.get_receive_auth_key();
self.create_refund_builder_intern(
- &*entropy_source,
+ &entropy_source,
|node_id, context, secp_ctx| {
router
.create_blinded_paths(node_id, receive_key, context, peers, secp_ctx)
@@ -905,12 +892,11 @@ where
/// blinded path can be constructed.
///
/// This is not exported to bindings users as builder patterns don't map outside of move semantics.
- pub fn create_invoice_builder_from_refund<'a, ES: Deref, R: Deref, F>(
+ pub fn create_invoice_builder_from_refund<'a, ES: EntropySource, R: Deref, F>(
&'a self, router: &R, entropy_source: ES, refund: &'a Refund,
usable_channels: Vec<ChannelDetails>, get_payment_info: F,
) -> Result<InvoiceBuilder<'a, DerivedSigningPubkey>, Bolt12SemanticError>
where
- ES::Target: EntropySource,
R::Target: Router,
F: Fn(u64, u32) -> Result<(PaymentHash, PaymentSecret), Bolt12SemanticError>,
{
@@ -919,7 +905,7 @@ where
}
let expanded_key = &self.inbound_payment_key;
- let entropy = &*entropy_source;
+ let entropy = &entropy_source;
let amount_msats = refund.amount_msats();
let relative_expiry = DEFAULT_RELATIVE_EXPIRY.as_secs() as u32;
@@ -1282,12 +1268,9 @@ where
/// received to our node.
///
/// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
- pub fn path_for_release_held_htlc<ES: Deref>(
+ pub fn path_for_release_held_htlc<ES: EntropySource>(
&self, intercept_id: InterceptId, prev_outbound_scid_alias: u64, htlc_id: u64, entropy: ES,
- ) -> BlindedMessagePath
- where
- ES::Target: EntropySource,
- {
+ ) -> BlindedMessagePath {
// In the future, we should support multi-hop paths here.
let context = MessageContext::AsyncPayments(AsyncPaymentsContext::ReleaseHeldHtlc {
intercept_id,
@@ -1302,7 +1285,7 @@ where
self.receive_auth_key,
context,
false,
- &*entropy,
+ &entropy,
&self.secp_ctx,
)
}
@@ -1589,13 +1572,12 @@ where
///
/// Returns `None` if we have enough offers cached already, verification of `message` fails, or we
/// fail to create blinded paths.
- pub fn handle_offer_paths<ES: Deref, R: Deref>(
+ pub fn handle_offer_paths<ES: EntropySource, R: Deref>(
&self, message: OfferPaths, context: AsyncPaymentsContext, responder: Responder,
peers: Vec<MessageForwardNode>, usable_channels: Vec<ChannelDetails>, entropy: ES,
router: R,
) -> Option<(ServeStaticInvoice, MessageContext)>
where
- ES::Target: EntropySource,
R::Target: Router,
{
let duration_since_epoch = self.duration_since_epoch();
@@ -1624,7 +1606,7 @@ where
}
let (mut offer_builder, offer_nonce) =
- match self.create_async_receive_offer_builder(&*entropy, message.paths) {
+ match self.create_async_receive_offer_builder(&entropy, message.paths) {
Ok((builder, nonce)) => (builder, nonce),
Err(_) => return None, // Only reachable if OfferPaths::paths is empty
};
diff --git a/lightning/src/offers/nonce.rs b/lightning/src/offers/nonce.rs
index 0675414..8c99a46 100644
--- a/lightning/src/offers/nonce.rs
+++ b/lightning/src/offers/nonce.rs
@@ -13,7 +13,6 @@ use crate::io::{self, Read};
use crate::ln::msgs::DecodeError;
use crate::sign::EntropySource;
use crate::util::ser::{Readable, Writeable, Writer};
-use core::ops::Deref;
#[allow(unused_imports)]
use crate::prelude::*;
@@ -34,10 +33,7 @@ impl Nonce {
pub const LENGTH: usize = 16;
/// Creates a `Nonce` from the given [`EntropySource`].
- pub fn from_entropy_source<ES: Deref>(entropy_source: ES) -> Self
- where
- ES::Target: EntropySource,
- {
+ pub fn from_entropy_source<ES: EntropySource>(entropy_source: ES) -> Self {
let mut bytes = [0u8; Self::LENGTH];
let rand_bytes = entropy_source.get_secure_random_bytes();
bytes.copy_from_slice(&rand_bytes[..Self::LENGTH]);
diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs
index dd2c3e2..c0fd9df 100644
--- a/lightning/src/offers/refund.rs
+++ b/lightning/src/offers/refund.rs
@@ -110,7 +110,6 @@ use bitcoin::constants::ChainHash;
use bitcoin::network::Network;
use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
use core::hash::{Hash, Hasher};
-use core::ops::Deref;
use core::str::FromStr;
use core::time::Duration;
@@ -624,13 +623,10 @@ macro_rules! respond_with_derived_signing_pubkey_methods { ($self: ident, $build
///
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
#[cfg(feature = "std")]
- pub fn respond_using_derived_keys<ES: Deref>(
+ pub fn respond_using_derived_keys<ES: EntropySource>(
&$self, payment_paths: Vec<BlindedPaymentPath>, payment_hash: PaymentHash,
expanded_key: &ExpandedKey, entropy_source: ES
- ) -> Result<$builder, Bolt12SemanticError>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<$builder, Bolt12SemanticError> {
let created_at = std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.expect("SystemTime::now() should come after SystemTime::UNIX_EPOCH");
@@ -648,13 +644,10 @@ macro_rules! respond_with_derived_signing_pubkey_methods { ($self: ident, $build
/// This is not exported to bindings users as builder patterns don't map outside of move semantics.
///
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
- pub fn respond_using_derived_keys_no_std<ES: Deref>(
+ pub fn respond_using_derived_keys_no_std<ES: EntropySource>(
&$self, payment_paths: Vec<BlindedPaymentPath>, payment_hash: PaymentHash,
created_at: core::time::Duration, expanded_key: &ExpandedKey, entropy_source: ES
- ) -> Result<$builder, Bolt12SemanticError>
- where
- ES::Target: EntropySource,
- {
+ ) -> Result<$builder, Bolt12SemanticError> {
if $self.features().requires_unknown_bits() {
return Err(Bolt12SemanticError::UnknownRequiredFeatures);
}
diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs
index dbeab39..d859d35 100644
--- a/lightning/src/onion_message/messenger.rs
+++ b/lightning/src/onion_message/messenger.rs
@@ -66,9 +66,7 @@ pub(super) const MAX_TIMER_TICKS: usize = 2;
/// languages.
pub trait AOnionMessenger {
/// A type implementing [`EntropySource`]
- type EntropySource: EntropySource + ?Sized;
- /// A type that may be dereferenced to [`Self::EntropySource`]
- type ES: Deref<Target = Self::EntropySource>;
+ type EntropySource: EntropySource;
/// A type implementing [`NodeSigner`]
type NodeSigner: NodeSigner + ?Sized;
/// A type that may be dereferenced to [`Self::NodeSigner`]
@@ -105,7 +103,7 @@ pub trait AOnionMessenger {
fn get_om(
&self,
) -> &OnionMessenger<
- Self::ES,
+ Self::EntropySource,
Self::NS,
Self::L,
Self::NL,
@@ -118,7 +116,7 @@ pub trait AOnionMessenger {
}
impl<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
L: Deref,
NL: Deref,
@@ -129,7 +127,6 @@ impl<
CMH: Deref,
> AOnionMessenger for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
NL::Target: NodeIdLookUp,
@@ -139,8 +136,7 @@ where
DRH::Target: DNSResolverMessageHandler,
CMH::Target: CustomOnionMessageHandler,
{
- type EntropySource = ES::Target;
- type ES = ES;
+ type EntropySource = ES;
type NodeSigner = NS::Target;
type NS = NS;
type Logger = L::Target;
@@ -284,7 +280,7 @@ where
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
pub struct OnionMessenger<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
L: Deref,
NL: Deref,
@@ -294,7 +290,6 @@ pub struct OnionMessenger<
DRH: Deref,
CMH: Deref,
> where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
NL::Target: NodeIdLookUp,
@@ -549,10 +544,9 @@ pub trait MessageRouter {
/// node. Otherwise, there is no way to find a path to the introduction node in order to send a
/// message, and thus an `Err` is returned. The impact of this may be somewhat muted when
/// additional dummy hops are added to the blinded path, but this protection is not complete.
-pub struct DefaultMessageRouter<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref>
+pub struct DefaultMessageRouter<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: EntropySource>
where
L::Target: Logger,
- ES::Target: EntropySource,
{
network_graph: G,
entropy_source: ES,
@@ -569,10 +563,9 @@ pub(crate) const DUMMY_HOPS_PATH_LENGTH: usize = 4;
// We add dummy hops until the path reaches this length (including the recipient).
pub(crate) const QR_CODED_DUMMY_HOPS_PATH_LENGTH: usize = 2;
-impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref> DefaultMessageRouter<G, L, ES>
+impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: EntropySource> DefaultMessageRouter<G, L, ES>
where
L::Target: Logger,
- ES::Target: EntropySource,
{
/// Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`].
pub fn new(network_graph: G, entropy_source: ES) -> Self {
@@ -660,7 +653,7 @@ where
local_node_receive_key,
context.clone(),
size_constrained,
- &**entropy_source,
+ &entropy_source,
secp_ctx,
)
};
@@ -738,11 +731,10 @@ where
}
}
-impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref> MessageRouter
+impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: EntropySource> MessageRouter
for DefaultMessageRouter<G, L, ES>
where
L::Target: Logger,
- ES::Target: EntropySource,
{
fn find_path(
&self, sender: PublicKey, peers: Vec<PublicKey>, destination: Destination,
@@ -784,19 +776,17 @@ where
/// node. Otherwise, there is no way to find a path to the introduction node in order to send a
/// message, and thus an `Err` is returned. The impact of this may be somewhat muted when
/// additional dummy hops are added to the blinded path, but this protection is not complete.
-pub struct NodeIdMessageRouter<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref>
+pub struct NodeIdMessageRouter<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: EntropySource>
where
L::Target: Logger,
- ES::Target: EntropySource,
{
network_graph: G,
entropy_source: ES,
}
-impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref> NodeIdMessageRouter<G, L, ES>
+impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: EntropySource> NodeIdMessageRouter<G, L, ES>
where
L::Target: Logger,
- ES::Target: EntropySource,
{
/// Creates a [`NodeIdMessageRouter`] using the given [`NetworkGraph`].
pub fn new(network_graph: G, entropy_source: ES) -> Self {
@@ -804,11 +794,10 @@ where
}
}
-impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref> MessageRouter
+impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: EntropySource> MessageRouter
for NodeIdMessageRouter<G, L, ES>
where
L::Target: Logger,
- ES::Target: EntropySource,
{
fn find_path(
&self, sender: PublicKey, peers: Vec<PublicKey>, destination: Destination,
@@ -1052,7 +1041,7 @@ pub enum PeeledOnion<T: OnionMessageContents> {
/// Returns the node id of the peer to send the message to, the message itself, and any addresses
/// needed to connect to the first node.
pub fn create_onion_message_resolving_destination<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
NL: Deref,
T: OnionMessageContents,
@@ -1062,7 +1051,6 @@ pub fn create_onion_message_resolving_destination<
mut path: OnionMessagePath, contents: T, reply_path: Option<BlindedMessagePath>,
) -> Result<(PublicKey, OnionMessage, Vec<SocketAddress>), SendError>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
NL::Target: NodeIdLookUp,
{
@@ -1089,13 +1077,12 @@ where
/// - unless it can be resolved by [`NodeIdLookUp::next_node_id`].
/// Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node
/// first with a [`ReadOnlyNetworkGraph`].
-pub fn create_onion_message<ES: Deref, NS: Deref, NL: Deref, T: OnionMessageContents>(
+pub fn create_onion_message<ES: EntropySource, NS: Deref, NL: Deref, T: OnionMessageContents>(
entropy_source: &ES, node_signer: &NS, node_id_lookup: &NL,
secp_ctx: &Secp256k1<secp256k1::All>, path: OnionMessagePath, contents: T,
reply_path: Option<BlindedMessagePath>,
) -> Result<(PublicKey, OnionMessage, Vec<SocketAddress>), SendError>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
NL::Target: NodeIdLookUp,
{
@@ -1394,7 +1381,7 @@ macro_rules! drop_handled_events_and_abort {
}
impl<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
L: Deref,
NL: Deref,
@@ -1405,7 +1392,6 @@ impl<
CMH: Deref,
> OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
NL::Target: NodeIdLookUp,
@@ -2038,7 +2024,7 @@ fn outbound_buffer_full(
}
impl<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
L: Deref,
NL: Deref,
@@ -2049,7 +2035,6 @@ impl<
CMH: Deref,
> EventsProvider for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
NL::Target: NodeIdLookUp,
@@ -2159,7 +2144,7 @@ where
}
impl<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
L: Deref,
NL: Deref,
@@ -2170,7 +2155,6 @@ impl<
CMH: Deref,
> BaseMessageHandler for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
NL::Target: NodeIdLookUp,
@@ -2231,7 +2215,7 @@ where
}
impl<
- ES: Deref,
+ ES: EntropySource,
NS: Deref,
L: Deref,
NL: Deref,
@@ -2242,7 +2226,6 @@ impl<
CMH: Deref,
> OnionMessageHandler for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH>
where
- ES::Target: EntropySource,
NS::Target: NodeSigner,
L::Target: Logger,
NL::Target: NodeIdLookUp,
diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs
index 2dd48ca..494860f 100644
--- a/lightning/src/routing/router.rs
+++ b/lightning/src/routing/router.rs
@@ -58,14 +58,13 @@ pub use lightning_types::routing::{RouteHint, RouteHintHop};
pub struct DefaultRouter<
G: Deref<Target = NetworkGraph<L>>,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
S: Deref,
SP: Sized,
Sc: ScoreLookUp<ScoreParams = SP>,
> where
L::Target: Logger,
S::Target: for<'a> LockableScore<'a, ScoreLookUp = Sc>,
- ES::Target: EntropySource,
{
network_graph: G,
logger: L,
@@ -80,7 +79,7 @@ pub const DEFAULT_PAYMENT_DUMMY_HOPS: usize = 3;
impl<
G: Deref<Target = NetworkGraph<L>>,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
S: Deref,
SP: Sized,
Sc: ScoreLookUp<ScoreParams = SP>,
@@ -88,7 +87,6 @@ impl<
where
L::Target: Logger,
S::Target: for<'a> LockableScore<'a, ScoreLookUp = Sc>,
- ES::Target: EntropySource,
{
/// Creates a new router.
pub fn new(
@@ -101,7 +99,7 @@ where
impl<
G: Deref<Target = NetworkGraph<L>>,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
S: Deref,
SP: Sized,
Sc: ScoreLookUp<ScoreParams = SP>,
@@ -109,7 +107,6 @@ impl<
where
L::Target: Logger,
S::Target: for<'a> LockableScore<'a, ScoreLookUp = Sc>,
- ES::Target: EntropySource,
{
#[rustfmt::skip]
fn find_route(
@@ -203,7 +200,7 @@ where
.map(|forward_node| {
BlindedPaymentPath::new_with_dummy_hops(
&[forward_node], recipient, &[DummyTlvs::default(); DEFAULT_PAYMENT_DUMMY_HOPS],
- local_node_receive_key, tlvs.clone(), u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA, &*self.entropy_source, secp_ctx
+ local_node_receive_key, tlvs.clone(), u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA, &self.entropy_source, secp_ctx
)
})
.take(MAX_PAYMENT_PATHS)
@@ -215,7 +212,7 @@ where
if network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient)) {
BlindedPaymentPath::new_with_dummy_hops(
&[], recipient, &[DummyTlvs::default(); DEFAULT_PAYMENT_DUMMY_HOPS],
- local_node_receive_key, tlvs, u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA, &*self.entropy_source, secp_ctx
+ local_node_receive_key, tlvs, u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA, &self.entropy_source, secp_ctx
).map(|path| vec![path])
} else {
Err(())
diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs
index 26252c7..51b00a6 100644
--- a/lightning/src/sign/mod.rs
+++ b/lightning/src/sign/mod.rs
@@ -878,6 +878,12 @@ pub trait EntropySource {
fn get_secure_random_bytes(&self) -> [u8; 32];
}
+impl<T: EntropySource + ?Sized, E: Deref<Target = T>> EntropySource for E {
+ fn get_secure_random_bytes(&self) -> [u8; 32] {
+ self.deref().get_secure_random_bytes()
+ }
+}
+
/// A trait that can handle cryptographic operations at the scope level of a node.
pub trait NodeSigner {
/// Get the [`ExpandedKey`] which provides cryptographic material for various Lightning Network operations.
diff --git a/lightning/src/util/anchor_channel_reserves.rs b/lightning/src/util/anchor_channel_reserves.rs
index 26212ca..0e2f53a 100644
--- a/lightning/src/util/anchor_channel_reserves.rs
+++ b/lightning/src/util/anchor_channel_reserves.rs
@@ -277,17 +277,9 @@ pub fn can_support_additional_anchor_channel<
EstimatorRef: Deref,
LoggerRef: Deref,
PersistRef: Deref,
- EntropySourceRef: Deref,
+ ES: EntropySource,
ChainMonitorRef: Deref<
- Target = ChainMonitor<
- ChannelSigner,
- FilterRef,
- B,
- EstimatorRef,
- LoggerRef,
- PersistRef,
- EntropySourceRef,
- >,
+ Target = ChainMonitor<ChannelSigner, FilterRef, B, EstimatorRef, LoggerRef, PersistRef, ES>,
>,
>(
context: &AnchorChannelReserveContext, utxos: &[Utxo], a_channel_manager: AChannelManagerRef,
@@ -299,7 +291,6 @@ where
EstimatorRef::Target: FeeEstimator,
LoggerRef::Target: Logger,
PersistRef::Target: Persist<ChannelSigner>,
- EntropySourceRef::Target: EntropySource,
{
let mut anchor_channels = new_hash_set();
// Calculate the number of in-progress anchor channels by inspecting ChannelMonitors with balance.
diff --git a/lightning/src/util/persist.rs b/lightning/src/util/persist.rs
index 92a565a..ecc2d94 100644
--- a/lightning/src/util/persist.rs
+++ b/lightning/src/util/persist.rs
@@ -445,12 +445,11 @@ impl<ChannelSigner: EcdsaChannelSigner, K: KVStoreSync + ?Sized> Persist<Channel
}
/// Read previously persisted [`ChannelMonitor`]s from the store.
-pub fn read_channel_monitors<K: Deref, ES: Deref, SP: Deref>(
+pub fn read_channel_monitors<K: Deref, ES: EntropySource, SP: Deref>(
kv_store: K, entropy_source: ES, signer_provider: SP,
) -> Result<Vec<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>)>, io::Error>
where
K::Target: KVStoreSync,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
{
let mut res = Vec::new();
@@ -465,7 +464,7 @@ where
CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE,
&stored_key,
)?),
- (&*entropy_source, &*signer_provider),
+ (&entropy_source, &*signer_provider),
) {
Ok(Some((block_hash, channel_monitor))) => {
let monitor_name = MonitorName::from_str(&stored_key)?;
@@ -591,7 +590,7 @@ fn poll_sync_future<F: Future>(future: F) -> F::Output {
pub struct MonitorUpdatingPersister<
K: Deref,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
SP: Deref,
BI: BroadcasterInterface,
FE: Deref,
@@ -599,16 +598,14 @@ pub struct MonitorUpdatingPersister<
where
K::Target: KVStoreSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator;
-impl<K: Deref, L: Deref, ES: Deref, SP: Deref, BI: BroadcasterInterface, FE: Deref>
+impl<K: Deref, L: Deref, ES: EntropySource, SP: Deref, BI: BroadcasterInterface, FE: Deref>
MonitorUpdatingPersister<K, L, ES, SP, BI, FE>
where
K::Target: KVStoreSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -698,7 +695,7 @@ impl<
ChannelSigner: EcdsaChannelSigner,
K: Deref,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
SP: Deref,
BI: BroadcasterInterface,
FE: Deref,
@@ -706,7 +703,6 @@ impl<
where
K::Target: KVStoreSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -783,7 +779,7 @@ pub struct MonitorUpdatingPersisterAsync<
K: Deref,
S: FutureSpawner,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
SP: Deref,
BI: BroadcasterInterface,
FE: Deref,
@@ -791,7 +787,6 @@ pub struct MonitorUpdatingPersisterAsync<
where
K::Target: KVStore,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator;
@@ -799,14 +794,13 @@ struct MonitorUpdatingPersisterAsyncInner<
K: Deref,
S: FutureSpawner,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
SP: Deref,
BI: BroadcasterInterface,
FE: Deref,
> where
K::Target: KVStore,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -825,7 +819,7 @@ impl<
K: Deref,
S: FutureSpawner,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
SP: Deref,
BI: BroadcasterInterface,
FE: Deref,
@@ -833,7 +827,6 @@ impl<
where
K::Target: KVStore,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -975,7 +968,7 @@ impl<
K: Deref + MaybeSend + MaybeSync + 'static,
S: FutureSpawner,
L: Deref + MaybeSend + MaybeSync + 'static,
- ES: Deref + MaybeSend + MaybeSync + 'static,
+ ES: EntropySource + MaybeSend + MaybeSync + 'static,
SP: Deref + MaybeSend + MaybeSync + 'static,
BI: BroadcasterInterface + MaybeSend + MaybeSync + 'static,
FE: Deref + MaybeSend + MaybeSync + 'static,
@@ -983,7 +976,6 @@ impl<
where
K::Target: KVStore + MaybeSync,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
<SP::Target as SignerProvider>::EcdsaSigner: MaybeSend + 'static,
@@ -1066,7 +1058,7 @@ impl<
K: Deref,
S: FutureSpawner,
L: Deref,
- ES: Deref,
+ ES: EntropySource,
SP: Deref,
BI: BroadcasterInterface,
FE: Deref,
@@ -1074,7 +1066,6 @@ impl<
where
K::Target: KVStore,
L::Target: Logger,
- ES::Target: EntropySource + Sized,
SP::Target: SignerProvider + Sized,
FE::Target: FeeEstimator,
{
@@ -1159,7 +1150,7 @@ where
}
match <Option<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>)>>::read(
&mut monitor_cursor,
- (&*self.entropy_source, &*self.signer_provider),
+ (&self.entropy_source, &*self.signer_provider),
) {
Ok(None) => Ok(None),
Ok(Some((blockhash, channel_monitor))) => {
diff --git a/lightning/src/util/scid_utils.rs b/lightning/src/util/scid_utils.rs
index b9dcc46..d57c529 100644
--- a/lightning/src/util/scid_utils.rs
+++ b/lightning/src/util/scid_utils.rs
@@ -80,8 +80,6 @@ pub(crate) mod fake_scid {
use bitcoin::constants::ChainHash;
use bitcoin::Network;
- use core::ops::Deref;
-
const TEST_SEGWIT_ACTIVATION_HEIGHT: u32 = 1;
const MAINNET_SEGWIT_ACTIVATION_HEIGHT: u32 = 481_824;
const MAX_TX_INDEX: u32 = 2_500;
@@ -110,13 +108,10 @@ pub(crate) mod fake_scid {
/// between segwit activation and the current best known height, and the tx index and output
/// 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<ES: Deref>(
+ pub(crate) fn get_fake_scid<ES: EntropySource>(
&self, highest_seen_blockheight: u32, chain_hash: &ChainHash,
fake_scid_rand_bytes: &[u8; 32], entropy_source: &ES,
- ) -> u64
- where
- ES::Target: EntropySource,
- {
+ ) -> u64 {
// Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for
// namespaces.
assert!((*self as u8) < MAX_NAMESPACES);
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.