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

Function plugin_parse_getmanifest_response

lightningd/plugin.c:1451–1546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1449}
1450
1451static const char *plugin_parse_getmanifest_response(const char *buffer,
1452 const jsmntok_t *toks,
1453 const jsmntok_t *idtok,
1454 struct plugin *plugin,
1455 const char **disabled)
1456{
1457 const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
1458 const char *err;
1459
1460 *disabled = NULL;
1461
1462 resulttok = json_get_member(buffer, toks, "result");
1463 if (!resulttok || resulttok->type != JSMN_OBJECT)
1464 return tal_fmt(plugin, "Invalid/missing result tok in '%.*s'",
1465 json_tok_full_len(toks),
1466 json_tok_full(buffer, toks));
1467
1468 /* Plugin can disable itself: returns why it's disabled. */
1469 tok = json_get_member(buffer, resulttok, "disable");
1470 if (tok) {
1471 /* Don't get upset if this was a built-in! */
1472 plugin->important = false;
1473 *disabled = json_strdup(plugin, buffer, tok);
1474 return NULL;
1475 }
1476
1477 dynamictok = json_get_member(buffer, resulttok, "dynamic");
1478 if (dynamictok && !json_to_bool(buffer, dynamictok, &plugin->dynamic)) {
1479 return tal_fmt(plugin, "Bad 'dynamic' field ('%.*s')",
1480 json_tok_full_len(dynamictok),
1481 json_tok_full(buffer, dynamictok));
1482 }
1483
1484 featurestok = json_get_member(buffer, resulttok, "featurebits");
1485
1486 if (featurestok) {
1487 bool have_featurebits = false;
1488 struct feature_set *fset = talz(tmpctx, struct feature_set);
1489
1490 BUILD_ASSERT(ARRAY_SIZE(feature_place_names)
1491 == ARRAY_SIZE(fset->bits));
1492
1493 for (int i = 0; i < ARRAY_SIZE(fset->bits); i++) {
1494 /* We don't allow setting the obs global init */
1495 if (!feature_place_names[i])
1496 continue;
1497
1498 tok = json_get_member(buffer, featurestok,
1499 feature_place_names[i]);
1500
1501 if (!tok)
1502 continue;
1503
1504 fset->bits[i] = json_tok_bin_from_hex(fset, buffer, tok);
1505 have_featurebits |= tal_bytelen(fset->bits[i]) > 0;
1506
1507 if (!fset->bits[i]) {
1508 return tal_fmt(

Callers 1

plugin_manifest_cbFunction · 0.85

Calls 14

tal_bytelenFunction · 0.85
plugin_notifications_addFunction · 0.85
plugin_opts_addFunction · 0.85
plugin_rpcmethods_addFunction · 0.85
plugin_subscriptions_addFunction · 0.85
plugin_hooks_addFunction · 0.85
plugin_add_paramsFunction · 0.85
json_get_memberFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_strdupFunction · 0.50
json_to_boolFunction · 0.50

Tested by

no test coverage detected