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

Method handle_init

plugins/src/lib.rs:325–346  ·  view source on GitHub ↗
(&mut self, call: messages::InitCall)

Source from the content-addressed store, hash-verified

323 }
324
325 fn handle_init(&mut self, call: messages::InitCall) -> Result<Configuration, Error> {
326 use options::Value as OValue;
327 use serde_json::Value as JValue;
328
329 // Match up the ConfigOptions and fill in their values if we
330 // have a matching entry.
331 for opt in self.options.iter_mut() {
332 if let Some(val) = call.options.get(opt.name()) {
333 opt.value = Some(match (opt.default(), &val) {
334 (OValue::String(_), JValue::String(s)) => OValue::String(s.clone()),
335 (OValue::Integer(_), JValue::Number(n)) => OValue::Integer(n.as_i64().unwrap()),
336 (OValue::Boolean(_), JValue::Bool(n)) => OValue::Boolean(*n),
337
338 // It's ok to panic, if we get here Core Lightning
339 // has not enforced the option type.
340 (_, _) => panic!("Mismatching types in options: {:?} != {:?}", opt, val),
341 });
342 }
343 }
344
345 Ok(call.configuration)
346 }
347}
348
349// Just some type aliases so we don't get confused in a lisp-like sea

Callers 1

configureMethod · 0.80

Calls 4

getMethod · 0.80
unwrapMethod · 0.80
nameMethod · 0.45
defaultMethod · 0.45

Tested by

no test coverage detected