From cb2cad8c940998e75a7921da1c209d9cd43b1007 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 18 Sep 2019 19:02:20 -0500 Subject: [PATCH] script: add helper for checking if a 'known type' To be used for verifying remote inputs' validity --- bitcoin/script.c | 6 ++++++ bitcoin/script.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/bitcoin/script.c b/bitcoin/script.c index 58cdd4e19..060cfc829 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -436,6 +436,12 @@ bool is_p2wpkh(const u8 *script, struct bitcoin_address *addr) return true; } +bool is_known_scripttype(const u8 *script) +{ + return is_p2wpkh(script, NULL) || is_p2wsh(script, NULL) + || is_p2sh(script, NULL) || is_p2pkh(script, NULL); +} + u8 **bitcoin_witness_sig_and_element(const tal_t *ctx, const struct bitcoin_signature *sig, const void *elem, size_t elemsize, diff --git a/bitcoin/script.h b/bitcoin/script.h index f15e893f5..69f46fcde 100644 --- a/bitcoin/script.h +++ b/bitcoin/script.h @@ -135,6 +135,9 @@ bool is_p2wsh(const u8 *script, struct sha256 *addr); /* Is this (version 0) pay to witness pubkey hash? (extract addr if not NULL) */ bool is_p2wpkh(const u8 *script, struct bitcoin_address *addr); +/* Is this one of the four above script types? */ +bool is_known_scripttype(const u8 *script); + /* Are these two scripts equal? */ bool scripteq(const u8 *s1, const u8 *s2);