lightningd/funding_tx: fill in scriptsigs for p2sh UTXOs.

This is a bit tricky: for our signing code, we don't want scriptsigs,
but to calculate the txid, we need them.  For most transactions in lightning,
they're pure segwit so it doesn't matter, but funding transactions can
have P2SH-wrapped P2WPKH inputs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-03-07 11:31:55 +10:30
parent afc31cd68f
commit ccff3ac437
16 changed files with 77 additions and 33 deletions

View File

@@ -259,6 +259,18 @@ u8 *bitcoin_redeem_p2wpkh(const tal_t *ctx, const struct pubkey *key)
return script;
}
u8 *bitcoin_scriptsig_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key)
{
u8 *redeemscript = bitcoin_redeem_p2wpkh(ctx, key), *script;
/* BIP141: The scriptSig must be exactly a push of the BIP16
* redeemScript or validation fails. */
script = tal_arr(ctx, u8, 0);
add_push_bytes(&script, redeemscript, tal_count(redeemscript));
tal_free(redeemscript);
return script;
}
/* Create an input which spends the p2sh-p2wpkh. */
void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx,
struct bitcoin_tx_input *input,