From 467b83495547f3109d91e7316ee56ecd54af6608 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 25 Oct 2022 14:41:10 +0200 Subject: [PATCH] add jade as airgapped keystore importer --- .../sparrow/control/WalletImportDialog.java | 2 +- .../com/sparrowwallet/sparrow/io/Jade.java | 45 +++++++++++++++++++ .../keystoreimport/HwAirgappedController.java | 4 +- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/sparrowwallet/sparrow/io/Jade.java diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java index e5c6c01d..ba7956ce 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java @@ -49,7 +49,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 GordianSeedTool(), new SeedSigner(), new SpecterDIY()); + List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new Jade(), new KeystoneSinglesig(), new PassportSinglesig(), new GordianSeedTool(), new SeedSigner(), 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/Jade.java b/src/main/java/com/sparrowwallet/sparrow/io/Jade.java new file mode 100644 index 00000000..f846161a --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/io/Jade.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 Jade implements KeystoreFileImport { + @Override + public boolean isEncrypted(File file) { + return false; + } + + @Override + public String getName() { + return "Jade"; + } + + @Override + public WalletModel getWalletModel() { + return WalletModel.JADE; + } + + @Override + public Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException { + throw new ImportException("Failed to detect a valid " + scriptType.getDescription() + " keystore."); + } + + @Override + public String getKeystoreImportDescription(int account) { + return "Import QR created on your Jade by selecting Xpub Export from the Settings menu once you have loaded your seed."; + } + + @Override + public boolean isKeystoreImportScannable() { + return true; + } + + @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 3959b875..a891dfa7 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 GordianSeedTool(), new SpecterDIY()); + importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new Jade(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedSigner(), new GordianSeedTool(), new SpecterDIY()); } else if(getMasterController().getWallet().getPolicyType().equals(PolicyType.MULTI)) { - importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new KeystoneMultisig(), new PassportMultisig(), new SeedSigner(), new GordianSeedTool(), new SpecterDIY()); + importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new Jade(), new KeystoneMultisig(), new PassportMultisig(), new SeedSigner(), new GordianSeedTool(), new SpecterDIY()); } for(KeystoreFileImport importer : importers) {