Check that the public key is valid for outputs.

This commit is contained in:
Braydon Fuller 2015-07-14 09:58:05 -04:00
parent 9f4b1a2c26
commit ad9dd2a41f
1 changed files with 6 additions and 2 deletions

View File

@ -282,12 +282,16 @@ Script.prototype.isPublicKeyOut = function() {
this.chunks[1].opcodenum === Opcode.OP_CHECKSIG) {
var pubkeyBuf = this.chunks[0].buf;
var version = pubkeyBuf[0];
var isVersion = false;
if ((version === 0x04 ||
version === 0x06 ||
version === 0x07) && pubkeyBuf.length === 65) {
return true;
isVersion = true;
} else if ((version === 0x03 || version === 0x02) && pubkeyBuf.length === 33) {
return true;
isVersion = true;
}
if (isVersion) {
return PublicKey.isValid(pubkeyBuf);
}
}
return false;