Skip to content

Commit 9e7b889

Browse files
committed
Allow setting default DNS resolvers for HRNs
1 parent ae879f3 commit 9e7b889

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

bindings/ldk_node.udl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ dictionary Config {
1313
u64 probing_liquidity_limit_multiplier;
1414
AnchorChannelsConfig? anchor_channels_config;
1515
SendingParameters? sending_parameters;
16+
HumanReadableNamesConfig? hrn_config;
17+
};
18+
19+
dictionary HumanReadableNamesConfig {
20+
sequence<PublicKey> dns_resolvers_node_ids;
1621
};
1722

1823
dictionary AnchorChannelsConfig {
@@ -312,6 +317,7 @@ enum NodeError {
312317
"LiquiditySourceUnavailable",
313318
"LiquidityFeeTooHigh",
314319
"HrnParsingFailed",
320+
"DnsResolversUnavailable",
315321
};
316322

317323
dictionary NodeStatus {
@@ -347,6 +353,7 @@ enum BuildError {
347353
"WalletSetupFailed",
348354
"LoggerSetupFailed",
349355
"NetworkMismatch",
356+
"DnsResolversUnavailable",
350357
};
351358

352359
[Trait]

src/builder.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ pub enum BuildError {
174174
LoggerSetupFailed,
175175
/// The given network does not match the node's previously configured network.
176176
NetworkMismatch,
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,
177181
}
178182

179183
impl fmt::Display for BuildError {
@@ -201,6 +205,9 @@ impl fmt::Display for BuildError {
201205
Self::NetworkMismatch => {
202206
write!(f, "Given network does not match the node's previously configured network.")
203207
},
208+
Self::DnsResolversUnavailable => {
209+
write!(f, "The DNS resolvers provided for HRN resolution is empty.")
210+
},
204211
}
205212
}
206213
}
@@ -1492,6 +1499,12 @@ fn build_with_store_internal(
14921499
},
14931500
};
14941501

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+
14951508
let (stop_sender, _) = tokio::sync::watch::channel(());
14961509
let (event_handling_stopped_sender, _) = tokio::sync::watch::channel(());
14971510

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub const WALLET_KEYS_SEED_LEN: usize = 64;
103103
/// | `log_level` | Debug |
104104
/// | `anchor_channels_config` | Some(..) |
105105
/// | `sending_parameters` | None |
106+
/// | `hrn_config` | None |
106107
///
107108
/// See [`AnchorChannelsConfig`] and [`SendingParameters`] for more information regarding their
108109
/// respective default values.
@@ -167,6 +168,10 @@ pub struct Config {
167168
/// **Note:** If unset, default parameters will be used, and you will be able to override the
168169
/// parameters on a per-payment basis in the corresponding method calls.
169170
pub sending_parameters: Option<SendingParameters>,
171+
/// Configuration options for Human-Readable Names ([BIP 353]).
172+
///
173+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
174+
pub hrn_config: Option<HumanReadableNamesConfig>,
170175
}
171176

172177
impl Default for Config {
@@ -181,6 +186,7 @@ impl Default for Config {
181186
anchor_channels_config: Some(AnchorChannelsConfig::default()),
182187
sending_parameters: None,
183188
node_alias: None,
189+
hrn_config: None,
184190
}
185191
}
186192
}

0 commit comments

Comments
 (0)