|
|
@ -26,19 +26,18 @@ struct bitcoin_tx *funding_tx(const tal_t *ctx, |
|
|
|
tx = tx_spending_utxos(ctx, utxomap, bip32_base, |
|
|
|
!amount_sat_eq(change, AMOUNT_SAT(0))); |
|
|
|
|
|
|
|
tx->output[0].amount = funding; |
|
|
|
wscript = bitcoin_redeem_2of2(tx, local_fundingkey, remote_fundingkey); |
|
|
|
SUPERVERBOSE("# funding witness script = %s\n", |
|
|
|
tal_hex(wscript, wscript)); |
|
|
|
tx->output[0].script = scriptpubkey_p2wsh(tx, wscript); |
|
|
|
bitcoin_tx_add_output(tx, scriptpubkey_p2wsh(tx, wscript), &funding); |
|
|
|
tal_free(wscript); |
|
|
|
|
|
|
|
if (!amount_sat_eq(change, AMOUNT_SAT(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; |
|
|
|
bitcoin_tx_add_output(tx, scriptpubkey_p2wpkh(tx, changekey), |
|
|
|
&change); |
|
|
|
permute_outputs(tx, NULL, map); |
|
|
|
*outnum = (map[0] == int2ptr(0) ? 0 : 1); |
|
|
|
} else { |
|
|
|