I am using geth via third party application. I want to verify that specific Ethereum accounts are already unlocked or not, since unlocking an account can be timeout.

personal.unlockAccount(eth.accounts[0], "password");

[Q] Is there any way to verify that specific Ethereum accounts are already unlocked?

Please note that following script:

var Personal = require('web3-eth-personal');

Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));



Returns, which does not have personal.listWallets:

Personal {
   RequestManager {
      HttpProvider {
        host: 'http://localhost:8545',
        timeout: 0,
        user: undefined,
        password: undefined,
        headers: undefined },
     polls: {},
     timeout: null },
  newAccount: { [Function: send] request: [Function: bound ], call: 'personal_newAccount' },
  importRawKey: { [Function: send] request: [Function: bound ], call: 'personal_importRawKey' },
  unlockAccount: { [Function: send] request: [Function: bound ], call: 'personal_unlockAccount' },
  ecRecover: { [Function: send] request: [Function: bound ], call: 'personal_ecRecover' },
  sign: { [Function: send] request: [Function: bound ], call: 'personal_sign' },
   { [Function: send]
     request: [Function: bound ],
     call: 'personal_sendTransaction' },
  lockAccount: { [Function: send] request: [Function: bound ], call: 'personal_lockAccount' },
  listAccounts: [Getter],
  getListAccounts: { [Function: get] request: [Function: bound ] } }
  • What do you mean with 'unlocked'? How can an account be locked / unlocked? Mar 12 '18 at 8:28
  • In order to send Tx we need to unlock an account: personal.unlockAccount(eth.accounts[0], "password"); @LauriPeltonen
    – alper
    Mar 12 '18 at 8:33
  • Ah in that sense :) Mar 12 '18 at 8:36
  • not necessarily exactly the same but some of the suggestions in this question may help
    – TC8
    Mar 12 '18 at 9:08

Have a look at https://ethereum.stackexchange.com/a/32059.

Running personal.listWallets displays a list of all your wallets and shows their status (locked or unlocked).

  • web3.personal does not provide listWallets under nodejs @Fischa7
    – alper
    Mar 13 '18 at 22:08

personal.listAccounts This will give you a list of address's within a wallet.

personal.listWallets.filter(function (wallet) {return wallet.status === 'Unlocked'})

Unfortunately, it doesn't support advanced javascript features (arrow functions and object destructuring), now (geth v1.10.0) . So it's not possible to write it as below concise way:

personal.listWallets.filter({status} => status === 'Unlocked')

Maybe in the future.

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.