Skip to content

Commit d071ce2

Browse files
authored
Merge pull request #6 from TheBlueMatt/2025-06-onion-resolution
Add an onion message-based DNSSEC HRN Resolver
2 parents bc474c0 + dc2b29a commit d071ce2

File tree

9 files changed

+435
-98
lines changed

9 files changed

+435
-98
lines changed

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[features]
1717
http = ["reqwest", "std", "serde", "serde_json"]
18-
std = ["dnssec-prover"]
18+
std = ["dnssec-prover", "getrandom"]
1919
default = ["std"]
2020

2121
[dependencies]
2222
lightning-invoice = { version = "0.33", default-features = false }
2323
lightning = { version = "0.1", default-features = false, features = ["dnssec"] }
2424
bitcoin = { version = "0.32", default-features = false }
25-
getrandom = { version = "0.3", default-features = false }
25+
getrandom = { version = "0.3", default-features = false, optional = true }
2626
dnssec-prover = { version = "0.6", default-features = false, optional = true, features = ["validation", "std", "tokio"] }
2727
reqwest = { version = "0.11", default-features = false, optional = true, features = ["rustls-tls-webpki-roots", "json"] }
2828
serde = { version = "1.0", default-features = false, optional = true, features = ["derive"] }
2929
serde_json = { version = "1.0", default-features = false, optional = true, features = ["alloc"] }
3030

3131
[dev-dependencies]
3232
tokio = { version = "1.0", default-features = false, features = ["rt", "macros"] }
33+
lightning = { version = "0.1", features = ["std"] }
34+
lightning-net-tokio = { version = "0.1", default-features = false }

ci/ci-tests.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ cargo check --verbose --color always
1313
cargo check --release --verbose --color always
1414
cargo test --no-default-features
1515
[ "$RUSTC_MINOR_VERSION" -gt 81 ] && cargo test --features http
16-
cargo test --features std
16+
# One std test syncs much of the lightning network graph, so --release is a must
17+
# At least until https://github.com/lightningdevkit/rust-lightning/pull/3687 gets backported
18+
export RUSTFLAGS="-C debug-assertions=on"
19+
cargo test --features std --release
1720
[ "$RUSTC_MINOR_VERSION" -gt 81 ] && cargo doc --document-private-items --no-default-features
1821
[ "$RUSTC_MINOR_VERSION" -gt 81 ] && cargo doc --document-private-items --features http,std
1922
exit 0

fuzz/src/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use bitcoin::Network;
1111

1212
use bitcoin_payment_instructions::amount::Amount;
13-
use bitcoin_payment_instructions::hrn::HumanReadableName;
1413
use bitcoin_payment_instructions::hrn_resolution::{
15-
DummyHrnResolver, HrnResolution, HrnResolutionFuture, HrnResolver, LNURLResolutionFuture,
14+
DummyHrnResolver, HrnResolution, HrnResolutionFuture, HrnResolver, HumanReadableName,
15+
LNURLResolutionFuture,
1616
};
1717
use bitcoin_payment_instructions::PaymentInstructions;
1818

src/dns_resolver.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ use dnssec_prover::rr::Name;
99

1010
use crate::amount::Amount;
1111
use crate::dnssec_utils::resolve_proof;
12-
use crate::hrn::HumanReadableName;
1312
use crate::hrn_resolution::{
14-
HrnResolution, HrnResolutionFuture, HrnResolver, LNURLResolutionFuture,
13+
HrnResolution, HrnResolutionFuture, HrnResolver, HumanReadableName, LNURLResolutionFuture,
1514
};
1615

1716
/// An [`HrnResolver`] which resolves BIP 353 Human Readable Names to payment instructions using a
@@ -59,7 +58,7 @@ mod tests {
5958
use crate::*;
6059

6160
#[tokio::test]
62-
async fn test_http_hrn_resolver() {
61+
async fn test_dns_hrn_resolver() {
6362
let resolver = DNSHrnResolver(SocketAddr::from_str("8.8.8.8:53").unwrap());
6463
let instructions = PaymentInstructions::parse(
6564

src/hrn.rs

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/hrn_resolution.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
//! associated types in this module.
88
99
use crate::amount::Amount;
10-
use crate::hrn::HumanReadableName;
1110

1211
use lightning_invoice::Bolt11Invoice;
1312

13+
pub use lightning::onion_message::dns_resolution::HumanReadableName;
14+
1415
use core::future::Future;
1516
use core::pin::Pin;
1617

src/http_resolver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescriptionRef};
1717

1818
use crate::amount::Amount;
1919
use crate::dnssec_utils::resolve_proof;
20-
use crate::hrn::HumanReadableName;
2120
use crate::hrn_resolution::{
22-
HrnResolution, HrnResolutionFuture, HrnResolver, LNURLResolutionFuture,
21+
HrnResolution, HrnResolutionFuture, HrnResolver, HumanReadableName, LNURLResolutionFuture,
2322
};
2423

2524
const DOH_ENDPOINT: &'static str = "https://dns.google/dns-query?dns=";

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ pub mod dns_resolver;
5757
#[cfg(feature = "http")]
5858
pub mod http_resolver;
5959

60+
#[cfg(feature = "std")] // TODO: Drop once we upgrade to LDK 0.2
61+
pub mod onion_message_resolver;
62+
6063
pub mod amount;
6164

6265
pub mod receive;
6366

6467
pub mod hrn_resolution;
6568

66-
pub mod hrn;
67-
6869
use amount::Amount;
69-
use hrn::HumanReadableName;
70-
use hrn_resolution::{HrnResolution, HrnResolver};
70+
use hrn_resolution::{HrnResolution, HrnResolver, HumanReadableName};
7171

7272
/// A method which can be used to make a payment
7373
#[derive(Clone, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)