mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
bkpr: Add an option to set the database to something else (postgres)
`lightningd` has an option --wallet that lets you supply a database dsn string to connect to a sqlite3/postgres database that's hosted/stored elsewhere. This adds the `--bookkeeper-db` option which does the same, except for the bookkeeping data for a node! Note that the default is to go in the `lightning-dir` in a database called `accounts.sqlite3`
This commit is contained in:
parent
3c79a456c0
commit
71c03bc082
5 changed files with 31 additions and 3 deletions
4
doc/lightning-listconfigs.7
generated
4
doc/lightning-listconfigs.7
generated
|
@ -81,6 +81,8 @@ On success, an object is returned, containing:
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
\fBbookkeeper-dir\fR (string, optional): \fBbookkeeper-dir\fR field from config or cmdline, or default
|
\fBbookkeeper-dir\fR (string, optional): \fBbookkeeper-dir\fR field from config or cmdline, or default
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
|
\fBbookkeeper-db\fR (string, optional): \fBbookkeeper-db\fR field from config or cmdline, or default
|
||||||
|
.IP \[bu]
|
||||||
\fBalways-use-proxy\fR (boolean, optional): \fBalways-use-proxy\fR field from config or cmdline, or default
|
\fBalways-use-proxy\fR (boolean, optional): \fBalways-use-proxy\fR field from config or cmdline, or default
|
||||||
.IP \[bu]
|
.IP \[bu]
|
||||||
\fBdaemon\fR (boolean, optional): \fBdaemon\fR field from config or cmdline, or default
|
\fBdaemon\fR (boolean, optional): \fBdaemon\fR field from config or cmdline, or default
|
||||||
|
@ -286,4 +288,4 @@ Vincenzo Palazzo \fI<vincenzo.palazzo@protonmail.com\fR> wrote the initial versi
|
||||||
|
|
||||||
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
|
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
|
||||||
|
|
||||||
\" SHA256STAMP:b1148d7469f7bac293482be6f501031e4cac02f9bc113cf372a31747eb7a6055
|
\" SHA256STAMP:acf490bbc9c764f67bf72de7383ea05422ce892dbf70de5ba8918fad15900bd8
|
||||||
|
|
|
@ -51,6 +51,7 @@ On success, an object is returned, containing:
|
||||||
- **disable-plugin** (array of strings, optional):
|
- **disable-plugin** (array of strings, optional):
|
||||||
- `disable-plugin` field from config or cmdline
|
- `disable-plugin` field from config or cmdline
|
||||||
- **bookkeeper-dir** (string, optional): `bookkeeper-dir` field from config or cmdline, or default
|
- **bookkeeper-dir** (string, optional): `bookkeeper-dir` field from config or cmdline, or default
|
||||||
|
- **bookkeeper-db** (string, optional): `bookkeeper-db` field from config or cmdline, or default
|
||||||
- **always-use-proxy** (boolean, optional): `always-use-proxy` field from config or cmdline, or default
|
- **always-use-proxy** (boolean, optional): `always-use-proxy` field from config or cmdline, or default
|
||||||
- **daemon** (boolean, optional): `daemon` field from config or cmdline, or default
|
- **daemon** (boolean, optional): `daemon` field from config or cmdline, or default
|
||||||
- **wallet** (string, optional): `wallet` field from config or cmdline, or default
|
- **wallet** (string, optional): `wallet` field from config or cmdline, or default
|
||||||
|
@ -213,4 +214,4 @@ RESOURCES
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Main web site: <https://github.com/ElementsProject/lightning>
|
Main web site: <https://github.com/ElementsProject/lightning>
|
||||||
[comment]: # ( SHA256STAMP:4a4cacd309d9593b45cb27563c25d9d3df7df8aef2b281145abeee27eae57fa9)
|
[comment]: # ( SHA256STAMP:999502771ada48f32011ea4df2443a2a3385d27377d8e55ec82cf283f9acd0a6)
|
||||||
|
|
|
@ -221,6 +221,13 @@ automatically by `lightningd`.
|
||||||
Directory to keep the accounts.sqlite3 database file in.
|
Directory to keep the accounts.sqlite3 database file in.
|
||||||
Defaults to lightning-dir.
|
Defaults to lightning-dir.
|
||||||
|
|
||||||
|
**bookkeeper-db**=*DSN*
|
||||||
|
Identify the location of the bookkeeper data. This is a fully qualified data source
|
||||||
|
name, including a scheme such as `sqlite3` or `postgres` followed by the
|
||||||
|
connection parameters.
|
||||||
|
Defaults to `sqlite3://accounts.sqlite3` in the `bookkeeper-dir`.
|
||||||
|
|
||||||
|
|
||||||
**encrypted-hsm**
|
**encrypted-hsm**
|
||||||
If set, you will be prompted to enter a password used to encrypt the `hsm_secret`.
|
If set, you will be prompted to enter a password used to encrypt the `hsm_secret`.
|
||||||
Note that once you encrypt the `hsm_secret` this option will be mandatory for
|
Note that once you encrypt the `hsm_secret` this option will be mandatory for
|
||||||
|
|
|
@ -97,6 +97,10 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "`bookkeeper-dir` field from config or cmdline, or default"
|
"description": "`bookkeeper-dir` field from config or cmdline, or default"
|
||||||
},
|
},
|
||||||
|
"bookkeeper-db": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "`bookkeeper-db` field from config or cmdline, or default"
|
||||||
|
},
|
||||||
"always-use-proxy": {
|
"always-use-proxy": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "`always-use-proxy` field from config or cmdline, or default"
|
"description": "`always-use-proxy` field from config or cmdline, or default"
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
/* The database that we store all the accounting data in */
|
/* The database that we store all the accounting data in */
|
||||||
static struct db *db ;
|
static struct db *db ;
|
||||||
|
|
||||||
static char *db_dsn = "sqlite3://accounts.sqlite3";
|
static char *db_dsn;
|
||||||
static char *datadir;
|
static char *datadir;
|
||||||
|
|
||||||
static struct fee_sum *find_sum_for_txid(struct fee_sum **sums,
|
static struct fee_sum *find_sum_for_txid(struct fee_sum **sums,
|
||||||
|
@ -1780,7 +1780,14 @@ static const char *init(struct plugin *p, const char *b, const jsmntok_t *t)
|
||||||
"Unable to switch to 'bookkeeper-dir'=%s",
|
"Unable to switch to 'bookkeeper-dir'=%s",
|
||||||
datadir);
|
datadir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No user suppled db_dsn, set one up here */
|
||||||
|
if (!db_dsn)
|
||||||
|
db_dsn = tal_fmt(NULL, "sqlite3://accounts.sqlite3");
|
||||||
|
|
||||||
|
plugin_log(p, LOG_DBG, "Setting up database at %s", db_dsn);
|
||||||
db = notleak(db_setup(p, p, db_dsn));
|
db = notleak(db_setup(p, p, db_dsn));
|
||||||
|
db_dsn = tal_free(db_dsn);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1791,6 +1798,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* No datadir is default */
|
/* No datadir is default */
|
||||||
datadir = NULL;
|
datadir = NULL;
|
||||||
|
db_dsn = NULL;
|
||||||
|
|
||||||
plugin_main(argv, init, PLUGIN_STATIC, true, NULL,
|
plugin_main(argv, init, PLUGIN_STATIC, true, NULL,
|
||||||
commands, ARRAY_SIZE(commands),
|
commands, ARRAY_SIZE(commands),
|
||||||
notifs, ARRAY_SIZE(notifs),
|
notifs, ARRAY_SIZE(notifs),
|
||||||
|
@ -1800,6 +1809,11 @@ int main(int argc, char *argv[])
|
||||||
"string",
|
"string",
|
||||||
"Location for bookkeeper records.",
|
"Location for bookkeeper records.",
|
||||||
charp_option, &datadir),
|
charp_option, &datadir),
|
||||||
|
plugin_option("bookkeeper-db",
|
||||||
|
"string",
|
||||||
|
"Location of the bookkeeper database",
|
||||||
|
charp_option, &db_dsn),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue