daemon: add --bitcoin-datadir for bitcoin-cli.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-03-15 17:08:40 +10:30
parent ab0b9271f0
commit 8f2e66089b
3 changed files with 17 additions and 4 deletions

View File

@ -19,13 +19,21 @@
#define BITCOIN_CLI "bitcoin-cli"
char *bitcoin_datadir;
static char **gather_args(const tal_t *ctx, const char *cmd, va_list ap)
{
size_t n = 2;
char **args = tal_arr(ctx, char *, n+1);
size_t n = 0;
char **args = tal_arr(ctx, char *, 1);
args[0] = BITCOIN_CLI;
args[1] = cast_const(char *, cmd);
args[n++] = BITCOIN_CLI;
tal_resize(&args, n + 1);
if (bitcoin_datadir) {
args[n++] = tal_fmt(args, "-datadir=%s", bitcoin_datadir);
tal_resize(&args, n + 1);
}
args[n++] = cast_const(char *, cmd);
tal_resize(&args, n + 1);
while ((args[n] = va_arg(ap, char *)) != NULL) {
args[n] = tal_strdup(args, args[n]);

View File

@ -10,6 +10,8 @@ struct lightningd_state;
struct ripemd160;
struct bitcoin_tx;
struct peer;
/* -datadir arg for bitcoin-cli. */
extern char *bitcoin_datadir;
void bitcoind_watch_addr(struct lightningd_state *dstate,
const struct ripemd160 *redeemhash);

View File

@ -213,6 +213,9 @@ int main(int argc, char *argv[])
"Print this message.");
opt_register_arg("--port", opt_set_uintval, NULL, &portnum,
"Port to bind to (otherwise, dynamic port is used)");
opt_register_arg("--bitcoin-datadir", opt_set_charp, NULL,
&bitcoin_datadir,
"-datadir arg for bitcoin-cli");
opt_register_logging(dstate->base_log);
opt_register_version();