Browse Source

plugin: Allow custom features only if the plugin is not dynamic

This is in order to avoid having to update featurebits as plugins get
activated and deactivated.
travis-debug
Christian Decker 5 years ago
committed by Rusty Russell
parent
commit
4737977128
  1. 14
      lightningd/plugin.c
  2. 1
      tests/plugins/feature-test.py

14
lightningd/plugin.c

@ -836,6 +836,7 @@ bool plugin_parse_getmanifest_response(const char *buffer,
struct plugin *plugin)
{
const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
bool have_featurebits = false;
u8 *featurebits;
resulttok = json_get_member(buffer, toks, "result");
@ -849,6 +850,7 @@ bool plugin_parse_getmanifest_response(const char *buffer,
json_tok_full(buffer, dynamictok));
featurestok = json_get_member(buffer, resulttok, "featurebits");
if (featurestok) {
for (int i = 0; i < NUM_PLUGIN_FEATURES_TYPE; i++) {
tok = json_get_member(buffer, featurestok,
@ -860,6 +862,8 @@ bool plugin_parse_getmanifest_response(const char *buffer,
featurebits =
json_tok_bin_from_hex(plugin, buffer, tok);
have_featurebits |= tal_bytelen(featurebits) > 0;
if (featurebits) {
plugin->featurebits[i] = featurebits;
} else {
@ -873,6 +877,16 @@ bool plugin_parse_getmanifest_response(const char *buffer,
}
}
if (plugin->dynamic && have_featurebits) {
plugin_kill(plugin,
"Custom featurebits only allows for non-dynamic "
"plugins: dynamic=%d, featurebits=%.*s",
plugin->dynamic,
featurestok->end - featurestok->start,
buffer + featurestok->start);
return true;
}
if (!plugin_opts_add(plugin, buffer, resulttok) ||
!plugin_rpcmethods_add(plugin, buffer, resulttok) ||
!plugin_subscriptions_add(plugin, buffer, resulttok) ||

1
tests/plugins/feature-test.py

@ -5,6 +5,7 @@ from pyln.client import Plugin
# Register a different set feature of feature bits for each location so we can
# later check that they are being passed correctly.
plugin = Plugin(
dynamic=False,
init_features=1 << 101,
node_features=1 << 103,
invoice_features=1 << 105,

Loading…
Cancel
Save