From e52c0d5b678a5dcdb2b0301cc830648c931b198e Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 27 Apr 2016 16:42:25 +1000 Subject: [PATCH] ECPair: use toBase58Check --- src/ecpair.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ecpair.js b/src/ecpair.js index c647196..e60cdfb 100644 --- a/src/ecpair.js +++ b/src/ecpair.js @@ -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 () {