diff --git a/drongo b/drongo index 4b682fb3..a38206f1 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 4b682fb3e710c4b2303295fdfde72195854097dc +Subproject commit a38206f17cd125044d87eb85bf2cf6dcd055e9a0 diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 4204bbe6..f396efd9 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -686,7 +686,11 @@ public class AppController implements Initializable { } private boolean attemptImportWallet(File file, SecureString password) { - List walletImporters = List.of(new ColdcardSinglesig(), new ColdcardMultisig(), new Electrum(), new SpecterDesktop(), new CoboVaultSinglesig(), new CoboVaultMultisig()); + List walletImporters = List.of(new ColdcardSinglesig(), new ColdcardMultisig(), + new Electrum(), + new SpecterDesktop(), + new CoboVaultSinglesig(), new CoboVaultMultisig(), + new PassportSinglesig()); for(WalletImport importer : walletImporters) { try(FileInputStream inputStream = new FileInputStream(file)) { if(importer.isEncrypted(file) && password == null) { diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java index 4ea8af2d..596a44f9 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java @@ -39,7 +39,7 @@ public class WalletImportDialog extends Dialog { AnchorPane.setRightAnchor(scrollPane, 0.0); Accordion importAccordion = new Accordion(); - List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig()); + List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new PassportSinglesig()); for(KeystoreFileImport importer : keystoreImporters) { FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer); importAccordion.getPanes().add(importPane); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index 5ccf25ce..32cf28e1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -57,7 +57,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { Map map = gson.fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), stringStringMap); if (map.get("xfp") == null) { - throw new ImportException("File was not a valid Coldcard wallet export"); + throw new ImportException("File was not a valid " + getName() + " wallet export"); } String masterFingerprint = map.get("xfp").getAsString(); @@ -107,7 +107,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { try { wallet.checkWallet(); } catch(InvalidWalletException e) { - throw new ImportException("Imported Coldcard wallet was invalid: " + e.getMessage()); + throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage()); } return wallet; diff --git a/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java new file mode 100644 index 00000000..0094be72 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java @@ -0,0 +1,38 @@ +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.InputStream; + +public class PassportMultisig extends ColdcardMultisig { + @Override + public String getName() { + return "Passport Multisig"; + } + + @Override + public WalletModel getWalletModel() { + return WalletModel.PASSPORT; + } + + @Override + public Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException { + Keystore keystore = super.getKeystore(scriptType, inputStream, password); + keystore.setLabel("Passport"); + keystore.setWalletModel(getWalletModel()); + + return keystore; + } + + @Override + public String getKeystoreImportDescription() { + return "Import file or QR created from Settings > Pair Software Wallet > Sparrow > Multisig > microSD/QR on your Passport."; + } + + @Override + public boolean isKeystoreImportScannable() { + return true; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java new file mode 100644 index 00000000..4191f015 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java @@ -0,0 +1,48 @@ +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.InputStream; + +public class PassportSinglesig extends ColdcardSinglesig { + @Override + public String getName() { + return "Passport"; + } + + @Override + public String getKeystoreImportDescription() { + return "Import file or QR created from Settings > Pair Software Wallet > Sparrow > Single Sig > microSD/QR on your Passport."; + } + + @Override + public Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException { + Keystore keystore = super.getKeystore(scriptType, inputStream, password); + keystore.setLabel("Passport"); + keystore.setWalletModel(getWalletModel()); + + return keystore; + } + + @Override + public WalletModel getWalletModel() { + return WalletModel.PASSPORT; + } + + @Override + public boolean isWalletImportScannable() { + return true; + } + + @Override + public boolean isKeystoreImportScannable() { + return true; + } + + @Override + public String getWalletImportDescription() { + return getKeystoreImportDescription(); + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java index 11621179..37e68084 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java @@ -16,9 +16,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 SpecterDIY()); + importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new PassportSinglesig(), new SpecterDIY()); } else if(getMasterController().getWallet().getPolicyType().equals(PolicyType.MULTI)) { - importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new SpecterDIY()); + importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new PassportMultisig(), new SpecterDIY()); } for(KeystoreImport importer : importers) { diff --git a/src/main/resources/image/passport.png b/src/main/resources/image/passport.png new file mode 100644 index 00000000..ce3b73cc Binary files /dev/null and b/src/main/resources/image/passport.png differ diff --git a/src/main/resources/image/passport@2x.png b/src/main/resources/image/passport@2x.png new file mode 100644 index 00000000..bde7bb7d Binary files /dev/null and b/src/main/resources/image/passport@2x.png differ diff --git a/src/main/resources/image/passport@3x.png b/src/main/resources/image/passport@3x.png new file mode 100644 index 00000000..c5dfbd35 Binary files /dev/null and b/src/main/resources/image/passport@3x.png differ