mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
bitcoin/script: define standard scriptpubkey lengths.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
31153e9506
commit
070929f92e
@@ -374,7 +374,7 @@ bool is_p2pkh(const u8 *script, struct bitcoin_address *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
|
||||
if (script_len != 25)
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2PKH_LEN)
|
||||
return false;
|
||||
if (script[0] != OP_DUP)
|
||||
return false;
|
||||
@@ -395,7 +395,7 @@ bool is_p2sh(const u8 *script, struct ripemd160 *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
|
||||
if (script_len != 23)
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2SH_LEN)
|
||||
return false;
|
||||
if (script[0] != OP_HASH160)
|
||||
return false;
|
||||
@@ -412,7 +412,7 @@ bool is_p2wsh(const u8 *script, struct sha256 *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
|
||||
if (script_len != 1 + 1 + sizeof(struct sha256))
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2WSH_LEN)
|
||||
return false;
|
||||
if (script[0] != OP_0)
|
||||
return false;
|
||||
@@ -427,7 +427,7 @@ bool is_p2wpkh(const u8 *script, struct bitcoin_address *addr)
|
||||
{
|
||||
size_t script_len = tal_len(script);
|
||||
|
||||
if (script_len != 1 + 1 + sizeof(struct ripemd160))
|
||||
if (script_len != BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN)
|
||||
return false;
|
||||
if (script[0] != OP_0)
|
||||
return false;
|
||||
|
||||
@@ -144,4 +144,16 @@ bool is_p2wpkh(const u8 *script, struct bitcoin_address *addr);
|
||||
/* Are these two scripts equal? */
|
||||
bool scripteq(const tal_t *s1, const tal_t *s2);
|
||||
|
||||
/* OP_DUP + OP_HASH160 + PUSH(20-byte-hash) + OP_EQUALVERIFY + OP_CHECKSIG */
|
||||
#define BITCOIN_SCRIPTPUBKEY_P2PKH_LEN (1 + 1 + 1 + 20 + 1 + 1)
|
||||
|
||||
/* OP_HASH160 + PUSH(20-byte-hash) + OP_EQUAL */
|
||||
#define BITCOIN_SCRIPTPUBKEY_P2SH_LEN (1 + 1 + 20 + 1)
|
||||
|
||||
/* OP_0 + PUSH(20-byte-hash) */
|
||||
#define BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN (1 + 1 + 20)
|
||||
|
||||
/* OP_0 + PUSH(32-byte-hash) */
|
||||
#define BITCOIN_SCRIPTPUBKEY_P2WSH_LEN (1 + 1 + 32)
|
||||
|
||||
#endif /* LIGHTNING_BITCOIN_SCRIPT_H */
|
||||
|
||||
Reference in New Issue
Block a user