File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use bitcoin::secp256k1;
1616
1717use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
1818use bitcoin:: hashes:: Hash ;
19+ use bitcoin:: hashes:: hex:: FromHex ;
1920use bitcoin:: hash_types:: BlockHash ;
2021
2122use bitcoin:: network:: constants:: Network ;
@@ -44,6 +45,7 @@ use crate::sync::{RwLock, RwLockReadGuard};
4445use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
4546use crate :: sync:: Mutex ;
4647use core:: ops:: { Bound , Deref } ;
48+ use core:: str:: FromStr ;
4749
4850#[ cfg( feature = "std" ) ]
4951use std:: time:: { SystemTime , UNIX_EPOCH } ;
@@ -150,6 +152,15 @@ impl TryFrom<NodeId> for PublicKey {
150152 }
151153}
152154
155+ impl FromStr for NodeId {
156+ type Err = bitcoin:: hashes:: hex:: Error ;
157+
158+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
159+ let data: [ u8 ; PUBLIC_KEY_SIZE ] = FromHex :: from_hex ( s) ?;
160+ Ok ( NodeId ( data) )
161+ }
162+ }
163+
153164/// Represents the network as nodes and channels between them
154165pub struct NetworkGraph < L : Deref > where L :: Target : Logger {
155166 secp_ctx : Secp256k1 < secp256k1:: VerifyOnly > ,
You can’t perform that action at this time.
0 commit comments