Skip to content

Commit

Permalink
fixup! txscript: Optimize IsPayToPubKey
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Feb 10, 2021
1 parent 81013ff commit a6ce226
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion txscript/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ func extractCompressedPubKey(script []byte) []byte {
// passed script if it is a standard pay-to-uncompressed-secp256k1-pubkey
// script. It will return nil otherwise.
func extractUncompressedPubKey(script []byte) []byte {
// A pay-to-compressed-pubkey script is of the form:
// A pay-to-uncompressed-pubkey script is of the form:
// OP_DATA_65 <65-byte uncompressed pubkey> OP_CHECKSIG
//
// All non-hybrid uncompressed secp256k1 public keys must start with 0x04.
// Hybrid uncompressed secp256k1 public keys start with 0x06 or 0x07:
// - 0x06 => hybrid format for even Y coords
// - 0x07 => hybrid format for odd Y coords
if len(script) == 67 &&
script[66] == OP_CHECKSIG &&
script[0] == OP_DATA_65 &&
Expand Down

0 comments on commit a6ce226

Please sign in to comment.