-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBip39UiMessages.java
More file actions
38 lines (32 loc) · 1.38 KB
/
Copy pathBip39UiMessages.java
File metadata and controls
38 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.example.bip39.integration;
import com.example.bip39.error.Bip39ErrorCode;
import java.util.EnumMap;
import java.util.Map;
import java.util.Objects;
public final class Bip39UiMessages {
private static final Map<Bip39ErrorCode, String> UI_MESSAGES = createUiMessages();
private Bip39UiMessages() {}
public static String messageFor(Bip39ErrorCode errorCode) {
Objects.requireNonNull(errorCode, "errorCode must not be null");
return UI_MESSAGES.get(errorCode);
}
private static Map<Bip39ErrorCode, String> createUiMessages() {
EnumMap<Bip39ErrorCode, String> messages = new EnumMap<>(Bip39ErrorCode.class);
messages.put(
Bip39ErrorCode.ERR_ENTROPY_LENGTH, "Entropy length must be 16, 20, 24, 28, or 32 bytes.");
messages.put(
Bip39ErrorCode.ERR_INVALID_MNEMONIC_FORMAT, "Enter words in normalized lowercase form.");
messages.put(
Bip39ErrorCode.ERR_INVALID_WORD_COUNT,
"Mnemonic word count must be 12, 15, 18, 21, or 24.");
messages.put(
Bip39ErrorCode.ERR_WORD_NOT_IN_LIST,
"Mnemonic contains a word outside the English BIP39 list.");
messages.put(
Bip39ErrorCode.ERR_CHECKSUM_MISMATCH,
"Mnemonic checksum does not match the words provided.");
messages.put(
Bip39ErrorCode.ERR_PBKDF2_FAILURE, "Seed derivation is unavailable in this runtime.");
return Map.copyOf(messages);
}
}