Networks: Consistency of network reference for 'livenet', and removed hardcoded value.

This commit is contained in:
Braydon Fuller 2014-12-02 10:48:21 -05:00
parent 2b866a8460
commit d5d88287cd
4 changed files with 5 additions and 4 deletions

View File

@ -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);
};

View File

@ -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);
};
/**

View File

@ -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');
});

View File

@ -62,7 +62,7 @@ describe('URI', function() {
uri = new URI('bitcoin:1DP69gMMvSuYhbnxsi4EJEFufUAbDrEQfj');
uri.address.should.be.instanceof(bitcore.Address);
uri.network.should.equal('mainnet');
uri.network.should.equal('livenet');
uri = new URI('bitcoin:mkYY5NRvikVBY1EPtaq9fAFgquesdjqECw');
uri.address.should.be.instanceof(bitcore.Address);
@ -92,7 +92,7 @@ describe('URI', function() {
address: '1DP69gMMvSuYhbnxsi4EJEFufUAbDrEQfj'
});
uri.address.should.be.instanceof(bitcore.Address);
uri.network.should.equal('mainnet');
uri.network.should.equal('livenet');
uri = new URI({
address: 'mkYY5NRvikVBY1EPtaq9fAFgquesdjqECw'