use base58check in extendedPublicKeyString

This commit is contained in:
Ryan X. Charles 2014-09-17 14:41:51 -07:00
parent 70659ad9d4
commit 70d9f0db93
1 changed files with 2 additions and 5 deletions

View File

@ -140,12 +140,9 @@ BIP32.prototype.buildExtendedPublicKey = function() {
BIP32.prototype.extendedPublicKeyString = function(format) {
if (format === undefined || format === 'base58') {
var hash = Hash.sha256sha256(this.extendedPublicKey);
var checksum = hash.slice(0, 4);
var data = Buffer.concat([this.extendedPublicKey, checksum]);
return base58.encode(data);
return Base58Check.encode(this.extendedPublicKey);
} else if (format === 'hex') {
return this.extendedPublicKey.toString('hex');;
return this.extendedPublicKey.toString('hex');
} else {
throw new Error('bad format');
}