Fix comment on funding transaction broadcast
[ldk-sample] / src / main.rs
index 97524e618d34665707cd6b62adb4342f3c4fe517..33b17078f3b9aea808d7cc2b83f4d5dcd1fa5fa8 100644 (file)
@@ -133,12 +133,23 @@ type ChainMonitor = chainmonitor::ChainMonitor<
        >,
 >;
 
+pub(crate) type GossipVerifier = lightning_block_sync::gossip::GossipVerifier<
+       lightning_block_sync::gossip::TokioSpawner,
+       Arc<lightning_block_sync::rpc::RpcClient>,
+       Arc<FilesystemLogger>,
+       SocketDescriptor,
+       Arc<ChannelManager>,
+       Arc<SimpleArcOnionMessenger<FilesystemLogger>>,
+       IgnoringMessageHandler,
+       Arc<KeysManager>,
+>;
+
 pub(crate) type PeerManager = SimpleArcPeerManager<
        SocketDescriptor,
        ChainMonitor,
        BitcoindClient,
        BitcoindClient,
-       Arc<BitcoindClient>,
+       GossipVerifier,
        FilesystemLogger,
 >;
 
@@ -192,7 +203,7 @@ async fn handle_ldk_events(
                        // satisfied.
                        let funded_tx = bitcoind_client.fund_raw_transaction(raw_tx).await;
 
-                       // Sign the final funding transaction and broadcast it.
+                       // Sign the final funding transaction and give it to LDK, who will eventually broadcast it.
                        let signed_tx = bitcoind_client.sign_raw_transaction_with_wallet(funded_tx.hex).await;
                        assert_eq!(signed_tx.complete, true);
                        let final_tx: Transaction =
@@ -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::<Arc<BitcoindClient>>,
-               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<ChannelManager> = 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