add support for deprecating importers and exporters, and deprecate cobo vault

This commit is contained in:
Craig Raw 2022-10-26 12:28:21 +02:00
parent 60dbc8ed84
commit 97d121244f
14 changed files with 54 additions and 23 deletions

View file

@ -1065,6 +1065,10 @@ public class AppController implements Initializable {
new KeystoneSinglesig(), new KeystoneMultisig(),
new CaravanMultisig());
for(WalletImport importer : walletImporters) {
if(importer.isDeprecated() && !Config.get().isShowDeprecatedImportExport()) {
continue;
}
try(FileInputStream inputStream = new FileInputStream(file)) {
if(importer.isEncrypted(file) && password == null) {
WalletPasswordDialog dlg = new WalletPasswordDialog(file.getName(), WalletPasswordDialog.PasswordRequirement.LOAD);

View file

@ -50,10 +50,12 @@ public class WalletExportDialog extends Dialog<Wallet> {
}
Accordion exportAccordion = new Accordion();
for (WalletExport exporter : exporters) {
for(WalletExport exporter : exporters) {
if(!exporter.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
FileWalletExportPane exportPane = new FileWalletExportPane(wallet, exporter);
exportAccordion.getPanes().add(exportPane);
}
}
exportAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
scrollPane.setContent(exportAccordion);

View file

@ -51,15 +51,19 @@ public class WalletImportDialog extends Dialog<Wallet> {
importAccordion = new Accordion();
List<KeystoreFileImport> keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new Jade(), new KeystoneSinglesig(), new PassportSinglesig(), new GordianSeedTool(), new SeedSigner(), new SpecterDIY());
for(KeystoreFileImport importer : keystoreImporters) {
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer);
importAccordion.getPanes().add(importPane);
}
}
List<WalletImport> walletImporters = List.of(new CaravanMultisig(), new ColdcardMultisig(), new CoboVaultMultisig(), new Electrum(), new KeystoneMultisig(), new Descriptor(), new SpecterDesktop(), new BlueWalletMultisig(), new Sparrow());
for(WalletImport importer : walletImporters) {
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
FileWalletImportPane importPane = new FileWalletImportPane(importer);
importAccordion.getPanes().add(importPane);
}
}
importAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));

View file

@ -67,4 +67,9 @@ public class CoboVaultMultisig extends ColdcardMultisig {
public boolean isWalletExportScannable() {
return true;
}
@Override
public boolean isDeprecated() {
return true;
}
}

View file

@ -102,6 +102,11 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
return true;
}
@Override
public boolean isDeprecated() {
return true;
}
private static class CoboVaultSinglesigKeystore {
public String ExtPubKey;
public String MasterFingerprint;

View file

@ -46,6 +46,7 @@ public class Config {
private boolean showTransactionHex = true;
private boolean showLoadingLog = true;
private boolean showAddressTransactionCount = false;
private boolean showDeprecatedImportExport = false;
private boolean preventSleep = false;
private List<File> recentWalletFiles;
private Integer keyDerivationPeriod;
@ -301,6 +302,15 @@ public class Config {
flush();
}
public boolean isShowDeprecatedImportExport() {
return showDeprecatedImportExport;
}
public void setShowDeprecatedImportExport(boolean showDeprecatedImportExport) {
this.showDeprecatedImportExport = showDeprecatedImportExport;
flush();
}
public boolean isPreventSleep() {
return preventSleep;
}

View file

@ -2,6 +2,6 @@ package com.sparrowwallet.sparrow.io;
import java.io.File;
public interface FileImport extends Import {
public interface FileImport extends ImportExport {
boolean isEncrypted(File file);
}

View file

@ -1,8 +0,0 @@
package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.wallet.WalletModel;
public interface Import {
String getName();
WalletModel getWalletModel();
}

View file

@ -2,7 +2,10 @@ package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.wallet.WalletModel;
public interface Export {
public interface ImportExport {
String getName();
WalletModel getWalletModel();
default boolean isDeprecated() {
return false;
}
}

View file

@ -1,5 +1,5 @@
package com.sparrowwallet.sparrow.io;
public interface KeystoreImport extends Import {
public interface KeystoreImport extends ImportExport {
String getKeystoreImportDescription();
}

View file

@ -4,7 +4,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
import java.io.OutputStream;
public interface WalletExport extends Export {
public interface WalletExport extends ImportExport {
void exportWallet(Wallet wallet, OutputStream outputStream) throws ExportException;
String getWalletExportDescription();
String getExportFileExtension(Wallet wallet);

View file

@ -4,7 +4,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
import java.io.InputStream;
public interface WalletImport extends Import, FileImport {
public interface WalletImport extends FileImport {
String getWalletImportDescription();
Wallet importWallet(InputStream inputStream, String password) throws ImportException;
boolean isWalletImportScannable();

View file

@ -24,11 +24,13 @@ public class HwAirgappedController extends KeystoreImportDetailController {
}
for(KeystoreFileImport importer : importers) {
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
FileKeystoreImportPane importPane = new FileKeystoreImportPane(getMasterController().getWallet(), importer, getMasterController().getRequiredDerivation());
if(getMasterController().getRequiredModel() == null || getMasterController().getRequiredModel() == importer.getWalletModel()) {
importAccordion.getPanes().add(importPane);
}
}
}
importAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
}

View file

@ -18,6 +18,10 @@ public class SwController extends KeystoreImportDetailController {
List<KeystoreImport> importers = List.of(new Bip39(), new Electrum(), new Bip32());
for(KeystoreImport importer : importers) {
if(importer.isDeprecated() && !Config.get().isShowDeprecatedImportExport()) {
continue;
}
TitledDescriptionPane importPane = null;
if(importer instanceof KeystoreFileImport) {