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>
This commit is contained in:
Christian Decker 2018-01-30 15:17:58 +01:00 committed by Rusty Russell
parent ca2f72fd5f
commit 70514d1e95
3 changed files with 32 additions and 0 deletions

View File

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

View File

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

View File

@ -548,6 +548,16 @@ void register_opts(struct lightningd *ld)
opt_register_arg("--alias", opt_set_alias, NULL, ld,
"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(
"--channel-update-interval=<s>", opt_set_u32, opt_show_u32,
&ld->config.channel_update_interval,