From 3c0d2813a09f85f6895b79663465c9bf18ca94e5 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 13 Jan 2018 13:56:38 -0800 Subject: [PATCH] bitcoind: properly handle spent outputs in gettxout exit status is not enough to detect spent outputs. gettxout will return a success exit code and 0 bytes. Signed-off-by: William Casarin --- lightningd/bitcoind.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c index 30110f306..3321098a8 100644 --- a/lightningd/bitcoind.c +++ b/lightningd/bitcoind.c @@ -432,7 +432,9 @@ static void process_gettxout(struct bitcoin_cli *bcli) struct bitcoin_tx_output out; bool valid; - if (*bcli->exitstatus != 0) { + /* As of at least v0.15.1.0, bitcoind returns "success" but an empty + string on a spent gettxout */ + if (*bcli->exitstatus != 0 || bcli->output_bytes == 0) { log_debug(bcli->bitcoind->log, "%s: not unspent output?", bcli_args(bcli)); tal_free(go);