What changed, and why it matters
This commit adds a new internal data-format definition (a 'wire format') for a Core Lightning plugin called 'bwatch'. It describes how the plugin will store block history and 'watch' records in its database. There is no executable code in the change—only a build-file update and a CSV file that defines data structures. Nothing in the commit suggests a security vulnerability, fix, or exposure.
No security action required. Review the generated serialization code in follow-up commits to ensure length fields (scriptpubkey_len, num_owners) are validated before use and that datastore reads do not trust malformed records.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces plugins/bwatch/bwatch_wire.csv, a wire-protocol definition consumed by Core Lightning’s code generator to produce bwatch_wiregen.c/h. It defines two subtypes (block_record_wire and watch_wire) and two message types (bwatch_block, bwatch_watch) for datastore serialization. The Makefile is updated to compile the generated source. No logic, parsing of untrusted input, or security-sensitive behavior is present in this commit.
Changed components
plugins/bwatch/bwatch_wire.csvplugins/MakefileInspect captured patch +41 / −2
diff --git a/plugins/Makefile b/plugins/Makefile
index 866b2d47..ea90317c 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -20,11 +20,13 @@ PLUGIN_BCLI_OBJS := $(PLUGIN_BCLI_SRC:.c=.o)
PLUGIN_BWATCH_SRC := plugins/bwatch/bwatch.c \
plugins/bwatch/bwatch_store.c \
plugins/bwatch/bwatch_scanner.c \
- plugins/bwatch/bwatch_interface.c
+ plugins/bwatch/bwatch_interface.c \
+ plugins/bwatch/bwatch_wiregen.c
PLUGIN_BWATCH_HEADER := plugins/bwatch/bwatch.h \
plugins/bwatch/bwatch_store.h \
plugins/bwatch/bwatch_scanner.h \
- plugins/bwatch/bwatch_interface.h
+ plugins/bwatch/bwatch_interface.h \
+ plugins/bwatch/bwatch_wiregen.h
PLUGIN_BWATCH_OBJS := $(PLUGIN_BWATCH_SRC:.c=.o)
PLUGIN_COMMANDO_SRC := plugins/commando.c
@@ -202,6 +204,7 @@ plugins/bwatch/bwatch.o: $(PLUGIN_BWATCH_HEADER)
plugins/bwatch/bwatch_store.o: $(PLUGIN_BWATCH_HEADER)
plugins/bwatch/bwatch_scanner.o: $(PLUGIN_BWATCH_HEADER)
plugins/bwatch/bwatch_interface.o: $(PLUGIN_BWATCH_HEADER)
+plugins/bwatch/bwatch_wiregen.o: $(PLUGIN_BWATCH_HEADER)
plugins/bwatch/bwatch: $(PLUGIN_BWATCH_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/keysend: $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a
diff --git a/plugins/bwatch/bwatch_wire.csv b/plugins/bwatch/bwatch_wire.csv
new file mode 100644
index 00000000..570e0b59
--- /dev/null
+++ b/plugins/bwatch/bwatch_wire.csv
@@ -0,0 +1,36 @@
+#include <bitcoin/block.h>
+#include <bitcoin/tx.h>
+
+# Block record: complete serializable structure
+subtype,block_record_wire
+subtypedata,block_record_wire,height,u32,
+subtypedata,block_record_wire,hash,bitcoin_blkid,
+subtypedata,block_record_wire,prev_hash,bitcoin_blkid,
+
+# Watch: complete serializable structure
+# Type is stored to enable reconstruction of watch key from wire data
+subtype,watch_wire
+subtypedata,watch_wire,type,u32,
+# Scriptpubkey key (for WATCH_SCRIPTPUBKEY)
+subtypedata,watch_wire,scriptpubkey_len,u32,
+subtypedata,watch_wire,scriptpubkey,u8,scriptpubkey_len
+# Outpoint key (for WATCH_OUTPOINT)
+subtypedata,watch_wire,outpoint,bitcoin_outpoint,
+# SCID key (for WATCH_SCID)
+subtypedata,watch_wire,scid_blockheight,u32,
+subtypedata,watch_wire,scid_txindex,u32,
+subtypedata,watch_wire,scid_outnum,u32,
+# Blockdepth key (for WATCH_BLOCKDEPTH): block where the tx confirmed
+subtypedata,watch_wire,blockdepth,u32,
+# Common fields
+subtypedata,watch_wire,start_block,u32,
+subtypedata,watch_wire,num_owners,u16,
+subtypedata,watch_wire,owners,wirestring,num_owners
+
+# Messages for datastore persistence - use these to serialize/deserialize
+# Each message wraps a single item for storage
+msgtype,bwatch_block,1
+msgdata,bwatch_block,block,block_record_wire,
+
+msgtype,bwatch_watch,2
+msgdata,bwatch_watch,watch,watch_wire,
Why this scored 12/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.