mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
script: break out redeemscript->scriptsig function
We're going to finalze some redeemscripts here shortly, so break out the ability to render an arbitrary redeemscript -> scriptsig
This commit is contained in:
@@ -261,18 +261,30 @@ u8 *bitcoin_redeem_p2sh_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 *bitcoin_scriptsig_redeem(const tal_t *ctx,
|
||||
const u8 *redeemscript TAKES)
|
||||
{
|
||||
u8 *redeemscript = bitcoin_redeem_p2sh_p2wpkh(ctx, key), *script;
|
||||
u8 *script;
|
||||
|
||||
/* BIP141: The scriptSig must be exactly a push of the BIP16
|
||||
* redeemScript or validation fails. */
|
||||
script = tal_arr(ctx, u8, 0);
|
||||
script_push_bytes(&script, redeemscript, tal_count(redeemscript));
|
||||
tal_free(redeemscript);
|
||||
script_push_bytes(&script, redeemscript,
|
||||
tal_count(redeemscript));
|
||||
|
||||
if (taken(redeemscript))
|
||||
tal_free(redeemscript);
|
||||
|
||||
return script;
|
||||
}
|
||||
|
||||
u8 *bitcoin_scriptsig_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key)
|
||||
{
|
||||
u8 *redeemscript =
|
||||
bitcoin_redeem_p2sh_p2wpkh(NULL, key);
|
||||
return bitcoin_scriptsig_redeem(ctx, take(redeemscript));
|
||||
}
|
||||
|
||||
u8 **bitcoin_witness_p2wpkh(const tal_t *ctx,
|
||||
const struct bitcoin_signature *sig,
|
||||
const struct pubkey *key)
|
||||
|
||||
@@ -43,6 +43,10 @@ u8 *bitcoin_redeem_p2pkh(const tal_t *ctx, const struct pubkey *pubkey,
|
||||
/* Create the redeemscript for a P2SH + P2WPKH. */
|
||||
u8 *bitcoin_redeem_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key);
|
||||
|
||||
/* Create the scriptsig for a redeemscript */
|
||||
u8 *bitcoin_scriptsig_redeem(const tal_t *ctx,
|
||||
const u8 *redeemscript TAKES);
|
||||
|
||||
/* Create scriptsig for p2sh-p2wpkh */
|
||||
u8 *bitcoin_scriptsig_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user