diff --git a/drongo b/drongo index 645be6a5..c1f6a124 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 645be6a5a5a7b434ea9a3991ae85e0b8b6d4f50b +Subproject commit c1f6a1245e4632deb19af64faaa6ffaaca475313 diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java index e7d6f121..4f2566a8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java @@ -42,12 +42,14 @@ public abstract class FileImportPane extends TitledDescriptionPane { protected ButtonBase importButton; private final SimpleStringProperty password = new SimpleStringProperty(""); private final boolean scannable; + private final boolean fileFormatAvailable; protected List wallets; - public FileImportPane(FileImport importer, String title, String description, String content, String imageUrl, boolean scannable) { + public FileImportPane(FileImport importer, String title, String description, String content, String imageUrl, boolean scannable, boolean fileFormatAvailable) { super(title, description, content, imageUrl); this.importer = importer; this.scannable = scannable; + this.fileFormatAvailable = fileFormatAvailable; buttonBox.getChildren().clear(); buttonBox.getChildren().add(createButton()); @@ -55,7 +57,7 @@ public abstract class FileImportPane extends TitledDescriptionPane { @Override protected Control createButton() { - if(scannable) { + if(scannable && fileFormatAvailable) { ToggleButton scanButton = new ToggleButton("Scan..."); Glyph cameraGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CAMERA); cameraGlyph.setFontSize(12); @@ -76,6 +78,16 @@ public abstract class FileImportPane extends TitledDescriptionPane { SegmentedButton segmentedButton = new SegmentedButton(); segmentedButton.getButtons().addAll(scanButton, fileButton); return segmentedButton; + } else if(scannable) { + importButton = new Button("Scan..."); + Glyph cameraGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CAMERA); + cameraGlyph.setFontSize(12); + importButton.setGraphic(cameraGlyph); + importButton.setAlignment(Pos.CENTER_RIGHT); + importButton.setOnAction(event -> { + importQR(); + }); + return importButton; } else { importButton = new Button("Import File..."); importButton.setAlignment(Pos.CENTER_RIGHT); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java index 3006eb6d..dfc09ac1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java @@ -16,7 +16,7 @@ public class FileKeystoreImportPane extends FileImportPane { private final KeyDerivation requiredDerivation; public FileKeystoreImportPane(Wallet wallet, KeystoreFileImport importer, KeyDerivation requiredDerivation) { - super(importer, importer.getName(), "Keystore import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable()); + super(importer, importer.getName(), "Keystore import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable(), importer.isFileFormatAvailable()); this.wallet = wallet; this.importer = importer; this.requiredDerivation = requiredDerivation; diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java index 8fb3b055..8d030d5d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java @@ -12,7 +12,7 @@ public class FileWalletImportPane extends FileImportPane { private final WalletImport importer; public FileWalletImportPane(WalletImport importer) { - super(importer, importer.getName(), "Wallet import", importer.getWalletImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isWalletImportScannable()); + super(importer, importer.getName(), "Wallet import", importer.getWalletImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isWalletImportScannable(), true); this.importer = importer; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java index 66c9920d..471b79e2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java @@ -40,7 +40,7 @@ public class FileWalletKeystoreImportPane extends FileImportPane { private byte[] fileBytes; public FileWalletKeystoreImportPane(KeystoreFileImport importer) { - super(importer, importer.getName(), "Wallet import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable()); + super(importer, importer.getName(), "Wallet import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable(), importer.isFileFormatAvailable()); this.importer = importer; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java index 65c9a733..c3959491 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java @@ -48,7 +48,7 @@ public class WalletImportDialog extends Dialog { AnchorPane.setRightAnchor(scrollPane, 0.0); importAccordion = new Accordion(); - List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SpecterDIY()); + List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedTool(), new SpecterDIY()); for(KeystoreFileImport importer : keystoreImporters) { FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer); importAccordion.getPanes().add(importPane); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java index aff61c42..c0e3827f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java @@ -8,4 +8,7 @@ import java.io.InputStream; public interface KeystoreFileImport extends KeystoreImport, FileImport { Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException; boolean isKeystoreImportScannable(); + default boolean isFileFormatAvailable() { + return true; + }; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/SeedTool.java b/src/main/java/com/sparrowwallet/sparrow/io/SeedTool.java new file mode 100644 index 00000000..bc865e73 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/io/SeedTool.java @@ -0,0 +1,45 @@ +package com.sparrowwallet.sparrow.io; + +import com.sparrowwallet.drongo.protocol.ScriptType; +import com.sparrowwallet.drongo.wallet.Keystore; +import com.sparrowwallet.drongo.wallet.WalletModel; + +import java.io.File; +import java.io.InputStream; + +public class SeedTool implements KeystoreFileImport { + @Override + public boolean isEncrypted(File file) { + return false; + } + + @Override + public String getName() { + return "Seed Tool"; + } + + @Override + public WalletModel getWalletModel() { + return WalletModel.SEED_TOOL; + } + + @Override + public Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException { + throw new ImportException("Only QR imports are supported."); + } + + @Override + public boolean isKeystoreImportScannable() { + return true; + } + + @Override + public String getKeystoreImportDescription() { + return "Select your seed and scan the QR code created by Authenticate > Derive Key > Other Key Derivations > Account Descriptor. Click the share icon at the bottom to show the QR."; + } + + @Override + public boolean isFileFormatAvailable() { + return false; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java index c35b7342..c6bf736e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java @@ -18,9 +18,9 @@ public class HwAirgappedController extends KeystoreImportDetailController { public void initializeView() { List importers = Collections.emptyList(); if(getMasterController().getWallet().getPolicyType().equals(PolicyType.SINGLE)) { - importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedSigner(), new SpecterDIY()); + importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedSigner(), new SeedTool(), new SpecterDIY()); } else if(getMasterController().getWallet().getPolicyType().equals(PolicyType.MULTI)) { - importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new KeystoneMultisig(), new PassportMultisig(), new SeedSigner(), new SpecterDIY()); + importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new KeystoneMultisig(), new PassportMultisig(), new SeedSigner(), new SeedTool(), new SpecterDIY()); } for(KeystoreFileImport importer : importers) { diff --git a/src/main/resources/image/seedtool.png b/src/main/resources/image/seedtool.png new file mode 100644 index 00000000..a0964cb1 Binary files /dev/null and b/src/main/resources/image/seedtool.png differ diff --git a/src/main/resources/image/seedtool@2x.png b/src/main/resources/image/seedtool@2x.png new file mode 100644 index 00000000..c00f266b Binary files /dev/null and b/src/main/resources/image/seedtool@2x.png differ diff --git a/src/main/resources/image/seedtool@3x.png b/src/main/resources/image/seedtool@3x.png new file mode 100644 index 00000000..1eee9972 Binary files /dev/null and b/src/main/resources/image/seedtool@3x.png differ