Skip to content

Commit e1b50cf

Browse files
committed
Implement to and from for PublicKey and NodeId
1 parent 157af6e commit e1b50cf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning/src/routing/gossip.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ impl Readable for NodeId {
130130
}
131131
}
132132

133+
impl From<PublicKey> for NodeId {
134+
fn from(pubkey: PublicKey) -> Self {
135+
Self::from_pubkey(&pubkey)
136+
}
137+
}
138+
139+
impl From<NodeId> for PublicKey {
140+
fn from(node_id: NodeId) -> PublicKey {
141+
PublicKey::from_slice( &node_id.0).unwrap()
142+
}
143+
}
144+
133145
/// Represents the network as nodes and channels between them
134146
pub struct NetworkGraph<L: Deref> where L::Target: Logger {
135147
secp_ctx: Secp256k1<secp256k1::VerifyOnly>,

0 commit comments

Comments
 (0)