use bitcoin::network::constants::Network;
use crate::events::{MessageSendEvent, MessageSendEventsProvider};
-use crate::ln::ChannelId;
+use crate::ln::types::ChannelId;
use crate::ln::features::{ChannelFeatures, NodeFeatures, InitFeatures};
use crate::ln::msgs::{DecodeError, ErrorAction, Init, LightningError, RoutingMessageHandler, SocketAddress, MAX_VALUE_MSAT};
use crate::ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, GossipTimestampFilter};
use crate::io_extras::{copy, sink};
use crate::prelude::*;
use core::{cmp, fmt};
-use core::convert::TryFrom;
use crate::sync::{RwLock, RwLockReadGuard, LockTestExt};
#[cfg(feature = "std")]
use core::sync::atomic::{AtomicUsize, Ordering};
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