Skip to content

Commit c9aa7bf

Browse files
committed
Add config options for HRN-related settings
1 parent 4889edc commit c9aa7bf

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

src/builder.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,11 +1503,20 @@ fn build_with_store_internal(
15031503
})?;
15041504
}
15051505

1506-
let resolver = if config.is_hrn_resolver {
1507-
Resolver::DNS(Arc::new(OMDomainResolver::ignoring_incoming_proofs(
1508-
"8.8.8.8:53".parse().map_err(|_| BuildError::DNSResolverSetupFailed)?,
1509-
)))
1506+
let resolver = if let Some(hrn_config) = &config.hrn_config {
1507+
if hrn_config.is_hrn_resolver {
1508+
let dns_addr = hrn_config.dns_server_address.as_str();
1509+
1510+
Resolver::DNS(Arc::new(OMDomainResolver::ignoring_incoming_proofs(
1511+
dns_addr.parse().map_err(|_| BuildError::DNSResolverSetupFailed)?,
1512+
)))
1513+
} else {
1514+
Resolver::HRN(Arc::new(LDKOnionMessageDNSSECHrnResolver::new(Arc::clone(
1515+
&network_graph,
1516+
))))
1517+
}
15101518
} else {
1519+
// hrn_config is None, default to the HRN resolver.
15111520
Resolver::HRN(Arc::new(LDKOnionMessageDNSSECHrnResolver::new(Arc::clone(&network_graph))))
15121521
};
15131522

src/config.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub const WALLET_KEYS_SEED_LEN: usize = 64;
114114
/// | `log_level` | Debug |
115115
/// | `anchor_channels_config` | Some(..) |
116116
/// | `route_parameters` | None |
117-
/// | `is_hrn_resolver` | false |
117+
/// | `hrn_config` | None |
118118
///
119119
/// See [`AnchorChannelsConfig`] and [`RouteParametersConfig`] for more information regarding their
120120
/// respective default values.
@@ -179,8 +179,10 @@ pub struct Config {
179179
/// **Note:** If unset, default parameters will be used, and you will be able to override the
180180
/// parameters on a per-payment basis in the corresponding method calls.
181181
pub route_parameters: Option<RouteParametersConfig>,
182-
/// This allows us to use our node as a DNS resolver for 3rd party HRN resolutions.
183-
pub is_hrn_resolver: bool,
182+
/// Configuration options for Human-Readable Names ([BIP 353]).
183+
///
184+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
185+
pub hrn_config: Option<HumanReadableNamesConfig>,
184186
}
185187

186188
impl Default for Config {
@@ -195,11 +197,28 @@ impl Default for Config {
195197
anchor_channels_config: Some(AnchorChannelsConfig::default()),
196198
route_parameters: None,
197199
node_alias: None,
198-
is_hrn_resolver: false,
200+
hrn_config: None,
199201
}
200202
}
201203
}
202204

205+
/// Configuration options for Human-Readable Names ([BIP 353]).
206+
///
207+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
208+
#[derive(Debug, Clone)]
209+
pub struct HumanReadableNamesConfig {
210+
/// The Default DNS resolvers to be used for resolving Human-Readable Names.
211+
///
212+
/// If not empty, the values set will be used as DNS resolvers when sending to HRNs.
213+
///
214+
/// **Note:** If empty, DNS resolvers would be selected from the network graph.
215+
pub default_dns_resolvers: Vec<PublicKey>,
216+
/// This allows us to use our node as a DNS resolver for 3rd party HRN resolutions.
217+
pub is_hrn_resolver: bool,
218+
/// The DNS Server which will be used for resolving HRNs.
219+
pub dns_server_address: String,
220+
}
221+
203222
/// Configuration options pertaining to 'Anchor' channels, i.e., channels for which the
204223
/// `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
205224
///

tests/common/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use bitcoin::{
2828
use electrsd::corepc_node::{Client as BitcoindClient, Node as BitcoinD};
2929
use electrsd::{corepc_node, ElectrsD};
3030
use electrum_client::ElectrumApi;
31-
use ldk_node::config::{AsyncPaymentsRole, Config, ElectrumSyncConfig, EsploraSyncConfig};
31+
use ldk_node::config::{
32+
AsyncPaymentsRole, Config, ElectrumSyncConfig, EsploraSyncConfig, HumanReadableNamesConfig,
33+
};
3234
use ldk_node::io::sqlite_store::SqliteStore;
3335
use ldk_node::payment::{PaymentDirection, PaymentKind, PaymentStatus};
3436
use ldk_node::{
@@ -290,7 +292,11 @@ pub(crate) fn setup_two_nodes(
290292
println!("\n== Node B ==");
291293
let mut config_b = random_config(anchor_channels);
292294
if second_node_is_hrn_resolver {
293-
config_b.node_config.is_hrn_resolver = true;
295+
config_b.node_config.hrn_config = Some(HumanReadableNamesConfig {
296+
default_dns_resolvers: Vec::new(),
297+
is_hrn_resolver: true,
298+
dns_server_address: "8.8.8.8:53".to_string(),
299+
});
294300
}
295301
if allow_0conf {
296302
config_b.node_config.trusted_peers_0conf.push(node_a.node_id());

tests/integration_tests_rust.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// accordance with one or both of these licenses.
77

88
mod common;
9-
use lightning::util::persist::KVStoreSync;
109
use std::collections::HashSet;
1110
use std::str::FromStr;
1211
use std::sync::Arc;

0 commit comments

Comments
 (0)