ethers.js/tests/make-tests/make-wallets.js

72 lines
2.3 KiB
JavaScript
Raw Normal View History

2017-02-24 22:42:54 +03:00
'use strict';
var fs = require('fs');
var path = require('path');
var utils = require('../utils.js');
2017-02-24 22:42:54 +03:00
function prefixAddress(address) {
if (address.substring(0, 2) !== '0x') {
address = '0x' + address;
}
return address.toLowerCase();
2017-02-24 22:42:54 +03:00
}
var Output = [];
/*
Output.push({
type: 'brainwallet',
address: '0xbed9d2E41BdD066f702C4bDB86eB3A3740101acC',
password: 'password',
privateKey: '',
username: 'ricmoo',
});
*/
var privateKeys = {
'0x0b88d4b324ec24c8c078551e6e5075547157e5b6': '0xd4375d2a931db84ea8825b69a3128913597744d9236cacec675cc18e1bda4446',
'0x2e326fa404fc3661de4f4361776ed9bbabdc26e3': '0xcf367fc32bf789b3339c6664af4a12263e9db0e0eb70f247da1d1165e150c487',
'0x00a329c0648769a73afac7f9381e08fb43dbea72': '0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7',
'0x4a9cf99357f5789251a8d7fad5b86d0f31eeb938': '0xa016182717223d01f776149ec0b4a217d0e9930cad263f205427c6d3cd5560e7',
'0x88a5c2d9919e46f883eb62f7b8dd9d0cc45bc290': '0xf03e581353c794928373fb0893bc731aefc4c4e234e643f3a46998b03cd4d7c5',
'0x17c5185167401ed00cf5f5b2fc97d9bbfdb7d025': '0x4242424242424242424242424242424242424242424242424242424242424242',
}
2017-02-24 22:42:54 +03:00
var walletPath = path.join(__dirname, 'test-wallets');
fs.readdirSync(walletPath).forEach(function(filename) {
var data = require(path.join(walletPath, filename));
var name = filename.substring(0, filename.length - 5).split('-')[1];
2017-02-24 22:42:54 +03:00
// The password is the last segment of the filename
var password = filename.substring(0, filename.length - 5).split('-');
password = password[password.length - 1];
if (password === 'life') { password = 'foo'; }
2017-02-24 22:42:54 +03:00
if (data.ethaddr) {
Output.push({
type: 'crowdsale',
address: prefixAddress(data.ethaddr),
json: JSON.stringify(data),
name: name,
2017-02-24 22:42:54 +03:00
password: password,
privateKey: privateKeys[prefixAddress(data.ethaddr)],
2017-02-24 22:42:54 +03:00
});
} else {
Output.push({
type: 'secret-storage',
address: prefixAddress(data.address),
json: JSON.stringify(data),
name: name,
2017-02-24 22:42:54 +03:00
password: password,
privateKey: privateKeys[prefixAddress(data.address)],
2017-02-24 22:42:54 +03:00
});
}
});
utils.saveTests('wallets', Output);