From a68b0910afdd259253db9a2c92045ca5bcf795c6 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Wed, 22 Jan 2014 16:29:09 +0700 Subject: [PATCH] Fix wrong bitcoin address from priv key. --- src/eckey.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/eckey.js b/src/eckey.js index bfd028b..6ec4f0d 100644 --- a/src/eckey.js +++ b/src/eckey.js @@ -48,8 +48,9 @@ ECKey.prototype.import = function (input,compressed) { : null }; -ECKey.prototype.getPub = function() { - return ECPubKey(ecparams.getG().multiply(this.priv),this.compressed) +ECKey.prototype.getPub = function(compressed) { + if (compressed === undefined) compressed = this.compressed + return ECPubKey(ecparams.getG().multiply(this.priv),compressed) } /** @@ -137,7 +138,7 @@ ECPubKey.prototype['export'] = function(format) { ECPubKey.prototype.toBytes = function(compressed) { if (compressed === undefined) compressed = this.compressed - return this.pub.getEncoded(this.compressed) + return this.pub.getEncoded(compressed) } ECPubKey.prototype.toHex = function() { @@ -159,10 +160,9 @@ ECPubKey.prototype.toString = function() { } ECPubKey.prototype.getBitcoinAddress = function(v) { - return new Address(util.sha256ripe160(this.export()),v); + return new Address(util.sha256ripe160(this.toBytes()), v); } - ECKey.prototype.sign = function (hash) { return ecdsa.sign(hash, this.priv); };