Skip to content

Commit c36be4f

Browse files
committed
script: make scriptpubkey_is_p2tr available internally
For use by a later commit.
1 parent dc27ce4 commit c36be4f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/script.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,10 @@ static bool scriptpubkey_is_p2wsh(const unsigned char *bytes, size_t bytes_len)
361361
bytes[1] == 32; /* SHA256 */
362362
}
363363

364-
static bool scriptpubkey_is_p2tr(const unsigned char *bytes, size_t bytes_len)
364+
bool scriptpubkey_is_p2tr(const unsigned char *bytes, size_t bytes_len)
365365
{
366-
return bytes_len == WALLY_SCRIPTPUBKEY_P2TR_LEN &&
366+
/* Note this is called from elsewhere hence we check 'bytes' for NULL */
367+
return bytes && bytes_len == WALLY_SCRIPTPUBKEY_P2TR_LEN &&
367368
bytes[0] == OP_1 && /* Segwit v1 */
368369
bytes[1] == 32; /* X-ONLY-PUBKEY */
369370
}

src/script.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ int script_get_push_opcode_size_from_bytes(
1818
/* Get OP_N */
1919
bool script_is_op_n(unsigned char op, bool allow_zero, size_t *n);
2020

21+
bool scriptpubkey_is_p2tr(const unsigned char *bytes, size_t bytes_len);
22+
2123
/* Convert 0-16 to OP_<N> */
2224
size_t value_to_op_n(uint64_t v);
2325

0 commit comments

Comments
 (0)