-
Notifications
You must be signed in to change notification settings - Fork 112
Add support for resolving BIP 353 Human-Readable Names #630
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
base: main
Are you sure you want to change the base?
Changes from all commits
9ea92d5
b11fead
998bdab
55522b9
f1d1fa1
869839a
38e17d1
da52af8
7973b8c
6068c1c
2149475
0517dbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ dictionary Config { | |
u64 probing_liquidity_limit_multiplier; | ||
AnchorChannelsConfig? anchor_channels_config; | ||
SendingParameters? sending_parameters; | ||
boolean is_hrn_resolver; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I think over at the first PR we discussed to introduce a dedicated config for HRN-related things, also to specify default resolvers, for example? Probably this should be part of such a config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we did - I'll re-introduce the dedicated config for HRN-related things. |
||
}; | ||
|
||
dictionary AnchorChannelsConfig { | ||
|
@@ -127,7 +128,7 @@ interface Node { | |
Bolt12Payment bolt12_payment(); | ||
SpontaneousPayment spontaneous_payment(); | ||
OnchainPayment onchain_payment(); | ||
UnifiedQrPayment unified_qr_payment(); | ||
UnifiedPayment unified_payment(); | ||
LSPS1Liquidity lsps1_liquidity(); | ||
[Throws=NodeError] | ||
void connect(PublicKey node_id, SocketAddress address, boolean persist); | ||
|
@@ -243,11 +244,11 @@ interface FeeRate { | |
u64 to_sat_per_vb_ceil(); | ||
}; | ||
|
||
interface UnifiedQrPayment { | ||
interface UnifiedPayment { | ||
[Throws=NodeError] | ||
string receive(u64 amount_sats, [ByRef]string message, u32 expiry_sec); | ||
[Throws=NodeError] | ||
QrPaymentResult send([ByRef]string uri_str); | ||
[Throws=NodeError, Async] | ||
UnifiedPaymentResult send([ByRef]string uri_str, u64? amount_msat); | ||
}; | ||
|
||
interface LSPS1Liquidity { | ||
|
@@ -311,6 +312,7 @@ enum NodeError { | |
"InsufficientFunds", | ||
"LiquiditySourceUnavailable", | ||
"LiquidityFeeTooHigh", | ||
"HrnResolverNotConfigured", | ||
}; | ||
|
||
dictionary NodeStatus { | ||
|
@@ -347,6 +349,7 @@ enum BuildError { | |
"WalletSetupFailed", | ||
"LoggerSetupFailed", | ||
"NetworkMismatch", | ||
"DNSResolverSetupFailed", | ||
}; | ||
|
||
[Trait] | ||
|
@@ -418,7 +421,7 @@ interface PaymentKind { | |
}; | ||
|
||
[Enum] | ||
interface QrPaymentResult { | ||
interface UnifiedPaymentResult { | ||
Onchain(Txid txid); | ||
Bolt11(PaymentId payment_id); | ||
Bolt12(PaymentId payment_id); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ use crate::peer_store::PeerStore; | |
use crate::runtime::Runtime; | ||
use crate::tx_broadcaster::TransactionBroadcaster; | ||
use crate::types::{ | ||
ChainMonitor, ChannelManager, DynStore, GossipSync, Graph, KeysManager, MessageRouter, | ||
OnionMessenger, PaymentStore, PeerManager, | ||
ChainMonitor, ChannelManager, DomainResolver, DynStore, GossipSync, Graph, HRNResolver, | ||
KeysManager, MessageRouter, OnionMessenger, PaymentStore, PeerManager, | ||
}; | ||
use crate::wallet::persist::KVStoreWalletPersister; | ||
use crate::wallet::Wallet; | ||
|
@@ -43,6 +43,7 @@ use lightning::io::Cursor; | |
use lightning::ln::channelmanager::{self, ChainParameters, ChannelManagerReadArgs}; | ||
use lightning::ln::msgs::{RoutingMessageHandler, SocketAddress}; | ||
use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler}; | ||
use lightning::onion_message::dns_resolution::DNSResolverMessageHandler; | ||
use lightning::routing::gossip::NodeAlias; | ||
use lightning::routing::router::DefaultRouter; | ||
use lightning::routing::scoring::{ | ||
|
@@ -59,6 +60,8 @@ use lightning::util::sweep::OutputSweeper; | |
|
||
use lightning_persister::fs_store::FilesystemStore; | ||
|
||
use lightning_dns_resolver::OMDomainResolver; | ||
|
||
use bdk_wallet::template::Bip84; | ||
use bdk_wallet::KeychainKind; | ||
use bdk_wallet::Wallet as BdkWallet; | ||
|
@@ -80,6 +83,8 @@ use std::sync::{Arc, Mutex, Once, RwLock}; | |
use std::time::SystemTime; | ||
use vss_client::headers::{FixedHeaders, LnurlAuthToJwtProvider, VssHeaderProvider}; | ||
|
||
use bitcoin_payment_instructions::onion_message_resolver::LDKOnionMessageDNSSECHrnResolver; | ||
|
||
const VSS_HARDENED_CHILD_INDEX: u32 = 877; | ||
const VSS_LNURL_AUTH_HARDENED_CHILD_INDEX: u32 = 138; | ||
const LSPS_HARDENED_CHILD_INDEX: u32 = 577; | ||
|
@@ -191,6 +196,8 @@ pub enum BuildError { | |
LoggerSetupFailed, | ||
/// The given network does not match the node's previously configured network. | ||
NetworkMismatch, | ||
/// An attempt to setup a DNS Resolver failed. | ||
DNSResolverSetupFailed, | ||
} | ||
|
||
impl fmt::Display for BuildError { | ||
|
@@ -219,12 +226,20 @@ impl fmt::Display for BuildError { | |
Self::NetworkMismatch => { | ||
write!(f, "Given network does not match the node's previously configured network.") | ||
}, | ||
Self::DNSResolverSetupFailed => { | ||
write!(f, "An attempt to setup a DNS resolver has failed.") | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for BuildError {} | ||
|
||
enum Resolver { | ||
HRN(Arc<HRNResolver>), | ||
DNS(Arc<DomainResolver>), | ||
} | ||
|
||
/// A builder for an [`Node`] instance, allowing to set some configuration and module choices from | ||
/// the getgo. | ||
/// | ||
|
@@ -1454,6 +1469,23 @@ fn build_with_store_internal( | |
})?; | ||
} | ||
|
||
let resolver = if config.is_hrn_resolver { | ||
Resolver::DNS(Arc::new(OMDomainResolver::ignoring_incoming_proofs( | ||
"8.8.8.8:53".parse().map_err(|_| BuildError::DNSResolverSetupFailed)?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to make the DNS server used configurable via the config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that makes sense - will do. |
||
))) | ||
} else { | ||
Resolver::HRN(Arc::new(LDKOnionMessageDNSSECHrnResolver::new(Arc::clone(&network_graph)))) | ||
}; | ||
|
||
let om_resolver = match resolver { | ||
Resolver::DNS(ref dns_resolver) => { | ||
Arc::clone(dns_resolver) as Arc<dyn DNSResolverMessageHandler + Send + Sync> | ||
}, | ||
Resolver::HRN(ref hrn_resolver) => { | ||
Arc::clone(hrn_resolver) as Arc<dyn DNSResolverMessageHandler + Send + Sync> | ||
}, | ||
}; | ||
|
||
// Initialize the PeerManager | ||
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new( | ||
Arc::clone(&keys_manager), | ||
|
@@ -1463,7 +1495,7 @@ fn build_with_store_internal( | |
message_router, | ||
Arc::clone(&channel_manager), | ||
IgnoringMessageHandler {}, | ||
IgnoringMessageHandler {}, | ||
Arc::clone(&om_resolver), | ||
IgnoringMessageHandler {}, | ||
)); | ||
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes(); | ||
|
@@ -1589,6 +1621,18 @@ fn build_with_store_internal( | |
Arc::clone(&keys_manager), | ||
)); | ||
|
||
let peer_manager_clone = Arc::clone(&peer_manager); | ||
|
||
let hrn_resolver = match resolver { | ||
Resolver::DNS(_) => None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, so if we're resolving for others, we won't be able to send to HRNs ourselves? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my understanding, it seems this is the case. The onion messenger can take only one type of |
||
Resolver::HRN(ref hrn_resolver) => { | ||
hrn_resolver.register_post_queue_action(Box::new(move || { | ||
peer_manager_clone.process_events(); | ||
})); | ||
Some(hrn_resolver) | ||
}, | ||
}; | ||
|
||
liquidity_source.as_ref().map(|l| l.set_peer_manager(Arc::clone(&peer_manager))); | ||
|
||
gossip_source.set_gossip_verifier( | ||
|
@@ -1696,6 +1740,7 @@ fn build_with_store_internal( | |
is_running, | ||
is_listening, | ||
node_metrics, | ||
hrn_resolver: hrn_resolver.cloned(), | ||
}) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this above to the group(s) of
lightning-*
imports (also the commented-out ones) and follow the scheme there.