ECPair: use toBase58Check

This commit is contained in:
Daniel Cousens 2016-04-27 16:42:25 +10:00
parent 85e3cce00e
commit e52c0d5b67

View file

@ -1,3 +1,4 @@
var baddress = require('./address')
var bcrypto = require('./crypto')
var bs58check = require('bs58check')
var ecdsa = require('./ecdsa')
@ -97,14 +98,7 @@ ECPair.makeRandom = function (options) {
}
ECPair.prototype.getAddress = function () {
var pubKey = this.getPublicKeyBuffer()
var pubKeyHash = bcrypto.hash160(pubKey)
var payload = new Buffer(21)
payload.writeUInt8(this.network.pubKeyHash, 0)
pubKeyHash.copy(payload, 1)
return bs58check.encode(payload)
return baddress.toBase58Check(bcrypto.hash160(this.getPublicKeyBuffer()), this.getNetwork().pubKeyHash)
}
ECPair.prototype.getNetwork = function () {