From 90bfa470460bc5f595693cc55df71a5d1b9cd9b9 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 31 Aug 2023 09:34:15 +0200 Subject: [PATCH] add jade multisig wallet import --- .../sparrow/control/FileWalletImportPane.java | 2 +- .../sparrow/control/WalletImportDialog.java | 2 +- .../sparrow/io/JadeMultisig.java | 29 +++++++++++++++++++ .../sparrow/io/WalletImport.java | 3 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java index a4abf902..2a581e3d 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(), true); + super(importer, importer.getName(), "Wallet import", importer.getWalletImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isWalletImportScannable(), importer.isWalletImportFileFormatAvailable()); 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 ba213cd2..c5719cab 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java @@ -59,7 +59,7 @@ public class WalletImportDialog extends Dialog { } } - List walletImporters = new ArrayList<>(List.of(new Bip129(), new CaravanMultisig(), new ColdcardMultisig(), new CoboVaultMultisig(), new Electrum(), new KeystoneMultisig(), new Descriptor(), new SpecterDesktop(), new BlueWalletMultisig(), new Sparrow())); + List walletImporters = new ArrayList<>(List.of(new Bip129(), new CaravanMultisig(), new ColdcardMultisig(), new CoboVaultMultisig(), new Electrum(), new KeystoneMultisig(), new Descriptor(), new SpecterDesktop(), new BlueWalletMultisig(), new Sparrow(), new JadeMultisig())); if(!selectedWalletForms.isEmpty()) { walletImporters.add(new WalletLabels(selectedWalletForms)); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/JadeMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/JadeMultisig.java index b0c0d3a2..0f6ce703 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/JadeMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/JadeMultisig.java @@ -1,8 +1,11 @@ package com.sparrowwallet.sparrow.io; +import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.drongo.wallet.WalletModel; +import java.io.InputStream; + public class JadeMultisig extends ColdcardMultisig { @Override public String getName() { @@ -38,4 +41,30 @@ public class JadeMultisig extends ColdcardMultisig { public boolean walletExportRequiresDecryption() { return false; } + + @Override + public String getWalletImportDescription() { + return "Import the QR created using Options > Wallet > Registered Wallets on your Jade."; + } + + @Override + public boolean isWalletImportScannable() { + return true; + } + + @Override + public boolean isWalletImportFileFormatAvailable() { + return false; + } + + @Override + public Wallet importWallet(InputStream inputStream, String password) throws ImportException { + Wallet wallet = super.importWallet(inputStream, password); + for(Keystore keystore : wallet.getKeystores()) { + keystore.setLabel(keystore.getLabel().replace("Coldcard", "Jade")); + keystore.setWalletModel(WalletModel.JADE); + } + + return wallet; + } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java b/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java index ee206761..1fbf36ba 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java @@ -8,4 +8,7 @@ public interface WalletImport extends FileImport { String getWalletImportDescription(); Wallet importWallet(InputStream inputStream, String password) throws ImportException; boolean isWalletImportScannable(); + default boolean isWalletImportFileFormatAvailable() { + return true; + } }