mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
bitcoin/script: rename bitcoin_redeem_p2wpkh -> bitcoin_redeem_p2sh_p2wpkh
This is its full name, and less confusing. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5f07e8405a
commit
39993f229d
@ -244,7 +244,7 @@ u8 *bitcoin_redeem_p2pkh(const tal_t *ctx, const struct pubkey *pubkey,
|
||||
}
|
||||
|
||||
/* Create the redeemscript for a P2SH + P2WPKH (for signing tx) */
|
||||
u8 *bitcoin_redeem_p2wpkh(const tal_t *ctx, const struct pubkey *key)
|
||||
u8 *bitcoin_redeem_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key)
|
||||
{
|
||||
struct ripemd160 keyhash;
|
||||
u8 der[PUBKEY_DER_LEN];
|
||||
@ -261,7 +261,7 @@ u8 *bitcoin_redeem_p2wpkh(const tal_t *ctx, const struct pubkey *key)
|
||||
|
||||
u8 *bitcoin_scriptsig_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key)
|
||||
{
|
||||
u8 *redeemscript = bitcoin_redeem_p2wpkh(ctx, key), *script;
|
||||
u8 *redeemscript = bitcoin_redeem_p2sh_p2wpkh(ctx, key), *script;
|
||||
|
||||
/* BIP141: The scriptSig must be exactly a push of the BIP16
|
||||
* redeemScript or validation fails. */
|
||||
@ -277,7 +277,7 @@ void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx,
|
||||
const secp256k1_ecdsa_signature *sig,
|
||||
const struct pubkey *key)
|
||||
{
|
||||
u8 *redeemscript = bitcoin_redeem_p2wpkh(ctx, key);
|
||||
u8 *redeemscript = bitcoin_redeem_p2sh_p2wpkh(ctx, key);
|
||||
|
||||
/* BIP141: The scriptSig must be exactly a push of the BIP16 redeemScript
|
||||
* or validation fails. */
|
||||
@ -285,12 +285,7 @@ void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx,
|
||||
add_push_bytes(&input->script, redeemscript, tal_count(redeemscript));
|
||||
tal_free(redeemscript);
|
||||
|
||||
/* BIP141: The witness must consist of exactly 2 items (≤ 520
|
||||
* bytes each). The first one a signature, and the second one
|
||||
* a public key. */
|
||||
input->witness = tal_arr(ctx, u8 *, 2);
|
||||
input->witness[0] = stack_sig(input->witness, sig);
|
||||
input->witness[1] = stack_key(input->witness, key);
|
||||
input->witness = bitcoin_witness_p2wpkh(ctx, sig, key);
|
||||
}
|
||||
|
||||
u8 **bitcoin_witness_p2wpkh(const tal_t *ctx,
|
||||
|
@ -42,10 +42,9 @@ u8 *bitcoin_redeem_p2pkh(const tal_t *ctx, const struct pubkey *pubkey,
|
||||
const secp256k1_ecdsa_signature *sig);
|
||||
|
||||
/* Create the redeemscript for a P2SH + P2WPKH. */
|
||||
u8 *bitcoin_redeem_p2wpkh(const tal_t *ctx,
|
||||
const struct pubkey *key);
|
||||
u8 *bitcoin_redeem_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key);
|
||||
|
||||
/* Create a witness which spends the 2of2. */
|
||||
/* Create a witness which spends the P2SH + P2WPKH. */
|
||||
void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx,
|
||||
struct bitcoin_tx_input *input,
|
||||
const secp256k1_ecdsa_signature *sig,
|
||||
|
@ -33,7 +33,7 @@ bool restore_wallet_address(struct lightningd_state *dstate,
|
||||
if (!pubkey_from_privkey(&w->privkey, &w->pubkey))
|
||||
return false;
|
||||
|
||||
redeemscript = bitcoin_redeem_p2wpkh(w, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_p2sh_p2wpkh(w, &w->pubkey);
|
||||
sha256(&h, redeemscript, tal_count(redeemscript));
|
||||
ripemd160(&w->p2sh, h.u.u8, sizeof(h));
|
||||
|
||||
@ -74,7 +74,7 @@ bool wallet_add_signed_input(struct lightningd_state *dstate,
|
||||
if (!w)
|
||||
return false;
|
||||
|
||||
redeemscript = bitcoin_redeem_p2wpkh(tx, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_p2sh_p2wpkh(tx, &w->pubkey);
|
||||
|
||||
sign_tx_input(tx, input_num,
|
||||
redeemscript,
|
||||
@ -120,7 +120,7 @@ static void json_newaddr(struct command *cmd,
|
||||
struct sha256 h;
|
||||
|
||||
new_keypair(&w->privkey, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_p2wpkh(cmd, &w->pubkey);
|
||||
redeemscript = bitcoin_redeem_p2sh_p2wpkh(cmd, &w->pubkey);
|
||||
sha256(&h, redeemscript, tal_count(redeemscript));
|
||||
ripemd160(&w->p2sh, h.u.u8, sizeof(h));
|
||||
|
||||
|
@ -44,7 +44,7 @@ static void json_newaddr(struct command *cmd,
|
||||
return;
|
||||
}
|
||||
|
||||
redeemscript = bitcoin_redeem_p2wpkh(cmd, &pubkey);
|
||||
redeemscript = bitcoin_redeem_p2sh_p2wpkh(cmd, &pubkey);
|
||||
sha256(&h, redeemscript, tal_count(redeemscript));
|
||||
ripemd160(&p2sh, h.u.u8, sizeof(h));
|
||||
|
||||
|
@ -399,7 +399,7 @@ static u8 *sign_funding_tx(const tal_t *ctx, const u8 *data)
|
||||
|
||||
bitcoin_keypair(&inprivkey, &inkey, in->keyindex);
|
||||
if (in->is_p2sh)
|
||||
subscript = bitcoin_redeem_p2wpkh(tmpctx, &inkey);
|
||||
subscript = bitcoin_redeem_p2sh_p2wpkh(tmpctx, &inkey);
|
||||
else
|
||||
subscript = NULL;
|
||||
wscript = p2wpkh_scriptcode(tmpctx, &inkey);
|
||||
|
Loading…
Reference in New Issue
Block a user