mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 13:25:43 +01:00
bitcoin-cli: rename bcli_args() to bcli_args_direct(), and also warp it in bcli_args()
1. bcli_args_direct() will be used in wait_for_bitcoind; At the beginning, we check if bitcoin-cli is running by "echo" command whitout any bitcoin_cli struction. If this first command fails, we need present the agrs gathered, like "-rpcuser", like "-rpcpassword". Related changes include: i) rename bcli_args() to bcli_args_direct(), and use 'const char **' as the paramater for bcli_args_direct(); ii) add a new function bcli_args() warpped on bcli_args_direct(), this warpping can reduce the large number of changes later in the file; 2. bcli_args() warpping on bcli_args_direct() is used like original.
This commit is contained in:
parent
c95b4eedf4
commit
a594196c7c
@ -111,24 +111,32 @@ static struct io_plan *output_init(struct io_conn *conn, struct bitcoin_cli *bcl
|
|||||||
static void next_bcli(struct bitcoind *bitcoind, enum bitcoind_prio prio);
|
static void next_bcli(struct bitcoind *bitcoind, enum bitcoind_prio prio);
|
||||||
|
|
||||||
/* For printing: simple string of args. */
|
/* For printing: simple string of args. */
|
||||||
static char *bcli_args(const tal_t *ctx, struct bitcoin_cli *bcli)
|
/* bcli_args_direct() will be used in wat_for_bitcoind(), where
|
||||||
|
* we send bitcoin-cli a "getblockchaininfo" command without
|
||||||
|
* struct bitcoin_cli */
|
||||||
|
static char *bcli_args_direct(const tal_t *ctx, const char **args)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char *ret = tal_strdup(ctx, bcli->args[0]);
|
char *ret = tal_strdup(ctx, args[0]);
|
||||||
|
|
||||||
for (i = 1; bcli->args[i]; i++) {
|
for (i = 1; args[i]; i++) {
|
||||||
ret = tal_strcat(ctx, take(ret), " ");
|
ret = tal_strcat(ctx, take(ret), " ");
|
||||||
if (strstarts(bcli->args[i], "-rpcpassword")) {
|
if (strstarts(args[i], "-rpcpassword")) {
|
||||||
ret = tal_strcat(ctx, take(ret), "-rpcpassword=...");
|
ret = tal_strcat(ctx, take(ret), "-rpcpassword=...");
|
||||||
} else if (strstarts(bcli->args[i], "-rpcuser")) {
|
} else if (strstarts(args[i], "-rpcuser")) {
|
||||||
ret = tal_strcat(ctx, take(ret), "-rpcuser=...");
|
ret = tal_strcat(ctx, take(ret), "-rpcuser=...");
|
||||||
} else {
|
} else {
|
||||||
ret = tal_strcat(ctx, take(ret), bcli->args[i]);
|
ret = tal_strcat(ctx, take(ret), args[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *bcli_args(const tal_t *ctx, struct bitcoin_cli *bcli)
|
||||||
|
{
|
||||||
|
return bcli_args_direct(ctx, bcli->args);
|
||||||
|
}
|
||||||
|
|
||||||
static void retry_bcli(struct bitcoin_cli *bcli)
|
static void retry_bcli(struct bitcoin_cli *bcli)
|
||||||
{
|
{
|
||||||
list_add_tail(&bcli->bitcoind->pending[bcli->prio], &bcli->list);
|
list_add_tail(&bcli->bitcoind->pending[bcli->prio], &bcli->list);
|
||||||
|
Loading…
Reference in New Issue
Block a user