Created
December 28, 2017 13:22
-
-
Save cyclux/cecf914aef9d1bb24a9ec3b370c5aec3 to your computer and use it in GitHub Desktop.
Generate IOTA addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var IOTA; | |
IOTA = require('./iota.lib.js/lib/iota'); | |
// Get values from CLI parameters | |
var index_start = parseInt(process.argv[2]); | |
var amountOfAddresses = process.argv[3]; | |
var seed = process.argv[4]; | |
var iotajs = new IOTA({ | |
'host': 'http://localhost', | |
'port': '14265' | |
}); | |
function generateAddresses(seed, index_start) { | |
if (!amountOfAddresses){ | |
amountOfAddresses = 20; | |
} | |
console.log('Generating ' + amountOfAddresses + ' addresses (start: ' + index_start + ')..'); | |
iotajs.api.getNewAddress(seed, {'index': index_start,'checksum': true, 'total': amountOfAddresses, 'security': 2, 'returnAll': true}, function(_, addresses) { | |
console.log('SEED: ' + seed); | |
var iter = -1; | |
addresses.map(function(address){ | |
iter += 1; | |
console.log('#' + iter + ' | ' + address); | |
}); | |
console.log('Successfully created new addresses!'); | |
}); | |
} | |
generateAddresses(seed, index_start); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
node generate_addresses.js 0 100 YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9Y
0 -> index start (default is 0)
100 -> index end (generate until this index )