Create (or overwrite) an account with a given secret key.
(
root: impl AsRef<Path>,
name: &AccountName,
sk: SecretKey,
)
| 161 | |
| 162 | /// Create (or overwrite) an account with a given secret key. |
| 163 | pub fn create( |
| 164 | root: impl AsRef<Path>, |
| 165 | name: &AccountName, |
| 166 | sk: SecretKey, |
| 167 | ) -> anyhow::Result<Self> { |
| 168 | let pk = sk.public_key(); |
| 169 | let dir = root.as_ref().join(name.path()); |
| 170 | let acc = Self { |
| 171 | name: name.clone(), |
| 172 | secret_key: sk, |
| 173 | public_key: pk, |
| 174 | path: dir, |
| 175 | }; |
| 176 | acc.export()?; |
| 177 | Ok(acc) |
| 178 | } |
| 179 | |
| 180 | /// Write the keys to files. |
| 181 | fn export(&self) -> anyhow::Result<()> { |
nothing calls this directly
no test coverage detected