mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
support hex border wallets grid pdf
This commit is contained in:
parent
a18c24e19f
commit
f85349bd36
1 changed files with 23 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.sparrowwallet.sparrow.control;
|
package com.sparrowwallet.sparrow.control;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.Utils;
|
||||||
import com.sparrowwallet.drongo.wallet.Bip39MnemonicCode;
|
import com.sparrowwallet.drongo.wallet.Bip39MnemonicCode;
|
||||||
import com.sparrowwallet.sparrow.AppServices;
|
import com.sparrowwallet.sparrow.AppServices;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
||||||
|
@ -169,21 +170,32 @@ public class MnemonicGridDialog extends Dialog<List<String>> {
|
||||||
List<String> abbreviations = selectedCells.stream()
|
List<String> abbreviations = selectedCells.stream()
|
||||||
.map(position -> (String)spreadsheetView.getGrid().getRows().get(position.getRow()).get(position.getColumn()).getItem()).collect(Collectors.toList());
|
.map(position -> (String)spreadsheetView.getGrid().getRows().get(position.getRow()).get(position.getColumn()).getItem()).collect(Collectors.toList());
|
||||||
|
|
||||||
|
boolean isInteger = abbreviations.stream().allMatch(Utils::isNumber);
|
||||||
|
boolean isHex = abbreviations.stream().allMatch(Utils::isHex);
|
||||||
|
|
||||||
List<String> words = new ArrayList<>();
|
List<String> words = new ArrayList<>();
|
||||||
for(String abbreviation : abbreviations) {
|
for(String abbreviation : abbreviations) {
|
||||||
for(String word : Bip39MnemonicCode.INSTANCE.getWordList()) {
|
if(isInteger) {
|
||||||
if((abbreviation.length() == 3 && word.equals(abbreviation)) || (abbreviation.length() >= 4 && word.startsWith(abbreviation))) {
|
|
||||||
words.add(word);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int index = Integer.parseInt(abbreviation);
|
int index = Integer.parseInt(abbreviation);
|
||||||
words.add(Bip39MnemonicCode.INSTANCE.getWordList().get(index - 1));
|
words.add(Bip39MnemonicCode.INSTANCE.getWordList().get(index - 1));
|
||||||
} catch(NumberFormatException e) {
|
} catch(NumberFormatException e) {
|
||||||
//ignore
|
//ignore
|
||||||
}
|
}
|
||||||
|
} else if(isHex) {
|
||||||
|
try {
|
||||||
|
int index = Integer.parseInt(abbreviation, 16);
|
||||||
|
words.add(Bip39MnemonicCode.INSTANCE.getWordList().get(index - 1));
|
||||||
|
} catch(NumberFormatException e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(String word : Bip39MnemonicCode.INSTANCE.getWordList()) {
|
||||||
|
if((abbreviation.length() == 3 && word.equals(abbreviation)) || (abbreviation.length() >= 4 && word.startsWith(abbreviation))) {
|
||||||
|
words.add(word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(words.size() != abbreviations.size()) {
|
if(words.size() != abbreviations.size()) {
|
||||||
|
|
Loading…
Reference in a new issue