channeld: change to_remote for option_anchor_outputs.

It's now a P2WSH to incorporate a CSV 1 delay.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-08-14 03:18:02 +09:30
parent e7423888ba
commit 3ff8311b40
4 changed files with 64 additions and 14 deletions

View File

@@ -34,6 +34,7 @@
#define OP_1SUB 0x8C
#define OP_ADD 0x93
#define OP_CHECKSIG 0xAC
#define OP_CHECKSIGVERIFY 0xAD
#define OP_CHECKMULTISIG 0xAE
#define OP_HASH160 0xA9
#define OP_CHECKSEQUENCEVERIFY 0xB2
@@ -321,6 +322,27 @@ u8 *scriptpubkey_witness_raw(const tal_t *ctx, u8 version,
return script;
}
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #3:
*
* #### `to_remote` Output
*
* If `option_anchor_outputs` applies to the commitment
* transaction, the `to_remote` output is encumbered by a one
* block csv lock.
* <remote_pubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY
*/
u8 *anchor_to_remote_redeem(const tal_t *ctx,
const struct pubkey *remote_key)
{
u8 *script = tal_arr(ctx, u8, 0);
add_push_key(&script, remote_key);
add_op(&script, OP_CHECKSIGVERIFY);
add_number(&script, 1);
add_op(&script, OP_CHECKSEQUENCEVERIFY);
return script;
}
/* Create a witness which spends the 2of2. */
u8 **bitcoin_witness_2of2(const tal_t *ctx,
const struct bitcoin_signature *sig1,