diff --git a/Cargo.lock b/Cargo.lock index 1ec48cc9..a8880fef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1706,9 +1706,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -1747,9 +1747,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.33" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02" dependencies = [ "cfg-if", "libc", diff --git a/ckb-sdk/src/wallet/keystore/mod.rs b/ckb-sdk/src/wallet/keystore/mod.rs index 7c9b208e..91b6bfd5 100644 --- a/ckb-sdk/src/wallet/keystore/mod.rs +++ b/ckb-sdk/src/wallet/keystore/mod.rs @@ -72,6 +72,7 @@ impl KeyStore { let abs_path = self.storage.store_key(key.filename(), &key, password)?; let hash160 = key.hash160().clone(); self.files.insert(hash160.clone(), abs_path); + self.ckb_roots.insert(hash160.clone(), key.ckb_root()); Ok(hash160) } pub fn get_accounts(&mut self) -> &HashMap { @@ -294,7 +295,7 @@ impl KeyStore { } // NOTE: assume refresh keystore directory is not a hot action - fn refresh_dir(&mut self) -> Result<(), Error> { + pub fn refresh_dir(&mut self) -> Result<(), Error> { let mut files = HashMap::default(); let mut ckb_roots = HashMap::default(); for entry in fs::read_dir(&self.keys_dir)? { diff --git a/src/subcommands/account.rs b/src/subcommands/account.rs index b0f36354..d4d3561b 100644 --- a/src/subcommands/account.rs +++ b/src/subcommands/account.rs @@ -184,6 +184,9 @@ impl<'a> CliSubCommand for AccountSubCommand<'a> { let only_mainnet_address = m.is_present("only-mainnet-address"); let only_testnet_address = m.is_present("only-testnet-address"); let partial_fields = only_mainnet_address || only_testnet_address; + self.key_store + .refresh_dir() + .map_err(|err| err.to_string())?; let resp = accounts .into_iter() .enumerate()