From cc6301edbbbb85405ac6a884d7da6318e93034e1 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Mon, 12 Sep 2016 18:50:34 -0400 Subject: [PATCH] Create compressed keys by default --- lib/privatekey.js | 2 +- test/privatekey.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/privatekey.js b/lib/privatekey.js index 9697bbfba..feef0463c 100644 --- a/lib/privatekey.js +++ b/lib/privatekey.js @@ -181,7 +181,7 @@ PrivateKey._transformBNBuffer = function(buf, network) { var info = {}; info.network = Networks.get(network) || Networks.defaultNetwork; info.bn = BN.fromBuffer(buf); - info.compressed = false; + info.compressed = true; return info; }; diff --git a/test/privatekey.js b/test/privatekey.js index 6df029934..e14a15310 100644 --- a/test/privatekey.js +++ b/test/privatekey.js @@ -82,6 +82,13 @@ describe('PrivateKey', function() { should.exist(a.bn); }); + it('should create a private key from buffer and set as compressed', function() { + var a = new PrivateKey(new Buffer('ff51c873a0aa6e46b1bf7bf2b01999f31dc17b2e8e4f0f3ea7328a476ded7bfc', 'hex')); + should.exist(a); + should.exist(a.bn); + a.compressed.should.equal(true); + }); + it('should create a private key from WIF buffer', function() { var a = new PrivateKey(Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m')); should.exist(a);