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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-05-23 20:35:17 +09:30
parent 3ab3281a4c
commit 805228b939

View File

@ -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);