MCPcopy Create free account
hub / github.com/ElementsProject/lightning / from_str

Method from_str

cln-rpc/src/primitives.rs:241–253  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

239impl FromStr for ShortChannelId {
240 type Err = crate::Error;
241 fn from_str(s: &str) -> Result<Self, Self::Err> {
242 let parts: Result<Vec<u64>, _> = s.split('x').map(|p| p.parse()).collect();
243 let parts = parts.with_context(|| format!("Malformed short_channel_id: {}", s))?;
244 if parts.len() != 3 {
245 return Err(anyhow!(
246 "Malformed short_channel_id: element count mismatch"
247 ));
248 }
249
250 Ok(ShortChannelId(
251 (parts[0] << 40) | (parts[1] << 16) | (parts[2] << 0),
252 ))
253 }
254}
255impl From<u64> for ShortChannelId {
256 fn from(scid: u64) -> Self {

Callers

nothing calls this directly

Calls 3

mapMethod · 0.80
parseMethod · 0.80
ShortChannelIdClass · 0.70

Tested by

no test coverage detected