diff --git a/src/hdwallet.js b/src/hdwallet.js index f259d63..a5036a3 100644 --- a/src/hdwallet.js +++ b/src/hdwallet.js @@ -159,6 +159,8 @@ HDWallet.prototype.toBase58 = function(isPrivate) { } HDWallet.prototype.toBuffer = function(isPrivate) { + if (isPrivate == undefined) isPrivate = !!this.priv + // Version var version = isPrivate ? this.network.bip32.private : this.network.bip32.public var buffer = new Buffer(HDWallet.LENGTH) diff --git a/test/hdwallet.js b/test/hdwallet.js index f4ad018..035cde1 100644 --- a/test/hdwallet.js +++ b/test/hdwallet.js @@ -71,7 +71,7 @@ describe('HDWallet', function() { it('exports ' + f.master.base58 + ' (public) correctly', function() { var hd = HDWallet.fromSeedHex(f.master.seed) - assert.equal(hd.toBase58(), f.master.base58) + assert.equal(hd.toBase58(false), f.master.base58) }) }) @@ -105,7 +105,7 @@ describe('HDWallet', function() { it('imports ' + f.master.base58Priv + ' (private) correctly', function() { var hd = HDWallet.fromBase58(f.master.base58Priv) - assert.equal(hd.toBase58(true), f.master.base58Priv) + assert.equal(hd.toBase58(), f.master.base58Priv) }) }) @@ -131,7 +131,7 @@ describe('HDWallet', function() { it('imports ' + f.master.hexPriv + ' (private) correctly', function() { var hd = HDWallet.fromHex(f.master.hexPriv) - assert.equal(hd.toBuffer(true).toString('hex'), f.master.hexPriv) + assert.equal(hd.toBuffer().toString('hex'), f.master.hexPriv) }) }) @@ -149,7 +149,7 @@ describe('HDWallet', function() { it('exports ' + f.master.hex + ' (public) correctly', function() { var hd = HDWallet.fromSeedHex(f.master.seed) - assert.equal(hd.toHex(), f.master.hex) + assert.equal(hd.toHex(false), f.master.hex) }) })