Skip to content

Commit b01a759

Browse files
remagpieforiequal0
authored andcommitted
Try to unlock account only when it is imported
1 parent 9f3abff commit b01a759

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

codechain/run_node.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,13 @@ fn load_password_file(path: &Option<String>) -> Result<PasswordFile, String> {
193193
fn unlock_accounts(ap: &AccountProvider, pf: &PasswordFile) -> Result<(), String> {
194194
for entry in pf.entries() {
195195
let entry_address = entry.address.into_address();
196-
ap.unlock_account_permanently(entry_address, entry.password.clone())
197-
.map_err(|e| format!("Failed to unlock account {}: {}", entry_address, e))?;
196+
let has_account = ap
197+
.has_account(&entry_address)
198+
.map_err(|e| format!("Unexpected error while querying account {}: {}", entry_address, e))?;
199+
if has_account {
200+
ap.unlock_account_permanently(entry_address, entry.password.clone())
201+
.map_err(|e| format!("Failed to unlock account {}: {}", entry_address, e))?;
202+
}
198203
}
199204
Ok(())
200205
}

0 commit comments

Comments
 (0)