public override void Execute() { var obj = _engine.Evaluate("Aelf.wallet.createNewWallet()"); string mnemonic = obj.ReadProperty <string>("mnemonic"); string privKey = obj.ReadProperty <string>("privateKey"); string address = obj.ReadProperty <string>("address"); JSValue keyPair = obj.ReadProperty <JSValue>("keyPair"); string pubKey = keyPair.CallFunction <string, string>("getPublic", "hex"); PrintAccount(address, mnemonic, privKey, pubKey); if (!ReadLine.Read("Saving account info to file? (Y/N): ").Equals("y", StringComparison.OrdinalIgnoreCase)) { return; } var password = PromptPassword(); var accountFile = _option.GetPathForAccount(address); Pem.WriteKeyPair(accountFile, privKey, pubKey, password); }
private void ExposeAccountSaver() { _context.GlobalObject.Binding.SetMethod <string, string, string, string>("__saveAccount__", (address, privKey, pubKey, password) => { Pem.WriteKeyPair(_option.GetPathForAccount(address), privKey, pubKey, password); }); }