From 0ba687732f4f00a8dd3bbad7a3656aff142e5866 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 8 Apr 2018 12:29:25 +0200 Subject: [PATCH] bitcoind: Do not copy the newline character when asking for a block In the short_channel_id check we were copying the entire result into the next bitcoin-cli call, including the newline character. Signed-off-by: Christian Decker Reported-By: @gdassori --- lightningd/bitcoind.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c index 73877dca3..9aaa8984e 100644 --- a/lightningd/bitcoind.c +++ b/lightningd/bitcoind.c @@ -604,6 +604,7 @@ static bool process_getblockhash_for_txout(struct bitcoin_cli *bcli) const struct bitcoin_tx_output *output, void *arg) = bcli->cb; struct get_output *go = bcli->cb_arg; + char *blockhash; if (*bcli->exitstatus != 0) { void *cbarg = go->cbarg; @@ -614,10 +615,11 @@ static bool process_getblockhash_for_txout(struct bitcoin_cli *bcli) return true; } + /* Strip the newline at the end of the previous output */ + blockhash = tal_strndup(NULL, bcli->output, bcli->output_bytes-1); + start_bitcoin_cli(bcli->bitcoind, NULL, process_getblock, false, cb, go, - "getblock", - take(tal_strndup(NULL, bcli->output,bcli->output_bytes)), - NULL); + "getblock", take(blockhash), NULL); return true; }