Skip to content

Add support for parsing the dns_resolver feature bit #3346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lightning-types/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
//! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information).
//! - `Trampoline` - supports receiving and forwarding Trampoline payments
//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) for more information).
//! - `DnsResolver` - supports resolving DNS names to TXT DNSSEC proofs for BIP 353 payments
//! (see [bLIP 32](https://github.com/lightning/blips/blob/master/blip-0032.md) for more information).
//!
//! LDK knows about the following features, but does not support them:
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
Expand Down Expand Up @@ -177,6 +179,10 @@ mod sealed {
ZeroConf | Keysend,
// Byte 7
Trampoline,
// Byte 8 - 31
,,,,,,,,,,,,,,,,,,,,,,,,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what ,,,,,,,,,,,,,,,,,,,,,,,, means in this case?

Copy link
Contributor

@jkczyz jkczyz Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are used by define_context! to form KNOWN_FEATURE_MASK, which needs bytes 8-31 zeroed.

// Byte 32
DnsResolver,
]
);
define_context!(ChannelContext, []);
Expand Down Expand Up @@ -565,6 +571,17 @@ mod sealed {
supports_trampoline_routing,
requires_trampoline_routing
);
define_feature!(
259,
DnsResolver,
[NodeContext],
"Feature flags for DNS resolving.",
set_dns_resolution_optional,
set_dns_resolution_required,
supports_dns_resolution,
requires_dns_resolution
);

// Note: update the module-level docs when a new feature bit is added!

#[cfg(any(test, feature = "_test_utils"))]
Expand Down
9 changes: 9 additions & 0 deletions lightning/src/onion_message/dns_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ use dnssec_prover::validation::verify_rr_stream;

use dnssec_prover::rr::Name;

use lightning_types::features::NodeFeatures;

use crate::blinded_path::message::DNSResolverContext;
use crate::io;
#[cfg(feature = "dnssec")]
Expand Down Expand Up @@ -67,6 +69,13 @@ pub trait DNSResolverMessageHandler {
/// With this, we should be able to validate the DNS record we requested.
fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext);

/// Gets the node feature flags which this handler itself supports. Useful for setting the
/// `dns_resolver` flag if this handler supports returning [`DNSSECProof`] messages in response
/// to [`DNSSECQuery`] messages.
fn provided_node_features(&self) -> NodeFeatures {
NodeFeatures::empty()
}

/// Release any [`DNSResolverMessage`]s that need to be sent.
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
vec![]
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/onion_message/messenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ where
fn provided_node_features(&self) -> NodeFeatures {
let mut features = NodeFeatures::empty();
features.set_onion_messages_optional();
features
features | self.dns_resolver_handler.provided_node_features()
}

fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
Expand Down
Loading