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 {
256
256
};
257
257
258
258
interface HumanReadableName {
259
- [Name=from_encoded]
259
+ [Throws=NodeError, Name=from_encoded]
260
260
constructor([ByRef] string encoded);
261
261
string user();
262
262
string domain();
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ pub enum Error {
123
123
/// Parsing a Human-Readable Name has failed
124
124
HrnParsingFailed ,
125
125
/// The given operation failed due to `dns-resolvers` not being configured in builder.
126
- DnsResolversNotConfigured ,
126
+ DnsResolversUnavailable ,
127
127
}
128
128
129
129
impl fmt:: Display for Error {
@@ -200,7 +200,7 @@ impl fmt::Display for Error {
200
200
Self :: HrnParsingFailed => {
201
201
write ! ( f, "Failed to parse a human-readable name." )
202
202
} ,
203
- Self :: DnsResolversNotConfigured => {
203
+ Self :: DnsResolversUnavailable => {
204
204
write ! ( f, "The given operation failed due to `dns-resolvers` not being configured in builder." )
205
205
} ,
206
206
}
Original file line number Diff line number Diff line change @@ -295,6 +295,8 @@ impl Bolt12Payment {
295
295
/// amount paid to be determined by the user.
296
296
///
297
297
/// If `dns_resolvers_node_ids` in [`Config.hrn_config`] is empty, this operation will fail.
298
+ ///
299
+ /// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
298
300
pub fn send_to_human_readable_name (
299
301
& self , hrn : HumanReadableName , amount_msat : u64 ,
300
302
) -> Result < PaymentId , Error > {
@@ -309,13 +311,14 @@ impl Bolt12Payment {
309
311
let retry_strategy = Retry :: Timeout ( LDK_PAYMENT_RETRY_TIMEOUT ) ;
310
312
let max_total_routing_fee_msat = None ;
311
313
312
- let destinations: Vec < Destination > = self
313
- . config
314
- . hrn_config
315
- . dns_resolvers_node_ids
316
- . iter ( )
317
- . map ( |node_id| Destination :: Node ( * node_id) )
318
- . collect ( ) ;
314
+ let destinations: Vec < Destination > = match & self . config . hrn_config {
315
+ Some ( hrn_config) => Ok ( hrn_config
316
+ . dns_resolvers_node_ids
317
+ . iter ( )
318
+ . map ( |node_id| Destination :: Node ( * node_id) )
319
+ . collect ( ) ) ,
320
+ None => Err ( Error :: DnsResolversUnavailable ) ,
321
+ } ?;
319
322
320
323
let hrn = maybe_convert_hrn ( hrn) ;
321
324
Original file line number Diff line number Diff line change @@ -667,13 +667,13 @@ impl HumanReadableName {
667
667
self . inner . clone ( )
668
668
}
669
669
670
- pub fn from_encoded ( encoded : & str ) -> Self {
670
+ pub fn from_encoded ( encoded : & str ) -> Result < Self , Error > {
671
671
let hrn = match LdkHumanReadableName :: from_encoded ( encoded) {
672
672
Ok ( hrn) => Ok ( hrn) ,
673
- Err ( e ) => Err ( format ! ( " Error creating HRN {:?}" , e ) ) ,
674
- } ;
673
+ Err ( _ ) => Err ( Error :: HrnParsingFailed ) ,
674
+ } ? ;
675
675
676
- Self { inner : hrn. expect ( "Error creating HRN" ) }
676
+ Ok ( Self { inner : hrn } )
677
677
}
678
678
679
679
pub fn user ( & self ) -> String {
You can’t perform that action at this time.
0 commit comments