Full public key validation isn't necessary.
This commit is contained in:
parent
febbcc6a6e
commit
770e0e3a7f
@ -245,7 +245,6 @@ Script.prototype.isPublicKeyHashOut = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} inaccurate - option to disable full (slow) public key validation
|
|
||||||
* @returns {boolean} if this is a pay to public key hash input script
|
* @returns {boolean} if this is a pay to public key hash input script
|
||||||
*/
|
*/
|
||||||
Script.prototype.isPublicKeyHashIn = function(inaccurate) {
|
Script.prototype.isPublicKeyHashIn = function(inaccurate) {
|
||||||
@ -259,16 +258,12 @@ Script.prototype.isPublicKeyHashIn = function(inaccurate) {
|
|||||||
pubkeyBuf.length
|
pubkeyBuf.length
|
||||||
) {
|
) {
|
||||||
var version = pubkeyBuf[0];
|
var version = pubkeyBuf[0];
|
||||||
var isVersion = false;
|
if ((version === 0x04 ||
|
||||||
if (version === 0x04 && pubkeyBuf.length === 65) {
|
version === 0x06 ||
|
||||||
isVersion = true;
|
version === 0x07) && pubkeyBuf.length === 65) {
|
||||||
|
return true;
|
||||||
} else if ((version === 0x03 || version === 0x02) && pubkeyBuf.length === 33) {
|
} else if ((version === 0x03 || version === 0x02) && pubkeyBuf.length === 33) {
|
||||||
isVersion = true;
|
return true;
|
||||||
}
|
|
||||||
if (inaccurate) {
|
|
||||||
return isVersion;
|
|
||||||
} else {
|
|
||||||
return PublicKey.isValid(pubkeyBuf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -774,7 +769,7 @@ Script.prototype.getAddressInfo = function() {
|
|||||||
} else if (this.isPublicKeyHashOut()) {
|
} else if (this.isPublicKeyHashOut()) {
|
||||||
info.hashBuffer = this.getData();
|
info.hashBuffer = this.getData();
|
||||||
info.type = Address.PayToPublicKeyHash;
|
info.type = Address.PayToPublicKeyHash;
|
||||||
} else if (this.isPublicKeyHashIn(true)) {
|
} else if (this.isPublicKeyHashIn()) {
|
||||||
// hash the publickey found in the scriptSig
|
// hash the publickey found in the scriptSig
|
||||||
info.hashBuffer = Hash.sha256ripemd160(this.chunks[1].buf);
|
info.hashBuffer = Hash.sha256ripemd160(this.chunks[1].buf);
|
||||||
info.type = Address.PayToPublicKeyHash;
|
info.type = Address.PayToPublicKeyHash;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user