diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java index dfc09ac1..fbb82cab 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(), importer.isFileFormatAvailable()); + super(importer, importer.getName(), "Keystore import", importer.getKeystoreImportDescription(getAccount(wallet, requiredDerivation)), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable(), importer.isFileFormatAvailable()); this.wallet = wallet; this.importer = importer; this.requiredDerivation = requiredDerivation; @@ -34,4 +34,17 @@ public class FileKeystoreImportPane extends FileImportPane { EventManager.get().post(new KeystoreImportEvent(keystore)); } } + + private static int getAccount(Wallet wallet, KeyDerivation requiredDerivation) { + if(wallet == null || requiredDerivation == null) { + return 0; + } + + int account = wallet.getScriptType().getAccount(requiredDerivation.getDerivationPath()); + if(account < 0) { + account = 0; + } + + return account; + } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java index 74c89bf2..6b2dfba6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java @@ -28,7 +28,7 @@ public class CoboVaultMultisig extends ColdcardMultisig { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created by using the Multisig Wallet > ... > Show/Export XPUB feature on your Cobo Vault."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java index c6948093..6b09d331 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java @@ -24,7 +24,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created by using the My Cobo Vault > ... > Export Wallet feature on your Cobo Vault."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index fcc21874..28e268db 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -84,8 +84,8 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle } @Override - public String getKeystoreImportDescription() { - return "Import file created by using the Settings > Multisig Wallets > Export XPUB > 0 feature on your Coldcard."; + public String getKeystoreImportDescription(int account) { + return "Import file created by using the Settings > Multisig Wallets > Export XPUB > " + account + " feature on your Coldcard."; } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index 7b0c1999..8908ae3a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -28,8 +28,8 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { } @Override - public String getKeystoreImportDescription() { - return "Import file created by using the Advanced > MicroSD > Export Wallet > Generic JSON > 0 feature on your Coldcard. Note this requires firmware version 3.1.3 or later."; + public String getKeystoreImportDescription(int account) { + return "Import file created by using the Advanced > MicroSD > Export Wallet > Generic JSON > " + account + " feature on your Coldcard. Note this requires firmware version 3.1.3 or later."; } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java index 5ecc3878..9cbe625c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java @@ -35,7 +35,7 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import a single keystore from an Electrum wallet (use File > Import > Electrum to import a multisig wallet)."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java b/src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java index 4f51cff7..0de1764a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java @@ -35,7 +35,7 @@ public class GordianSeedTool implements KeystoreFileImport { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Select your seed and scan the QR code created by Authenticate > Derive Key > Other Key Derivations > " + Network.get().toDisplayString() + " > Master Key > Account Descriptor. Click the share icon at the bottom."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneMultisig.java index 16d49f1a..e3004954 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneMultisig.java @@ -28,7 +28,7 @@ public class KeystoneMultisig extends ColdcardMultisig { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created by using the Multisig Wallet > ... > Show/Export XPUB feature on your Keystone."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java index 65308b8d..08c61863 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java @@ -27,7 +27,7 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created by using the My Keystone > ... > Export Wallet feature on your Keystone. Make sure to set the Watch-only Wallet to Sparrow in the Settings first."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java index c0e3827f..ce1dddd4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java @@ -7,6 +7,10 @@ import java.io.InputStream; public interface KeystoreFileImport extends KeystoreImport, FileImport { Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException; + String getKeystoreImportDescription(int account); + default String getKeystoreImportDescription() { + return getKeystoreImportDescription(0); + } boolean isKeystoreImportScannable(); default boolean isFileFormatAvailable() { return true; diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreImport.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreImport.java index 985caa05..882abc55 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreImport.java @@ -1,8 +1,5 @@ package com.sparrowwallet.sparrow.io; -import com.sparrowwallet.drongo.policy.PolicyType; -import com.sparrowwallet.drongo.wallet.WalletModel; - public interface KeystoreImport extends Import { String getKeystoreImportDescription(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java index e66d7164..d75b761c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/PassportMultisig.java @@ -27,7 +27,7 @@ public class PassportMultisig extends ColdcardMultisig { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created from New Account > Sparrow > Multisig > QR Code/microSD on your Passport. For existing accounts, use Manage Account > Export by QR/microSD."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java index 9c5d13b3..49b1f6eb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/PassportSinglesig.java @@ -13,7 +13,7 @@ public class PassportSinglesig extends ColdcardSinglesig { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created from New Account > Sparrow > Standard > QR Code/microSD on your Passport. For existing accounts, use Manage Account > Export by QR/microSD."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/SeedSigner.java b/src/main/java/com/sparrowwallet/sparrow/io/SeedSigner.java index 8c9511dd..3919dfdd 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/SeedSigner.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/SeedSigner.java @@ -9,7 +9,7 @@ public class SeedSigner extends SpecterDIY { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import QR created on your SeedSigner by selecting xPub from Seed in the Seed Tools menu once you have entered your seed."; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java b/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java index ccb78574..24925acc 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java @@ -45,7 +45,7 @@ public class SpecterDIY implements KeystoreFileImport, WalletExport { } @Override - public String getKeystoreImportDescription() { + public String getKeystoreImportDescription(int account) { return "Import file or QR created by using the Master Public Keys feature on your Specter DIY device. Note the default is P2WPKH for Single Signature, and P2WSH for Multi Signature."; }