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

Function plugin_parse_getmanifest_response

lightningd/plugin.c:1679–1822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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