1

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"));

if(!web3.isConnected()){
    console.log("notconnected");
    process.exit();
}

console.log(web3.personal

Returns, which does not have personal.listWallets:

Personal {
  _requestManager:
   RequestManager {
     provider:
      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' },
  sendTransaction:
   { [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 ] } }
4
  • What do you mean with 'unlocked'? How can an account be locked / unlocked? Mar 12, 2018 at 8:28
  • In order to send Tx we need to unlock an account: personal.unlockAccount(eth.accounts[0], "password"); @LauriPeltonen
    – alper
    Mar 12, 2018 at 8:33
  • Ah in that sense :) Mar 12, 2018 at 8:36
  • not necessarily exactly the same but some of the suggestions in this question may help
    – TC8
    Mar 12, 2018 at 9:08

3 Answers 3

1

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).

1
  • web3.personal does not provide listWallets under nodejs @Fischa7
    – alper
    Mar 13, 2018 at 22:08
0

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

0
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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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