- UtilMethods.constructor_BlockHashChannelManagerZ_read(channel_manager_serialized, keys_interface, fee_estimator, chain_watch, tx_broadcaster,
- logger, UserConfig.constructor_default(), monitors);
- if (res instanceof Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err) {
- throw new InvalidSerializedDataException();
+ UtilMethods.C2Tuple_BlockHashChannelManagerZ_read(channel_manager_serialized, keys_interface, fee_estimator, chain_monitor.as_Watch(), tx_broadcaster,
+ logger, config, monitors);
+ if (!res.is_ok()) {
+ throw new InvalidSerializedDataException("Serialized ChannelManager was corrupt");
+ }
+ this.channel_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.get_b();
+ this.channel_manager_latest_block_hash = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.get_a();
+ this.chain_monitor = chain_monitor;
+ this.logger = logger;
+ byte[] random_data = keys_interface.get_secure_random_bytes();
+ if (net_graph_serialized != null) {
+ Result_NetworkGraphDecodeErrorZ graph_res = NetworkGraph.read(net_graph_serialized);
+ if (!graph_res.is_ok()) {
+ throw new InvalidSerializedDataException("Serialized Network Graph was corrupt");
+ }
+ this.net_graph = ((Result_NetworkGraphDecodeErrorZ.Result_NetworkGraphDecodeErrorZ_OK)graph_res).res;
+ } else {
+ this.net_graph = null;
+ }
+ Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node);
+ assert node_secret.is_ok();
+ if (net_graph != null) {
+ //TODO: We really need to expose the Access here to let users prevent DoS issues
+ this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
+ this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
+ graph_msg_handler.as_RoutingMessageHandler(),
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ } else {
+ this.graph_msg_handler = null;
+ this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), no_custom_messages.as_RoutingMessageHandler(),
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ 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;
+ if (filter != null) {
+ for (ChannelMonitor monitor : monitors) {
+ monitor.load_outputs_to_watch(filter);
+ }