Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Flow utilities and OffersMessageFlow implementation #3639

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,11 +1083,14 @@ mod tests {
IgnoringMessageHandler, MessageHandler, PeerManager, SocketDescriptor,
};
use lightning::ln::types::ChannelId;
use lightning::offers::flow::OffersMessageFlow;
use lightning::onion_message::messenger::{DefaultMessageRouter, OnionMessenger};
use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
use lightning::routing::router::{CandidateRouteHop, DefaultRouter, Path, RouteHop};
use lightning::routing::scoring::{ChannelUsage, LockableScore, ScoreLookUp, ScoreUpdate};
use lightning::sign::{ChangeDestinationSource, InMemorySigner, KeysManager};
use lightning::sign::{
ChangeDestinationSource, InMemorySigner, KeysManager, NodeSigner, Recipient,
};
use lightning::types::features::{ChannelFeatures, NodeFeatures};
use lightning::types::payment::PaymentHash;
use lightning::util::config::UserConfig;
Expand Down Expand Up @@ -1152,6 +1155,11 @@ mod tests {
Arc<KeysManager>,
>,
>,
Arc<
OffersMessageFlow<
Arc<KeysManager>,
>,
>,
Arc<test_utils::TestLogger>,
>;

Expand Down Expand Up @@ -1559,6 +1567,13 @@ mod tests {
network_graph.clone(),
Arc::clone(&keys_manager),
));
let flow = Arc::new(OffersMessageFlow::new(
network,
keys_manager.get_node_id(Recipient::Node).unwrap(),
genesis_block.header.time,
keys_manager.get_inbound_payment_key(),
keys_manager.clone(),
));
let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Bitcoin));
let kv_store =
Arc::new(FilesystemStore::new(format!("{}_persister_{}", &persist_dir, i).into()));
Expand All @@ -1579,6 +1594,7 @@ mod tests {
tx_broadcaster.clone(),
router.clone(),
msg_router.clone(),
flow.clone(),
logger.clone(),
keys_manager.clone(),
keys_manager.clone(),
Expand Down
6 changes: 5 additions & 1 deletion lightning-block-sync/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ where
/// use lightning::chain::chaininterface::BroadcasterInterface;
/// use lightning::chain::chaininterface::FeeEstimator;
/// use lightning::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs};
/// use lightning::offers::flow::Flow;
/// use lightning::onion_message::messenger::MessageRouter;
/// use lightning::routing::router::Router;
/// use lightning::sign;
Expand All @@ -71,6 +72,7 @@ where
/// F: FeeEstimator,
/// R: Router,
/// MR: MessageRouter,
/// FW: Flow,
/// L: Logger,
/// C: chain::Filter,
/// P: chainmonitor::Persist<SP::EcdsaSigner>,
Expand All @@ -85,6 +87,7 @@ where
/// fee_estimator: &F,
/// router: &R,
/// message_router: &MR,
/// flow: &FW,
/// logger: &L,
/// persister: &P,
/// ) {
Expand All @@ -105,11 +108,12 @@ where
/// tx_broadcaster,
/// router,
/// message_router,
/// flow,
/// logger,
/// config,
/// vec![&mut monitor],
/// );
/// <(BlockHash, ChannelManager<&ChainMonitor<SP::EcdsaSigner, &C, &T, &F, &L, &P>, &T, &ES, &NS, &SP, &F, &R, &MR, &L>)>::read(
/// <(BlockHash, ChannelManager<&ChainMonitor<SP::EcdsaSigner, &C, &T, &F, &L, &P>, &T, &ES, &NS, &SP, &F, &R, &MR, &FW, &L>)>::read(
/// &mut Cursor::new(&serialized_manager), read_args).unwrap()
/// };
///
Expand Down
16 changes: 15 additions & 1 deletion lightning-liquidity/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#![allow(unused_macros)]

use lightning::chain::Filter;
use lightning::sign::EntropySource;
use lightning::offers::flow::OffersMessageFlow;
use lightning::sign::{EntropySource, NodeSigner, Recipient};

use bitcoin::blockdata::constants::{genesis_block, ChainHash};
use bitcoin::blockdata::transaction::Transaction;
Expand Down Expand Up @@ -91,6 +92,11 @@ type ChannelManager = channelmanager::ChannelManager<
Arc<KeysManager>,
>,
>,
Arc<
OffersMessageFlow<
Arc<KeysManager>,
>,
>,
Arc<test_utils::TestLogger>,
>;

Expand Down Expand Up @@ -421,6 +427,13 @@ pub(crate) fn create_liquidity_node(
));
let msg_router =
Arc::new(DefaultMessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));
let flow = Arc::new(OffersMessageFlow::new(
network,
keys_manager.get_node_id(Recipient::Node).unwrap(),
genesis_block.header.time,
keys_manager.get_inbound_payment_key(),
keys_manager.clone(),
));
let chain_source = Arc::new(test_utils::TestChainSource::new(Network::Bitcoin));
let kv_store =
Arc::new(FilesystemStore::new(format!("{}_persister_{}", &persist_dir, i).into()));
Expand All @@ -439,6 +452,7 @@ pub(crate) fn create_liquidity_node(
tx_broadcaster.clone(),
router.clone(),
msg_router.clone(),
flow.clone(),
logger.clone(),
keys_manager.clone(),
keys_manager.clone(),
Expand Down
Loading