psbt: finalize to-remote with option_anchor_outputs.

Until it gains miniscript support, wally doesn't know how to
finalize P2WSH.  This happens with `option_anchor_outputs` for
to-remote, which requires a 1 block delay to force use of
anchor outputs for CPFP.

So we finalize this ourselves.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-08-14 11:00:42 +09:30
parent 754765c139
commit 591e8f9663
5 changed files with 63 additions and 0 deletions

View File

@@ -340,9 +340,25 @@ u8 *anchor_to_remote_redeem(const tal_t *ctx,
add_number(&script, 1);
add_op(&script, OP_CHECKSEQUENCEVERIFY);
assert(is_anchor_witness_script(script, tal_bytelen(script)));
return script;
}
bool is_anchor_witness_script(const u8 *script, size_t script_len)
{
if (script_len != 34 + 1 + 1 + 1)
return false;
if (script[0] != OP_PUSHBYTES(33))
return false;
if (script[34] != OP_CHECKSIGVERIFY)
return false;
if (script[35] != 0x51)
return false;
if (script[36] != OP_CHECKSEQUENCEVERIFY)
return false;
return true;
}
/* Create a witness which spends the 2of2. */
u8 **bitcoin_witness_2of2(const tal_t *ctx,
const struct bitcoin_signature *sig1,