Browse Source

Check that the public key is valid for outputs.

patch-2
Braydon Fuller 9 years ago
parent
commit
ad9dd2a41f
  1. 8
      lib/script/script.js

8
lib/script/script.js

@ -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;

Loading…
Cancel
Save