I have a script that I run with geth attach, and then I use:
primary = eth.accounts[0];
personal.unlockAccount(primary, "password");
like I saw in the example script.
Doing this in geth usually takes about one or two seconds. I learned there was another way to unlock accounts. I was wondering if it was faster to unlock directly with geth --unlock "0xaddress" --password "password" attach. What does it do differently ?
How can I know if it unlocked successfully ? If I use a random address or password instead of the correct ones, attach still opens correctly.
EDIT: I found in the answer of a duplicate question that you can't use --unlock with attach, which wasn't in the original answer (or at least not clearly).
Geth attach "opens correctly" because it ignores those flags. You can run geth --unlock "0xaddress" --password "password" attach or geth --password --testnet --testnet attach and it will open like geth attach (flag order seems to be important sometimes though, you can't use password after testnet or it ignores attach).
--passwordalways expect a file path ? If I have my password in a variable, could--password $passwordwork ? I can't get it to work. My primary account is unlocked automatically for some reason, and I can't unlock my second with--unlock– Teleporting Goat Jan 17 '17 at 12:48