Create a witness which spends the 2of2. */
| 428 | |
| 429 | /* Create a witness which spends the 2of2. */ |
| 430 | u8 **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 */ |
| 455 | u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key) |