Use defaultNetwork in Script.toAddress
This commit is contained in:
parent
754add30df
commit
9deec5e1c2
@ -702,11 +702,11 @@ Script.fromAddress = function(address) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Network} [network]
|
||||
* @return {Address} the associated address for this script
|
||||
*/
|
||||
Script.prototype.toAddress = function(network) {
|
||||
network = Networks.get(network);
|
||||
$.checkArgument(network, 'Must provide a network');
|
||||
network = Networks.get(network) || Networks.defaultNetwork;
|
||||
if (this.isPublicKeyHashOut() || this.isScriptHashOut()) {
|
||||
return new Address(this, network);
|
||||
}
|
||||
|
||||
@ -592,6 +592,12 @@ describe('Script', function() {
|
||||
});
|
||||
|
||||
describe('toAddress', function() {
|
||||
it('uses default network', function() {
|
||||
var stringAddress = '1NaTVwXDDUJaXDQajoa9MqHhz4uTxtgK14';
|
||||
var address = new Address(stringAddress);
|
||||
var script = new Script(address);
|
||||
script.toAddress().toString().should.equal(stringAddress);
|
||||
});
|
||||
it('for a P2PKH address', function() {
|
||||
var stringAddress = '1NaTVwXDDUJaXDQajoa9MqHhz4uTxtgK14';
|
||||
var address = new Address(stringAddress);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user