Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

11.6. 賬號管理

11.6.1. 新建賬號

查看賬號

				
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				
				
			

11.6.2. 查看賬號

				
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				
				
			

11.6.3. 從私鑰導入以太坊地址

首先將私鑰存儲到檔案中,然後導入,導入後需要輸入密碼。

			
[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