mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-01-18 21:34:48 +01:00
Merge pull request #1806 from arik-so/2022-10-background-processor-deparametrization
Remove generic `Signer` parameter where it can be inferred from `KeysInterface`
This commit is contained in:
commit
49c9f1885d
@ -17,7 +17,7 @@ extern crate lightning_rapid_gossip_sync;
|
||||
use lightning::chain;
|
||||
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
|
||||
use lightning::chain::chainmonitor::{ChainMonitor, Persist};
|
||||
use lightning::chain::keysinterface::{Sign, KeysInterface};
|
||||
use lightning::chain::keysinterface::KeysInterface;
|
||||
use lightning::ln::channelmanager::ChannelManager;
|
||||
use lightning::ln::msgs::{ChannelMessageHandler, OnionMessageHandler, RoutingMessageHandler};
|
||||
use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor};
|
||||
@ -338,7 +338,6 @@ macro_rules! define_run_body {
|
||||
#[cfg(feature = "futures")]
|
||||
pub async fn process_events_async<
|
||||
'a,
|
||||
Signer: 'static + Sign,
|
||||
CA: 'static + Deref + Send + Sync,
|
||||
CF: 'static + Deref + Send + Sync,
|
||||
CW: 'static + Deref + Send + Sync,
|
||||
@ -355,7 +354,7 @@ pub async fn process_events_async<
|
||||
EventHandlerFuture: core::future::Future<Output = ()>,
|
||||
EventHandler: Fn(Event) -> EventHandlerFuture,
|
||||
PS: 'static + Deref + Send,
|
||||
M: 'static + Deref<Target = ChainMonitor<Signer, CF, T, F, L, P>> + Send + Sync,
|
||||
M: 'static + Deref<Target = ChainMonitor<<K::Target as KeysInterface>::Signer, CF, T, F, L, P>> + Send + Sync,
|
||||
CM: 'static + Deref<Target = ChannelManager<CW, T, K, F, L>> + Send + Sync,
|
||||
PGS: 'static + Deref<Target = P2PGossipSync<G, CA, L>> + Send + Sync,
|
||||
RGS: 'static + Deref<Target = RapidGossipSync<G, L>> + Send,
|
||||
@ -373,17 +372,17 @@ pub async fn process_events_async<
|
||||
where
|
||||
CA::Target: 'static + chain::Access,
|
||||
CF::Target: 'static + chain::Filter,
|
||||
CW::Target: 'static + chain::Watch<Signer>,
|
||||
CW::Target: 'static + chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: 'static + BroadcasterInterface,
|
||||
K::Target: 'static + KeysInterface<Signer = Signer>,
|
||||
K::Target: 'static + KeysInterface,
|
||||
F::Target: 'static + FeeEstimator,
|
||||
L::Target: 'static + Logger,
|
||||
P::Target: 'static + Persist<Signer>,
|
||||
P::Target: 'static + Persist<<K::Target as KeysInterface>::Signer>,
|
||||
CMH::Target: 'static + ChannelMessageHandler,
|
||||
OMH::Target: 'static + OnionMessageHandler,
|
||||
RMH::Target: 'static + RoutingMessageHandler,
|
||||
UMH::Target: 'static + CustomMessageHandler,
|
||||
PS::Target: 'static + Persister<'a, Signer, CW, T, K, F, L, SC>,
|
||||
PS::Target: 'static + Persister<'a, CW, T, K, F, L, SC>,
|
||||
{
|
||||
let mut should_break = true;
|
||||
let async_event_handler = |event| {
|
||||
@ -457,7 +456,6 @@ impl BackgroundProcessor {
|
||||
/// [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable
|
||||
pub fn start<
|
||||
'a,
|
||||
Signer: 'static + Sign,
|
||||
CA: 'static + Deref + Send + Sync,
|
||||
CF: 'static + Deref + Send + Sync,
|
||||
CW: 'static + Deref + Send + Sync,
|
||||
@ -473,7 +471,7 @@ impl BackgroundProcessor {
|
||||
RMH: 'static + Deref + Send + Sync,
|
||||
EH: 'static + EventHandler + Send,
|
||||
PS: 'static + Deref + Send,
|
||||
M: 'static + Deref<Target = ChainMonitor<Signer, CF, T, F, L, P>> + Send + Sync,
|
||||
M: 'static + Deref<Target = ChainMonitor<<K::Target as KeysInterface>::Signer, CF, T, F, L, P>> + Send + Sync,
|
||||
CM: 'static + Deref<Target = ChannelManager<CW, T, K, F, L>> + Send + Sync,
|
||||
PGS: 'static + Deref<Target = P2PGossipSync<G, CA, L>> + Send + Sync,
|
||||
RGS: 'static + Deref<Target = RapidGossipSync<G, L>> + Send,
|
||||
@ -488,17 +486,17 @@ impl BackgroundProcessor {
|
||||
where
|
||||
CA::Target: 'static + chain::Access,
|
||||
CF::Target: 'static + chain::Filter,
|
||||
CW::Target: 'static + chain::Watch<Signer>,
|
||||
CW::Target: 'static + chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: 'static + BroadcasterInterface,
|
||||
K::Target: 'static + KeysInterface<Signer = Signer>,
|
||||
K::Target: 'static + KeysInterface,
|
||||
F::Target: 'static + FeeEstimator,
|
||||
L::Target: 'static + Logger,
|
||||
P::Target: 'static + Persist<Signer>,
|
||||
P::Target: 'static + Persist<<K::Target as KeysInterface>::Signer>,
|
||||
CMH::Target: 'static + ChannelMessageHandler,
|
||||
OMH::Target: 'static + OnionMessageHandler,
|
||||
RMH::Target: 'static + RoutingMessageHandler,
|
||||
UMH::Target: 'static + CustomMessageHandler,
|
||||
PS::Target: 'static + Persister<'a, Signer, CW, T, K, F, L, SC>,
|
||||
PS::Target: 'static + Persister<'a, CW, T, K, F, L, SC>,
|
||||
{
|
||||
let stop_thread = Arc::new(AtomicBool::new(false));
|
||||
let stop_thread_clone = stop_thread.clone();
|
||||
|
@ -61,16 +61,15 @@ BlockSourceResult<ValidatedBlockHeader> where B::Target: BlockSource {
|
||||
///
|
||||
/// async fn init_sync<
|
||||
/// B: BlockSource,
|
||||
/// K: KeysInterface<Signer = S>,
|
||||
/// S: keysinterface::Sign,
|
||||
/// K: KeysInterface,
|
||||
/// T: BroadcasterInterface,
|
||||
/// F: FeeEstimator,
|
||||
/// L: Logger,
|
||||
/// C: chain::Filter,
|
||||
/// P: chainmonitor::Persist<S>,
|
||||
/// P: chainmonitor::Persist<K::Signer>,
|
||||
/// >(
|
||||
/// block_source: &B,
|
||||
/// chain_monitor: &ChainMonitor<S, &C, &T, &F, &L, &P>,
|
||||
/// chain_monitor: &ChainMonitor<K::Signer, &C, &T, &F, &L, &P>,
|
||||
/// config: UserConfig,
|
||||
/// keys_manager: &K,
|
||||
/// tx_broadcaster: &T,
|
||||
@ -80,7 +79,7 @@ BlockSourceResult<ValidatedBlockHeader> where B::Target: BlockSource {
|
||||
/// ) {
|
||||
/// // Read a serialized channel monitor paired with the block hash when it was persisted.
|
||||
/// let serialized_monitor = "...";
|
||||
/// let (monitor_block_hash, mut monitor) = <(BlockHash, ChannelMonitor<S>)>::read(
|
||||
/// let (monitor_block_hash, mut monitor) = <(BlockHash, ChannelMonitor<K::Signer>)>::read(
|
||||
/// &mut Cursor::new(&serialized_monitor), keys_manager).unwrap();
|
||||
///
|
||||
/// // Read the channel manager paired with the block hash when it was persisted.
|
||||
@ -95,7 +94,7 @@ BlockSourceResult<ValidatedBlockHeader> where B::Target: BlockSource {
|
||||
/// config,
|
||||
/// vec![&mut monitor],
|
||||
/// );
|
||||
/// <(BlockHash, ChannelManager<&ChainMonitor<S, &C, &T, &F, &L, &P>, &T, &K, &F, &L>)>::read(
|
||||
/// <(BlockHash, ChannelManager<&ChainMonitor<K::Signer, &C, &T, &F, &L, &P>, &T, &K, &F, &L>)>::read(
|
||||
/// &mut Cursor::new(&serialized_manager), read_args).unwrap()
|
||||
/// };
|
||||
///
|
||||
|
@ -8,7 +8,7 @@ use bech32::ToBase32;
|
||||
use bitcoin_hashes::{Hash, sha256};
|
||||
use lightning::chain;
|
||||
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
|
||||
use lightning::chain::keysinterface::{Recipient, KeysInterface, Sign};
|
||||
use lightning::chain::keysinterface::{Recipient, KeysInterface};
|
||||
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
|
||||
use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY};
|
||||
#[cfg(feature = "std")]
|
||||
@ -54,7 +54,7 @@ use crate::sync::Mutex;
|
||||
/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
|
||||
/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
|
||||
/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
|
||||
pub fn create_phantom_invoice<Signer: Sign, K: Deref, L: Deref>(
|
||||
pub fn create_phantom_invoice<K: Deref, L: Deref>(
|
||||
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: String,
|
||||
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
|
||||
logger: L, network: Currency,
|
||||
@ -65,7 +65,7 @@ where
|
||||
{
|
||||
let description = Description::new(description).map_err(SignOrCreationError::CreationError)?;
|
||||
let description = InvoiceDescription::Direct(&description,);
|
||||
_create_phantom_invoice::<Signer, K, L>(
|
||||
_create_phantom_invoice::<K, L>(
|
||||
amt_msat, payment_hash, description, invoice_expiry_delta_secs, phantom_route_hints,
|
||||
keys_manager, logger, network,
|
||||
)
|
||||
@ -103,7 +103,7 @@ where
|
||||
/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
|
||||
/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
|
||||
/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
|
||||
pub fn create_phantom_invoice_with_description_hash<Signer: Sign, K: Deref, L: Deref>(
|
||||
pub fn create_phantom_invoice_with_description_hash<K: Deref, L: Deref>(
|
||||
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, invoice_expiry_delta_secs: u32,
|
||||
description_hash: Sha256, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
|
||||
logger: L, network: Currency
|
||||
@ -112,14 +112,14 @@ where
|
||||
K::Target: KeysInterface,
|
||||
L::Target: Logger,
|
||||
{
|
||||
_create_phantom_invoice::<Signer, K, L>(
|
||||
_create_phantom_invoice::<K, L>(
|
||||
amt_msat, payment_hash, InvoiceDescription::Hash(&description_hash),
|
||||
invoice_expiry_delta_secs, phantom_route_hints, keys_manager, logger, network,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn _create_phantom_invoice<Signer: Sign, K: Deref, L: Deref>(
|
||||
fn _create_phantom_invoice<K: Deref, L: Deref>(
|
||||
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: InvoiceDescription,
|
||||
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, keys_manager: K,
|
||||
logger: L, network: Currency,
|
||||
@ -690,7 +690,6 @@ mod test {
|
||||
use lightning::ln::functional_test_utils::*;
|
||||
use lightning::ln::msgs::ChannelMessageHandler;
|
||||
use lightning::routing::router::{PaymentParameters, RouteParameters, find_route};
|
||||
use lightning::util::enforcing_trait_impls::EnforcingSigner;
|
||||
use lightning::util::events::{MessageSendEvent, MessageSendEventsProvider, Event};
|
||||
use lightning::util::test_utils;
|
||||
use lightning::util::config::UserConfig;
|
||||
@ -1016,7 +1015,7 @@ mod test {
|
||||
let non_default_invoice_expiry_secs = 4200;
|
||||
|
||||
let invoice =
|
||||
crate::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger>(
|
||||
crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(
|
||||
Some(payment_amt), payment_hash, "test".to_string(), non_default_invoice_expiry_secs,
|
||||
route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet
|
||||
).unwrap();
|
||||
@ -1125,7 +1124,7 @@ mod test {
|
||||
nodes[2].node.get_phantom_route_hints(),
|
||||
];
|
||||
|
||||
let invoice = crate::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger>(Some(payment_amt), Some(payment_hash), "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet).unwrap();
|
||||
let invoice = crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(Some(payment_amt), Some(payment_hash), "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet).unwrap();
|
||||
|
||||
let chan_0_1 = &nodes[1].node.list_usable_channels()[0];
|
||||
assert_eq!(invoice.route_hints()[0].0[0].htlc_minimum_msat, chan_0_1.inbound_htlc_minimum_msat);
|
||||
@ -1153,7 +1152,7 @@ mod test {
|
||||
let description_hash = crate::Sha256(Hash::hash("Description hash phantom invoice".as_bytes()));
|
||||
let non_default_invoice_expiry_secs = 4200;
|
||||
let invoice = crate::utils::create_phantom_invoice_with_description_hash::<
|
||||
EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger,
|
||||
&test_utils::TestKeysInterface, &test_utils::TestLogger,
|
||||
>(
|
||||
Some(payment_amt), None, non_default_invoice_expiry_secs, description_hash,
|
||||
route_hints, &nodes[1].keys_manager, &nodes[1].logger, Currency::BitcoinTestnet
|
||||
@ -1470,7 +1469,7 @@ mod test {
|
||||
.map(|route_hint| route_hint.phantom_scid)
|
||||
.collect::<HashSet<u64>>();
|
||||
|
||||
let invoice = crate::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface, &test_utils::TestLogger>(invoice_amt, None, "test".to_string(), 3600, phantom_route_hints, &invoice_node.keys_manager, &invoice_node.logger, Currency::BitcoinTestnet).unwrap();
|
||||
let invoice = crate::utils::create_phantom_invoice::<&test_utils::TestKeysInterface, &test_utils::TestLogger>(invoice_amt, None, "test".to_string(), 3600, phantom_route_hints, &invoice_node.keys_manager, &invoice_node.logger, Currency::BitcoinTestnet).unwrap();
|
||||
|
||||
let invoice_hints = invoice.private_routes();
|
||||
|
||||
|
@ -20,7 +20,7 @@ extern crate libc;
|
||||
use bitcoin::hash_types::{BlockHash, Txid};
|
||||
use bitcoin::hashes::hex::FromHex;
|
||||
use lightning::chain::channelmonitor::ChannelMonitor;
|
||||
use lightning::chain::keysinterface::{Sign, KeysInterface};
|
||||
use lightning::chain::keysinterface::KeysInterface;
|
||||
use lightning::util::ser::{ReadableArgs, Writeable};
|
||||
use lightning::util::persist::KVStorePersister;
|
||||
use std::fs;
|
||||
@ -59,10 +59,10 @@ impl FilesystemPersister {
|
||||
}
|
||||
|
||||
/// Read `ChannelMonitor`s from disk.
|
||||
pub fn read_channelmonitors<Signer: Sign, K: Deref> (
|
||||
pub fn read_channelmonitors<K: Deref> (
|
||||
&self, keys_manager: K
|
||||
) -> Result<Vec<(BlockHash, ChannelMonitor<Signer>)>, std::io::Error>
|
||||
where K::Target: KeysInterface<Signer=Signer> + Sized,
|
||||
) -> Result<Vec<(BlockHash, ChannelMonitor<<K::Target as KeysInterface>::Signer>)>, std::io::Error>
|
||||
where K::Target: KeysInterface + Sized,
|
||||
{
|
||||
let mut path = PathBuf::from(&self.path_to_channel_data);
|
||||
path.push("monitors");
|
||||
@ -105,7 +105,7 @@ impl FilesystemPersister {
|
||||
|
||||
let contents = fs::read(&file.path())?;
|
||||
let mut buffer = Cursor::new(&contents);
|
||||
match <(BlockHash, ChannelMonitor<Signer>)>::read(&mut buffer, &*keys_manager) {
|
||||
match <(BlockHash, ChannelMonitor<<K::Target as KeysInterface>::Signer>)>::read(&mut buffer, &*keys_manager) {
|
||||
Ok((blockhash, channel_monitor)) => {
|
||||
if channel_monitor.get_funding_txo().0.txid != txid.unwrap() || channel_monitor.get_funding_txo().0.index != index.unwrap() {
|
||||
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "ChannelMonitor was stored in the wrong file"));
|
||||
|
@ -3551,8 +3551,8 @@ where
|
||||
|
||||
const MAX_ALLOC_SIZE: usize = 64*1024;
|
||||
|
||||
impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
|
||||
for (BlockHash, ChannelMonitor<Signer>) {
|
||||
impl<'a, K: KeysInterface> 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 {
|
||||
($key: expr) => {
|
||||
@ -3736,7 +3736,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
|
||||
return Err(DecodeError::InvalidValue);
|
||||
}
|
||||
}
|
||||
let onchain_tx_handler: OnchainTxHandler<Signer> = ReadableArgs::read(reader, keys_manager)?;
|
||||
let onchain_tx_handler: OnchainTxHandler<K::Signer> = ReadableArgs::read(reader, keys_manager)?;
|
||||
|
||||
let lockdown_from_offchain = Readable::read(reader)?;
|
||||
let holder_tx_signed = Readable::read(reader)?;
|
||||
|
@ -4205,7 +4205,7 @@ impl<Signer: Sign> Channel<Signer> {
|
||||
pub fn shutdown<K: Deref>(
|
||||
&mut self, keys_provider: &K, their_features: &InitFeatures, msg: &msgs::Shutdown
|
||||
) -> Result<(Option<msgs::Shutdown>, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), ChannelError>
|
||||
where K::Target: KeysInterface<Signer = Signer>
|
||||
where K::Target: KeysInterface
|
||||
{
|
||||
if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
|
||||
return Err(ChannelError::Close("Peer sent shutdown when we needed a channel_reestablish".to_owned()));
|
||||
@ -5825,7 +5825,7 @@ impl<Signer: Sign> Channel<Signer> {
|
||||
/// holding cell HTLCs for payment failure.
|
||||
pub fn get_shutdown<K: Deref>(&mut self, keys_provider: &K, their_features: &InitFeatures, target_feerate_sats_per_kw: Option<u32>)
|
||||
-> Result<(msgs::Shutdown, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), APIError>
|
||||
where K::Target: KeysInterface<Signer = Signer> {
|
||||
where K::Target: KeysInterface {
|
||||
for htlc in self.pending_outbound_htlcs.iter() {
|
||||
if let OutboundHTLCState::LocalAnnounced(_) = htlc.state {
|
||||
return Err(APIError::APIMisuseError{err: "Cannot begin shutdown with pending HTLCs. Process pending events first".to_owned()});
|
||||
@ -6284,8 +6284,8 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
|
||||
}
|
||||
|
||||
const MAX_ALLOC_SIZE: usize = 64*1024;
|
||||
impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
|
||||
where K::Target: KeysInterface<Signer = Signer> {
|
||||
impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<<K::Target as KeysInterface>::Signer>
|
||||
where K::Target: KeysInterface {
|
||||
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);
|
||||
|
@ -6946,10 +6946,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> Writeable for ChannelMana
|
||||
/// which you've already broadcasted the transaction.
|
||||
///
|
||||
/// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
|
||||
pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
where M::Target: chain::Watch<Signer>,
|
||||
pub struct ChannelManagerReadArgs<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
where M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: BroadcasterInterface,
|
||||
K::Target: KeysInterface<Signer = Signer>,
|
||||
K::Target: KeysInterface,
|
||||
F::Target: FeeEstimator,
|
||||
L::Target: Logger,
|
||||
{
|
||||
@ -6992,14 +6992,14 @@ pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K:
|
||||
/// this struct.
|
||||
///
|
||||
/// (C-not exported) because we have no HashMap bindings
|
||||
pub channel_monitors: HashMap<OutPoint, &'a mut ChannelMonitor<Signer>>,
|
||||
pub channel_monitors: HashMap<OutPoint, &'a mut ChannelMonitor<<K::Target as KeysInterface>::Signer>>,
|
||||
}
|
||||
|
||||
impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
ChannelManagerReadArgs<'a, Signer, M, T, K, F, L>
|
||||
where M::Target: chain::Watch<Signer>,
|
||||
impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
ChannelManagerReadArgs<'a, M, T, K, F, L>
|
||||
where M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: BroadcasterInterface,
|
||||
K::Target: KeysInterface<Signer = Signer>,
|
||||
K::Target: KeysInterface,
|
||||
F::Target: FeeEstimator,
|
||||
L::Target: Logger,
|
||||
{
|
||||
@ -7007,7 +7007,7 @@ impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
/// HashMap for you. This is primarily useful for C bindings where it is not practical to
|
||||
/// populate a HashMap directly from C.
|
||||
pub fn new(keys_manager: K, fee_estimator: F, chain_monitor: M, tx_broadcaster: T, logger: L, default_config: UserConfig,
|
||||
mut channel_monitors: Vec<&'a mut ChannelMonitor<Signer>>) -> Self {
|
||||
mut channel_monitors: Vec<&'a mut ChannelMonitor<<K::Target as KeysInterface>::Signer>>) -> Self {
|
||||
Self {
|
||||
keys_manager, fee_estimator, chain_monitor, tx_broadcaster, logger, default_config,
|
||||
channel_monitors: channel_monitors.drain(..).map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect()
|
||||
@ -7018,28 +7018,28 @@ impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
// Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the
|
||||
// SipmleArcChannelManager type:
|
||||
impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
ReadableArgs<ChannelManagerReadArgs<'a, <K::Target as KeysInterface>::Signer, M, T, K, F, L>> for (BlockHash, Arc<ChannelManager<M, T, K, F, L>>)
|
||||
ReadableArgs<ChannelManagerReadArgs<'a, M, T, K, F, L>> for (BlockHash, Arc<ChannelManager<M, T, K, F, L>>)
|
||||
where M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: BroadcasterInterface,
|
||||
K::Target: KeysInterface,
|
||||
F::Target: FeeEstimator,
|
||||
L::Target: Logger,
|
||||
{
|
||||
fn read<R: io::Read>(reader: &mut R, args: ChannelManagerReadArgs<'a, <K::Target as KeysInterface>::Signer, M, T, K, F, L>) -> Result<Self, DecodeError> {
|
||||
fn read<R: io::Read>(reader: &mut R, args: ChannelManagerReadArgs<'a, M, T, K, F, L>) -> Result<Self, DecodeError> {
|
||||
let (blockhash, chan_manager) = <(BlockHash, ChannelManager<M, T, K, F, L>)>::read(reader, args)?;
|
||||
Ok((blockhash, Arc::new(chan_manager)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
|
||||
ReadableArgs<ChannelManagerReadArgs<'a, <K::Target as KeysInterface>::Signer, M, T, K, F, L>> for (BlockHash, ChannelManager<M, T, K, F, L>)
|
||||
ReadableArgs<ChannelManagerReadArgs<'a, M, T, K, F, L>> for (BlockHash, ChannelManager<M, T, K, F, L>)
|
||||
where M::Target: chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: BroadcasterInterface,
|
||||
K::Target: KeysInterface,
|
||||
F::Target: FeeEstimator,
|
||||
L::Target: Logger,
|
||||
{
|
||||
fn read<R: io::Read>(reader: &mut R, mut args: ChannelManagerReadArgs<'a, <K::Target as KeysInterface>::Signer, M, T, K, F, L>) -> Result<Self, DecodeError> {
|
||||
fn read<R: io::Read>(reader: &mut R, mut args: ChannelManagerReadArgs<'a, M, T, K, F, L>) -> Result<Self, DecodeError> {
|
||||
let _ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
|
||||
|
||||
let genesis_hash: BlockHash = Readable::read(reader)?;
|
||||
|
@ -14,7 +14,7 @@ use bitcoin::hashes::{Hash, HashEngine};
|
||||
use bitcoin::hashes::cmp::fixed_time_eq;
|
||||
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
|
||||
use bitcoin::hashes::sha256::Hash as Sha256;
|
||||
use crate::chain::keysinterface::{KeyMaterial, KeysInterface, Sign};
|
||||
use crate::chain::keysinterface::{KeyMaterial, KeysInterface};
|
||||
use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
|
||||
use crate::ln::msgs;
|
||||
use crate::ln::msgs::MAX_VALUE_MSAT;
|
||||
@ -91,8 +91,8 @@ impl Method {
|
||||
/// `current_time` is a Unix timestamp representing the current time.
|
||||
///
|
||||
/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
|
||||
pub fn create<Signer: Sign, 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<Signer = Signer>
|
||||
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
|
||||
{
|
||||
let metadata_bytes = construct_metadata_bytes(min_value_msat, Method::LdkPaymentHash, invoice_expiry_delta_secs, current_time)?;
|
||||
|
||||
|
@ -25,7 +25,7 @@ use crate::sync::Arc;
|
||||
|
||||
struct MessengerNode {
|
||||
keys_manager: Arc<test_utils::TestKeysInterface>,
|
||||
messenger: OnionMessenger<EnforcingSigner, Arc<test_utils::TestKeysInterface>, Arc<test_utils::TestLogger>, Arc<TestCustomMessageHandler>>,
|
||||
messenger: OnionMessenger<Arc<test_utils::TestKeysInterface>, Arc<test_utils::TestLogger>, Arc<TestCustomMessageHandler>>,
|
||||
logger: Arc<test_utils::TestLogger>,
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine};
|
||||
use bitcoin::hashes::sha256::Hash as Sha256;
|
||||
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
|
||||
|
||||
use crate::chain::keysinterface::{InMemorySigner, KeysInterface, KeysManager, Recipient, Sign};
|
||||
use crate::chain::keysinterface::{KeysInterface, KeysManager, Recipient};
|
||||
use crate::ln::features::{InitFeatures, NodeFeatures};
|
||||
use crate::ln::msgs::{self, OnionMessageHandler};
|
||||
use crate::ln::onion_utils;
|
||||
@ -104,8 +104,8 @@ use crate::prelude::*;
|
||||
///
|
||||
/// [offers]: <https://github.com/lightning/bolts/pull/798>
|
||||
/// [`OnionMessenger`]: crate::onion_message::OnionMessenger
|
||||
pub struct OnionMessenger<Signer: Sign, K: Deref, L: Deref, CMH: Deref>
|
||||
where K::Target: KeysInterface<Signer = Signer>,
|
||||
pub struct OnionMessenger<K: Deref, L: Deref, CMH: Deref>
|
||||
where K::Target: KeysInterface,
|
||||
L::Target: Logger,
|
||||
CMH:: Target: CustomOnionMessageHandler,
|
||||
{
|
||||
@ -186,8 +186,8 @@ pub trait CustomOnionMessageHandler {
|
||||
fn read_custom_message<R: io::Read>(&self, message_type: u64, buffer: &mut R) -> Result<Option<Self::CustomMessage>, msgs::DecodeError>;
|
||||
}
|
||||
|
||||
impl<Signer: Sign, K: Deref, L: Deref, CMH: Deref> OnionMessenger<Signer, K, L, CMH>
|
||||
where K::Target: KeysInterface<Signer = Signer>,
|
||||
impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
|
||||
where K::Target: KeysInterface,
|
||||
L::Target: Logger,
|
||||
CMH::Target: CustomOnionMessageHandler,
|
||||
{
|
||||
@ -295,8 +295,8 @@ fn outbound_buffer_full(peer_node_id: &PublicKey, buffer: &HashMap<PublicKey, Ve
|
||||
false
|
||||
}
|
||||
|
||||
impl<Signer: Sign, K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for OnionMessenger<Signer, K, L, CMH>
|
||||
where K::Target: KeysInterface<Signer = Signer>,
|
||||
impl<K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for OnionMessenger<K, L, CMH>
|
||||
where K::Target: KeysInterface,
|
||||
L::Target: Logger,
|
||||
CMH::Target: CustomOnionMessageHandler + Sized,
|
||||
{
|
||||
@ -439,8 +439,8 @@ impl<Signer: Sign, K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for Onion
|
||||
}
|
||||
}
|
||||
|
||||
impl<Signer: Sign, K: Deref, L: Deref, CMH: Deref> OnionMessageProvider for OnionMessenger<Signer, K, L, CMH>
|
||||
where K::Target: KeysInterface<Signer = Signer>,
|
||||
impl<K: Deref, L: Deref, CMH: Deref> OnionMessageProvider for OnionMessenger<K, L, CMH>
|
||||
where K::Target: KeysInterface,
|
||||
L::Target: Logger,
|
||||
CMH::Target: CustomOnionMessageHandler,
|
||||
{
|
||||
@ -462,7 +462,7 @@ impl<Signer: Sign, K: Deref, L: Deref, CMH: Deref> OnionMessageProvider for Onio
|
||||
///
|
||||
/// [`SimpleArcChannelManager`]: crate::ln::channelmanager::SimpleArcChannelManager
|
||||
/// [`SimpleArcPeerManager`]: crate::ln::peer_handler::SimpleArcPeerManager
|
||||
pub type SimpleArcOnionMessenger<L> = OnionMessenger<InMemorySigner, Arc<KeysManager>, Arc<L>, IgnoringMessageHandler>;
|
||||
pub type SimpleArcOnionMessenger<L> = OnionMessenger<Arc<KeysManager>, Arc<L>, IgnoringMessageHandler>;
|
||||
/// Useful for simplifying the parameters of [`SimpleRefChannelManager`] and
|
||||
/// [`SimpleRefPeerManager`]. See their docs for more details.
|
||||
///
|
||||
@ -470,7 +470,7 @@ pub type SimpleArcOnionMessenger<L> = OnionMessenger<InMemorySigner, Arc<KeysMan
|
||||
///
|
||||
/// [`SimpleRefChannelManager`]: crate::ln::channelmanager::SimpleRefChannelManager
|
||||
/// [`SimpleRefPeerManager`]: crate::ln::peer_handler::SimpleRefPeerManager
|
||||
pub type SimpleRefOnionMessenger<'a, 'b, L> = OnionMessenger<InMemorySigner, &'a KeysManager, &'b L, IgnoringMessageHandler>;
|
||||
pub type SimpleRefOnionMessenger<'a, 'b, L> = OnionMessenger<&'a KeysManager, &'b L, IgnoringMessageHandler>;
|
||||
|
||||
/// Construct onion packet payloads and keys for sending an onion message along the given
|
||||
/// `unblinded_path` to the given `destination`.
|
||||
|
@ -26,10 +26,10 @@ pub trait KVStorePersister {
|
||||
}
|
||||
|
||||
/// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
|
||||
pub trait Persister<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>>
|
||||
where M::Target: 'static + chain::Watch<Signer>,
|
||||
pub trait Persister<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>>
|
||||
where M::Target: 'static + chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: 'static + BroadcasterInterface,
|
||||
K::Target: 'static + KeysInterface<Signer = Signer>,
|
||||
K::Target: 'static + KeysInterface,
|
||||
F::Target: 'static + FeeEstimator,
|
||||
L::Target: 'static + Logger,
|
||||
{
|
||||
@ -43,10 +43,10 @@ pub trait Persister<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L:
|
||||
fn persist_scorer(&self, scorer: &S) -> Result<(), io::Error>;
|
||||
}
|
||||
|
||||
impl<'a, A: KVStorePersister, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, Signer, M, T, K, F, L, S> for A
|
||||
where M::Target: 'static + chain::Watch<Signer>,
|
||||
impl<'a, A: KVStorePersister, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, M, T, K, F, L, S> for A
|
||||
where M::Target: 'static + chain::Watch<<K::Target as KeysInterface>::Signer>,
|
||||
T::Target: 'static + BroadcasterInterface,
|
||||
K::Target: 'static + KeysInterface<Signer = Signer>,
|
||||
K::Target: 'static + KeysInterface,
|
||||
F::Target: 'static + FeeEstimator,
|
||||
L::Target: 'static + Logger,
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ pub fn scid_from_parts(block: u64, tx_index: u64, vout_index: u64) -> Result<u64
|
||||
pub(crate) mod fake_scid {
|
||||
use bitcoin::hash_types::BlockHash;
|
||||
use bitcoin::hashes::hex::FromHex;
|
||||
use crate::chain::keysinterface::{Sign, KeysInterface};
|
||||
use crate::chain::keysinterface::KeysInterface;
|
||||
use crate::util::chacha20::ChaCha20;
|
||||
use crate::util::scid_utils;
|
||||
|
||||
@ -98,8 +98,8 @@ 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<Signer: Sign, K: Deref>(&self, highest_seen_blockheight: u32, genesis_hash: &BlockHash, fake_scid_rand_bytes: &[u8; 32], keys_manager: &K) -> u64
|
||||
where K::Target: KeysInterface<Signer = Signer>,
|
||||
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,
|
||||
{
|
||||
// Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for
|
||||
// namespaces.
|
||||
|
Loading…
Reference in New Issue
Block a user