What changed, and why it matters
This commit adds two new internal plugin commands, addscidwatch and delscidwatch, to the bwatch plugin in Core Lightning. They let lightningd ask the plugin to start or stop monitoring a specific Lightning channel identifier (short_channel_id) for a particular owner. The change is purely additive and exposes existing watch functionality through a new, more precise lookup path. There is no indication of a security bug or fix.
No security action required. Treat as a normal feature addition; review can follow standard code-review practices.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch registers two new RPC handlers in plugins/bwatch/bwatch.c and implements them in plugins/bwatch/bwatch_interface.c. The handlers wrap the existing bwatch_add_watch/bwatch_del_watch infrastructure with WATCH_SCID, using a short_channel_id instead of a scriptPubKey or outpoint. Parameters are validated with the standard param() helper, including param_short_channel_id and param_u32. No new parsing, authentication, or memory-management code is introduced beyond the existing patterns used by addoutpointwatch/deloutpointwatch.
Changed components
plugins/bwatch/bwatch.cplugins/bwatch/bwatch_interface.cplugins/bwatch/bwatch_interface.hInspect captured patch +58 / −0
diff --git a/plugins/bwatch/bwatch.c b/plugins/bwatch/bwatch.c
index d0512474..fdb8fe76 100644
--- a/plugins/bwatch/bwatch.c
+++ b/plugins/bwatch/bwatch.c
@@ -290,8 +290,10 @@ static const char *init(struct command *cmd,
static const struct plugin_command commands[] = {
{ "addscriptpubkeywatch", json_bwatch_add_scriptpubkey },
{ "addoutpointwatch", json_bwatch_add_outpoint },
+ { "addscidwatch", json_bwatch_add_scid },
{ "delscriptpubkeywatch", json_bwatch_del_scriptpubkey },
{ "deloutpointwatch", json_bwatch_del_outpoint },
+ { "delscidwatch", json_bwatch_del_scid },
};
int main(int argc, char *argv[])
diff --git a/plugins/bwatch/bwatch_interface.c b/plugins/bwatch/bwatch_interface.c
index c6a1e106..ce8da769 100644
--- a/plugins/bwatch/bwatch_interface.c
+++ b/plugins/bwatch/bwatch_interface.c
@@ -410,3 +410,51 @@ struct command_result *json_bwatch_del_outpoint(struct command *cmd,
outpoint, NULL, NULL, NULL, owner);
return command_success(cmd, json_out_obj(cmd, "removed", "true"));
}
+
+/* Register a short_channel_id watch for `owner` from `start_block`
+ * onwards. The scid pins the watch to one specific (block, txindex,
+ * outnum). */
+struct command_result *json_bwatch_add_scid(struct command *cmd,
+ const char *buffer,
+ const jsmntok_t *params)
+{
+ struct bwatch *bwatch = bwatch_of(cmd->plugin);
+ const char *owner;
+ struct short_channel_id *scid;
+ u32 *start_block;
+
+ if (!param(cmd, buffer, params,
+ p_req("owner", param_string, &owner),
+ p_req("scid", param_short_channel_id, &scid),
+ p_req("start_block", param_u32, &start_block),
+ NULL))
+ return command_param_failed();
+
+ /* New owner is appended to the watch's owner list; same owner
+ * re-adding lowers start_block if needed (rescan handled later). */
+ bwatch_add_watch(cmd, bwatch, WATCH_SCID,
+ NULL, NULL, scid, NULL,
+ *start_block, owner);
+ return command_success(cmd, json_out_obj(cmd, NULL, NULL));
+}
+
+/* Drop one owner from a scid watch; the watch itself goes away once
+ * the last owner is removed. */
+struct command_result *json_bwatch_del_scid(struct command *cmd,
+ const char *buffer,
+ const jsmntok_t *params)
+{
+ struct bwatch *bwatch = bwatch_of(cmd->plugin);
+ const char *owner;
+ struct short_channel_id *scid;
+
+ if (!param(cmd, buffer, params,
+ p_req("owner", param_string, &owner),
+ p_req("scid", param_short_channel_id, &scid),
+ NULL))
+ return command_param_failed();
+
+ bwatch_del_watch(cmd, bwatch, WATCH_SCID,
+ NULL, NULL, scid, NULL, owner);
+ return command_success(cmd, json_out_obj(cmd, "removed", "true"));
+}
diff --git a/plugins/bwatch/bwatch_interface.h b/plugins/bwatch/bwatch_interface.h
index c9477413..edd5085f 100644
--- a/plugins/bwatch/bwatch_interface.h
+++ b/plugins/bwatch/bwatch_interface.h
@@ -45,6 +45,14 @@ struct command_result *json_bwatch_del_outpoint(struct command *cmd,
const char *buffer,
const jsmntok_t *params);
+/* RPC handlers: add / remove a scid watch. */
+struct command_result *json_bwatch_add_scid(struct command *cmd,
+ const char *buffer,
+ const jsmntok_t *params);
+struct command_result *json_bwatch_del_scid(struct command *cmd,
+ const char *buffer,
+ const jsmntok_t *params);
+
/* Send a block_processed RPC to watchman after a new block has been
* persisted. The next poll is started from the ack callback so we don't
* race ahead of watchman's view of the chain. Chains on the same poll
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.