Parity

如何在奇偶校驗 cli 上導出/顯示私鑰?

  • April 9, 2020

我在平價上做了這個命令

parity --chain mainnet account new

我得到了地址,但是如何導出或查看私鑰?

應該keystore在文件系統的某處創建一個文件夾。

找到這個文件夾的路徑,在下面的腳本中設置它並通過 Node.js 執行這個腳本:

const fs         = require("fs");
const keythereum = require("keythereum");

const KEYSTORE_DIR  = "The full path of your keystore folder";
const PASSWORD_FILE = "The full path of your password file";

for (const file of fs.readdirSync(KEYSTORE_DIR)) {
   const keyObject  = JSON.parse(fs.readFileSync(KEYSTORE_DIR + "/" + file, "utf8"));
   const publicAddr = keyObject.address;
   const privateKey = keythereum.recover(fs.readFileSync(PASSWORD_FILE), keyObject).toString("hex");
   console.log(`0x${publicAddr}: 0x${privateKey}`);
}

引用自:https://ethereum.stackexchange.com/questions/72336