From 4b663e596a9f65b4073cbd89e576112c8bac8766 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 15 Jan 2018 12:04:34 +1030 Subject: [PATCH] lightningd: don't crash when txout lookup fails. Gossipd already correctly handles the "empty output means lookup failed" case. Signed-off-by: Rusty Russell --- lightningd/gossip_control.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 4a0e10cbf..cdd28149d 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -60,9 +60,16 @@ static void got_txout(struct bitcoind *bitcoind, const struct bitcoin_tx_output *output, struct short_channel_id *scid) { + const u8 *script; + /* output will be NULL if it wasn't found */ + if (output) + script = output->script; + else + script = NULL; + subd_send_msg(bitcoind->ld->gossip, - towire_gossip_get_txout_reply(scid, scid, output->script)); + towire_gossip_get_txout_reply(scid, scid, script)); tal_free(scid); }