handle p2sh default derivation change and other small fixes

This commit is contained in:
Craig Raw 2020-10-26 15:12:10 +02:00
parent c8cd2d1cd9
commit be5a48ce71
9 changed files with 18 additions and 8 deletions

2
drongo

@ -1 +1 @@
Subproject commit c4f5218f29ef58e9ce265373206a093157610fdb Subproject commit 401d3b8bfbffb8396a4d76737b4d335389b60051

View file

@ -447,7 +447,7 @@ public class AppController implements Initializable {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Transaction"); fileChooser.setTitle("Open Transaction");
fileChooser.getExtensionFilters().addAll( 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("PSBT", "*.psbt"),
new FileChooser.ExtensionFilter("TXN", "*.txn") new FileChooser.ExtensionFilter("TXN", "*.txn")
); );

View file

@ -3,6 +3,7 @@ package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.ExtendedKey; import com.sparrowwallet.drongo.ExtendedKey;
import com.sparrowwallet.drongo.KeyDerivation; import com.sparrowwallet.drongo.KeyDerivation;
import com.sparrowwallet.drongo.crypto.ChildNumber; import com.sparrowwallet.drongo.crypto.ChildNumber;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.psbt.PSBT; import com.sparrowwallet.drongo.psbt.PSBT;
import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.KeystoreSource; import com.sparrowwallet.drongo.wallet.KeystoreSource;
@ -199,7 +200,8 @@ public class DevicePane extends TitledDescriptionPane {
importKeystore(wallet.getScriptType().getDefaultDerivation()); 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"}; 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]); MenuItem item = new MenuItem(accounts[i]);
final List<ChildNumber> derivation = wallet.getScriptType().getDefaultDerivation(i); final List<ChildNumber> derivation = wallet.getScriptType().getDefaultDerivation(i);
item.setOnAction(event -> { item.setOnAction(event -> {

View file

@ -21,6 +21,7 @@ import org.controlsfx.control.SegmentedButton;
import org.controlsfx.control.textfield.CustomPasswordField; import org.controlsfx.control.textfield.CustomPasswordField;
import org.controlsfx.control.textfield.TextFields; import org.controlsfx.control.textfield.TextFields;
import org.controlsfx.glyphfont.Glyph; import org.controlsfx.glyphfont.Glyph;
import org.controlsfx.tools.Platform;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -84,7 +85,7 @@ public abstract class FileImportPane extends TitledDescriptionPane {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open " + importer.getWalletModel().toDisplayString() + " File"); fileChooser.setTitle("Open " + importer.getWalletModel().toDisplayString() + " File");
fileChooser.getExtensionFilters().addAll( 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("JSON", "*.json"),
new FileChooser.ExtensionFilter("TXT", "*.txt") new FileChooser.ExtensionFilter("TXT", "*.txt")
); );

View file

@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.KeyDerivation; import com.sparrowwallet.drongo.KeyDerivation;
import com.sparrowwallet.drongo.crypto.ChildNumber; import com.sparrowwallet.drongo.crypto.ChildNumber;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.drongo.wallet.*;
import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.KeystoreImportEvent; import com.sparrowwallet.sparrow.event.KeystoreImportEvent;
@ -107,7 +108,8 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane {
importKeystore(wallet.getScriptType().getDefaultDerivation(), false); 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"}; 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]); MenuItem item = new MenuItem(accounts[i]);
final List<ChildNumber> derivation = wallet.getScriptType().getDefaultDerivation(i); final List<ChildNumber> derivation = wallet.getScriptType().getDefaultDerivation(i);
item.setOnAction(event -> { item.setOnAction(event -> {

View file

@ -88,7 +88,7 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle
wallet.setPolicyType(PolicyType.MULTI); wallet.setPolicyType(PolicyType.MULTI);
int threshold = 2; int threshold = 2;
ScriptType scriptType = null; ScriptType scriptType = ScriptType.P2SH;
String derivation = null; String derivation = null;
try { try {

View file

@ -84,7 +84,7 @@ public class Hwi {
if(result.get("xpub") != null) { if(result.get("xpub") != null) {
return result.get("xpub").getAsString(); return result.get("xpub").getAsString();
} else { } else {
throw new ImportException("Could not retrieve xpub"); throw new ImportException("Could not retrieve xpub - reconnect your device and try again.");
} }
} catch(IOException e) { } catch(IOException e) {
throw new ImportException(e); throw new ImportException(e);

View file

@ -109,7 +109,7 @@ public class ServerPreferencesController extends PreferencesDetailController {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select Electrum Server certificate"); fileChooser.setTitle("Select Electrum Server certificate");
fileChooser.getExtensionFilters().addAll( 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") new FileChooser.ExtensionFilter("CRT", "*.crt")
); );

View file

@ -4,6 +4,7 @@
-fx-base: #373e43; -fx-base: #373e43;
-fx-control-inner-background: derive(-fx-base, 35%); -fx-control-inner-background: derive(-fx-base, 35%);
-fx-control-inner-background-alt: -fx-control-inner-background ; -fx-control-inner-background-alt: -fx-control-inner-background ;
-fx-default-button: -fx-accent;
} }
.label{ .label{
@ -97,6 +98,10 @@
-fx-fill: #e06c75; -fx-fill: #e06c75;
} }
.root .invalid-checksum {
-fx-text-fill: #e06c75;
}
.root .etched-raised-border { .root .etched-raised-border {
-fx-border-color: #ffffff, #000000; -fx-border-color: #ffffff, #000000;
-fx-border-style: solid, solid; -fx-border-style: solid, solid;