Skip to content

Commit 6893fe7

Browse files
committed
fixup! Add support for sending to human-readable names that resolve to Bolt12 Offers
1 parent 1276068 commit 6893fe7

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ impl Node {
872872
Arc::clone(&self.channel_manager),
873873
Arc::clone(&self.payment_store),
874874
Arc::clone(&self.logger),
875+
Arc::clone(&self.config),
875876
)
876877
}
877878

@@ -885,6 +886,7 @@ impl Node {
885886
Arc::clone(&self.channel_manager),
886887
Arc::clone(&self.payment_store),
887888
Arc::clone(&self.logger),
889+
Arc::clone(&self.config),
888890
))
889891
}
890892

src/payment/bolt12.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
1111
12-
use crate::config::LDK_PAYMENT_RETRY_TIMEOUT;
12+
use crate::config::{Config, LDK_PAYMENT_RETRY_TIMEOUT};
1313
use crate::error::Error;
1414
use crate::ffi::{maybe_deref, maybe_wrap};
1515
use crate::logger::{log_error, log_info, LdkLogger, Logger};
@@ -53,15 +53,16 @@ pub struct Bolt12Payment {
5353
channel_manager: Arc<ChannelManager>,
5454
payment_store: Arc<PaymentStore>,
5555
logger: Arc<Logger>,
56+
config: Arc<Config>,
5657
}
5758

5859
impl Bolt12Payment {
5960
pub(crate) fn new(
6061
runtime: Arc<RwLock<Option<Arc<tokio::runtime::Runtime>>>>,
6162
channel_manager: Arc<ChannelManager>, payment_store: Arc<PaymentStore>,
62-
logger: Arc<Logger>,
63+
logger: Arc<Logger>, config: Arc<Config>,
6364
) -> Self {
64-
Self { runtime, channel_manager, payment_store, logger }
65+
Self { runtime, channel_manager, payment_store, logger, config }
6566
}
6667

6768
/// Send a payment given an offer.
@@ -278,11 +279,9 @@ impl Bolt12Payment {
278279
/// This can be used to pay so-called "zero-amount" offers, i.e., an offer that leaves the
279280
/// amount paid to be determined by the user.
280281
///
281-
/// `dns_resolvers` should be a list of node Destinations that are configured for dns resolution (as outlined in bLIP 32).
282-
/// These nodes can be found by running a search through the `NetworkGraph` to find nodes that announce the
283-
/// `dns_resolver` feature flag.
282+
/// If `dns_resolvers` in Config is set to `None`, this operation will fail.
284283
pub fn send_to_human_readable_name(
285-
&self, name: &str, amount_msat: u64, dns_resolvers: Vec<Destination>,
284+
&self, name: &str, amount_msat: u64,
286285
) -> Result<PaymentId, Error> {
287286
let rt_lock = self.runtime.read().unwrap();
288287
if rt_lock.is_none() {
@@ -297,6 +296,11 @@ impl Bolt12Payment {
297296
let retry_strategy = Retry::Timeout(LDK_PAYMENT_RETRY_TIMEOUT);
298297
let max_total_routing_fee_msat = None;
299298

299+
let dns_resolvers = match &self.config.dns_resolvers {
300+
Some(dns_resolvers) => Ok(dns_resolvers.clone()),
301+
None => Err(Error::DnsResolversNotConfigured),
302+
}?;
303+
300304
match self.channel_manager.pay_for_offer_from_human_readable_name(
301305
hrn.clone(),
302306
amount_msat,

0 commit comments

Comments
 (0)