diff --git a/drongo b/drongo index 8a6d2da5..ca833fbf 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 8a6d2da5c911b3f63426c9e5331c55a36c27befc +Subproject commit ca833fbf6807e9db30135562000329b7423b9fb7 diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index d4f9ca47..96da5e5f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -709,7 +709,7 @@ public class AppController implements Initializable { AppServices.moveToActiveWindowScreen(window, 800, 450); File file = fileChooser.showSaveDialog(window); if(file != null) { - if(!asText && !file.getName().toLowerCase().endsWith(".psbt")) { + if(!asText && !file.getName().toLowerCase(Locale.ROOT).endsWith(".psbt")) { file = new File(file.getAbsolutePath() + ".psbt"); } @@ -2207,7 +2207,7 @@ public class AppController implements Initializable { if(!whirlpoolTransactions.isEmpty()) { BlockTransaction blockTransaction = whirlpoolTransactions.get(0); String status; - String walletName = event.getWallet().getMasterName() + " " + event.getWallet().getName().toLowerCase(); + String walletName = event.getWallet().getMasterName() + " " + event.getWallet().getName().toLowerCase(Locale.ROOT); long value = blockTransaction.getTransaction().getOutputs().iterator().next().getValue(); long mempoolValue = whirlpoolTransactions.stream().filter(tx -> tx.getHeight() <= 0).mapToLong(tx -> value).sum(); long blockchainValue = whirlpoolTransactions.stream().filter(tx -> tx.getHeight() > 0).mapToLong(tx -> value).sum(); diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index f1ecc510..2b78fdc1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -136,7 +136,7 @@ public class MainApp extends Application { public static void main(String[] argv) { Args args = new Args(); - JCommander jCommander = JCommander.newBuilder().addObject(args).programName(APP_NAME.toLowerCase()).acceptUnknownOptions(true).build(); + JCommander jCommander = JCommander.newBuilder().addObject(args).programName(APP_NAME.toLowerCase(Locale.ROOT)).acceptUnknownOptions(true).build(); jCommander.parse(argv); if(args.help) { jCommander.usage(); @@ -158,7 +158,7 @@ public class MainApp extends Application { String envNetwork = System.getenv(NETWORK_ENV_PROPERTY); if(envNetwork != null) { try { - Network.set(Network.valueOf(envNetwork.toUpperCase())); + Network.set(Network.valueOf(envNetwork.toUpperCase(Locale.ROOT))); } catch(Exception e) { getLogger().warn("Invalid " + NETWORK_ENV_PROPERTY + " property: " + envNetwork); } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletExportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletExportPane.java index ca2b506c..6c867042 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletExportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletExportPane.java @@ -21,6 +21,7 @@ import org.controlsfx.glyphfont.Glyph; import java.io.*; import java.nio.charset.StandardCharsets; +import java.util.Locale; import java.util.Optional; public class FileWalletExportPane extends TitledDescriptionPane { @@ -80,7 +81,7 @@ public class FileWalletExportPane extends TitledDescriptionPane { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export " + exporter.getWalletModel().toDisplayString() + " File"); String extension = exporter.getExportFileExtension(wallet); - String fileName = wallet.getFullName() + "-" + exporter.getWalletModel().toDisplayString().toLowerCase().replace(" ", ""); + String fileName = wallet.getFullName() + "-" + exporter.getWalletModel().toDisplayString().toLowerCase(Locale.ROOT).replace(" ", ""); if(exporter instanceof Sparrow) { fileName = wallet.getMasterName(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java index 54a281d5..62ffa966 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MessageSignDialog.java @@ -37,6 +37,7 @@ import tornadofx.control.Form; import java.security.SignatureException; import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.Optional; public class MessageSignDialog extends Dialog { @@ -184,7 +185,7 @@ public class MessageSignDialog extends Dialog { if(buttons.length > 0) { dialogPane.getButtonTypes().addAll(buttons); - ButtonType customSignButtonType = Arrays.stream(buttons).filter(buttonType -> buttonType.getText().toLowerCase().contains("sign")).findFirst().orElse(null); + ButtonType customSignButtonType = Arrays.stream(buttons).filter(buttonType -> buttonType.getText().toLowerCase(Locale.ROOT).contains("sign")).findFirst().orElse(null); if(customSignButtonType != null) { Button customSignButton = (Button)dialogPane.lookupButton(customSignButtonType); customSignButton.setDefaultButton(true); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java index b1ffe010..79271a2e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java @@ -17,6 +17,8 @@ import javafx.util.Duration; import org.controlsfx.glyphfont.Glyph; import org.controlsfx.tools.Platform; +import java.util.Locale; + public class MixStatusCell extends TreeTableCell { private static final int ERROR_DISPLAY_MILLIS = 5 * 60 * 1000; @@ -114,7 +116,7 @@ public class MixStatusCell extends TreeTableCell { progressIndicator.setProgress(mixProgress.getMixStep().getProgressPercent() == 100 ? -1 : mixProgress.getMixStep().getProgressPercent() / 100.0); setGraphic(progressIndicator); Tooltip tt = new Tooltip(); - String status = mixProgress.getMixStep().getMessage().substring(0, 1).toUpperCase() + mixProgress.getMixStep().getMessage().substring(1); + String status = mixProgress.getMixStep().getMessage().substring(0, 1).toUpperCase(Locale.ROOT) + mixProgress.getMixStep().getMessage().substring(1); tt.setText(status); setTooltip(tt); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java index 10da4dbc..91178b47 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystorePane.java @@ -271,7 +271,7 @@ public class MnemonicKeystorePane extends TitledDescriptionPane { String text = change.getText(); // if text was added, fix the text to fit the requirements if(!text.isEmpty()) { - String newText = text.replace(" ", "").toLowerCase(); + String newText = text.replace(" ", "").toLowerCase(Locale.ROOT); int carretPos = change.getCaretPosition() - text.length() + newText.length(); change.setText(newText); // fix caret position based on difference in originally added text and fixed text diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java index afd0c21f..4fb7ba40 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRDisplayDialog.java @@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.util.Locale; @SuppressWarnings("deprecation") public class QRDisplayDialog extends Dialog { @@ -131,7 +132,7 @@ public class QRDisplayDialog extends Dialog { private void nextPart() { if(!useLegacyEncoding) { String fragment = encoder.nextPart(); - currentPart = fragment.toUpperCase(); + currentPart = fragment.toUpperCase(Locale.ROOT); } else { currentPart = legacyParts[legacyPartIndex]; legacyPartIndex++; diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java index 03274a6e..320cc4ea 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java @@ -185,7 +185,7 @@ public class QRScanDialog extends Dialog { String qrtext = qrResult.getText(); Matcher partMatcher = PART_PATTERN.matcher(qrtext); - if(qrtext.toLowerCase().startsWith(UR.UR_PREFIX)) { + if(qrtext.toLowerCase(Locale.ROOT).startsWith(UR.UR_PREFIX)) { if(LegacyURDecoder.isLegacyURFragment(qrtext)) { legacyDecoder.receivePart(qrtext); Platform.runLater(() -> percentComplete.setValue(legacyDecoder.getPercentComplete())); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java index 5acab5f4..13feab21 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java @@ -20,6 +20,7 @@ import tornadofx.control.Form; import java.util.ArrayList; import java.util.List; +import java.util.Locale; public class SearchWalletDialog extends Dialog { private static final Logger log = LoggerFactory.getLogger(SearchWalletDialog.class); @@ -134,7 +135,7 @@ public class SearchWalletDialog extends Dialog { }); search.textProperty().addListener((observable, oldValue, newValue) -> { - searchWallet(newValue.toLowerCase()); + searchWallet(newValue.toLowerCase(Locale.ROOT)); }); setResizable(true); @@ -159,7 +160,7 @@ public class SearchWalletDialog extends Dialog { for(Entry entry : walletTransactionsEntry.getChildren()) { if(entry instanceof TransactionEntry transactionEntry) { if(transactionEntry.getBlockTransaction().getHash().toString().equals(searchText) || - (transactionEntry.getLabel() != null && transactionEntry.getLabel().toLowerCase().contains(searchText)) || + (transactionEntry.getLabel() != null && transactionEntry.getLabel().toLowerCase(Locale.ROOT).contains(searchText)) || (transactionEntry.getValue() != null && searchValue != null && Math.abs(transactionEntry.getValue()) == searchValue)) { matchingEntries.add(entry); } @@ -170,8 +171,8 @@ public class SearchWalletDialog extends Dialog { NodeEntry purposeEntry = walletForm.getNodeEntry(keyPurpose); for(Entry entry : purposeEntry.getChildren()) { if(entry instanceof NodeEntry nodeEntry) { - if(nodeEntry.getAddress().toString().toLowerCase().contains(searchText) || - (nodeEntry.getLabel() != null && nodeEntry.getLabel().toLowerCase().contains(searchText)) || + if(nodeEntry.getAddress().toString().toLowerCase(Locale.ROOT).contains(searchText) || + (nodeEntry.getLabel() != null && nodeEntry.getLabel().toLowerCase(Locale.ROOT).contains(searchText)) || (nodeEntry.getValue() != null && searchValue != null && Math.abs(nodeEntry.getValue()) == searchValue)) { matchingEntries.add(entry); } @@ -184,8 +185,8 @@ public class SearchWalletDialog extends Dialog { NodeEntry purposeEntry = nestedWalletForm.getNodeEntry(keyPurpose); for(Entry entry : purposeEntry.getChildren()) { if(entry instanceof NodeEntry nodeEntry) { - if(nodeEntry.getAddress().toString().toLowerCase().contains(searchText) || - (nodeEntry.getLabel() != null && nodeEntry.getLabel().toLowerCase().contains(searchText)) || + if(nodeEntry.getAddress().toString().toLowerCase(Locale.ROOT).contains(searchText) || + (nodeEntry.getLabel() != null && nodeEntry.getLabel().toLowerCase(Locale.ROOT).contains(searchText)) || (nodeEntry.getValue() != null && searchValue != null && Math.abs(nodeEntry.getValue()) == searchValue)) { matchingEntries.add(entry); } @@ -197,8 +198,8 @@ public class SearchWalletDialog extends Dialog { WalletUtxosEntry walletUtxosEntry = walletForm.getWalletUtxosEntry(); for(Entry entry : walletUtxosEntry.getChildren()) { if(entry instanceof HashIndexEntry hashIndexEntry) { - if(hashIndexEntry.getBlockTransaction().getHash().toString().toLowerCase().equals(searchText) || - (hashIndexEntry.getLabel() != null && hashIndexEntry.getLabel().toLowerCase().contains(searchText)) || + if(hashIndexEntry.getBlockTransaction().getHash().toString().toLowerCase(Locale.ROOT).equals(searchText) || + (hashIndexEntry.getLabel() != null && hashIndexEntry.getLabel().toLowerCase(Locale.ROOT).contains(searchText)) || (hashIndexEntry.getValue() != null && searchValue != null && Math.abs(hashIndexEntry.getValue()) == searchValue)) { matchingEntries.add(entry); } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletLabelDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletLabelDialog.java index d7a59c50..45b4aa28 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletLabelDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletLabelDialog.java @@ -15,6 +15,8 @@ import org.controlsfx.validation.ValidationSupport; import org.controlsfx.validation.Validator; import org.controlsfx.validation.decoration.StyleClassValidationDecoration; +import java.util.Locale; + public class WalletLabelDialog extends Dialog { private static final int MAX_LABEL_LENGTH = 25; @@ -29,7 +31,7 @@ public class WalletLabelDialog extends Dialog { AppServices.setStageIcon(dialogPane.getScene().getWindow()); setTitle(walletType + " Name"); - dialogPane.setHeaderText("Enter a name for this " + walletType.toLowerCase() + ":"); + dialogPane.setHeaderText("Enter a name for this " + walletType.toLowerCase(Locale.ROOT) + ":"); dialogPane.getStylesheets().add(AppServices.class.getResource("general.css").toExternalForm()); dialogPane.getButtonTypes().addAll(ButtonType.CANCEL); dialogPane.setPrefWidth(400); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java index 6b09d331..0ce22f40 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java @@ -14,6 +14,7 @@ import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.Locale; public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { private static final Logger log = LoggerFactory.getLogger(CoboVaultSinglesig.class); @@ -47,7 +48,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { keystore.setLabel(getName()); keystore.setSource(KeystoreSource.HW_AIRGAPPED); keystore.setWalletModel(WalletModel.COBO_VAULT); - keystore.setKeyDerivation(new KeyDerivation(coboKeystore.MasterFingerprint.toLowerCase(), "m/" + coboKeystore.AccountKeyPath)); + keystore.setKeyDerivation(new KeyDerivation(coboKeystore.MasterFingerprint.toLowerCase(Locale.ROOT), "m/" + coboKeystore.AccountKeyPath)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(coboKeystore.ExtPubKey)); ExtendedKey.Header header = ExtendedKey.Header.fromExtendedKey(coboKeystore.ExtPubKey); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index 28e268db..2d7fa482 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -18,6 +18,7 @@ import java.io.*; import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; public class ColdcardMultisig implements WalletImport, KeystoreFileImport, WalletExport { @@ -198,7 +199,7 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle if(multipleDerivations) { writer.append("Derivation: ").append(keystore.getKeyDerivation().getDerivationPath()).append("\n"); } - writer.append(keystore.getKeyDerivation().getMasterFingerprint().toUpperCase()).append(": ").append(keystore.getExtendedPublicKey().toString()).append("\n"); + writer.append(keystore.getKeyDerivation().getMasterFingerprint().toUpperCase(Locale.ROOT)).append(": ").append(keystore.getExtendedPublicKey().toString()).append("\n"); if(multipleDerivations) { writer.append("\n"); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index 8908ae3a..a96d8aa6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -17,6 +17,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; +import java.util.Locale; import java.util.Map; public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { @@ -71,7 +72,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { ColdcardKeystore ck = gson.fromJson(map.get(key), ColdcardKeystore.class); if(ck.name != null) { - ScriptType ckScriptType = ScriptType.valueOf(ck.name.replace("p2wpkh-p2sh", "p2sh_p2wpkh").replace("p2sh-p2wpkh", "p2sh_p2wpkh").toUpperCase()); + ScriptType ckScriptType = ScriptType.valueOf(ck.name.replace("p2wpkh-p2sh", "p2sh_p2wpkh").replace("p2sh-p2wpkh", "p2sh_p2wpkh").toUpperCase(Locale.ROOT)); if(ckScriptType.equals(scriptType)) { Keystore keystore = new Keystore(); keystore.setLabel(getName()); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java index d6c2ce8d..f9732efb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java @@ -83,7 +83,7 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport if(ek.root_fingerprint == null && ek.ckcc_xfp != null) { byte[] le = new byte[4]; Utils.uint32ToByteArrayLE(Long.parseLong(ek.ckcc_xfp), le, 0); - ek.root_fingerprint = Utils.bytesToHex(le).toUpperCase(); + ek.root_fingerprint = Utils.bytesToHex(le).toUpperCase(Locale.ROOT); } ew.keystores.put(key, ek); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java index a3000972..7bd44a0e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java @@ -757,7 +757,7 @@ public class Hwi { private static class DeviceModelSerializer implements JsonSerializer { @Override public JsonElement serialize(WalletModel src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toString().toLowerCase()); + return new JsonPrimitive(src.toString().toLowerCase(Locale.ROOT)); } } @@ -766,7 +766,7 @@ public class Hwi { public WalletModel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String modelStr = json.getAsJsonPrimitive().getAsString(); try { - return WalletModel.valueOf(modelStr.toUpperCase()); + return WalletModel.valueOf(modelStr.toUpperCase(Locale.ROOT)); } catch(Exception e) { for(WalletModel model : WalletModel.values()) { if(modelStr.startsWith(model.getType())) { diff --git a/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java b/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java index e1221b23..ab918ab9 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java @@ -24,7 +24,7 @@ public class IOUtils { try { String type = Files.probeContentType(file.toPath()); if(type == null) { - if(file.getName().toLowerCase().endsWith("txn") || file.getName().toLowerCase().endsWith("psbt")) { + if(file.getName().toLowerCase(Locale.ROOT).endsWith("txn") || file.getName().toLowerCase(Locale.ROOT).endsWith("psbt")) { return FileType.TEXT; } diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java index 209c534b..fea1b0b4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java @@ -19,6 +19,7 @@ import javafx.scene.layout.StackPane; import java.io.IOException; import java.net.URL; import java.util.List; +import java.util.Locale; import java.util.ResourceBundle; public class KeystoreImportController implements Initializable { @@ -51,7 +52,7 @@ public class KeystoreImportController implements Initializable { } KeystoreSource importType = (KeystoreSource) selectedToggle.getUserData(); - String fxmlName = importType.toString().toLowerCase(); + String fxmlName = importType.toString().toLowerCase(Locale.ROOT); if(importType == KeystoreSource.SW_SEED || importType == KeystoreSource.SW_WATCH) { fxmlName = "sw"; } @@ -91,7 +92,12 @@ public class KeystoreImportController implements Initializable { importPane.getChildren().removeAll(importPane.getChildren()); try { - FXMLLoader importLoader = new FXMLLoader(AppServices.class.getResource("keystoreimport/" + fxmlName + ".fxml")); + URL url = AppServices.class.getResource("keystoreimport/" + fxmlName + ".fxml"); + if(url == null) { + throw new IllegalStateException("Cannot find keystoreimport/" + fxmlName + ".fxml"); + } + + FXMLLoader importLoader = new FXMLLoader(url); Node importTypeNode = importLoader.load(); KeystoreImportDetailController controller = importLoader.getController(); controller.setMasterController(this); diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Auth47.java b/src/main/java/com/sparrowwallet/sparrow/net/Auth47.java index bbbfe745..1b4cdd4b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/Auth47.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/Auth47.java @@ -128,7 +128,7 @@ public class Auth47 { } Proxy proxy = AppServices.getProxy(); - if(proxy == null && callback.getHost().toLowerCase().endsWith(TorService.TOR_ADDRESS_SUFFIX)) { + if(proxy == null && callback.getHost().toLowerCase(Locale.ROOT).endsWith(TorService.TOR_ADDRESS_SUFFIX)) { throw new Auth47Exception("A Tor proxy must be configured to authenticate this resource."); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 9db6fe33..9998c05c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -990,7 +990,7 @@ public class ElectrumServer { public static boolean supportsBatching(List serverVersion) { if(serverVersion.size() > 0) { - String server = serverVersion.get(0).toLowerCase(); + String server = serverVersion.get(0).toLowerCase(Locale.ROOT); if(server.contains("electrumx")) { return true; } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java index 8fb5e0b2..b1096e9d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java @@ -33,8 +33,8 @@ public enum ExchangeSource { COINBASE("Coinbase") { @Override public List getSupportedCurrencies() { - return getRates().data.rates.keySet().stream().filter(code -> isValidISO4217Code(code.toUpperCase())) - .map(code -> Currency.getInstance(code.toUpperCase())).collect(Collectors.toList()); + return getRates().data.rates.keySet().stream().filter(code -> isValidISO4217Code(code.toUpperCase(Locale.ROOT))) + .map(code -> Currency.getInstance(code.toUpperCase(Locale.ROOT))).collect(Collectors.toList()); } @Override @@ -68,8 +68,8 @@ public enum ExchangeSource { COINGECKO("Coingecko") { @Override public List getSupportedCurrencies() { - return getRates().rates.entrySet().stream().filter(rate -> "fiat".equals(rate.getValue().type) && isValidISO4217Code(rate.getKey().toUpperCase())) - .map(rate -> Currency.getInstance(rate.getKey().toUpperCase())).collect(Collectors.toList()); + return getRates().rates.entrySet().stream().filter(rate -> "fiat".equals(rate.getValue().type) && isValidISO4217Code(rate.getKey().toUpperCase(Locale.ROOT))) + .map(rate -> Currency.getInstance(rate.getKey().toUpperCase(Locale.ROOT))).collect(Collectors.toList()); } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java b/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java index a4fc1b15..bb7a22b1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java @@ -9,6 +9,7 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; +import java.util.Locale; public enum Protocol { TCP { @@ -101,7 +102,7 @@ public enum Protocol { } public String toUrlString() { - return toString().toLowerCase() + "://"; + return toString().toLowerCase(Locale.ROOT) + "://"; } public String toUrlString(String host) { @@ -117,7 +118,7 @@ public enum Protocol { } public static boolean isOnionAddress(HostAndPort server) { - return server.getHost().toLowerCase().endsWith(TorService.TOR_ADDRESS_SUFFIX); + return server.getHost().toLowerCase(Locale.ROOT).endsWith(TorService.TOR_ADDRESS_SUFFIX); } public static boolean isOnionAddress(String address) { diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesController.java index 2fe79206..1caa4932 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/PreferencesController.java @@ -15,6 +15,7 @@ import javafx.scene.layout.StackPane; import java.io.IOException; import java.net.URL; +import java.util.Locale; import java.util.ResourceBundle; public class PreferencesController implements Initializable { @@ -48,7 +49,7 @@ public class PreferencesController implements Initializable { } PreferenceGroup preferenceGroup = (PreferenceGroup) selectedToggle.getUserData(); - String fxmlName = preferenceGroup.toString().toLowerCase(); + String fxmlName = preferenceGroup.toString().toLowerCase(Locale.ROOT); setPreferencePane(fxmlName); }); } diff --git a/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java b/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java index 00d02cbe..43c1d7a2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java +++ b/src/main/java/com/sparrowwallet/sparrow/soroban/Soroban.java @@ -41,7 +41,7 @@ public class Soroban { private int bip47Account; public Soroban(Network network, HostAndPort torProxy) { - this.sorobanServer = SorobanServer.valueOf(network.getName().toUpperCase()); + this.sorobanServer = SorobanServer.valueOf(network.getName().toUpperCase(Locale.ROOT)); this.httpClientService = new JavaHttpClientService(torProxy); } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 642f9e0a..d366737e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -913,7 +913,7 @@ public class HeadersController extends TransactionFormController implements Init AppServices.moveToActiveWindowScreen(window, 800, 450); File file = fileChooser.showSaveDialog(window); if(file != null) { - if(!file.getName().toLowerCase().endsWith(".psbt")) { + if(!file.getName().toLowerCase(Locale.ROOT).endsWith(".psbt")) { file = new File(file.getAbsolutePath() + ".psbt"); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/AddressesController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/AddressesController.java index ad47a22c..f89c40b2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/AddressesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/AddressesController.java @@ -23,6 +23,7 @@ import java.io.*; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.ResourceBundle; @@ -144,7 +145,7 @@ public class AddressesController extends WalletFormController implements Initial FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export Addresses to CSV"); - fileChooser.setInitialFileName(getWalletForm().getWallet().getFullName() + "-" + keyPurpose.name().toLowerCase() + "-addresses.csv"); + fileChooser.setInitialFileName(getWalletForm().getWallet().getFullName() + "-" + keyPurpose.name().toLowerCase(Locale.ROOT) + "-addresses.csv"); Wallet copy = getWalletForm().getWallet().copy(); WalletNode purposeNode = copy.getNode(keyPurpose); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java b/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java index c97b9cdc..9fc2af35 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java @@ -1,15 +1,5 @@ package com.sparrowwallet.sparrow.wallet; public enum Function { - TRANSACTIONS("transactions"), SEND("send"), RECEIVE("receive"), ADDRESSES("addresses"), UTXOS("utxos"), SETTINGS("settings"), LOCK("lock"); - - private final String name; - - Function(String name) { - this.name = name; - } - - public String getName() { - return name; - } + TRANSACTIONS, SEND, RECEIVE, ADDRESSES, UTXOS, SETTINGS, LOCK; } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/MixToController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/MixToController.java index 8c27c1b2..e74f1daa 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/MixToController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/MixToController.java @@ -17,10 +17,7 @@ import javafx.scene.control.ComboBox; import javafx.util.StringConverter; import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.ResourceBundle; +import java.util.*; import java.util.stream.Collectors; import static com.sparrowwallet.drongo.wallet.StandardAccount.*; @@ -112,7 +109,7 @@ public class MixToController implements Initializable { return ""; } - return indexRange.toString().charAt(0) + indexRange.toString().substring(1).toLowerCase(); + return indexRange.toString().charAt(0) + indexRange.toString().substring(1).toLowerCase(Locale.ROOT); } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java index 9e7c7984..0c8297a6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java @@ -30,9 +30,9 @@ import org.controlsfx.glyphfont.Glyph; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.io.IOException; import java.net.URL; +import java.util.Locale; import java.util.ResourceBundle; import static com.sparrowwallet.sparrow.AppServices.showErrorDialog; @@ -90,12 +90,9 @@ public class WalletController extends WalletFormController implements Initializa try { if(!existing) { - URL url = AppServices.class.getResource("wallet/" + function.getName() + ".fxml"); + URL url = AppServices.class.getResource("wallet/" + function.toString().toLowerCase(Locale.ROOT) + ".fxml"); if(url == null) { - url = AppServices.class.getResource("wallet" + File.separator + function.getName() + ".fxml"); - } - if(url == null) { - throw new IllegalStateException("Cannot find wallet/" + function.toString().toLowerCase() + ".fxml"); + throw new IllegalStateException("Cannot find wallet/" + function.toString().toLowerCase(Locale.ROOT) + ".fxml"); } FXMLLoader functionLoader = new FXMLLoader(url); diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index 6417c8fa..74762f09 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -82,7 +82,7 @@ public class Whirlpool { private final BooleanProperty mixingProperty = new SimpleBooleanProperty(false); public Whirlpool(Network network, HostAndPort torProxy) { - this.whirlpoolServer = WhirlpoolServer.valueOf(network.getName().toUpperCase()); + this.whirlpoolServer = WhirlpoolServer.valueOf(network.getName().toUpperCase(Locale.ROOT)); this.httpClientService = new JavaHttpClientService(torProxy); this.stompClientService = new JavaStompClientService(httpClientService); this.torClientService = new SparrowTorClientService(this); @@ -441,7 +441,7 @@ public class Whirlpool { List headers = ExtendedKey.Header.getHeaders(Network.get()); ExtendedKey.Header header = headers.stream().filter(head -> head.getDefaultScriptType().equals(wallet.getScriptType()) && !head.isPrivateKey()).findFirst().orElse(ExtendedKey.Header.xpub); xpub.m = wallet.getKeystores().get(0).getExtendedPublicKey().toString(header); - xpub.path = node.getDerivationPath().toUpperCase(); + xpub.path = node.getDerivationPath().toUpperCase(Locale.ROOT); out.xpub = xpub; diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java index c3cf3f2c..0d799f60 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/WhirlpoolController.java @@ -110,7 +110,7 @@ public class WhirlpoolController { scode.setText(mixConfig.getScode() == null ? "" : mixConfig.getScode()); scode.setTextFormatter(new TextFormatter<>((change) -> { - change.setText(change.getText().toUpperCase()); + change.setText(change.getText().toUpperCase(Locale.ROOT)); return change; })); scode.textProperty().addListener((observable, oldValue, newValue) -> { diff --git a/src/test/java/com/sparrowwallet/sparrow/io/CaravanMultisigTest.java b/src/test/java/com/sparrowwallet/sparrow/io/CaravanMultisigTest.java index d79c4de3..37346450 100644 --- a/src/test/java/com/sparrowwallet/sparrow/io/CaravanMultisigTest.java +++ b/src/test/java/com/sparrowwallet/sparrow/io/CaravanMultisigTest.java @@ -11,6 +11,7 @@ import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.Locale; public class CaravanMultisigTest extends IoTest { @Test @@ -21,7 +22,7 @@ public class CaravanMultisigTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("wsh(sortedmulti(2,mercury,venus,earth))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("wsh(sortedmulti(2,mercury,venus,earth))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertTrue(wallet.isValid()); Assert.assertEquals("8188029f", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); diff --git a/src/test/java/com/sparrowwallet/sparrow/io/ColdcardMultisigTest.java b/src/test/java/com/sparrowwallet/sparrow/io/ColdcardMultisigTest.java index cd7768c3..3310e332 100644 --- a/src/test/java/com/sparrowwallet/sparrow/io/ColdcardMultisigTest.java +++ b/src/test/java/com/sparrowwallet/sparrow/io/ColdcardMultisigTest.java @@ -12,6 +12,7 @@ import org.junit.Assert; import org.junit.Test; import java.io.*; +import java.util.Locale; public class ColdcardMultisigTest extends IoTest { @Test @@ -64,7 +65,7 @@ public class ColdcardMultisigTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertTrue(wallet.isValid()); } @@ -77,7 +78,7 @@ public class ColdcardMultisigTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard1,coldcard2,coldcard3,coldcard4)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertTrue(wallet.isValid()); } @@ -89,7 +90,7 @@ public class ColdcardMultisigTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType()); Assert.assertEquals(3, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("wsh(sortedmulti(3,coldcard1,coldcard2,coldcard3))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("wsh(sortedmulti(3,coldcard1,coldcard2,coldcard3))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("06b57041", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub6EfEGa5isJbQFSswM5Uptw5BSq2Td1ZDJr3QUNUcMySpC7itZ3ccypVHtLPnvMzKQ2qxrAgH49vhVxRcaQLFbixAVRR8RACrYTp88Uv9h8Z", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); diff --git a/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java b/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java index 1f5bfc88..4b2fb82c 100644 --- a/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java +++ b/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java @@ -14,6 +14,7 @@ import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.Locale; public class ElectrumTest extends IoTest { @Test @@ -24,7 +25,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType()); Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("ab543c67", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub6FFEQVG6QR28chQzgSJ7Gjx5j5BGLkCMgZ9bc41YJCXfwYiCKUQdcwm4Fe1stvzRjosz5udMedYZFRL56AeZXCsiVmnVUysio4jkAKTukmN", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -44,7 +45,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType()); Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("sh(wpkh(trezortest))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("ab543c67", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub6FFEQVG6QR28chQzgSJ7Gjx5j5BGLkCMgZ9bc41YJCXfwYiCKUQdcwm4Fe1stvzRjosz5udMedYZFRL56AeZXCsiVmnVUysio4jkAKTukmN", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -59,7 +60,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -82,7 +83,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -100,7 +101,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2WPKH, wallet.getScriptType()); Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("f881eac5", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub69iSRreMB6fu24sU8Tdxv7yYGqzPkDwPkwqUfKJTxW3p8afW7XvTewVCapuX3dQjdD197iF65WcjYaNpFbwWT3RyuZ1KJ3ToJNVWKWyAJ6f", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -120,7 +121,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2WPKH, wallet.getScriptType()); Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("wpkh(electrum)", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("59c5474f", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub68YmVxWbxqjpxbUqqaPrgkBQPBSJuq6gEaL22uuytSEojtS2x5eLPN2uspUuyigtnMkoHrFSF1KwoXPwjzuaUjErUwztxfHquAwuaQhSd9J", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); diff --git a/src/test/java/com/sparrowwallet/sparrow/io/SpecterDesktopTest.java b/src/test/java/com/sparrowwallet/sparrow/io/SpecterDesktopTest.java index d1dc71d0..df9ad7a0 100644 --- a/src/test/java/com/sparrowwallet/sparrow/io/SpecterDesktopTest.java +++ b/src/test/java/com/sparrowwallet/sparrow/io/SpecterDesktopTest.java @@ -6,6 +6,8 @@ import com.sparrowwallet.drongo.wallet.Wallet; import org.junit.Assert; import org.junit.Test; +import java.util.Locale; + public class SpecterDesktopTest extends IoTest { @Test public void testImport() throws ImportException { @@ -15,7 +17,7 @@ public class SpecterDesktopTest extends IoTest { Assert.assertEquals(PolicyType.SINGLE, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WPKH, wallet.getScriptType()); Assert.assertEquals(1, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wpkh(keystore1))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("sh(wpkh(keystore1))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("4df18faa", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/49'/0'/0'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub6BgwyseZdeGJj2vB3FPHSGPxR1LLkr8AsAJqedrgjwBXKXXVWkH31fhwtQXgrM7uMrWjLwXhuDhhenNAh5eBdUSjrHkrKfaXutcJdAfgQ8D", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -30,7 +32,7 @@ public class SpecterDesktopTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2WSH, wallet.getScriptType()); Assert.assertEquals(3, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("wsh(sortedmulti(3,keystore1,keystore2,keystore3,keystore4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase()); + Assert.assertEquals("wsh(sortedmulti(3,keystore1,keystore2,keystore3,keystore4))", wallet.getDefaultPolicy().getMiniscript().getScript().toLowerCase(Locale.ROOT)); Assert.assertEquals("ca9a2b19", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/0'/0'/2'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("xpub6EhbRDNhmMX863W8RujJyAMw1vtM4MHXnsk14paK1ZBEH75k44gWqfaraXCrzg6w9pzC2yLc28vAdUfpB9ShuEB1HA9xMs6BjmRi4PKbt1K", wallet.getKeystores().get(0).getExtendedPublicKey().toString());