不能用箱子写密钥文件
Cannot write keyfile with crate
我正在尝试使用此处的函数 https://docs.rs/ethkey/0.2.5/ethkey/ 为以太坊编写密钥文件:
let key = EthAccount::load_or_generate("Users/Documents/Code/Thor/thor/parity/keys", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address());
不幸的是,它不起作用并且出现以下错误:
thread 'main' panicked at 'should load or generate new eth key: Error(SerdeJsonError(Error("Is a directory (os error 21)", line: 0, column: 0)), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })', src/libcore/result.rs:999:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
更新
load_or_generate
当我输入 ~
作为第一个参数时有效,但不是我真正想要我的密钥的文件路径,即 Users/Documents/Code/Thor/thor/parity/keys
更新
我现在使用前面带有斜线的完整路径,但仍然有效。即
let key = EthAccount::load_or_generate("./Users/samueldare/Documents/Code/Thor/thor/parity/keys", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address());
我会在这方面得到指点
在文件路径的开头添加“/”。
https://doc.rust-lang.org/std/path/struct.Path.html
例如:
let key = EthAccount::load_or_generate("/Users/Documents/Code/Thor/thor/parity/keys", "passwd")
.expect("should load or generate new eth key");
在您的第一个问题中,这不是必需的,因为您使用“~”作为您的路径,这本身就是一个有效路径。这一次,您从“/Users...”开始,这需要一个初始斜杠“/”。
我正在尝试使用此处的函数 https://docs.rs/ethkey/0.2.5/ethkey/ 为以太坊编写密钥文件:
let key = EthAccount::load_or_generate("Users/Documents/Code/Thor/thor/parity/keys", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address());
不幸的是,它不起作用并且出现以下错误:
thread 'main' panicked at 'should load or generate new eth key: Error(SerdeJsonError(Error("Is a directory (os error 21)", line: 0, column: 0)), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })', src/libcore/result.rs:999:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
更新
load_or_generate
当我输入 ~
作为第一个参数时有效,但不是我真正想要我的密钥的文件路径,即 Users/Documents/Code/Thor/thor/parity/keys
更新
我现在使用前面带有斜线的完整路径,但仍然有效。即
let key = EthAccount::load_or_generate("./Users/samueldare/Documents/Code/Thor/thor/parity/keys", "passwd")
.expect("should load or generate new eth key");
println!("{:?}", key.address());
我会在这方面得到指点
在文件路径的开头添加“/”。
https://doc.rust-lang.org/std/path/struct.Path.html
例如:
let key = EthAccount::load_or_generate("/Users/Documents/Code/Thor/thor/parity/keys", "passwd")
.expect("should load or generate new eth key");
在您的第一个问题中,这不是必需的,因为您使用“~”作为您的路径,这本身就是一个有效路径。这一次,您从“/Users...”开始,这需要一个初始斜杠“/”。