[Ethereum] Error: personal_unlockAccount method not implemented

json-rpcnodejsweb3js

Using web3 under nodejs I suddenly want to unlock my account before calling a DAO contract function:

var Web3 = require('./node_modules/web3/lib/web3');

// dont override global variable
if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
   window.Web3 = Web3;
}

module.exports = Web3;

var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

var accounts = web3.eth.accounts;
web3.personal.unlockAccount(accounts[0], "mypassword", 2);
console.log("yay")

But then I get this error:

/home/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61
        throw errors.InvalidResponse(result);
        ^

Error: The method personal_unlockAccount does not exist/is not available
    at Object.module.exports.InvalidResponse (/home/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/errors.js:35:16)
    at RequestManager.send (/hhome/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61:22)
    at Personal.send [as unlockAccount] (/home/andres/Documents/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/method.js:145:58)
    at Object.<anonymous> (/hhome/andres/Documents/Code/Crypto/ethWithdrawer/approver_test.js:77:15)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)

Or this other error in other box:

/home/user/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61
throw errors.InvalidResponse(result);
^

Error: personal_unlockAccount method not implemented
at Object.module.exports.InvalidResponse (/home/user/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/errors.js:35:16)
at RequestManager.send (/home/user/Code/Crypto/ethWithdrawer/node_modules/web3/lib/web3/requestmanager.js:61:22)
at Personal.send [as unlockAccount] (/home/user/Code/Dao/ethWithdrawer/node_modules/web3/lib/web3/method.js:145:58)
at /home/user/Code/Crypto/ethWithdrawer/web3caller.js:33:19
at Array.forEach (native)
at Object.<anonymous> (/home/user/Code/Crypto/ethWithdrawer/web3caller.js:23:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

What's the problem? The function is there, I can see it by doing console.log(web3.personal).

Best Answer

I assume that you are attempting to connect to a geth node. It might be that this node does not have the personal management API loaded which you could specify while starting

geth --rpcapi eth,web3,personal --rpc

as described. Please take care, everyone with (local) access to your machine could now mess with your accounts, therefore this is disabled by default.