mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2026-08-10 08:37:05 +00:00
if validating derivations, disallow paths that match other networks
This commit is contained in:
@@ -80,6 +80,7 @@ public class SparrowDesktop extends Application {
|
||||
}
|
||||
|
||||
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_SCRIPT_TYPES_PROPERTY, Boolean.toString(!Config.get().isValidateDerivationPaths()));
|
||||
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, Boolean.toString(!Config.get().isValidateDerivationPaths()));
|
||||
|
||||
if(Config.get().getAppHeight() != null && Config.get().getAppWidth() != null) {
|
||||
mainStage.setWidth(Config.get().getAppWidth());
|
||||
|
||||
@@ -175,6 +175,7 @@ public class GeneralPreferencesController extends PreferencesDetailController {
|
||||
validateDerivationPaths.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
config.setValidateDerivationPaths(newValue);
|
||||
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_SCRIPT_TYPES_PROPERTY, Boolean.toString(!newValue));
|
||||
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_NETWORKS_PROPERTY, Boolean.toString(!newValue));
|
||||
});
|
||||
|
||||
groupByAddress.setSelected(config.isGroupByAddress());
|
||||
|
||||
@@ -186,7 +186,7 @@ public class KeystoreController extends WalletFormController implements Initiali
|
||||
return null;
|
||||
}));
|
||||
derivation.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if(KeyDerivation.isValid(newValue) && !walletForm.getWallet().derivationMatchesAnotherScriptType(newValue)) {
|
||||
if(KeyDerivation.isValid(newValue) && !walletForm.getWallet().derivationMatchesAnotherScriptType(newValue) && !walletForm.getWallet().derivationMatchesAnotherNetwork(newValue)) {
|
||||
keystore.setKeyDerivation(new KeyDerivation(keystore.getKeyDerivation().getMasterFingerprint(), newValue));
|
||||
EventManager.get().post(new SettingsChangedEvent(walletForm.getWallet(), SettingsChangedEvent.Type.KEYSTORE_DERIVATION));
|
||||
}
|
||||
@@ -287,7 +287,8 @@ public class KeystoreController extends WalletFormController implements Initiali
|
||||
validationSupport.registerValidator(derivation, Validator.combine(
|
||||
Validator.createEmptyValidator("Derivation is required"),
|
||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Derivation is invalid", !KeyDerivation.isValid(newValue)),
|
||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Derivation matches another script type", walletForm.getWallet().derivationMatchesAnotherScriptType(newValue))
|
||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Derivation matches another script type", walletForm.getWallet().derivationMatchesAnotherScriptType(newValue)),
|
||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Derivation matches another network", walletForm.getWallet().derivationMatchesAnotherNetwork(newValue))
|
||||
));
|
||||
|
||||
validationSupport.registerValidator(fingerprint, Validator.combine(
|
||||
|
||||
Reference in New Issue
Block a user