Skip to content

Commit 2b79fae

Browse files
committed
Update to tiny-bip39 2.0.0
1 parent ff22f86 commit 2b79fae

File tree

6 files changed

+34
-59
lines changed

6 files changed

+34
-59
lines changed

Diff for: Cargo.lock

+5-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: crates/atuin-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ reqwest = { workspace = true, optional = true }
6565
hex = { version = "0.4", optional = true }
6666
sha2 = { version = "0.10", optional = true }
6767
indicatif = "0.17.7"
68-
tiny-bip39 = "=1.0.0"
68+
tiny-bip39 = "2.0.0"
6969

7070
# theme
7171
crossterm = { version = "0.28.1", features = ["serde"] }

Diff for: crates/atuin-client/src/login.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,16 @@ pub async fn login(
2323
let key = match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) {
2424
Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?,
2525
Err(err) => {
26-
match err.downcast_ref::<bip39::ErrorKind>() {
27-
Some(err) => {
28-
match err {
29-
// assume they copied in the base64 key
30-
bip39::ErrorKind::InvalidWord => key,
31-
bip39::ErrorKind::InvalidChecksum => {
32-
bail!("key mnemonic was not valid")
33-
}
34-
bip39::ErrorKind::InvalidKeysize(_)
35-
| bip39::ErrorKind::InvalidWordLength(_)
36-
| bip39::ErrorKind::InvalidEntropyLength(_, _) => {
37-
bail!("key was not the correct length")
38-
}
39-
}
26+
match err {
27+
// assume they copied in the base64 key
28+
bip39::ErrorKind::InvalidWord(_) => key,
29+
bip39::ErrorKind::InvalidChecksum => {
30+
bail!("key mnemonic was not valid")
4031
}
41-
_ => {
42-
// unknown error. assume they copied the base64 key
43-
key
32+
bip39::ErrorKind::InvalidKeysize(_)
33+
| bip39::ErrorKind::InvalidWordLength(_)
34+
| bip39::ErrorKind::InvalidEntropyLength(_, _) => {
35+
bail!("key was not the correct length")
4436
}
4537
}
4638
}

Diff for: crates/atuin/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ rpassword = "7.0"
7070
semver = { workspace = true }
7171
rustix = { workspace = true }
7272
runtime-format = "0.1.3"
73-
tiny-bip39 = "1"
73+
tiny-bip39 = "2"
7474
futures-util = "0.3"
7575
fuzzy-matcher = "0.3.7"
7676
colored = "2.0.4"

Diff for: crates/atuin/src/command/client/account/login.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,16 @@ impl Cmd {
7777
match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) {
7878
Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?,
7979
Err(err) => {
80-
match err.downcast_ref::<bip39::ErrorKind>() {
81-
Some(err) => {
82-
match err {
83-
// assume they copied in the base64 key
84-
bip39::ErrorKind::InvalidWord => key,
85-
bip39::ErrorKind::InvalidChecksum => {
86-
bail!("key mnemonic was not valid")
87-
}
88-
bip39::ErrorKind::InvalidKeysize(_)
89-
| bip39::ErrorKind::InvalidWordLength(_)
90-
| bip39::ErrorKind::InvalidEntropyLength(_, _) => {
91-
bail!("key was not the correct length")
92-
}
93-
}
80+
match err {
81+
// assume they copied in the base64 key
82+
bip39::ErrorKind::InvalidWord(_) => key,
83+
bip39::ErrorKind::InvalidChecksum => {
84+
bail!("key mnemonic was not valid")
9485
}
95-
_ => {
96-
// unknown error. assume they copied the base64 key
97-
key
86+
bip39::ErrorKind::InvalidKeysize(_)
87+
| bip39::ErrorKind::InvalidWordLength(_)
88+
| bip39::ErrorKind::InvalidEntropyLength(_, _) => {
89+
bail!("key was not the correct length")
9890
}
9991
}
10092
}

Diff for: crates/atuin/src/command/client/store/rekey.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,16 @@ impl Rekey {
2323
let key = match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) {
2424
Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?,
2525
Err(err) => {
26-
match err.downcast_ref::<bip39::ErrorKind>() {
27-
Some(err) => {
28-
match err {
29-
// assume they copied in the base64 key
30-
bip39::ErrorKind::InvalidWord => key,
31-
bip39::ErrorKind::InvalidChecksum => {
32-
bail!("key mnemonic was not valid")
33-
}
34-
bip39::ErrorKind::InvalidKeysize(_)
35-
| bip39::ErrorKind::InvalidWordLength(_)
36-
| bip39::ErrorKind::InvalidEntropyLength(_, _) => {
37-
bail!("key was not the correct length")
38-
}
39-
}
26+
match err {
27+
// assume they copied in the base64 key
28+
bip39::ErrorKind::InvalidWord(_) => key,
29+
bip39::ErrorKind::InvalidChecksum => {
30+
bail!("key mnemonic was not valid")
4031
}
41-
_ => {
42-
// unknown error. assume they copied the base64 key
43-
key
32+
bip39::ErrorKind::InvalidKeysize(_)
33+
| bip39::ErrorKind::InvalidWordLength(_)
34+
| bip39::ErrorKind::InvalidEntropyLength(_, _) => {
35+
bail!("key was not the correct length")
4436
}
4537
}
4638
}

0 commit comments

Comments
 (0)