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 @@ -280,6 +280,8 @@ impl Bolt12Payment {
280
280
/// amount paid to be determined by the user.
281
281
///
282
282
/// 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
283
285
pub fn send_to_human_readable_name (
284
286
& self , hrn : HumanReadableName , amount_msat : u64 ,
285
287
) -> Result < PaymentId , Error > {
@@ -294,13 +296,14 @@ impl Bolt12Payment {
294
296
let retry_strategy = Retry :: Timeout ( LDK_PAYMENT_RETRY_TIMEOUT ) ;
295
297
let max_total_routing_fee_msat = None ;
296
298
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
+ } ?;
304
307
305
308
let hrn = maybe_convert_hrn ( hrn) ;
306
309
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