1

I want to invoke a send transaction from my nodejs code using web3js api. But I'm getting error at unlock step: could not decrypt key with given passphrase. I added default account assignment after looking at some other posts. But still the same error. Any clue?

web3.eth.defaultAccount = web3.eth.coinbase;;
web3.personal.unlockAccount (fromAddress, passphrase, 15000, function(err, result) {

    if (err) {
        console.log('DAO unlock error: ' +err);
        return next(err, null);
    }

    web3.eth.sendTransaction(fromAddress, toAddress, passphrase, sendAmount, function (err, result) {
        if (err) return next(err, null);

        return next(null, result);
    });


});
0

I tested your code and the callback of unlockAccount not be executed, but also didn't get error info of "could not decrypt key with given passphrase". I modified your code and the result of executing is ok, as follows:

var fromAddress = eth.accounts[0];
var toAddress = eth.accounts[1];
var flag = personal.unlockAccount(eth.accounts[1], "123",1500);
if(flag){
    eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:10000000000000}, function (err, result) {
        if (err){
          console.log(err);
          return;
        }
        return console.log('true');
    });
}

and there is a transaction created

> txpool.status
{
  pending: 1,
  queued: 0
}

Hope it helps~

0

I found the answer to https://stackoverflow.com/questions/48271310/geth-error-could-not-decrypt-key-with-given-passphrase helped me - for some reason unlocking using personal.unlockAccount(eth.accounts[0]) worked just fine when entering a blank passphrase (or personal.unlockAccount(eth.accounts[0], "", 15000) ) - I initially suspected that there's an issue with the passphrase setting for coinbase, but after further reading it looks like it's looking for the account password (which hadn't been set) and not the passphrase

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.