From be5a48ce71c0564c2d08340fa653f4525d8202d6 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 26 Oct 2020 15:12:10 +0200 Subject: [PATCH] handle p2sh default derivation change and other small fixes --- drongo | 2 +- src/main/java/com/sparrowwallet/sparrow/AppController.java | 2 +- .../java/com/sparrowwallet/sparrow/control/DevicePane.java | 4 +++- .../com/sparrowwallet/sparrow/control/FileImportPane.java | 3 ++- .../sparrow/control/MnemonicKeystoreImportPane.java | 4 +++- .../java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java | 2 +- src/main/java/com/sparrowwallet/sparrow/io/Hwi.java | 2 +- .../sparrow/preferences/ServerPreferencesController.java | 2 +- src/main/resources/com/sparrowwallet/sparrow/darktheme.css | 5 +++++ 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drongo b/drongo index c4f5218f..401d3b8b 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit c4f5218f29ef58e9ce265373206a093157610fdb +Subproject commit 401d3b8bfbffb8396a4d76737b4d335389b60051 diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 062140d2..fe97d129 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -447,7 +447,7 @@ public class AppController implements Initializable { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open Transaction"); fileChooser.getExtensionFilters().addAll( - new FileChooser.ExtensionFilter("All Files", "*"), + new FileChooser.ExtensionFilter("All Files", org.controlsfx.tools.Platform.getCurrent().equals(org.controlsfx.tools.Platform.UNIX) ? "*" : "*.*"), new FileChooser.ExtensionFilter("PSBT", "*.psbt"), new FileChooser.ExtensionFilter("TXN", "*.txn") ); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/DevicePane.java b/src/main/java/com/sparrowwallet/sparrow/control/DevicePane.java index 2fcf1fe4..4aed8aa7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/DevicePane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/DevicePane.java @@ -3,6 +3,7 @@ package com.sparrowwallet.sparrow.control; import com.sparrowwallet.drongo.ExtendedKey; import com.sparrowwallet.drongo.KeyDerivation; import com.sparrowwallet.drongo.crypto.ChildNumber; +import com.sparrowwallet.drongo.protocol.ScriptType; import com.sparrowwallet.drongo.psbt.PSBT; import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.KeystoreSource; @@ -199,7 +200,8 @@ public class DevicePane extends TitledDescriptionPane { importKeystore(wallet.getScriptType().getDefaultDerivation()); }); String[] accounts = new String[] {"Default Account #0", "Account #1", "Account #2", "Account #3", "Account #4", "Account #5", "Account #6", "Account #7", "Account #8", "Account #9"}; - for(int i = 0; i < accounts.length; i++) { + int scriptAccountsLength = ScriptType.P2SH.equals(wallet.getScriptType()) ? 1 : accounts.length; + for(int i = 0; i < scriptAccountsLength; i++) { MenuItem item = new MenuItem(accounts[i]); final List derivation = wallet.getScriptType().getDefaultDerivation(i); item.setOnAction(event -> { diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java index 376dda14..8271bbec 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java @@ -21,6 +21,7 @@ import org.controlsfx.control.SegmentedButton; import org.controlsfx.control.textfield.CustomPasswordField; import org.controlsfx.control.textfield.TextFields; import org.controlsfx.glyphfont.Glyph; +import org.controlsfx.tools.Platform; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,7 +85,7 @@ public abstract class FileImportPane extends TitledDescriptionPane { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open " + importer.getWalletModel().toDisplayString() + " File"); fileChooser.getExtensionFilters().addAll( - new FileChooser.ExtensionFilter("All Files", "*"), + new FileChooser.ExtensionFilter("All Files", Platform.getCurrent().equals(Platform.UNIX) ? "*" : "*.*"), new FileChooser.ExtensionFilter("JSON", "*.json"), new FileChooser.ExtensionFilter("TXT", "*.txt") ); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java index 94282e20..20467e9c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java @@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.control; import com.sparrowwallet.drongo.KeyDerivation; import com.sparrowwallet.drongo.crypto.ChildNumber; +import com.sparrowwallet.drongo.protocol.ScriptType; import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.event.KeystoreImportEvent; @@ -107,7 +108,8 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane { importKeystore(wallet.getScriptType().getDefaultDerivation(), false); }); String[] accounts = new String[] {"Default Account #0", "Account #1", "Account #2", "Account #3", "Account #4", "Account #5", "Account #6", "Account #7", "Account #8", "Account #9"}; - for(int i = 0; i < accounts.length; i++) { + int scriptAccountsLength = ScriptType.P2SH.equals(wallet.getScriptType()) ? 1 : accounts.length; + for(int i = 0; i < scriptAccountsLength; i++) { MenuItem item = new MenuItem(accounts[i]); final List derivation = wallet.getScriptType().getDefaultDerivation(i); item.setOnAction(event -> { diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index b0be5e48..3c3ed108 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -88,7 +88,7 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle wallet.setPolicyType(PolicyType.MULTI); int threshold = 2; - ScriptType scriptType = null; + ScriptType scriptType = ScriptType.P2SH; String derivation = null; try { diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java index 9bcfa82d..98cfb008 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java @@ -84,7 +84,7 @@ public class Hwi { if(result.get("xpub") != null) { return result.get("xpub").getAsString(); } else { - throw new ImportException("Could not retrieve xpub"); + throw new ImportException("Could not retrieve xpub - reconnect your device and try again."); } } catch(IOException e) { throw new ImportException(e); diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java index 2952c256..fda75b33 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java @@ -109,7 +109,7 @@ public class ServerPreferencesController extends PreferencesDetailController { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select Electrum Server certificate"); fileChooser.getExtensionFilters().addAll( - new FileChooser.ExtensionFilter("All Files", "*"), + new FileChooser.ExtensionFilter("All Files", org.controlsfx.tools.Platform.getCurrent().equals(org.controlsfx.tools.Platform.UNIX) ? "*" : "*.*"), new FileChooser.ExtensionFilter("CRT", "*.crt") ); diff --git a/src/main/resources/com/sparrowwallet/sparrow/darktheme.css b/src/main/resources/com/sparrowwallet/sparrow/darktheme.css index a23d0ce5..7fbbdfed 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/darktheme.css +++ b/src/main/resources/com/sparrowwallet/sparrow/darktheme.css @@ -4,6 +4,7 @@ -fx-base: #373e43; -fx-control-inner-background: derive(-fx-base, 35%); -fx-control-inner-background-alt: -fx-control-inner-background ; + -fx-default-button: -fx-accent; } .label{ @@ -97,6 +98,10 @@ -fx-fill: #e06c75; } +.root .invalid-checksum { + -fx-text-fill: #e06c75; +} + .root .etched-raised-border { -fx-border-color: #ffffff, #000000; -fx-border-style: solid, solid;