Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lightning/src/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ impl NodeId {
NodeId(pubkey.serialize())
}

/// Create a new NodeId from a slice of bytes
pub fn from_slice(bytes: &[u8]) -> Result<Self, DecodeError> {
if bytes.len() != PUBLIC_KEY_SIZE {
return Err(DecodeError::InvalidValue);
}
let mut data = [0; PUBLIC_KEY_SIZE];
data.copy_from_slice(bytes);
Ok(NodeId(data))
}

/// Get the public key slice from this NodeId
pub fn as_slice(&self) -> &[u8] {
&self.0
Expand Down