use lightning::chain::channelmonitor::{ChannelMonitor, MonitorEvent};
use lightning::chain::transaction::OutPoint;
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
-use lightning::chain::keysinterface::{KeyMaterial, KeysInterface, InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider};
+use lightning::chain::keysinterface::{KeyMaterial, InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider};
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
use lightning::ln::channelmanager::{self, ChainParameters, ChannelDetails, ChannelManager, PaymentSendFailure, ChannelManagerReadArgs, PaymentId};
use lightning::ln::channel::FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
}
}
-impl KeysInterface for KeyProvider {}
-
impl KeyProvider {
fn make_enforcement_state_cell(&self, commitment_seed: [u8; 32]) -> Arc<Mutex<EnforcementState>> {
let mut revoked_commitments = self.enforcement_states.lock().unwrap();
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
use lightning::chain::chainmonitor;
use lightning::chain::transaction::OutPoint;
-use lightning::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, KeysInterface, EntropySource, NodeSigner, SignerProvider};
+use lightning::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider};
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentId};
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
}
}
-impl KeysInterface for KeyProvider {}
-
#[inline]
pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
let input = Arc::new(InputData {
best_block: BestBlock::from_genesis(network),
};
let channelmanager = Arc::new(ChannelManager::new(fee_est.clone(), monitor.clone(), broadcast.clone(), &router, Arc::clone(&logger), keys_manager.clone(), config, params));
- // Adding new calls to `KeysInterface::get_secure_random_bytes` during startup can change all the
+ // Adding new calls to `EntropySource::get_secure_random_bytes` during startup can change all the
// keys subsequently generated in this test. Rather than regenerating all the messages manually,
// it's easier to just increment the counter here so the keys don't change.
keys_manager.counter.fetch_sub(3, Ordering::AcqRel);
use bitcoin::secp256k1::ecdh::SharedSecret;
use bitcoin::secp256k1::ecdsa::RecoverableSignature;
-use lightning::chain::keysinterface::{Recipient, KeyMaterial, KeysInterface, EntropySource, NodeSigner, SignerProvider};
+use lightning::chain::keysinterface::{Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider};
use lightning::ln::msgs::{self, DecodeError, OnionMessageHandler};
use lightning::ln::script::ShutdownScript;
use lightning::util::enforcing_trait_impls::EnforcingSigner;
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!() }
}
-impl KeysInterface for KeyProvider {}
-
#[cfg(test)]
mod tests {
use lightning::util::logger::{Logger, Record};
use lightning::chain;
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
use lightning::chain::chainmonitor::{ChainMonitor, Persist};
-use lightning::chain::keysinterface::{KeysInterface, SignerProvider};
+use lightning::chain::keysinterface::{EntropySource, NodeSigner, SignerProvider};
use lightning::ln::channelmanager::ChannelManager;
use lightning::ln::msgs::{ChannelMessageHandler, OnionMessageHandler, RoutingMessageHandler};
use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor};
CF::Target: 'static + chain::Filter,
CW::Target: 'static + chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: 'static + BroadcasterInterface,
- K::Target: 'static + KeysInterface,
+ K::Target: 'static + EntropySource + NodeSigner + SignerProvider,
F::Target: 'static + FeeEstimator,
R::Target: 'static + Router,
L::Target: 'static + Logger,
CF::Target: 'static + chain::Filter,
CW::Target: 'static + chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: 'static + BroadcasterInterface,
- K::Target: 'static + KeysInterface,
+ K::Target: 'static + EntropySource + NodeSigner + SignerProvider,
F::Target: 'static + FeeEstimator,
R::Target: 'static + Router,
L::Target: 'static + Logger,
use bitcoin::network::constants::Network;
use lightning::chain::{BestBlock, Confirm, chainmonitor};
use lightning::chain::channelmonitor::ANTI_REORG_DELAY;
- use lightning::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, KeysInterface, KeysManager, NodeSigner};
+ use lightning::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, KeysManager, NodeSigner};
use lightning::chain::transaction::OutPoint;
use lightning::get_event_msg;
use lightning::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChainParameters, ChannelManager, SimpleArcChannelManager};
/// use lightning::chain::chaininterface::BroadcasterInterface;
/// use lightning::chain::chaininterface::FeeEstimator;
/// use lightning::chain::keysinterface;
-/// use lightning::chain::keysinterface::KeysInterface;
+/// use lightning::chain::keysinterface::{EntropySource, NodeSigner, SignerProvider};
/// use lightning::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs};
/// use lightning::routing::router::Router;
/// use lightning::util::config::UserConfig;
///
/// async fn init_sync<
/// B: BlockSource,
-/// K: KeysInterface,
+/// K: EntropySource + NodeSigner + SignerProvider,
/// T: BroadcasterInterface,
/// F: FeeEstimator,
/// R: Router,
use bitcoin_hashes::Hash;
use lightning::chain;
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
-use lightning::chain::keysinterface::{Recipient, KeysInterface, NodeSigner, SignerProvider};
+use lightning::chain::keysinterface::{Recipient, NodeSigner, SignerProvider, EntropySource};
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY};
#[cfg(feature = "std")]
/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
/// in excess of the current time.
///
-/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
+/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
/// requirement).
///
logger: L, network: Currency,
) -> Result<Invoice, SignOrCreationError<()>>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
L::Target: Logger,
{
let description = Description::new(description).map_err(SignOrCreationError::CreationError)?;
/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
/// in excess of the current time.
///
-/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
+/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
/// requirement).
///
logger: L, network: Currency
) -> Result<Invoice, SignOrCreationError<()>>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
L::Target: Logger,
{
_create_phantom_invoice::<K, L>(
logger: L, network: Currency,
) -> Result<Invoice, SignOrCreationError<()>>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
L::Target: Logger,
{
use std::time::{SystemTime, UNIX_EPOCH};
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
use lightning::util::events::{MessageSendEvent, MessageSendEventsProvider, Event};
use lightning::util::test_utils;
use lightning::util::config::UserConfig;
- use lightning::chain::keysinterface::KeysInterface;
use crate::utils::create_invoice_from_channelmanager_and_duration_since_epoch;
use std::collections::HashSet;
use bitcoin::hash_types::{BlockHash, Txid};
use bitcoin::hashes::hex::FromHex;
use lightning::chain::channelmonitor::ChannelMonitor;
-use lightning::chain::keysinterface::{KeysInterface, SignerProvider};
+use lightning::chain::keysinterface::{EntropySource, SignerProvider};
use lightning::util::ser::{ReadableArgs, Writeable};
use lightning::util::persist::KVStorePersister;
use std::fs;
pub fn read_channelmonitors<K: Deref> (
&self, keys_manager: K
) -> std::io::Result<Vec<(BlockHash, ChannelMonitor<<K::Target as SignerProvider>::Signer>)>>
- where K::Target: KeysInterface + Sized,
+ where K::Target: EntropySource + SignerProvider + Sized,
{
let mut path = PathBuf::from(&self.path_to_channel_data);
path.push("monitors");
use crate::chain::{BestBlock, WatchedOutput};
use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator, LowerBoundedFeeEstimator};
use crate::chain::transaction::{OutPoint, TransactionData};
-use crate::chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, Sign, KeysInterface};
+use crate::chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, Sign, SignerProvider, EntropySource};
#[cfg(anchors)]
use crate::chain::onchaintx::ClaimEvent;
use crate::chain::onchaintx::OnchainTxHandler;
const MAX_ALLOC_SIZE: usize = 64*1024;
-impl<'a, K: KeysInterface> ReadableArgs<&'a K>
+impl<'a, K: EntropySource + SignerProvider> ReadableArgs<&'a K>
for (BlockHash, ChannelMonitor<K::Signer>) {
fn read<R: io::Read>(reader: &mut R, keys_manager: &'a K) -> Result<Self, DecodeError> {
macro_rules! unwrap_obj {
/// [`SpendableOutputs`]: crate::util::events::Event::SpendableOutputs
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SpendableOutputDescriptor {
- /// An output to a script which was provided via [`KeysInterface`] directly, either from
+ /// An output to a script which was provided via [`SignerProvider`] directly, either from
/// [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already
/// know how to spend it. No secret keys are provided as LDK was never given any key.
/// These may include outputs from a transaction punishing our counterparty or claiming an HTLC
/// [`BaseSign::channel_keys_id`].
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer;
- /// Reads a [`Signer`] for this [`KeysInterface`] from the given input stream.
+ /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream.
/// This is only called during deserialization of other objects which contain
/// [`Sign`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s).
/// The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript;
}
-/// A trait to describe an object which can get user secrets and key material.
-pub trait KeysInterface: EntropySource + NodeSigner + SignerProvider {}
-
#[derive(Clone)]
/// A simple implementation of [`Sign`] that just keeps the private keys in memory.
///
}
}
-/// Simple [`KeysInterface`] implementation that takes a 32-byte seed for use as a BIP 32 extended
-/// key and derives keys from that.
+/// Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a
+/// 32-byte seed for use as a BIP 32 extended key and derives keys from that.
///
/// Your `node_id` is seed/0'.
/// Unilateral closes may use seed/1'.
}
}
-impl KeysInterface for KeysManager {}
-
/// Similar to [`KeysManager`], but allows the node using this struct to receive phantom node
/// payments.
///
}
}
-impl KeysInterface for PhantomKeysManager {}
-
impl PhantomKeysManager {
/// Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed`
/// that is shared across all nodes that intend to participate in [phantom node payments]
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
use bitcoin::secp256k1;
-use crate::chain::keysinterface::BaseSign;
+use crate::chain::keysinterface::{BaseSign, EntropySource, SignerProvider};
use crate::ln::msgs::DecodeError;
use crate::ln::PaymentPreimage;
#[cfg(anchors)]
use crate::chain::chaininterface::ConfirmationTarget;
use crate::chain::chaininterface::{FeeEstimator, BroadcasterInterface, LowerBoundedFeeEstimator};
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER};
-use crate::chain::keysinterface::{Sign, KeysInterface};
+use crate::chain::keysinterface::Sign;
#[cfg(anchors)]
use crate::chain::package::PackageSolvingData;
use crate::chain::package::PackageTemplate;
}
}
-impl<'a, K: KeysInterface> ReadableArgs<(&'a K, u64, [u8; 32])> for OnchainTxHandler<K::Signer> {
+impl<'a, K: EntropySource + SignerProvider> ReadableArgs<(&'a K, u64, [u8; 32])> for OnchainTxHandler<K::Signer> {
fn read<R: io::Read>(reader: &mut R, args: (&'a K, u64, [u8; 32])) -> Result<Self, DecodeError> {
let keys_manager = args.0;
let channel_value_satoshis = args.1;
use crate::ln::chan_utils::{get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment};
use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1};
use crate::util::test_utils;
- use crate::chain::keysinterface::{KeysInterface, BaseSign, SignerProvider};
+ use crate::chain::keysinterface::{BaseSign, SignerProvider};
use bitcoin::{Network, Txid};
use bitcoin::hashes::Hash;
use crate::ln::PaymentHash;
use crate::chain::chaininterface::{FeeEstimator, ConfirmationTarget, LowerBoundedFeeEstimator};
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
use crate::chain::transaction::{OutPoint, TransactionData};
-use crate::chain::keysinterface::{Sign, EntropySource, KeysInterface, BaseSign, SignerProvider};
+use crate::chain::keysinterface::{Sign, EntropySource, BaseSign, SignerProvider};
use crate::util::events::ClosureReason;
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter};
use crate::util::logger::Logger;
channel_value_satoshis: u64, push_msat: u64, user_id: u128, config: &UserConfig, current_chain_height: u32,
outbound_scid_alias: u64
) -> Result<Channel<Signer>, APIError>
- where K::Target: KeysInterface<Signer = Signer>,
+ where K::Target: EntropySource + SignerProvider<Signer = Signer>,
F::Target: FeeEstimator,
{
let opt_anchors = false; // TODO - should be based on features
msg: &msgs::OpenChannel, user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L,
outbound_scid_alias: u64
) -> Result<Channel<Signer>, ChannelError>
- where K::Target: KeysInterface<Signer = Signer>,
+ where K::Target: EntropySource + SignerProvider<Signer = Signer>,
F::Target: FeeEstimator,
L::Target: Logger,
{
&mut self, msg: &msgs::FundingCreated, best_block: BestBlock, keys_source: &K, logger: &L
) -> Result<(msgs::FundingSigned, ChannelMonitor<<K::Target as SignerProvider>::Signer>, Option<msgs::ChannelReady>), ChannelError>
where
- K::Target: KeysInterface,
+ K::Target: SignerProvider,
L::Target: Logger
{
if self.is_outbound() {
&mut self, msg: &msgs::FundingSigned, best_block: BestBlock, keys_source: &K, logger: &L
) -> Result<(ChannelMonitor<<K::Target as SignerProvider>::Signer>, Transaction, Option<msgs::ChannelReady>), ChannelError>
where
- K::Target: KeysInterface,
+ K::Target: SignerProvider,
L::Target: Logger
{
if !self.is_outbound() {
pub fn shutdown<K: Deref>(
&mut self, keys_provider: &K, their_features: &InitFeatures, msg: &msgs::Shutdown
) -> Result<(Option<msgs::Shutdown>, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), ChannelError>
- where K::Target: KeysInterface
+ where K::Target: SignerProvider
{
if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
return Err(ChannelError::Close("Peer sent shutdown when we needed a channel_reestablish".to_owned()));
/// holding cell HTLCs for payment failure.
pub fn get_shutdown<K: Deref>(&mut self, keys_provider: &K, their_features: &InitFeatures, target_feerate_sats_per_kw: Option<u32>)
-> Result<(msgs::Shutdown, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), APIError>
- where K::Target: KeysInterface {
+ where K::Target: SignerProvider {
for htlc in self.pending_outbound_htlcs.iter() {
if let OutboundHTLCState::LocalAnnounced(_) = htlc.state {
return Err(APIError::APIMisuseError{err: "Cannot begin shutdown with pending HTLCs. Process pending events first".to_owned()});
const MAX_ALLOC_SIZE: usize = 64*1024;
impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<<K::Target as SignerProvider>::Signer>
- where K::Target: KeysInterface {
+ where K::Target: EntropySource + SignerProvider {
fn read<R : io::Read>(reader: &mut R, args: (&'a K, u32)) -> Result<Self, DecodeError> {
let (keys_source, serialized_height) = args;
let ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
use crate::ln::chan_utils::{htlc_success_tx_weight, htlc_timeout_tx_weight};
use crate::chain::BestBlock;
use crate::chain::chaininterface::{FeeEstimator, LowerBoundedFeeEstimator, ConfirmationTarget};
- use crate::chain::keysinterface::{BaseSign, InMemorySigner, Recipient, KeyMaterial, KeysInterface, EntropySource, NodeSigner, SignerProvider};
+ use crate::chain::keysinterface::{BaseSign, InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider};
use crate::chain::transaction::OutPoint;
use crate::util::config::UserConfig;
use crate::util::enforcing_trait_impls::EnforcingSigner;
}
}
- impl KeysInterface for Keys {}
-
#[cfg(not(feature = "grind_signatures"))]
fn public_from_secret_hex(secp_ctx: &Secp256k1<bitcoin::secp256k1::All>, hex: &str) -> PublicKey {
PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode(hex).unwrap()[..]).unwrap())
use crate::ln::outbound_payment;
use crate::ln::outbound_payment::{OutboundPayments, PendingOutboundPayment};
use crate::ln::wire::Encode;
-use crate::chain::keysinterface::{EntropySource, KeysInterface, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
+use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient, Sign, SignerProvider};
use crate::util::config::{UserConfig, ChannelConfig};
use crate::util::events::{Event, EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
use crate::util::events;
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
where
M::Target: chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: BroadcasterInterface,
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner + SignerProvider,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, ClosureReason};
use crate::util::test_utils;
use crate::util::config::ChannelConfig;
- use crate::chain::keysinterface::{EntropySource, KeysInterface};
+ use crate::chain::keysinterface::EntropySource;
#[test]
fn test_notify_limits() {
pub mod bench {
use crate::chain::Listen;
use crate::chain::chainmonitor::{ChainMonitor, Persist};
- use crate::chain::keysinterface::{EntropySource, KeysManager, KeysInterface, InMemorySigner};
+ use crate::chain::keysinterface::{EntropySource, KeysManager, InMemorySigner};
use crate::ln::channelmanager::{self, BestBlock, ChainParameters, ChannelManager, PaymentHash, PaymentPreimage, PaymentId};
use crate::ln::functional_test_utils::*;
use crate::ln::msgs::{ChannelMessageHandler, Init};
use crate::chain::channelmonitor;
use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY};
use crate::chain::transaction::OutPoint;
-use crate::chain::keysinterface::{BaseSign, EntropySource, KeysInterface};
+use crate::chain::keysinterface::{BaseSign, EntropySource};
use crate::ln::{PaymentPreimage, PaymentSecret, PaymentHash};
use crate::ln::channel::{commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC, CONCURRENT_INBOUND_HTLC_FEE_BUFFER, FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE, MIN_AFFORDABLE_HTLC_COUNT};
use crate::ln::channelmanager::{self, PaymentId, RAACommitmentOrder, PaymentSendFailure, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA};
use bitcoin::hashes::cmp::fixed_time_eq;
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
use bitcoin::hashes::sha256::Hash as Sha256;
-use crate::chain::keysinterface::{KeyMaterial, KeysInterface, EntropySource};
+use crate::chain::keysinterface::{KeyMaterial, EntropySource};
use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
use crate::ln::msgs;
use crate::ln::msgs::MAX_VALUE_MSAT;
/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
/// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material
pub fn create<K: Deref>(keys: &ExpandedKey, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32, keys_manager: &K, current_time: u64) -> Result<(PaymentHash, PaymentSecret), ()>
- where K::Target: KeysInterface
+ where K::Target: EntropySource
{
let metadata_bytes = construct_metadata_bytes(min_value_msat, Method::LdkPaymentHash, invoice_expiry_delta_secs, current_time)?;
//! returned errors decode to the correct thing.
use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS};
-use crate::chain::keysinterface::{EntropySource, KeysInterface, NodeSigner, Recipient};
+use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
use crate::ln::{PaymentHash, PaymentSecret};
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
use crate::ln::channelmanager::{self, HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingAddHTLCInfo, PendingHTLCInfo, PendingHTLCRouting, PaymentId};
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::secp256k1::{self, Secp256k1, SecretKey};
-use crate::chain::keysinterface::{EntropySource, KeysInterface, NodeSigner, Recipient};
+use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
use crate::ln::channelmanager::{HTLCSource, IDEMPOTENCY_TIMEOUT_TICKS, PaymentId};
use crate::ln::msgs::DecodeError;
payment_id: PaymentId, keys_manager: &K, best_block_height: u32, send_payment_along_path: F
) -> Result<(), PaymentSendFailure>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
{
keys_manager: &K, best_block_height: u32, send_payment_along_path: F
) -> Result<PaymentHash, PaymentSendFailure>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
{
send_payment_along_path: F
) -> Result<(), PaymentSendFailure>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
{
best_block_height: u32, send_payment_along_path: F
) -> Result<(PaymentHash, PaymentId), PaymentSendFailure>
where
- K::Target: KeysInterface,
+ K::Target: EntropySource + NodeSigner,
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
{
fn add_new_pending_payment<K: Deref>(
&self, payment_hash: PaymentHash, payment_secret: Option<PaymentSecret>, payment_id: PaymentId,
route: &Route, keys_manager: &K, best_block_height: u32
- ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where K::Target: KeysInterface {
+ ) -> Result<Vec<[u8; 32]>, PaymentSendFailure> where K::Target: EntropySource + NodeSigner {
let mut onion_session_privs = Vec::with_capacity(route.paths.len());
for _ in 0..route.paths.len() {
onion_session_privs.push(keys_manager.get_secure_random_bytes());
send_payment_along_path: F
) -> Result<(), PaymentSendFailure>
where
- K::Target: KeysInterface,
+ K::Target: NodeSigner,
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
{
send_payment_along_path: F
) -> Result<(), PaymentSendFailure>
where
- K::Target: KeysInterface,
+ K::Target: NodeSigner,
F: Fn(&Vec<RouteHop>, &Option<PaymentParameters>, &PaymentHash, &Option<PaymentSecret>, u64,
u32, PaymentId, &Option<PaymentPreimage>, [u8; 32]) -> Result<(), APIError>
{
use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Listen, Watch};
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS};
+use crate::chain::keysinterface::EntropySource;
use crate::chain::transaction::OutPoint;
-use crate::chain::keysinterface::{EntropySource, KeysInterface};
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
use crate::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS};
use crate::ln::msgs;
//! LSP).
use crate::chain::ChannelMonitorUpdateStatus;
-use crate::chain::keysinterface::{Recipient, KeysInterface, NodeSigner};
+use crate::chain::keysinterface::{Recipient, NodeSigner};
use crate::ln::channelmanager::{self, ChannelManager, MIN_CLTV_EXPIRY_DELTA, PaymentId};
use crate::routing::gossip::RoutingFees;
use crate::routing::router::{PaymentParameters, RouteHint, RouteHintHop};
use crate::chain::{ChannelMonitorUpdateStatus, Watch};
use crate::chain::chaininterface::LowerBoundedFeeEstimator;
use crate::chain::channelmonitor::ChannelMonitor;
-use crate::chain::keysinterface::{EntropySource, KeysInterface};
+use crate::chain::keysinterface::EntropySource;
use crate::chain::transaction::OutPoint;
use crate::ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs, PaymentId};
use crate::ln::msgs;
//! Tests of our shutdown and closing_signed negotiation logic.
-use crate::chain::keysinterface::{EntropySource, KeysInterface, SignerProvider};
+use crate::chain::keysinterface::{EntropySource, SignerProvider};
use crate::chain::transaction::OutPoint;
use crate::ln::channelmanager::{self, PaymentSendFailure, PaymentId};
use crate::routing::router::{PaymentParameters, get_route};
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
-use crate::chain::keysinterface::{KeysInterface, NodeSigner, Recipient};
+use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
use super::packet::ControlTlvs;
use super::utils;
use crate::ln::msgs::DecodeError;
///
/// Errors if less than two hops are provided or if `node_pk`(s) are invalid.
// TODO: make all payloads the same size with padding + add dummy hops
- pub fn new<K: KeysInterface, T: secp256k1::Signing + secp256k1::Verification>
+ pub fn new<K: EntropySource, T: secp256k1::Signing + secp256k1::Verification>
(node_pks: &[PublicKey], keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<Self, ()>
{
if node_pks.len() < 2 { return Err(()) }
// Advance the blinded path by one hop, so make the second hop into the new introduction node.
pub(super) fn advance_by_one<K: Deref, T: secp256k1::Signing + secp256k1::Verification>
(&mut self, keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<(), ()>
- where K::Target: KeysInterface
+ where K::Target: NodeSigner
{
let control_tlvs_ss = keys_manager.ecdh(Recipient::Node, &self.blinding_point, None)?;
let rho = onion_utils::gen_rho_from_shared_secret(&control_tlvs_ss.secret_bytes());
//! Onion message testing and test utilities live here.
-use crate::chain::keysinterface::{KeysInterface, NodeSigner, Recipient};
+use crate::chain::keysinterface::{NodeSigner, Recipient};
use crate::ln::features::InitFeatures;
use crate::ln::msgs::{self, DecodeError, OnionMessageHandler};
use super::{BlindedPath, CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError};
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
-use crate::chain::keysinterface::{EntropySource, KeysInterface, KeysManager, NodeSigner, Recipient};
+use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient};
use crate::ln::features::{InitFeatures, NodeFeatures};
use crate::ln::msgs::{self, OnionMessageHandler};
use crate::ln::onion_utils;
/// # extern crate bitcoin;
/// # use bitcoin::hashes::_export::_core::time::Duration;
/// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
-/// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
+/// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager};
/// # use lightning::ln::msgs::DecodeError;
/// # use lightning::ln::peer_handler::IgnoringMessageHandler;
/// # use lightning::onion_message::{BlindedPath, CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger};
/// [offers]: <https://github.com/lightning/bolts/pull/798>
/// [`OnionMessenger`]: crate::onion_message::OnionMessenger
pub struct OnionMessenger<K: Deref, L: Deref, CMH: Deref>
- where K::Target: KeysInterface,
+ where K::Target: NodeSigner,
L::Target: Logger,
CMH:: Target: CustomOnionMessageHandler,
{
InvalidMessage,
/// Our next-hop peer's buffer was full or our total outbound buffer was full.
BufferFull,
- /// Failed to retrieve our node id from the provided [`KeysInterface`].
+ /// Failed to retrieve our node id from the provided [`NodeSigner`].
///
- /// [`KeysInterface`]: crate::chain::keysinterface::KeysInterface
+ /// [`NodeSigner`]: crate::chain::keysinterface::NodeSigner
GetNodeIdFailed,
/// We attempted to send to a blinded path where we are the introduction node, and failed to
/// advance the blinded path to make the second hop the new introduction node. Either
}
impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
- where K::Target: KeysInterface,
+ where K::Target: EntropySource + NodeSigner,
L::Target: Logger,
CMH::Target: CustomOnionMessageHandler,
{
}
impl<K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for OnionMessenger<K, L, CMH>
- where K::Target: KeysInterface,
+ where K::Target: NodeSigner,
L::Target: Logger,
CMH::Target: CustomOnionMessageHandler + Sized,
{
}
impl<K: Deref, L: Deref, CMH: Deref> OnionMessageProvider for OnionMessenger<K, L, CMH>
- where K::Target: KeysInterface,
+ where K::Target: NodeSigner,
L::Target: Logger,
CMH::Target: CustomOnionMessageHandler,
{
use crate::routing::scoring::{ChannelUsage, Score, ProbabilisticScorer, ProbabilisticScoringParameters};
use crate::routing::test_utils::{add_channel, add_or_update_node, build_graph, build_line_graph, id_to_feature_flags, get_nodes, update_channel};
use crate::chain::transaction::OutPoint;
- use crate::chain::keysinterface::{EntropySource, KeysInterface};
+ use crate::chain::keysinterface::EntropySource;
use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
use crate::ln::channelmanager;
use bitcoin::hashes::Hash;
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
use crate::chain::transaction::OutPoint;
- use crate::chain::keysinterface::{EntropySource, KeysManager,KeysInterface};
+ use crate::chain::keysinterface::{EntropySource, KeysManager};
use crate::ln::channelmanager::{self, ChannelCounterparty, ChannelDetails};
use crate::ln::features::InvoiceFeatures;
use crate::routing::gossip::NetworkGraph;
//! # use lightning::routing::gossip::NetworkGraph;
//! # use lightning::routing::router::{RouteParameters, find_route};
//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};
-//! # use lightning::chain::keysinterface::{KeysManager, KeysInterface};
+//! # use lightning::chain::keysinterface::KeysManager;
//! # use lightning::util::logger::{Logger, Record};
//! # use bitcoin::secp256k1::PublicKey;
//! #
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
// EnforcingSigner has two fields - `inner` ([`InMemorySigner`]) and `state`
// ([`EnforcementState`]). `inner` is serialized here and deserialized by
- // [`KeysInterface::read_chan_signer`]. `state` is managed by [`KeysInterface`]
+ // [`SignerProvider::read_chan_signer`]. `state` is managed by [`SignerProvider`]
// and will be serialized as needed by the implementation of that trait.
self.inner.write(writer)?;
Ok(())
use crate::chain;
use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
use crate::chain::chainmonitor::{Persist, MonitorUpdateId};
-use crate::chain::keysinterface::{Sign, KeysInterface, SignerProvider};
+use crate::chain::keysinterface::{Sign, SignerProvider};
use crate::chain::transaction::OutPoint;
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate};
use crate::ln::channelmanager::ChannelManager;
pub trait Persister<'a, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref, S: WriteableScore<'a>>
where M::Target: 'static + chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: 'static + BroadcasterInterface,
- K::Target: 'static + KeysInterface,
+ K::Target: 'static + SignerProvider,
F::Target: 'static + FeeEstimator,
R::Target: 'static + Router,
L::Target: 'static + Logger,
impl<'a, A: KVStorePersister, M: Deref, T: Deref, K: Deref, F: Deref, R: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, M, T, K, F, R, L, S> for A
where M::Target: 'static + chain::Watch<<K::Target as SignerProvider>::Signer>,
T::Target: 'static + BroadcasterInterface,
- K::Target: 'static + KeysInterface,
+ K::Target: 'static + SignerProvider,
F::Target: 'static + FeeEstimator,
R::Target: 'static + Router,
L::Target: 'static + Logger,
pub(crate) mod fake_scid {
use bitcoin::hash_types::BlockHash;
use bitcoin::hashes::hex::FromHex;
- use crate::chain::keysinterface::{KeysInterface, EntropySource};
+ use crate::chain::keysinterface::EntropySource;
use crate::util::chacha20::ChaCha20;
use crate::util::scid_utils;
/// index are also selected from a "reasonable" range. We add this logic because it makes it
/// non-obvious at a glance that the scid is fake, e.g. if it appears in invoice route hints.
pub(crate) fn get_fake_scid<K: Deref>(&self, highest_seen_blockheight: u32, genesis_hash: &BlockHash, fake_scid_rand_bytes: &[u8; 32], keys_manager: &K) -> u64
- where K::Target: KeysInterface,
+ where K::Target: EntropySource,
{
// Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for
// namespaces.
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!(); }
}
-impl keysinterface::KeysInterface for OnlyReadsKeysInterface {
-}
-
pub struct TestChainMonitor<'a> {
pub added_monitors: Mutex<Vec<(OutPoint, channelmonitor::ChannelMonitor<EnforcingSigner>)>>,
pub monitor_updates: Mutex<HashMap<[u8; 32], Vec<channelmonitor::ChannelMonitorUpdate>>>,
}
}
-impl keysinterface::KeysInterface for TestKeysInterface {}
-
impl TestKeysInterface {
pub fn new(seed: &[u8; 32], network: Network) -> Self {
let now = Duration::from_secs(genesis_block(network).header.time as u64);