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

Function bitcoin_witness_2of2

bitcoin/script.c:368–390  ·  view source on GitHub ↗

Create a witness which spends the 2of2. */

Source from the content-addressed store, hash-verified

366
367/* Create a witness which spends the 2of2. */
368u8 **bitcoin_witness_2of2(const tal_t *ctx,
369 const struct bitcoin_signature *sig1,
370 const struct bitcoin_signature *sig2,
371 const struct pubkey *key1,
372 const struct pubkey *key2)
373{
374 u8 **witness = tal_arr(ctx, u8 *, 4);
375
376 /* OP_CHECKMULTISIG has an out-by-one bug, which MBZ */
377 witness[0] = stack_number(witness, 0);
378
379 /* sig order should match key order. */
380 if (pubkey_cmp(key1, key2) < 0) {
381 witness[1] = stack_sig(witness, sig1);
382 witness[2] = stack_sig(witness, sig2);
383 } else {
384 witness[1] = stack_sig(witness, sig2);
385 witness[2] = stack_sig(witness, sig1);
386 }
387
388 witness[3] = bitcoin_redeem_2of2(witness, key1, key2);
389 return witness;
390}
391
392/* Create scriptcode (fake witness, basically) for P2WPKH */
393u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key)

Callers 5

mainFunction · 0.85
reportFunction · 0.85
sign_last_txFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

stack_numberFunction · 0.85
pubkey_cmpFunction · 0.85
stack_sigFunction · 0.85
bitcoin_redeem_2of2Function · 0.85

Tested by 2

mainFunction · 0.68
reportFunction · 0.68