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

Function bitcoin_witness_2of2

bitcoin/script.c:430–452  ·  view source on GitHub ↗

Create a witness which spends the 2of2. */

Source from the content-addressed store, hash-verified

428
429/* Create a witness which spends the 2of2. */
430u8 **bitcoin_witness_2of2(const tal_t *ctx,
431 const struct bitcoin_signature *sig1,
432 const struct bitcoin_signature *sig2,
433 const struct pubkey *key1,
434 const struct pubkey *key2)
435{
436 u8 **witness = tal_arr(ctx, u8 *, 4);
437
438 /* OP_CHECKMULTISIG has an out-by-one bug, which MBZ */
439 witness[0] = stack_number(witness, 0);
440
441 /* sig order should match key order. */
442 if (pubkey_cmp(key1, key2) < 0) {
443 witness[1] = stack_sig(witness, sig1);
444 witness[2] = stack_sig(witness, sig2);
445 } else {
446 witness[1] = stack_sig(witness, sig2);
447 witness[2] = stack_sig(witness, sig1);
448 }
449
450 witness[3] = bitcoin_redeem_2of2(witness, key1, key2);
451 return witness;
452}
453
454/* Create scriptcode (fake witness, basically) for P2WPKH */
455u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key)

Callers 6

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