I am using eth-lightwallet on a NodeJS server. I am getting a stack trace when I try and get the private key from the keystore. It is flagging this line "keystore.generateNewAddress(pwDerivedKey);" I cannot see how it is related. When I comment out the line "account.prv_key = keystore.exportPrivateKey(sendingAddr, pwDerivedKey);" it appears to work flawlessly. Am I doing something wrong? The error is throwing "No seed set" however when I look in debug mode the seed is most certainly set. I am new to Node and suspect it has something to do with the asynchronous nature of Node. I have included the code and the stacktrace below. Thank you.
lightwallet.keystore.deriveKeyFromPassword('mypassword',
function (err, pwDerivedKey) {
var seed = lightwallet.keystore.generateRandomSeed();
var keystore = new lightwallet.keystore(seed, pwDerivedKey);
keystore.generateNewAddress(pwDerivedKey);
account.address = keystore.getAddresses()[0];
account.prv_key = keystore.exportPrivateKey(sendingAddr, pwDerivedKey);
})
/Users/username/WebstormProjects/eth-project/nodejs-server/node_modules/eth-lightwallet/lib/keystore.js:389
throw new Error('KeyStore.generateNewAddress: No seed set');
^
Error: KeyStore.generateNewAddress: No seed set
at KeyStore.generateNewAddress (/Users/username/WebstormProjects/eth-project/nodejs-server/node_modules/eth-lightwallet/lib/keystore.js:389:11)
at /Users/username/WebstormProjects/eth-project/nodejs-server/controllers/ActorService.js:39:20
at cb (/Users/username/WebstormProjects/eth-project/nodejs-server/node_modules/eth-lightwallet/lib/keystore.js:459:7)
at /Users/username/WebstormProjects/eth-project/nodejs-server/node_modules/eth-lightwallet/node_modules/scrypt-async/scrypt-async.js:474:9
at Immediate._onImmediate (/Users/username/WebstormProjects/eth-project/nodejs-server/node_modules/eth-lightwallet/node_modules/scrypt-async/scrypt-async.js:433:11)
at processImmediate [as _immediateCallback] (timers.js:383:17)