We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 75822b8 + 227d73d commit 282b52fCopy full SHA for 282b52f
lightning/src/routing/gossip.rs
@@ -74,6 +74,16 @@ impl NodeId {
74
NodeId(pubkey.serialize())
75
}
76
77
+ /// Create a new NodeId from a slice of bytes
78
+ pub fn from_slice(bytes: &[u8]) -> Result<Self, DecodeError> {
79
+ if bytes.len() != PUBLIC_KEY_SIZE {
80
+ return Err(DecodeError::InvalidValue);
81
+ }
82
+ let mut data = [0; PUBLIC_KEY_SIZE];
83
+ data.copy_from_slice(bytes);
84
+ Ok(NodeId(data))
85
86
+
87
/// Get the public key slice from this NodeId
88
pub fn as_slice(&self) -> &[u8] {
89
&self.0
0 commit comments