File tree Expand file tree Collapse file tree 4 files changed +17
-14
lines changed
Expand file tree Collapse file tree 4 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -256,7 +256,7 @@ interface LSPS1Liquidity {
256256};
257257
258258interface HumanReadableName {
259- [Name=from_encoded]
259+ [Throws=NodeError, Name=from_encoded]
260260 constructor([ByRef] string encoded);
261261 string user();
262262 string domain();
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ pub enum Error {
123123 /// Parsing a Human-Readable Name has failed
124124 HrnParsingFailed ,
125125 /// The given operation failed due to `dns-resolvers` not being configured in builder.
126- DnsResolversNotConfigured ,
126+ DnsResolversUnavailable ,
127127}
128128
129129impl fmt:: Display for Error {
@@ -200,7 +200,7 @@ impl fmt::Display for Error {
200200 Self :: HrnParsingFailed => {
201201 write ! ( f, "Failed to parse a human-readable name." )
202202 } ,
203- Self :: DnsResolversNotConfigured => {
203+ Self :: DnsResolversUnavailable => {
204204 write ! ( f, "The given operation failed due to `dns-resolvers` not being configured in builder." )
205205 } ,
206206 }
Original file line number Diff line number Diff line change @@ -280,6 +280,8 @@ impl Bolt12Payment {
280280 /// amount paid to be determined by the user.
281281 ///
282282 /// If `dns_resolvers_node_ids` in [`Config.hrn_config`] is empty, this operation will fail.
283+ ///
284+ /// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
283285 pub fn send_to_human_readable_name (
284286 & self , hrn : HumanReadableName , amount_msat : u64 ,
285287 ) -> Result < PaymentId , Error > {
@@ -294,13 +296,14 @@ impl Bolt12Payment {
294296 let retry_strategy = Retry :: Timeout ( LDK_PAYMENT_RETRY_TIMEOUT ) ;
295297 let max_total_routing_fee_msat = None ;
296298
297- let destinations: Vec < Destination > = self
298- . config
299- . hrn_config
300- . dns_resolvers_node_ids
301- . iter ( )
302- . map ( |node_id| Destination :: Node ( * node_id) )
303- . collect ( ) ;
299+ let destinations: Vec < Destination > = match & self . config . hrn_config {
300+ Some ( hrn_config) => Ok ( hrn_config
301+ . dns_resolvers_node_ids
302+ . iter ( )
303+ . map ( |node_id| Destination :: Node ( * node_id) )
304+ . collect ( ) ) ,
305+ None => Err ( Error :: DnsResolversUnavailable ) ,
306+ } ?;
304307
305308 let hrn = maybe_convert_hrn ( hrn) ;
306309
Original file line number Diff line number Diff line change @@ -667,13 +667,13 @@ impl HumanReadableName {
667667 self . inner . clone ( )
668668 }
669669
670- pub fn from_encoded ( encoded : & str ) -> Self {
670+ pub fn from_encoded ( encoded : & str ) -> Result < Self , Error > {
671671 let hrn = match LdkHumanReadableName :: from_encoded ( encoded) {
672672 Ok ( hrn) => Ok ( hrn) ,
673- Err ( e ) => Err ( format ! ( " Error creating HRN {:?}" , e ) ) ,
674- } ;
673+ Err ( _ ) => Err ( Error :: HrnParsingFailed ) ,
674+ } ? ;
675675
676- Self { inner : hrn. expect ( "Error creating HRN" ) }
676+ Ok ( Self { inner : hrn } )
677677 }
678678
679679 pub fn user ( & self ) -> String {
You can’t perform that action at this time.
0 commit comments