sql: add support for listnetworkevents
What changed, and why it matters
This commit adds a new read-only data table called 'networkevents' to the experimental SQL plugin. It lets users query network event history using SQL, similar to existing tables. There is no indication of a security bug or vulnerability fix.
No security action needed. Treat as a normal feature addition.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change extends the SQL plugin to expose the existing listnetworkevents RPC as a SQL table named ‘networkevents’. It adds the RPC to the SQL_LISTRPCS build list, registers a default refresh function, and updates the test to verify the generated schema columns. The table is read-only and follows the same pattern as other list RPCs already supported by the plugin.
Changed components
plugins/sql.cplugins/Makefiletests/test_plugin.pyInspect captured patch +20 / −3
diff --git a/plugins/Makefile b/plugins/Makefile
index 335e3847..7ca2622e 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -203,7 +203,7 @@ plugins/recover: $(PLUGIN_RECOVER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
# This covers all the low-level list RPCs which return simple arrays
-SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listclosedchannels listtransactions listsendpays listchainmoves listchannelmoves bkpr-listaccountevents bkpr-listincome
+SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listclosedchannels listtransactions listsendpays listchainmoves listchannelmoves bkpr-listaccountevents bkpr-listincome listnetworkevents
SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/$l.json)
SQL_SCHEMA_PARTS := $(foreach l,$(SQL_LISTRPCS), plugins/sql-schema_$l_gen.h)
diff --git a/plugins/sql.c b/plugins/sql.c
index be7df11d..17c63faf 100644
--- a/plugins/sql.c
+++ b/plugins/sql.c
@@ -1517,7 +1517,8 @@ static const struct refresh_funcs refresh_funcs[] = {
{ "listclosedchannels", default_refresh },
{ "listtransactions", default_refresh },
{ "bkpr-listaccountevents", default_refresh },
- { "bkpr-listincome", default_refresh }
+ { "bkpr-listincome", default_refresh },
+ { "listnetworkevents", default_refresh },
};
static const struct refresh_funcs *find_command_refresh(const char *cmdname)
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 03109f3b..1ef55942 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -3907,7 +3907,23 @@ def test_sql(node_factory, bitcoind):
{'name': 'txid',
'type': 'txid'},
{'name': 'payment_id',
- 'type': 'hex'}]}}
+ 'type': 'hex'}]},
+ 'networkevents': {
+ 'columns': [{'name': 'created_index',
+ 'type': 'u64'},
+ {'name': 'timestamp',
+ 'type': 'u64'},
+ {'name': 'peer_id',
+ 'type': 'pubkey'},
+ {'name': 'type',
+ 'type': 'string'},
+ {'name': 'reason',
+ 'type': 'string'},
+ {'name': 'duration_nsec',
+ 'type': 'u64'},
+ {'name': 'connect_attempted',
+ 'type': 'boolean'}]},
+ }
sqltypemap = {'string': 'TEXT',
'boolean': 'INTEGER',
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.