|
@ -326,6 +326,12 @@ describe('Address', function() { |
|
|
address.toString().should.equal('19gH5uhqY6DKrtkU66PsZPUZdzTd11Y7ke'); |
|
|
address.toString().should.equal('19gH5uhqY6DKrtkU66PsZPUZdzTd11Y7ke'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should use the default network for pubkey', function() { |
|
|
|
|
|
var pubkey = new PublicKey('0285e9737a74c30a873f74df05124f2aa6f53042c2fc0a130d6cbd7d16b944b004'); |
|
|
|
|
|
var address = Address.fromPublicKey(pubkey); |
|
|
|
|
|
address.network.should.equal(Networks.defaultNetwork); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
it('should make this address from an uncompressed pubkey', function() { |
|
|
it('should make this address from an uncompressed pubkey', function() { |
|
|
var pubkey = new PublicKey('0485e9737a74c30a873f74df05124f2aa6f53042c2fc0a130d6cbd7d16b944b00' + |
|
|
var pubkey = new PublicKey('0485e9737a74c30a873f74df05124f2aa6f53042c2fc0a130d6cbd7d16b944b00' + |
|
|
'4833fef26c8be4c4823754869ff4e46755b85d851077771c220e2610496a29d98'); |
|
|
'4833fef26c8be4c4823754869ff4e46755b85d851077771c220e2610496a29d98'); |
|
@ -335,6 +341,26 @@ describe('Address', function() { |
|
|
b.toString().should.equal('16JXnhxjJUhxfyx4y6H4sFcxrgt8kQ8ewX'); |
|
|
b.toString().should.equal('16JXnhxjJUhxfyx4y6H4sFcxrgt8kQ8ewX'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should classify from a custom network', function() { |
|
|
|
|
|
var custom = { |
|
|
|
|
|
name: 'customnetwork', |
|
|
|
|
|
pubkeyhash: 0x1c, |
|
|
|
|
|
privatekey: 0x1e, |
|
|
|
|
|
scripthash: 0x28, |
|
|
|
|
|
xpubkey: 0x02e8de8f, |
|
|
|
|
|
xprivkey: 0x02e8da54, |
|
|
|
|
|
networkMagic: 0x0c110907, |
|
|
|
|
|
port: 7333 |
|
|
|
|
|
}; |
|
|
|
|
|
var addressString = 'CX4WePxBwq1Y6u7VyMJfmmitE7GiTgC9aE'; |
|
|
|
|
|
Networks.add(custom); |
|
|
|
|
|
var network = Networks.get('customnetwork'); |
|
|
|
|
|
var address = Address.fromString(addressString); |
|
|
|
|
|
address.type.should.equal(Address.PayToPublicKeyHash); |
|
|
|
|
|
address.network.should.equal(network); |
|
|
|
|
|
Networks.remove(network); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('from a script', function() { |
|
|
describe('from a script', function() { |
|
|
it('should fail to build address from a non p2sh,p2pkh script', function() { |
|
|
it('should fail to build address from a non p2sh,p2pkh script', function() { |
|
|
var s = new Script('OP_CHECKMULTISIG'); |
|
|
var s = new Script('OP_CHECKMULTISIG'); |
|
@ -482,6 +508,15 @@ describe('Address', function() { |
|
|
expect(new Address(address.toObject()).toString()).to.equal(P2SHLivenet[0]); |
|
|
expect(new Address(address.toObject()).toString()).to.equal(P2SHLivenet[0]); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('will use the default network for an object', function() { |
|
|
|
|
|
var obj = { |
|
|
|
|
|
hash: '19a7d869032368fd1f1e26e5e73a4ad0e474960e', |
|
|
|
|
|
type: 'scripthash' |
|
|
|
|
|
}; |
|
|
|
|
|
var address = new Address(obj); |
|
|
|
|
|
address.network.should.equal(Networks.defaultNetwork); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('creating a P2SH address from public keys', function() { |
|
|
describe('creating a P2SH address from public keys', function() { |
|
|
|
|
|
|
|
|
var public1 = '02da5798ed0c055e31339eb9b5cef0d3c0ccdec84a62e2e255eb5c006d4f3e7f5b'; |
|
|
var public1 = '02da5798ed0c055e31339eb9b5cef0d3c0ccdec84a62e2e255eb5c006d4f3e7f5b'; |
|
|