add config option to disable script type derivation validation

This commit is contained in:
Craig Raw 2021-02-22 16:05:18 +02:00
parent 9060a4b284
commit 62d83151d7
5 changed files with 30 additions and 1 deletions

2
drongo

@ -1 +1 @@
Subproject commit 79216fac912724e7b06b3ffe15e38ddf005e665f Subproject commit fe91063e8fa5acb967907c6e1f65b21e7bca0375

View file

@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow;
import com.beust.jcommander.JCommander; import com.beust.jcommander.JCommander;
import com.sparrowwallet.drongo.Network; import com.sparrowwallet.drongo.Network;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.control.WelcomeDialog; import com.sparrowwallet.sparrow.control.WelcomeDialog;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands; import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
@ -73,6 +74,8 @@ public class MainApp extends Application {
Config.get().setCoreWallet(""); Config.get().setCoreWallet("");
} }
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_SCRIPT_TYPES_PROPERTY, Boolean.toString(!Config.get().isValidateDerivationPaths()));
AppController appController = AppServices.newAppWindow(stage); AppController appController = AppServices.newAppWindow(stage);
if(createNewWallet) { if(createNewWallet) {

View file

@ -25,6 +25,7 @@ public class Config {
private FeeRatesSelection feeRatesSelection; private FeeRatesSelection feeRatesSelection;
private Currency fiatCurrency; private Currency fiatCurrency;
private ExchangeSource exchangeSource; private ExchangeSource exchangeSource;
private boolean validateDerivationPaths = true;
private boolean groupByAddress = true; private boolean groupByAddress = true;
private boolean includeMempoolChange = true; private boolean includeMempoolChange = true;
private boolean notifyNewTransactions = true; private boolean notifyNewTransactions = true;
@ -154,6 +155,15 @@ public class Config {
flush(); flush();
} }
public boolean isValidateDerivationPaths() {
return validateDerivationPaths;
}
public void setValidateDerivationPaths(boolean validateDerivationPaths) {
this.validateDerivationPaths = validateDerivationPaths;
flush();
}
public boolean isGroupByAddress() { public boolean isGroupByAddress() {
return groupByAddress; return groupByAddress;
} }

View file

@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow.preferences; package com.sparrowwallet.sparrow.preferences;
import com.sparrowwallet.drongo.BitcoinUnit; import com.sparrowwallet.drongo.BitcoinUnit;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch; import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch;
import com.sparrowwallet.sparrow.event.*; import com.sparrowwallet.sparrow.event.*;
@ -32,6 +33,9 @@ public class GeneralPreferencesController extends PreferencesDetailController {
@FXML @FXML
private ComboBox<ExchangeSource> exchangeSource; private ComboBox<ExchangeSource> exchangeSource;
@FXML
private UnlabeledToggleSwitch validateDerivationPaths;
@FXML @FXML
private UnlabeledToggleSwitch groupByAddress; private UnlabeledToggleSwitch groupByAddress;
@ -93,6 +97,12 @@ public class GeneralPreferencesController extends PreferencesDetailController {
updateCurrencies(exchangeSource.getSelectionModel().getSelectedItem()); updateCurrencies(exchangeSource.getSelectionModel().getSelectedItem());
validateDerivationPaths.setSelected(config.isValidateDerivationPaths());
validateDerivationPaths.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
config.setValidateDerivationPaths(newValue);
System.setProperty(Wallet.ALLOW_DERIVATIONS_MATCHING_OTHER_SCRIPT_TYPES_PROPERTY, Boolean.toString(!newValue));
});
groupByAddress.setSelected(config.isGroupByAddress()); groupByAddress.setSelected(config.isGroupByAddress());
includeMempoolChange.setSelected(config.isIncludeMempoolChange()); includeMempoolChange.setSelected(config.isIncludeMempoolChange());
groupByAddress.selectedProperty().addListener((observableValue, oldValue, newValue) -> { groupByAddress.selectedProperty().addListener((observableValue, oldValue, newValue) -> {

View file

@ -71,6 +71,12 @@
</ComboBox> </ComboBox>
</Field> </Field>
</Fieldset> </Fieldset>
<Fieldset inputGrow="SOMETIMES" text="Wallet" styleClass="wideLabelFieldSet">
<Field text="Validate derivations:">
<UnlabeledToggleSwitch fx:id="validateDerivationPaths" />
<HelpLabel helpText="Disallow keystores to have derivation paths that match the defaults for other script types."/>
</Field>
</Fieldset>
<Fieldset inputGrow="SOMETIMES" text="Coin Selection" styleClass="wideLabelFieldSet"> <Fieldset inputGrow="SOMETIMES" text="Coin Selection" styleClass="wideLabelFieldSet">
<Field text="Group by address:"> <Field text="Group by address:">
<UnlabeledToggleSwitch fx:id="groupByAddress" /> <UnlabeledToggleSwitch fx:id="groupByAddress" />