|
8 | 8 | use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL}; |
9 | 9 | use crate::config::{ |
10 | 10 | default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig, |
11 | | - EsploraSyncConfig, HumanReadableNamesConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, |
12 | | - WALLET_KEYS_SEED_LEN, |
| 11 | + EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN, |
13 | 12 | }; |
14 | 13 |
|
15 | 14 | use crate::connection::ConnectionManager; |
@@ -175,8 +174,10 @@ pub enum BuildError { |
175 | 174 | LoggerSetupFailed, |
176 | 175 | /// The given network does not match the node's previously configured network. |
177 | 176 | NetworkMismatch, |
178 | | - /// The dns_resolvers list provided for HRN resolution is empty |
179 | | - DnsResolversEmpty, |
| 177 | + /// The [`dns_resolvers_node_ids`] provided for HRN resolution is empty. |
| 178 | + /// |
| 179 | + /// [`dns_resolvers_node_ids`]: crate::config::HumanReadableNamesConfig::dns_resolvers_node_ids |
| 180 | + DnsResolversUnavailable, |
180 | 181 | } |
181 | 182 |
|
182 | 183 | impl fmt::Display for BuildError { |
@@ -204,7 +205,7 @@ impl fmt::Display for BuildError { |
204 | 205 | Self::NetworkMismatch => { |
205 | 206 | write!(f, "Given network does not match the node's previously configured network.") |
206 | 207 | }, |
207 | | - Self::DnsResolversEmpty => { |
| 208 | + Self::DnsResolversUnavailable => { |
208 | 209 | write!(f, "The dns_resolvers list provided for HRN resolution is empty.") |
209 | 210 | }, |
210 | 211 | } |
@@ -465,12 +466,6 @@ impl NodeBuilder { |
465 | 466 | Ok(self) |
466 | 467 | } |
467 | 468 |
|
468 | | - /// Sets the default [`Config::hrn_config`] to be used when sending payments to HRNs. |
469 | | - pub fn set_hrn_config(&mut self, hrn_config: HumanReadableNamesConfig) -> &mut Self { |
470 | | - self.config.hrn_config = hrn_config; |
471 | | - self |
472 | | - } |
473 | | - |
474 | 469 | /// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options |
475 | 470 | /// previously configured. |
476 | 471 | pub fn build(&self) -> Result<Node, BuildError> { |
@@ -852,11 +847,6 @@ impl ArcedNodeBuilder { |
852 | 847 | self.inner.write().unwrap().set_node_alias(node_alias).map(|_| ()) |
853 | 848 | } |
854 | 849 |
|
855 | | - /// Sets the default [`Config::hrn_config`] to be used when sending payments to HRNs. |
856 | | - pub fn set_hrn_config(&self, hrn_config: HumanReadableNamesConfig) { |
857 | | - self.inner.write().unwrap().set_hrn_config(hrn_config); |
858 | | - } |
859 | | - |
860 | 850 | /// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options |
861 | 851 | /// previously configured. |
862 | 852 | pub fn build(&self) -> Result<Arc<Node>, BuildError> { |
@@ -1509,6 +1499,12 @@ fn build_with_store_internal( |
1509 | 1499 | }, |
1510 | 1500 | }; |
1511 | 1501 |
|
| 1502 | + if let Some(hrn_config) = &config.hrn_config { |
| 1503 | + if hrn_config.dns_resolvers_node_ids.is_empty() { |
| 1504 | + return Err(BuildError::DnsResolversUnavailable); |
| 1505 | + } |
| 1506 | + }; |
| 1507 | + |
1512 | 1508 | let (stop_sender, _) = tokio::sync::watch::channel(()); |
1513 | 1509 | let (event_handling_stopped_sender, _) = tokio::sync::watch::channel(()); |
1514 | 1510 |
|
|
0 commit comments