File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use bitcoin::secp256k1;
16
16
17
17
use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
18
18
use bitcoin:: hashes:: Hash ;
19
+ use bitcoin:: hashes:: hex:: FromHex ;
19
20
use bitcoin:: hash_types:: BlockHash ;
20
21
21
22
use bitcoin:: network:: constants:: Network ;
@@ -44,6 +45,7 @@ use crate::sync::{RwLock, RwLockReadGuard};
44
45
use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
45
46
use crate :: sync:: Mutex ;
46
47
use core:: ops:: { Bound , Deref } ;
48
+ use core:: str:: FromStr ;
47
49
48
50
#[ cfg( feature = "std" ) ]
49
51
use std:: time:: { SystemTime , UNIX_EPOCH } ;
@@ -150,6 +152,15 @@ impl TryFrom<NodeId> for PublicKey {
150
152
}
151
153
}
152
154
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
+
153
164
/// Represents the network as nodes and channels between them
154
165
pub struct NetworkGraph < L : Deref > where L :: Target : Logger {
155
166
secp_ctx : Secp256k1 < secp256k1:: VerifyOnly > ,
You can’t perform that action at this time.
0 commit comments