Browse Source

cli: Add rpcuser, rpcpassword and rpcconnect to bitcoind

Might help alleviate some of the issues of having to run a full-node
on the same machine as `lightningd`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
70514d1e95
  1. 19
      lightningd/bitcoind.c
  2. 3
      lightningd/bitcoind.h
  3. 10
      lightningd/options.c

19
lightningd/bitcoind.c

@ -42,6 +42,22 @@ static char **gather_args(const struct bitcoind *bitcoind,
args[n++] = tal_fmt(args, "-datadir=%s", bitcoind->datadir); args[n++] = tal_fmt(args, "-datadir=%s", bitcoind->datadir);
tal_resize(&args, n + 1); tal_resize(&args, n + 1);
} }
if (bitcoind->rpcconnect) {
args[n++] = tal_fmt(args, "-rpcconnect=%s", bitcoind->rpcconnect);
tal_resize(&args, n + 1);
}
if (bitcoind->rpcuser) {
args[n++] = tal_fmt(args, "-rpcuser=%s", bitcoind->rpcuser);
tal_resize(&args, n + 1);
}
if (bitcoind->rpcpass) {
args[n++] = tal_fmt(args, "-rpcpassword=%s", bitcoind->rpcpass);
tal_resize(&args, n + 1);
}
args[n++] = cast_const(char *, cmd); args[n++] = cast_const(char *, cmd);
tal_resize(&args, n + 1); tal_resize(&args, n + 1);
@ -716,6 +732,9 @@ struct bitcoind *new_bitcoind(const tal_t *ctx,
bitcoind->req_running = false; bitcoind->req_running = false;
bitcoind->shutdown = false; bitcoind->shutdown = false;
bitcoind->error_count = 0; bitcoind->error_count = 0;
bitcoind->rpcuser = NULL;
bitcoind->rpcpass = NULL;
bitcoind->rpcconnect = NULL;
list_head_init(&bitcoind->pending); list_head_init(&bitcoind->pending);
tal_add_destructor(bitcoind, destroy_bitcoind); tal_add_destructor(bitcoind, destroy_bitcoind);

3
lightningd/bitcoind.h

@ -49,6 +49,9 @@ struct bitcoind {
/* Ignore results, we're shutting down. */ /* Ignore results, we're shutting down. */
bool shutdown; bool shutdown;
/* Passthrough parameters for bitcoin-cli */
char *rpcuser, *rpcpass, *rpcconnect;
}; };
struct bitcoind *new_bitcoind(const tal_t *ctx, struct bitcoind *new_bitcoind(const tal_t *ctx,

10
lightningd/options.c

@ -548,6 +548,16 @@ void register_opts(struct lightningd *ld)
opt_register_arg("--alias", opt_set_alias, NULL, ld, opt_register_arg("--alias", opt_set_alias, NULL, ld,
"Up to 32-byte alias for node"); "Up to 32-byte alias for node");
opt_register_arg("--bitcoin-rpcuser", opt_set_talstr, NULL,
&ld->topology->bitcoind->rpcuser,
"bitcoind RPC username");
opt_register_arg("--bitcoin-rpcpassword", opt_set_talstr, NULL,
&ld->topology->bitcoind->rpcpass,
"bitcoind RPC password");
opt_register_arg("--bitcoin-rpcconnect", opt_set_talstr, NULL,
&ld->topology->bitcoind->rpcconnect,
"bitcoind RPC host to connect to");
opt_register_arg( opt_register_arg(
"--channel-update-interval=<s>", opt_set_u32, opt_show_u32, "--channel-update-interval=<s>", opt_set_u32, opt_show_u32,
&ld->config.channel_update_interval, &ld->config.channel_update_interval,

Loading…
Cancel
Save