知乎专栏 | 多维度架构 |
查看账号
neo@netkiller ~/ethereum % geth account list Account #0: {83fda0ba7e6cfa8d7319d78fa0e6b753a2bcb5a6} keystore:///home/neo/.ethereum/keystore/UTC--2018-01-20T04-04-06.786586541Z--83fda0ba7e6cfa8d7319d78fa0e6b753a2bcb5a6
创建账号
neo@netkiller ~/ethereum % geth account new Your new account is locked with a password. Please give a password. Do not forget this password. Passphrase: Repeat passphrase: Address: {e8abf98484325fd6afc59b804ac15804b978e607}
指定密码
$ echo "abc123" > password $ geth --password /path/to/password account new
账号创建在 ~/.ethereum/keystore 目录下
Mac: ~/Library/Ethereum/keystore Linux: ~/.ethereum/keystore Windows: %APPDATA%/Ethereum/keystore
neo@netkiller ~/.ethereum/keystore % ll total 8.0K -rw------- 1 neo neo 491 Jan 19 18:04 UTC--2018-01-20T04-04-06.786586541Z--83fda0ba7e6cfa8d7319d78fa0e6b753a2bcb5a6 -rw------- 1 neo neo 491 Jan 19 20:11 UTC--2018-01-20T06-11-23.608902164Z--e8abf98484325fd6afc59b804ac15804b978e607
neo@netkiller ~/ethereum % geth account list Account #0: {83fda0ba7e6cfa8d7319d78fa0e6b753a2bcb5a6} keystore:///home/neo/.ethereum/keystore/UTC--2018-01-20T04-04-06.786586541Z--83fda0ba7e6cfa8d7319d78fa0e6b753a2bcb5a6 Account #1: {e8abf98484325fd6afc59b804ac15804b978e607} keystore:///home/neo/.ethereum/keystore/UTC--2018-01-20T06-11-23.608902164Z--e8abf98484325fd6afc59b804ac15804b978e607
首先将私钥存储到文件中,然后导入,导入后需要输入密码。
[ethereum@netkiller ~]$ echo "f592b7bf06ca9fd7696ba95d6ed8e357de6a2379b6d5fe1ffd53c6b4b063cd4a" > privatekey [ethereum@netkiller ~]$ geth account import privatekey INFO [04-27|17:25:38] Maximum peer count ETH=25 LES=0 total=25 Your new account is locked with a password. Please give a password. Do not forget this password. Passphrase: Repeat passphrase: Address: {372fda02e8a1eca513f2ee5901dc55b8b5dd7411}
查看导入文件
[ethereum@netkiller ~]$ ls .ethereum/keystore/*372fda02e8a1eca513f2ee5901dc55b8b5dd7411 .ethereum/keystore/UTC--2018-04-27T09-25-48.189741023Z--372fda02e8a1eca513f2ee5901dc55b8b5dd7411 [ethereum@netkiller ~]$ cat .ethereum/keystore/UTC--2018-04-27T09-25-48.189741023Z--372fda02e8a1eca513f2ee5901dc55b8b5dd7411 {"address":"372fda02e8a1eca513f2ee5901dc55b8b5dd7411","crypto":{"cipher":"aes-128-ctr","ciphertext":"8e23a0274a4d91bea61273ee3ce2951c292698df13b2214e8afab5c9595a72c4","cipherparams":{"iv":"c5f4fd65e6b6da4f83d30f8d327905d1"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"593eb041c4425723af7ef58a55c03fc875749cd0f7174ce011047e41205e6cdd"},"mac":"e1f3bebd85632db39aaa6ff03fa7641109c1fe46cfcc4251c32d27ad002343eb"},"id":"ca863875-0702-49a8-b5c5-c46a50b95375","version":3}
最后一定记得删除私钥问题,因为这个私钥没有加密过,一旦泄露后果不堪设想。
[ethereum@netkiller ~]$ rm -rf privatekey
如果不存储文件可以单行执行,然后删除 history 历史文件
[ethereum@netkiller ~]$ geth account import <(echo f592b7bf06ca9fd7696ba95d6ed8e357de6a2379b6d5fe1ffd53c6b4b063cd4a) [ethereum@netkiller ~]$ >.bash_history