Skip to content

Commit

Permalink
script: make scriptpubkey_is_p2tr available internally
Browse files Browse the repository at this point in the history
For use by a later commit.
  • Loading branch information
jgriffiths committed Feb 11, 2025
1 parent dc27ce4 commit c36be4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,10 @@ static bool scriptpubkey_is_p2wsh(const unsigned char *bytes, size_t bytes_len)
bytes[1] == 32; /* SHA256 */
}

static bool scriptpubkey_is_p2tr(const unsigned char *bytes, size_t bytes_len)
bool scriptpubkey_is_p2tr(const unsigned char *bytes, size_t bytes_len)
{
return bytes_len == WALLY_SCRIPTPUBKEY_P2TR_LEN &&
/* Note this is called from elsewhere hence we check 'bytes' for NULL */
return bytes && bytes_len == WALLY_SCRIPTPUBKEY_P2TR_LEN &&
bytes[0] == OP_1 && /* Segwit v1 */
bytes[1] == 32; /* X-ONLY-PUBKEY */
}
Expand Down
2 changes: 2 additions & 0 deletions src/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ int script_get_push_opcode_size_from_bytes(
/* Get OP_N */
bool script_is_op_n(unsigned char op, bool allow_zero, size_t *n);

bool scriptpubkey_is_p2tr(const unsigned char *bytes, size_t bytes_len);

/* Convert 0-16 to OP_<N> */
size_t value_to_op_n(uint64_t v);

Expand Down

0 comments on commit c36be4f

Please # to comment.