Crate 找不到路径

塞缪尔·达雷

我正在尝试使用此板条箱生成以太坊地址: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 (/Users/samueldare/Documents/Code/Thor/ethkey) 在 1.34 秒内完成开发 [unoptimized + debuginfo] 目标运行target/debug/ethkey线程“main”恐慌于“应该加载或生成新的 eth 密钥” : Error(IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" }), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })', src/libcore/result .rs:999:5 注意:使用RUST_BACKTRACE=1环境变量运行以显示回溯。

~/最后一次尝试用 Rust生成密钥文件,但它似乎仍然不起作用。

我将不胜感激任何与此有关的指示

园丁

的第一个参数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) ✗ 

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章