mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
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.
This commit is contained in:
committed by
Rusty Russell
parent
5bd419d9fd
commit
4737977128
@@ -836,6 +836,7 @@ bool plugin_parse_getmanifest_response(const char *buffer,
|
|||||||
struct plugin *plugin)
|
struct plugin *plugin)
|
||||||
{
|
{
|
||||||
const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
|
const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
|
||||||
|
bool have_featurebits = false;
|
||||||
u8 *featurebits;
|
u8 *featurebits;
|
||||||
|
|
||||||
resulttok = json_get_member(buffer, toks, "result");
|
resulttok = json_get_member(buffer, toks, "result");
|
||||||
@@ -849,6 +850,7 @@ bool plugin_parse_getmanifest_response(const char *buffer,
|
|||||||
json_tok_full(buffer, dynamictok));
|
json_tok_full(buffer, dynamictok));
|
||||||
|
|
||||||
featurestok = json_get_member(buffer, resulttok, "featurebits");
|
featurestok = json_get_member(buffer, resulttok, "featurebits");
|
||||||
|
|
||||||
if (featurestok) {
|
if (featurestok) {
|
||||||
for (int i = 0; i < NUM_PLUGIN_FEATURES_TYPE; i++) {
|
for (int i = 0; i < NUM_PLUGIN_FEATURES_TYPE; i++) {
|
||||||
tok = json_get_member(buffer, featurestok,
|
tok = json_get_member(buffer, featurestok,
|
||||||
@@ -860,6 +862,8 @@ bool plugin_parse_getmanifest_response(const char *buffer,
|
|||||||
featurebits =
|
featurebits =
|
||||||
json_tok_bin_from_hex(plugin, buffer, tok);
|
json_tok_bin_from_hex(plugin, buffer, tok);
|
||||||
|
|
||||||
|
have_featurebits |= tal_bytelen(featurebits) > 0;
|
||||||
|
|
||||||
if (featurebits) {
|
if (featurebits) {
|
||||||
plugin->featurebits[i] = featurebits;
|
plugin->featurebits[i] = featurebits;
|
||||||
} else {
|
} 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) ||
|
if (!plugin_opts_add(plugin, buffer, resulttok) ||
|
||||||
!plugin_rpcmethods_add(plugin, buffer, resulttok) ||
|
!plugin_rpcmethods_add(plugin, buffer, resulttok) ||
|
||||||
!plugin_subscriptions_add(plugin, buffer, resulttok) ||
|
!plugin_subscriptions_add(plugin, buffer, resulttok) ||
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from pyln.client import Plugin
|
|||||||
# Register a different set feature of feature bits for each location so we can
|
# Register a different set feature of feature bits for each location so we can
|
||||||
# later check that they are being passed correctly.
|
# later check that they are being passed correctly.
|
||||||
plugin = Plugin(
|
plugin = Plugin(
|
||||||
|
dynamic=False,
|
||||||
init_features=1 << 101,
|
init_features=1 << 101,
|
||||||
node_features=1 << 103,
|
node_features=1 << 103,
|
||||||
invoice_features=1 << 105,
|
invoice_features=1 << 105,
|
||||||
|
|||||||
Reference in New Issue
Block a user