From 5b4a62d822480c856d67edfd383d42f488eb7c95 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 25 Jan 2018 10:01:08 -0800 Subject: [PATCH] doc: some sqlite db info for HACKING Signed-off-by: William Casarin --- doc/HACKING.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/HACKING.md b/doc/HACKING.md index 67b583c5b..aa635b2b1 100644 --- a/doc/HACKING.md +++ b/doc/HACKING.md @@ -98,6 +98,32 @@ will print out (to stderr) a command such as: Run this command to start debugging. You may need to type `return` one more time to exit the infinite while loop, otherwise you can type `continue` to begin. +Database +-------- + +c-lightning state is persisted in `lightning-dir`. It is a sqlite database +stored in the `lightningd.sqlite3` file, typically under `~/.lightning`. You can +run queries against this file like so: + + $ sqlite3 ~/.lightning/lightningd.sqlite3 "SELECT HEX(prev_out_tx), prev_out_index, status FROM outputs" + +Or you can launch into the sqlite3 repl and check things out from there: + + $ sqlite3 ~/.lightning/lightningd.sqlite3 + SQLite version 3.21.0 2017-10-24 18:55:49 + Enter ".help" for usage hints. + sqlite> .tables + channel_configs invoices peers vars + channel_htlcs outputs shachain_known version + channels payments shachains + sqlite> .schema outputs + ... + +Some data is stored as raw bytes, use `HEX(column)` to pretty print these. + +Make sure that clightning is not running when you query the database, as some +queries may lock the database and cause crashes. + Testing -------