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 ] } }
alper
  • 8,395
  • 11
  • 63
  • 152

3 Answers3

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

Fischa7
  • 108
  • 3
0

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

T Hyland
  • 1
  • 1
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.

Mir-Ismaili
  • 111
  • 4