mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
bkpr: add option --bookkeeper-dir
Allow setting custom directory for bookkeeper's database and default directory for any csv file creation
This commit is contained in:
parent
12b5c06219
commit
c05900c676
5 changed files with 34 additions and 4 deletions
4
doc/lightning-listconfigs.7
generated
4
doc/lightning-listconfigs.7
generated
|
@ -78,6 +78,8 @@ On success, an object is returned, containing:
|
|||
|
||||
.RE
|
||||
|
||||
.IP \[bu]
|
||||
\fBbookkeeper-dir\fR (string, optional): \fBbookkeeper-dir\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
|
||||
.IP \[bu]
|
||||
|
@ -284,4 +286,4 @@ Vincenzo Palazzo \fI<vincenzo.palazzo@protonmail.com\fR> wrote the initial versi
|
|||
|
||||
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
|
||||
|
||||
\" SHA256STAMP:7ac9ef3477f64fd3a4181cb27b8810ecf2c1a082688180716adfe79843ab09aa
|
||||
\" SHA256STAMP:b1148d7469f7bac293482be6f501031e4cac02f9bc113cf372a31747eb7a6055
|
||||
|
|
|
@ -50,6 +50,7 @@ On success, an object is returned, containing:
|
|||
- **rpc-file** (string, optional): `rpc-file` field from config or cmdline, or default
|
||||
- **disable-plugin** (array of strings, optional):
|
||||
- `disable-plugin` field from config or cmdline
|
||||
- **bookkeeper-dir** (string, optional): `bookkeeper-dir` 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
|
||||
- **wallet** (string, optional): `wallet` field from config or cmdline, or default
|
||||
|
@ -212,4 +213,4 @@ RESOURCES
|
|||
---------
|
||||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
[comment]: # ( SHA256STAMP:4645e3f14c53ccc23b2ed42c2886064e5d718a8eef5e6bd6dd3a932cadfd8e8f)
|
||||
[comment]: # ( SHA256STAMP:4a4cacd309d9593b45cb27563c25d9d3df7df8aef2b281145abeee27eae57fa9)
|
||||
|
|
|
@ -217,6 +217,10 @@ authenticate with username `user` and password `pass`, and then use the
|
|||
database `db_name`. The database must exist, but the schema will be managed
|
||||
automatically by `lightningd`.
|
||||
|
||||
**bookkeeper-dir**=*DIR*
|
||||
Directory to keep the accounts.sqlite3 database file in.
|
||||
Defaults to lightning-dir.
|
||||
|
||||
**encrypted-hsm**
|
||||
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
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
"description": "`disable-plugin` field from config or cmdline"
|
||||
}
|
||||
},
|
||||
"bookkeeper-dir": {
|
||||
"type": "string",
|
||||
"description": "`bookkeeper-dir` field from config or cmdline, or default"
|
||||
},
|
||||
"always-use-proxy": {
|
||||
"type": "boolean",
|
||||
"description": "`always-use-proxy` field from config or cmdline, or default"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <common/memleak.h>
|
||||
#include <common/type_to_string.h>
|
||||
#include <db/exec.h>
|
||||
#include <errno.h>
|
||||
#include <plugins/bkpr/account.h>
|
||||
#include <plugins/bkpr/account_entry.h>
|
||||
#include <plugins/bkpr/chain_event.h>
|
||||
|
@ -18,6 +19,8 @@
|
|||
#include <plugins/bkpr/onchain_fee.h>
|
||||
#include <plugins/bkpr/recorder.h>
|
||||
#include <plugins/libplugin.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define CHAIN_MOVE "chain_mvt"
|
||||
#define CHANNEL_MOVE "channel_mvt"
|
||||
|
@ -25,8 +28,8 @@
|
|||
/* The database that we store all the accounting data in */
|
||||
static struct db *db ;
|
||||
|
||||
// FIXME: make relative to directory we're loaded into
|
||||
static char *db_dsn = "sqlite3://accounts.sqlite3";
|
||||
static char *datadir;
|
||||
|
||||
static struct fee_sum *find_sum_for_txid(struct fee_sum **sums,
|
||||
struct bitcoin_txid *txid)
|
||||
|
@ -1386,7 +1389,17 @@ static const struct plugin_command commands[] = {
|
|||
|
||||
static const char *init(struct plugin *p, const char *b, const jsmntok_t *t)
|
||||
{
|
||||
// FIXME: pass in database DSN as an option??
|
||||
/* Switch to bookkeeper-dir, if specified */
|
||||
if (datadir && chdir(datadir) != 0) {
|
||||
if (mkdir(datadir, 0700) != 0 && errno != EEXIST)
|
||||
plugin_err(p,
|
||||
"Unable to create 'bookkeeper-dir'=%s",
|
||||
datadir);
|
||||
if (chdir(datadir) != 0)
|
||||
plugin_err(p,
|
||||
"Unable to switch to 'bookkeeper-dir'=%s",
|
||||
datadir);
|
||||
}
|
||||
db = notleak(db_setup(p, p, db_dsn));
|
||||
|
||||
return NULL;
|
||||
|
@ -1396,11 +1409,17 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
setup_locale();
|
||||
|
||||
/* No datadir is default */
|
||||
datadir = NULL;
|
||||
plugin_main(argv, init, PLUGIN_STATIC, true, NULL,
|
||||
commands, ARRAY_SIZE(commands),
|
||||
notifs, ARRAY_SIZE(notifs),
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
plugin_option("bookkeeper-dir",
|
||||
"string",
|
||||
"Location for bookkeeper records.",
|
||||
charp_option, &datadir),
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue