Skip to content

Commit a952d2d

Browse files
authored
Merge pull request #3346 from TheBlueMatt/2024-10-dns-feature-flag
Add support for parsing the dns_resolver feature bit
2 parents f94bf98 + 457b634 commit a952d2d

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lightning-types/src/features.rs

+17
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
//! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information).
6969
//! - `Trampoline` - supports receiving and forwarding Trampoline payments
7070
//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) for more information).
71+
//! - `DnsResolver` - supports resolving DNS names to TXT DNSSEC proofs for BIP 353 payments
72+
//! (see [bLIP 32](https://github.com/lightning/blips/blob/master/blip-0032.md) for more information).
7173
//!
7274
//! LDK knows about the following features, but does not support them:
7375
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
@@ -174,6 +176,10 @@ mod sealed {
174176
ZeroConf | Keysend,
175177
// Byte 7
176178
Trampoline,
179+
// Byte 8 - 31
180+
,,,,,,,,,,,,,,,,,,,,,,,,
181+
// Byte 32
182+
DnsResolver,
177183
]
178184
);
179185
define_context!(ChannelContext, []);
@@ -562,6 +568,17 @@ mod sealed {
562568
supports_trampoline_routing,
563569
requires_trampoline_routing
564570
);
571+
define_feature!(
572+
259,
573+
DnsResolver,
574+
[NodeContext],
575+
"Feature flags for DNS resolving.",
576+
set_dns_resolution_optional,
577+
set_dns_resolution_required,
578+
supports_dns_resolution,
579+
requires_dns_resolution
580+
);
581+
565582
// Note: update the module-level docs when a new feature bit is added!
566583

567584
#[cfg(any(test, feature = "_test_utils"))]

lightning/src/onion_message/dns_resolution.rs

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ use dnssec_prover::validation::verify_rr_stream;
3434

3535
use dnssec_prover::rr::Name;
3636

37+
use lightning_types::features::NodeFeatures;
38+
3739
use crate::blinded_path::message::DNSResolverContext;
3840
use crate::io;
3941
#[cfg(feature = "dnssec")]
@@ -67,6 +69,13 @@ pub trait DNSResolverMessageHandler {
6769
/// With this, we should be able to validate the DNS record we requested.
6870
fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext);
6971

72+
/// Gets the node feature flags which this handler itself supports. Useful for setting the
73+
/// `dns_resolver` flag if this handler supports returning [`DNSSECProof`] messages in response
74+
/// to [`DNSSECQuery`] messages.
75+
fn provided_node_features(&self) -> NodeFeatures {
76+
NodeFeatures::empty()
77+
}
78+
7079
/// Release any [`DNSResolverMessage`]s that need to be sent.
7180
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
7281
vec![]

lightning/src/onion_message/messenger.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ where
17781778
fn provided_node_features(&self) -> NodeFeatures {
17791779
let mut features = NodeFeatures::empty();
17801780
features.set_onion_messages_optional();
1781-
features
1781+
features | self.dns_resolver_handler.provided_node_features()
17821782
}
17831783

17841784
fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {

0 commit comments

Comments
 (0)