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 } ;
1313use crate :: error:: Error ;
1414use crate :: logger:: { log_error, log_info, LdkLogger , Logger } ;
1515use crate :: payment:: store:: {
@@ -23,7 +23,6 @@ use lightning::offers::offer::{Amount, Offer, Quantity};
2323use lightning:: offers:: parse:: Bolt12SemanticError ;
2424use lightning:: offers:: refund:: Refund ;
2525use lightning:: onion_message:: dns_resolution:: HumanReadableName ;
26- use lightning:: onion_message:: messenger:: Destination ;
2726use lightning:: util:: string:: UntrustedString ;
2827
2928use rand:: RngCore ;
@@ -43,15 +42,16 @@ pub struct Bolt12Payment {
4342 channel_manager : Arc < ChannelManager > ,
4443 payment_store : Arc < PaymentStore < Arc < Logger > > > ,
4544 logger : Arc < Logger > ,
45+ config : Arc < Config > ,
4646}
4747
4848impl Bolt12Payment {
4949 pub ( crate ) fn new (
5050 runtime : Arc < RwLock < Option < Arc < tokio:: runtime:: Runtime > > > > ,
5151 channel_manager : Arc < ChannelManager > , payment_store : Arc < PaymentStore < Arc < Logger > > > ,
52- logger : Arc < Logger > ,
52+ logger : Arc < Logger > , config : Arc < Config > ,
5353 ) -> Self {
54- Self { runtime, channel_manager, payment_store, logger }
54+ Self { runtime, channel_manager, payment_store, logger, config }
5555 }
5656
5757 /// Send a payment given an offer.
@@ -266,11 +266,9 @@ impl Bolt12Payment {
266266 /// This can be used to pay so-called "zero-amount" offers, i.e., an offer that leaves the
267267 /// amount paid to be determined by the user.
268268 ///
269- /// `dns_resolvers` should be a list of node Destinations that are configured for dns resolution (as outlined in bLIP 32).
270- /// These nodes can be found by running a search through the `NetworkGraph` to find nodes that announce the
271- /// `dns_resolver` feature flag.
269+ /// If `dns_resolvers` in Config is set to `None`, this operation will fail.
272270 pub fn send_to_human_readable_name (
273- & self , name : & str , amount_msat : u64 , dns_resolvers : Vec < Destination > ,
271+ & self , name : & str , amount_msat : u64 ,
274272 ) -> Result < PaymentId , Error > {
275273 let rt_lock = self . runtime . read ( ) . unwrap ( ) ;
276274 if rt_lock. is_none ( ) {
@@ -285,6 +283,11 @@ impl Bolt12Payment {
285283 let retry_strategy = Retry :: Timeout ( LDK_PAYMENT_RETRY_TIMEOUT ) ;
286284 let max_total_routing_fee_msat = None ;
287285
286+ let dns_resolvers = match & self . config . dns_resolvers {
287+ Some ( dns_resolvers) => Ok ( dns_resolvers. clone ( ) ) ,
288+ None => Err ( Error :: DnsResolversNotConfigured ) ,
289+ } ?;
290+
288291 match self . channel_manager . pay_for_offer_from_human_readable_name (
289292 hrn. clone ( ) ,
290293 amount_msat,
0 commit comments