MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bitcoin_redeem_p2sh_p2wpkh

Function bitcoin_redeem_p2sh_p2wpkh

bitcoin/script.c:214–227  ·  view source on GitHub ↗

Create the redeemscript for a P2SH + P2WPKH (for signing tx) */

Source from the content-addressed store, hash-verified

212
213/* Create the redeemscript for a P2SH + P2WPKH (for signing tx) */
214u8 *bitcoin_redeem_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key)
215{
216 struct ripemd160 keyhash;
217 u8 *script = tal_arr(ctx, u8, 0);
218
219 /* BIP141: BIP16 redeemScript pushed in the scriptSig is exactly a
220 * push of a version byte plus a push of a witness program. */
221 add_number(&script, 0);
222 pubkey_to_hash160(key, &keyhash);
223 script_push_bytes(&script, &keyhash, sizeof(keyhash));
224
225 assert(tal_count(script) == BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN);
226 return script;
227}
228
229u8 *bitcoin_scriptsig_redeem(const tal_t *ctx,
230 const u8 *redeemscript TAKES)

Callers 6

encode_pubkey_to_addrFunction · 0.85
json_add_utxoFunction · 0.85
psbt_using_utxosFunction · 0.85

Calls 3

add_numberFunction · 0.85
pubkey_to_hash160Function · 0.70
script_push_bytesFunction · 0.70

Tested by

no test coverage detected