- this.chain_watch = chain_watch;
- channel_manager = ChannelManager.constructor_new(fee_estimator, chain_watch, tx_broadcaster, logger, keys_interface, config, network, current_blockchain_tip_hash, current_blockchain_tip_height);
+ this.chain_monitor = chain_monitor;
+ this.router = router;
+ BestBlock block = BestBlock.of(current_blockchain_tip_hash, current_blockchain_tip_height);
+ ChainParameters params = ChainParameters.of(network, block);
+ channel_manager = ChannelManager.of(fee_estimator, chain_monitor.as_Watch(), tx_broadcaster, logger, keys_interface, config, params);
+ this.logger = logger;
+ byte[] random_data = keys_interface.get_secure_random_bytes();
+ if (router != null) {
+ this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(),
+ keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ } else {
+ this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), (IgnoringMessageHandler.of()).as_RoutingMessageHandler(),
+ keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ }
+ NioPeerHandler nio_peer_handler = null;
+ try {
+ nio_peer_handler = new NioPeerHandler(this.peer_manager);
+ } catch (IOException e) {
+ throw new IllegalStateException("We should never fail to construct nio objects unless we're on a platform that cannot run LDK.");
+ }
+ this.nio_peer_handler = nio_peer_handler;
+ }
+
+ /**
+ * Abstract interface which should handle Events and persist the ChannelManager. When you call chain_sync_completed
+ * a background thread is started which will automatically call these methods for you when events occur.
+ */
+ public interface EventHandler {
+ void handle_event(Event events);
+ void persist_manager(byte[] channel_manager_bytes);