Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ightwallet.keystore.deriveKeyFromPassword is not an function ??? #186

Open
Hunter-Nomad opened this issue Feb 7, 2018 · 1 comment
Open

Comments

@Hunter-Nomad
Copy link

const lightwallet = require('eth-lightwallet');
lightwallet.keystore.deriveKeyFromPassword('12321',
    function (err, pwDerivedKey) {
        var seed = lightwallet.keystore.generateRandomSeed();
        var keystore = new lightwallet.keystore(seed, pwDerivedKey);

        keystore.generateNewAddress(pwDerivedKey);
        var address = keystore.getAddresses()[0];
        var prv_key = keystore.exportPrivateKey(address, pwDerivedKey);
        console.log('address and key: ', address, prv_key);
});

**

/home/user/Ethereum/web3jstest/test.js:26
lightwallet.keystore.deriveKeyFromPassword('12321',
^

TypeError: lightwallet.keystore.deriveKeyFromPassword is not a function
at Object. (/home/user/Ethereum/web3jstest/test.js:26:22)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3

**

@johunsang
Copy link

johunsang commented Feb 27, 2018

var password = Math.random().toString();
var seed = lightwallet.keystore.generateRandomSeed();

lightwallet.keystore.createVault({
    password: password,
    seedPhrase: seed,
    hdPathString: "m/0'/0'/0'"
}, function (err, ks) {

    ks.keyFromPassword(password, function (err, pwDerivedKey) {
        if (!ks.isDerivedKeyCorrect(pwDerivedKey)) {
            throw new Error("Incorrect derived key!");
        }

        try {
            ks.generateNewAddress(pwDerivedKey, 1);
        } catch (err) {
            console.log(err);
            console.trace();
        }
        var address = ks.getAddresses()[0];
        var prv_key = ks.exportPrivateKey(address, pwDerivedKey);

        console.log('address and key: ', address, prv_key);


    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants