close_shutdown: make sure script_pubkey is standard.

As per BOLT update 9c3f150d2a44af6ee2c3be03acd6ef80ea184f4e.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-08-31 16:06:32 +09:30
parent 2804a4de7a
commit f90fb4934f
3 changed files with 54 additions and 2 deletions

View File

@@ -454,6 +454,23 @@ u8 *p2wpkh_scriptcode(const tal_t *ctx,
return script;
}
bool is_p2pkh(const u8 *script, size_t script_len)
{
if (script_len != 25)
return false;
if (script[0] != OP_DUP)
return false;
if (script[1] != OP_HASH160)
return false;
if (script[2] != OP_PUSHBYTES(20))
return false;
if (script[23] != OP_EQUALVERIFY)
return false;
if (script[24] != OP_CHECKSIG)
return false;
return true;
}
bool is_p2sh(const u8 *script, size_t script_len)
{
if (script_len != 23)
@@ -478,6 +495,17 @@ bool is_p2wsh(const u8 *script, size_t script_len)
return true;
}
bool is_p2wpkh(const u8 *script, size_t script_len)
{
if (script_len != 1 + 1 + sizeof(struct ripemd160))
return false;
if (script[0] != OP_0)
return false;
if (script[1] != OP_PUSHBYTES(sizeof(struct ripemd160)))
return false;
return true;
}
/* A common script pattern: A can have it with secret, or B can have
* it after delay. */
u8 *bitcoin_redeem_secret_or_delay(const tal_t *ctx,