我正在尝试使用此板条箱生成以太坊地址:https://docs.rs/ethkey/0.2.5/ethkey/
use ethkey::prelude::*;
fn main() {
let key = EthAccount::load_or_generate("~/", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address())
}
这是文档中的示例,似乎不起作用。 我收到以下错误:
货运运行编译ethkey v0.1.0 (/用户/ samueldare /文档/代码/ Thor / ethkey) 在1.34秒内完成开发[未优化+ debuginfo]目标 恐慌的运行
target/debug/ethkey
线程“主”应该加载或生成新的eth密钥:Error(IoError(Os {code:2,kind: 找不到,消息:“没有这样的文件或目录”}),状态{next_error: 无,回溯:InternalBacktrace {回溯:无}})', src / libcore / result.rs:999:5注意:使用RUST_BACKTRACE=1
运行 环境变量以显示回溯。
我已经使用~/
作为在rust中生成密钥文件的最后一次尝试,但是它似乎仍然不起作用。
我将不胜感激与此相关的所有指针
答案 0 :(得分:1)
load_or_generate()
的第一个参数采用std::path::Path,不带斜杠('/')。删除斜杠:
fn main() {
let key = EthAccount::load_or_generate("~", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address())
}
示例输出:
05:47 ethtest (master) ✗ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/ethtest`
Address(0x8248af6d1765e559509060b88e540a3567c42d20)
05:47 ethtest (master) ✗