From: Matt Corallo Date: Sat, 30 Sep 2023 03:01:07 +0000 (+0000) Subject: Verify gossip using our RpcClient and the new LDK verification impl X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=88bd0ca9ec1c511b3e3eb36095fbacca7ccc78fc;p=ldk-sample Verify gossip using our RpcClient and the new LDK verification impl --- diff --git a/Cargo.toml b/Cargo.toml index adac61d..d73ce6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] lightning = { version = "0.0.117", features = ["max_level_trace"] } -lightning-block-sync = { version = "0.0.117", features = [ "rpc-client" ] } +lightning-block-sync = { version = "0.0.117", features = [ "rpc-client", "tokio" ] } lightning-invoice = { version = "0.25.0" } lightning-net-tokio = { version = "0.0.117" } lightning-persister = { version = "0.0.117" } diff --git a/src/bitcoind_client.rs b/src/bitcoind_client.rs index 3a41bc6..9f28015 100644 --- a/src/bitcoind_client.rs +++ b/src/bitcoind_client.rs @@ -28,7 +28,7 @@ use std::sync::Arc; use std::time::Duration; pub struct BitcoindClient { - bitcoind_rpc_client: Arc, + pub(crate) bitcoind_rpc_client: Arc, host: String, port: u16, rpc_user: String, diff --git a/src/main.rs b/src/main.rs index 97524e6..50edb22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,12 +133,23 @@ type ChainMonitor = chainmonitor::ChainMonitor< >, >; +pub(crate) type GossipVerifier = lightning_block_sync::gossip::GossipVerifier< + lightning_block_sync::gossip::TokioSpawner, + Arc, + Arc, + SocketDescriptor, + Arc, + Arc>, + IgnoringMessageHandler, + Arc, +>; + pub(crate) type PeerManager = SimpleArcPeerManager< SocketDescriptor, ChainMonitor, BitcoindClient, BitcoindClient, - Arc, + GossipVerifier, FilesystemLogger, >; @@ -733,11 +744,8 @@ async fn start_ldk() { } // Step 14: Optional: Initialize the P2PGossipSync - let gossip_sync = Arc::new(P2PGossipSync::new( - Arc::clone(&network_graph), - None::>, - logger.clone(), - )); + let gossip_sync = + Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger))); // Step 15: Initialize the PeerManager let channel_manager: Arc = Arc::new(channel_manager); @@ -766,6 +774,15 @@ async fn start_ldk() { Arc::clone(&keys_manager), )); + // Install a GossipVerifier in in the P2PGossipSync + let utxo_lookup = GossipVerifier::new( + Arc::clone(&bitcoind_client.bitcoind_rpc_client), + lightning_block_sync::gossip::TokioSpawner, + Arc::clone(&gossip_sync), + Arc::clone(&peer_manager), + ); + gossip_sync.add_utxo_lookup(Some(utxo_lookup)); + // ## Running LDK // Step 16: Initialize networking