Skip to content

Commit 88bd0ca

Browse files
committed
Verify gossip using our RpcClient and the new LDK verification impl
1 parent f5d699d commit 88bd0ca

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2018"
99

1010
[dependencies]
1111
lightning = { version = "0.0.117", features = ["max_level_trace"] }
12-
lightning-block-sync = { version = "0.0.117", features = [ "rpc-client" ] }
12+
lightning-block-sync = { version = "0.0.117", features = [ "rpc-client", "tokio" ] }
1313
lightning-invoice = { version = "0.25.0" }
1414
lightning-net-tokio = { version = "0.0.117" }
1515
lightning-persister = { version = "0.0.117" }

src/bitcoind_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::sync::Arc;
2828
use std::time::Duration;
2929

3030
pub struct BitcoindClient {
31-
bitcoind_rpc_client: Arc<RpcClient>,
31+
pub(crate) bitcoind_rpc_client: Arc<RpcClient>,
3232
host: String,
3333
port: u16,
3434
rpc_user: String,

src/main.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,23 @@ type ChainMonitor = chainmonitor::ChainMonitor<
133133
>,
134134
>;
135135

136+
pub(crate) type GossipVerifier = lightning_block_sync::gossip::GossipVerifier<
137+
lightning_block_sync::gossip::TokioSpawner,
138+
Arc<lightning_block_sync::rpc::RpcClient>,
139+
Arc<FilesystemLogger>,
140+
SocketDescriptor,
141+
Arc<ChannelManager>,
142+
Arc<SimpleArcOnionMessenger<FilesystemLogger>>,
143+
IgnoringMessageHandler,
144+
Arc<KeysManager>,
145+
>;
146+
136147
pub(crate) type PeerManager = SimpleArcPeerManager<
137148
SocketDescriptor,
138149
ChainMonitor,
139150
BitcoindClient,
140151
BitcoindClient,
141-
Arc<BitcoindClient>,
152+
GossipVerifier,
142153
FilesystemLogger,
143154
>;
144155

@@ -733,11 +744,8 @@ async fn start_ldk() {
733744
}
734745

735746
// Step 14: Optional: Initialize the P2PGossipSync
736-
let gossip_sync = Arc::new(P2PGossipSync::new(
737-
Arc::clone(&network_graph),
738-
None::<Arc<BitcoindClient>>,
739-
logger.clone(),
740-
));
747+
let gossip_sync =
748+
Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
741749

742750
// Step 15: Initialize the PeerManager
743751
let channel_manager: Arc<ChannelManager> = Arc::new(channel_manager);
@@ -766,6 +774,15 @@ async fn start_ldk() {
766774
Arc::clone(&keys_manager),
767775
));
768776

777+
// Install a GossipVerifier in in the P2PGossipSync
778+
let utxo_lookup = GossipVerifier::new(
779+
Arc::clone(&bitcoind_client.bitcoind_rpc_client),
780+
lightning_block_sync::gossip::TokioSpawner,
781+
Arc::clone(&gossip_sync),
782+
Arc::clone(&peer_manager),
783+
);
784+
gossip_sync.add_utxo_lookup(Some(utxo_lookup));
785+
769786
// ## Running LDK
770787
// Step 16: Initialize networking
771788

0 commit comments

Comments
 (0)