Commit 0d7bfe4a authored by Zhenzhen Zhan's avatar Zhenzhen Zhan
Browse files

Address conversion

parent 94d52f5f
......@@ -256,13 +256,13 @@ describe('PrivateKey', function() {
it('should output this known livenet address correctly', function() {
var privkey = PrivateKey.fromWIF('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m');
var address = privkey.toAddress();
address.toString().should.equal('1A6ut1tWnUq1SEQLMr4ttDh24wcbJ5o9TT');
address.toString().should.equal('CRWM4uCa9xu5WnxRkxaRegMcyENeEG2qshbU');
});
it('should output this known testnet address correctly', function() {
var privkey = PrivateKey.fromWIF('cR4qogdN9UxLZJXCNFNwDRRZNeLRWuds9TTSuLNweFVjiaE4gPaq');
var address = privkey.toAddress();
address.toString().should.equal('mtX8nPZZdJ8d3QNLRJ1oJTiEi26Sj6LQXS');
address.toString().should.equal('tCRWRzZbwogyj2wuG76D7hviw5Vg1K8AVH7be');
});
it('creates network specific address', function() {
......@@ -423,12 +423,12 @@ describe('PrivateKey', function() {
it('creates an address as expected from WIF, livenet', function() {
var privkey = new PrivateKey('5J2NYGstJg7aJQEqNwYp4enG5BSfFdKXVTtBLvHicnRGD5kjxi6');
privkey.publicKey.toAddress().toString().should.equal('135bwugFCmhmNU3SeCsJeTqvo5ViymgwZ9');
privkey.publicKey.toAddress().toString().should.equal('CRWE3bGTwhKNPYtfQ4rnT67s896n7PfRP6bA');
});
it('creates an address as expected from WIF, testnet', function() {
var privkey = new PrivateKey('92VYMmwFLXRwXn5688edGxYYgMFsc3fUXYhGp17WocQhU6zG1kd');
privkey.publicKey.toAddress().toString().should.equal('moiAvLUw16qgrwhFGo1eDnXHC2wPMYiv7Y');
privkey.publicKey.toAddress().toString().should.equal('tCRWMBbjtj4MXk1ioS14chmeFtYA2A4oYDQXq');
});
});
......@@ -337,13 +337,13 @@ describe('PublicKey', function() {
it('should output this known mainnet address correctly', function() {
var pk = new PublicKey('03c87bd0e162f26969da8509cafcb7b8c8d202af30b928c582e263dd13ee9a9781');
var address = pk.toAddress('livenet');
address.toString().should.equal('1A6ut1tWnUq1SEQLMr4ttDh24wcbJ5o9TT');
address.toString().should.equal('CRWM4uCa9xu5WnxRkxaRegMcyENeEG2qshbU');
});
it('should output this known testnet address correctly', function() {
var pk = new PublicKey('0293126ccc927c111b88a0fe09baa0eca719e2a3e087e8a5d1059163f5c566feef');
var address = pk.toAddress('testnet');
address.toString().should.equal('mtX8nPZZdJ8d3QNLRJ1oJTiEi26Sj6LQXS');
address.toString().should.equal('tCRWRzZbwogyj2wuG76D7hviw5Vg1K8AVH7be');
});
});
......@@ -358,13 +358,13 @@ describe('PublicKey', function() {
['Kwr371tjA9u2rFSMZjTNun2PXXP3WPZu2afRHTcta6KxEUdm1vEw', 'CRWZmJBN9L4ys7BPeXX72qkyuXAE2tnXQHJP'],
['L3Hq7a8FEQwJkW1M2GNKDW28546Vp5miewcCzSqUD9kCAXrJdS3g', 'CRWPPiLrEo7oDJWUX9YzUVjkFtz54pAEep8N']
];
data.forEach(function(d){
var publicKey = PrivateKey.fromWIF(d[0]).toPublicKey();
var address = Address.fromString(d[1]);
address.hashBuffer.should.deep.equal(publicKey._getID());
});
});
describe('#toString', function() {
......
......@@ -21,10 +21,10 @@ describe('MultiSigScriptHashInput', function() {
var public1 = privateKey1.publicKey;
var public2 = privateKey2.publicKey;
var public3 = privateKey3.publicKey;
var address = new Address('CJmUPXS4thHXQQ5Lx3YRtaEBoRwSggDWtH');
var address = new Address('CRMNqJUeo7WGoW2vTdweUH7hu4dufwpD79NN');
var output = {
address: 'CJmUPXS4thHXQQ5Lx3YRtaEBoRwSggDWtH',
address: 'CRMNqJUeo7WGoW2vTdweUH7hu4dufwpD79NN',
txId: '66e64ef8a3b384164b78453fa8c8194de9a473ba14f89485a0e433699daec140',
outputIndex: 0,
script: new Script(address),
......
......@@ -11,7 +11,7 @@ var UnspentOutput = bitcore.Transaction.UnspentOutput;
describe('UnspentOutput', function() {
var sampleData1 = {
'address': 'mszYqVnqKoQx4jcTdJXxwKAissE3Jbrrc1',
'address': 'tCRWRTyf42xgEKGvbMDR8E6MnXyqrSigmmGhF',
'txId': 'a477af6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458',
'outputIndex': 0,
'script': 'OP_DUP OP_HASH160 20 0x88d9931ea73d60eaf7e5671efc0552b912911f2a OP_EQUALVERIFY OP_CHECKSIG',
......@@ -20,7 +20,7 @@ describe('UnspentOutput', function() {
var sampleData2 = {
'txid': 'e42447187db5a29d6db161661e4bc66d61c3e499690fe5ea47f87b79ca573986',
'vout': 1,
'address': 'mgBCJAsvzgT2qNNeXsoECg2uPKrUsZ76up',
'address': 'tCRWDed7j84M7MMhE7QKhVMd9QAMK5AGitPEd',
'scriptPubKey': '76a914073b7eae2823efa349e3b9155b8a735526463a0f88ac',
'amount': 0.01080000
};
......@@ -49,7 +49,7 @@ describe('UnspentOutput', function() {
it('displays nicely on the console', function() {
var expected = '<UnspentOutput: a477af6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458:0' +
', satoshis: 1020000, address: mszYqVnqKoQx4jcTdJXxwKAissE3Jbrrc1>';
', satoshis: 1020000, address: tCRWRTyf42xgEKGvbMDR8E6MnXyqrSigmmGhF>';
expect(new UnspentOutput(sampleData1).inspect()).to.equal(expected);
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment