From 805228b9399d9ddc082db8ceb68c9d6e5dd6677e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 23 May 2017 20:35:17 +0930 Subject: [PATCH] lightningd/funding_tx: fix no-change-needed case. We only allocate one output in that case, and changekey is undefined. Signed-off-by: Rusty Russell --- lightningd/funding_tx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lightningd/funding_tx.c b/lightningd/funding_tx.c index 4c504c745..37549b0da 100644 --- a/lightningd/funding_tx.c +++ b/lightningd/funding_tx.c @@ -47,12 +47,11 @@ struct bitcoin_tx *funding_tx(const tal_t *ctx, tx->output[0].script = scriptpubkey_p2wsh(tx, wscript); tal_free(wscript); - tx->output[1].script = scriptpubkey_p2wpkh(tx, changekey); - if (change_satoshis != 0) { const void *map[2]; map[0] = int2ptr(0); map[1] = int2ptr(1); + tx->output[1].script = scriptpubkey_p2wpkh(tx, changekey); tx->output[1].amount = change_satoshis; permute_outputs(tx->output, tal_count(tx->output), map); *outnum = (map[0] == int2ptr(0) ? 0 : 1);