(二)區塊鏈開發之以太坊CLI控制檯命令

1、賬戶管理

創建新賬戶(密碼:Testteam1&)

➜  geth geth --datadir "./db" account new
INFO [10-09|17:20:34.942] 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: {751b9bad789fe375d498463bc8125892b3c433ad}

列出已存在賬號

➜  geth geth --datadir "./db" account list
INFO [10-09|17:23:44.141] Maximum peer count                       ETH=25 LES=0 total=25
Account #0: {2dd6b2362d6351b18bd3af9519b8e5b2e44d0339} keystore:///Users/xxx/Desktop/nasnano/ethereum/geth/db/keystore/UTC--2018-10-09T04-00-29.721332367Z--2dd6b2362d6351b18bd3af9519b8e5b2e44d0339
Account #1: {98d03a20eb02fc526534cabbda6dc2e6b43de214} keystore:///Users/xxx/Desktop/nasnano/ethereum/geth/db/keystore/UTC--2018-10-09T05-12-32.419943606Z--98d03a20eb02fc526534cabbda6dc2e6b43de214
Account #2: {751b9bad789fe375d498463bc8125892b3c433ad} keystore:///Users/xxx/Desktop/nasnano/ethereum/geth/db/keystore/UTC--2018-10-09T09-21-18.110637457Z--751b9bad789fe375d498463bc8125892b3c433ad

修改賬號密碼

➜  geth geth --datadir "./db" account update 2dd6b2362d6351b18bd3af9519b8e5b2e44d0339
INFO [10-09|17:27:18.958] Maximum peer count                       ETH=25 LES=0 total=25
Unlocking account 2dd6b2362d6351b18bd3af9519b8e5b2e44d0339 | Attempt 1/3
Passphrase:
INFO [10-09|17:27:27.612] Unlocked account                         address=0x2dd6b2362D6351B18BD3af9519b8E5B2e44d0339
Please give a new password. Do not forget this password.
Passphrase:
Repeat passphrase:

導入祕鑰文件(ecc.key是ECDSA的私鑰)

➜  geth geth --datadir "./db" account update import ecc.key

2、區塊數據管理(需要限制節點運行)

導出區塊數據(導出db目錄中的區塊數據到bak文件)

➜  geth geth --datadir "./db" account update import ecc.key

移除區塊數據(移除db目錄中的區塊數據)

➜  geth geth --datadir "./db" removedb

導入區塊數據

➜  geth geth --datadir "./db" init gensis.json

➜  geth geth --datadir "./db" import ./bak

跟新區塊數據(更新db目錄中區塊數據,會向其他節點重新同步數據)

➜  geth geth --datadir "./db" upgradedb

從區塊鏈中Dump指定區塊數據

➜  geth geth --datadir "./db" dump 0

geth dump number/blockHash,dump後可以傳入區塊編號或區塊hash值

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章