pass desired account number to keystore import description

This commit is contained in:
Craig Raw 2022-04-27 10:53:11 +02:00
parent 37a8a0a7f9
commit e565786bbc
15 changed files with 32 additions and 18 deletions

View file

@ -16,7 +16,7 @@ public class FileKeystoreImportPane extends FileImportPane {
private final KeyDerivation requiredDerivation; private final KeyDerivation requiredDerivation;
public FileKeystoreImportPane(Wallet wallet, KeystoreFileImport importer, 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.wallet = wallet;
this.importer = importer; this.importer = importer;
this.requiredDerivation = requiredDerivation; this.requiredDerivation = requiredDerivation;
@ -34,4 +34,17 @@ public class FileKeystoreImportPane extends FileImportPane {
EventManager.get().post(new KeystoreImportEvent(keystore)); 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;
}
} }

View file

@ -28,7 +28,7 @@ public class CoboVaultMultisig extends ColdcardMultisig {
} }
@Override @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."; return "Import file or QR created by using the Multisig Wallet > ... > Show/Export XPUB feature on your Cobo Vault.";
} }

View file

@ -24,7 +24,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
} }
@Override @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."; return "Import file or QR created by using the My Cobo Vault > ... > Export Wallet feature on your Cobo Vault.";
} }

View file

@ -84,8 +84,8 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle
} }
@Override @Override
public String getKeystoreImportDescription() { public String getKeystoreImportDescription(int account) {
return "Import file created by using the Settings > Multisig Wallets > Export XPUB > 0 feature on your Coldcard."; return "Import file created by using the Settings > Multisig Wallets > Export XPUB > " + account + " feature on your Coldcard.";
} }
@Override @Override

View file

@ -28,8 +28,8 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport {
} }
@Override @Override
public String getKeystoreImportDescription() { public String getKeystoreImportDescription(int account) {
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."; 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 @Override

View file

@ -35,7 +35,7 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport
} }
@Override @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)."; return "Import a single keystore from an Electrum wallet (use File > Import > Electrum to import a multisig wallet).";
} }

View file

@ -35,7 +35,7 @@ public class GordianSeedTool implements KeystoreFileImport {
} }
@Override @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."; 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.";
} }

View file

@ -28,7 +28,7 @@ public class KeystoneMultisig extends ColdcardMultisig {
} }
@Override @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."; return "Import file or QR created by using the Multisig Wallet > ... > Show/Export XPUB feature on your Keystone.";
} }

View file

@ -27,7 +27,7 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport {
} }
@Override @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."; 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.";
} }

View file

@ -7,6 +7,10 @@ import java.io.InputStream;
public interface KeystoreFileImport extends KeystoreImport, FileImport { public interface KeystoreFileImport extends KeystoreImport, FileImport {
Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException; Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException;
String getKeystoreImportDescription(int account);
default String getKeystoreImportDescription() {
return getKeystoreImportDescription(0);
}
boolean isKeystoreImportScannable(); boolean isKeystoreImportScannable();
default boolean isFileFormatAvailable() { default boolean isFileFormatAvailable() {
return true; return true;

View file

@ -1,8 +1,5 @@
package com.sparrowwallet.sparrow.io; package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.policy.PolicyType;
import com.sparrowwallet.drongo.wallet.WalletModel;
public interface KeystoreImport extends Import { public interface KeystoreImport extends Import {
String getKeystoreImportDescription(); String getKeystoreImportDescription();
} }

View file

@ -27,7 +27,7 @@ public class PassportMultisig extends ColdcardMultisig {
} }
@Override @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."; 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.";
} }

View file

@ -13,7 +13,7 @@ public class PassportSinglesig extends ColdcardSinglesig {
} }
@Override @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."; 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.";
} }

View file

@ -9,7 +9,7 @@ public class SeedSigner extends SpecterDIY {
} }
@Override @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."; return "Import QR created on your SeedSigner by selecting xPub from Seed in the Seed Tools menu once you have entered your seed.";
} }

View file

@ -45,7 +45,7 @@ public class SpecterDIY implements KeystoreFileImport, WalletExport {
} }
@Override @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."; 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.";
} }