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

Function plugin_parse_getmanifest_response

lightningd/plugin.c:1667–1810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1665}
1666
1667static const char *plugin_parse_getmanifest_response(const char *buffer,
1668 const jsmntok_t *toks,
1669 const jsmntok_t *idtok,
1670 struct plugin *plugin,
1671 const char **disabled)
1672{
1673 const jsmntok_t *resulttok, *featurestok, *custommsgtok, *tok;
1674 const char *err;
1675 struct lightningd *ld = plugin->plugins->ld;
1676
1677 *disabled = NULL;
1678
1679 resulttok = json_get_member(buffer, toks, "result");
1680 if (!resulttok || resulttok->type != JSMN_OBJECT)
1681 return tal_fmt(plugin, "Invalid/missing result tok in '%.*s'",
1682 json_tok_full_len(toks),
1683 json_tok_full(buffer, toks));
1684
1685 /* Plugin can disable itself: returns why it's disabled. */
1686 tok = json_get_member(buffer, resulttok, "disable");
1687 if (tok) {
1688 /* Don't get upset if this was a built-in! */
1689 plugin->important = false;
1690 *disabled = json_strdup(plugin, buffer, tok);
1691 return NULL;
1692 }
1693
1694 err = bool_setting(plugin, "getmanifest", buffer, resulttok, "dynamic",
1695 &plugin->dynamic);
1696 if (err)
1697 return err;
1698
1699 featurestok = json_get_member(buffer, resulttok, "featurebits");
1700
1701 if (featurestok) {
1702 bool have_featurebits = false;
1703 struct feature_set *fset = talz(tmpctx, struct feature_set);
1704
1705 BUILD_ASSERT(ARRAY_SIZE(feature_place_names)
1706 == ARRAY_SIZE(fset->bits));
1707
1708 for (int i = 0; i < ARRAY_SIZE(fset->bits); i++) {
1709 /* We don't allow setting the obs global init */
1710 if (!feature_place_names[i])
1711 continue;
1712
1713 tok = json_get_member(buffer, featurestok,
1714 feature_place_names[i]);
1715
1716 if (!tok)
1717 continue;
1718
1719 fset->bits[i] = json_tok_bin_from_hex(fset, buffer, tok);
1720 have_featurebits |= tal_bytelen(fset->bits[i]) > 0;
1721
1722 if (!fset->bits[i]) {
1723 return tal_fmt(
1724 plugin,

Callers 1

plugin_manifest_cbFunction · 0.85

Calls 15

json_get_memberFunction · 0.85
bool_settingFunction · 0.85
tal_bytelenFunction · 0.85
feature_set_orFunction · 0.85
feature_set_dupFunction · 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_tok_full_lenFunction · 0.50

Tested by

no test coverage detected