diff --git a/lib/address.js b/lib/address.js index 2d4e043b0..295f2771f 100644 --- a/lib/address.js +++ b/lib/address.js @@ -233,6 +233,7 @@ Address._transformString = function(data, network, type){ */ Address.fromPublicKey = function(data, network){ var info = Address._transformPublicKey(data); + network = network || networks.defaultNetwork.name; return new Address(info.hashBuffer, network, info.type); }; diff --git a/lib/publickey.js b/lib/publickey.js index b777a8909..eb8fbf7d9 100644 --- a/lib/publickey.js +++ b/lib/publickey.js @@ -331,7 +331,7 @@ PublicKey.prototype.toDER = function(compressed) { * @returns {Address} An address generated from the public key */ PublicKey.prototype.toAddress = function(network) { - return Address.fromPublicKey(this, network || 'livenet'); + return Address.fromPublicKey(this, network); }; /** diff --git a/test/publickey.js b/test/publickey.js index 299eef008..58a3d07ef 100644 --- a/test/publickey.js +++ b/test/publickey.js @@ -260,7 +260,7 @@ describe('PublicKey', function() { it('should output this known mainnet address correctly', function() { var pk = new PublicKey('03c87bd0e162f26969da8509cafcb7b8c8d202af30b928c582e263dd13ee9a9781'); - var address = pk.toAddress('mainnet'); + var address = pk.toAddress('livenet'); address.toString().should.equal('1A6ut1tWnUq1SEQLMr4ttDh24wcbJ5o9TT'); });