Skip to content

Commit 2c256c9

Browse files
committed
Add configuration options for HRN settings
Introduce new configuration parameters to manage Human-Readable Name (HRN) resolution and DNSSEC validation behavior. These settings allow users to define custom resolution preferences for BOLT12 offer lookups. Moving these parameters into the central configuration struct ensures that node behavior is customizable at runtime and consistent across different network environments. This abstraction is necessary to support diverse DNSSEC requirements without hard-coding resolution logic.
1 parent 9e0cfc5 commit 2c256c9

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

bindings/ldk_node.udl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dictionary Config {
1313
u64 probing_liquidity_limit_multiplier;
1414
AnchorChannelsConfig? anchor_channels_config;
1515
RouteParametersConfig? route_parameters;
16+
HumanReadableNamesConfig? hrn_config;
1617
};
1718

1819
dictionary AnchorChannelsConfig {
@@ -517,6 +518,16 @@ dictionary RouteParametersConfig {
517518
u8 max_channel_saturation_power_of_half;
518519
};
519520

521+
[Enum]
522+
interface HRNResolverConfig {
523+
Blip32();
524+
Dns(string dns_server_address, boolean enable_hrn_resolution_service);
525+
};
526+
527+
dictionary HumanReadableNamesConfig {
528+
HRNResolverConfig resolution_config;
529+
};
530+
520531
dictionary CustomTlvRecord {
521532
u64 type_num;
522533
sequence<u8> value;

src/config.rs

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ pub(crate) const HRN_RESOLUTION_TIMEOUT_SECS: u64 = 5;
127127
/// | `probing_liquidity_limit_multiplier` | 3 |
128128
/// | `log_level` | Debug |
129129
/// | `anchor_channels_config` | Some(..) |
130-
/// | `route_parameters` | None |
130+
/// | `route_parameters` | None |
131+
/// | `hrn_config` | Some(..) |
131132
///
132133
/// See [`AnchorChannelsConfig`] and [`RouteParametersConfig`] for more information regarding their
133134
/// respective default values.
@@ -192,6 +193,18 @@ pub struct Config {
192193
/// **Note:** If unset, default parameters will be used, and you will be able to override the
193194
/// parameters on a per-payment basis in the corresponding method calls.
194195
pub route_parameters: Option<RouteParametersConfig>,
196+
/// Configuration options for Human-Readable Names ([BIP 353]).
197+
///
198+
/// By default, this uses the `Dns` variant with the following settings:
199+
/// * **DNS Server**: `8.8.8.8:53` (Google Public DNS)
200+
/// * **Resolution Service**: Enabled (`true`)
201+
///
202+
/// **Note:** Enabling `enable_hrn_resolution_service` is only one part of the
203+
/// configuration. For resolution to function correctly, the local node must
204+
/// also be configured as an **announceable node** within the network.
205+
///
206+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
207+
pub hrn_config: Option<HumanReadableNamesConfig>,
195208
}
196209

197210
impl Default for Config {
@@ -206,6 +219,57 @@ impl Default for Config {
206219
anchor_channels_config: Some(AnchorChannelsConfig::default()),
207220
route_parameters: None,
208221
node_alias: None,
222+
hrn_config: Some(HumanReadableNamesConfig::default()),
223+
}
224+
}
225+
}
226+
227+
/// Configuration options for how our node resolves Human-Readable Names (HRNs) when acting as a client.
228+
#[derive(Debug, Clone)]
229+
pub enum HRNResolverConfig {
230+
/// Use bLIP-32 to ask other nodes to resolve names for us.
231+
Blip32,
232+
/// Resolve names locally using a specific DNS server.
233+
Dns {
234+
/// The IP and port of the DNS server.
235+
/// **Default:** `8.8.8.8:53` (Google Public DNS)
236+
dns_server_address: String,
237+
/// If set to true, this allows others to use our node for HRN resolutions ([bLIP-32]).
238+
///
239+
/// **Note:** This feature requires the underlying node to be announceable.
240+
///
241+
/// [bLIP-32]: https://github.com/lightning/blips/blob/master/blip-0032.md
242+
enable_hrn_resolution_service: bool,
243+
},
244+
}
245+
246+
/// Configuration options for Human-Readable Names ([BIP 353]).
247+
/// By default, this uses the `Dns` variant with the following settings:
248+
/// * **DNS Server**: `8.8.8.8:53` (Google Public DNS)
249+
/// * **Resolution Service**: Enabled (`true`)
250+
///
251+
/// **Note:** Enabling `enable_hrn_resolution_service` is only one part of the
252+
/// configuration. For resolution to function correctly, the local node must
253+
/// also be configured as an **announceable node** within the network.
254+
///
255+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
256+
#[derive(Debug, Clone)]
257+
pub struct HumanReadableNamesConfig {
258+
/// This sets how our node resolves names when we want to send a payment.
259+
///
260+
/// By default, this uses the `Dns` variant with the following settings:
261+
/// * **DNS Server**: `8.8.8.8:53` (Google Public DNS)
262+
/// * **Resolution Service**: Enabled (`true`)
263+
pub resolution_config: HRNResolverConfig,
264+
}
265+
266+
impl Default for HumanReadableNamesConfig {
267+
fn default() -> Self {
268+
HumanReadableNamesConfig {
269+
resolution_config: HRNResolverConfig::Dns {
270+
dns_server_address: "8.8.8.8:53".to_string(),
271+
enable_hrn_resolution_service: true,
272+
},
209273
}
210274
}
211275
}

src/ffi/types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ pub use vss_client::headers::{VssHeaderProvider, VssHeaderProviderError};
4646
use crate::builder::sanitize_alias;
4747
pub use crate::config::{
4848
default_config, AnchorChannelsConfig, BackgroundSyncConfig, ElectrumSyncConfig,
49-
EsploraSyncConfig, MaxDustHTLCExposure, SyncTimeoutsConfig,
49+
EsploraSyncConfig, HRNResolverConfig, HumanReadableNamesConfig, MaxDustHTLCExposure,
50+
SyncTimeoutsConfig,
5051
};
5152
pub use crate::entropy::{generate_entropy_mnemonic, EntropyError, NodeEntropy, WordCount};
5253
use crate::error::Error;

0 commit comments

Comments
 (0)