mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
add support for deprecating importers and exporters, and deprecate cobo vault
This commit is contained in:
parent
60dbc8ed84
commit
97d121244f
14 changed files with 54 additions and 23 deletions
|
@ -1065,6 +1065,10 @@ public class AppController implements Initializable {
|
||||||
new KeystoneSinglesig(), new KeystoneMultisig(),
|
new KeystoneSinglesig(), new KeystoneMultisig(),
|
||||||
new CaravanMultisig());
|
new CaravanMultisig());
|
||||||
for(WalletImport importer : walletImporters) {
|
for(WalletImport importer : walletImporters) {
|
||||||
|
if(importer.isDeprecated() && !Config.get().isShowDeprecatedImportExport()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try(FileInputStream inputStream = new FileInputStream(file)) {
|
try(FileInputStream inputStream = new FileInputStream(file)) {
|
||||||
if(importer.isEncrypted(file) && password == null) {
|
if(importer.isEncrypted(file) && password == null) {
|
||||||
WalletPasswordDialog dlg = new WalletPasswordDialog(file.getName(), WalletPasswordDialog.PasswordRequirement.LOAD);
|
WalletPasswordDialog dlg = new WalletPasswordDialog(file.getName(), WalletPasswordDialog.PasswordRequirement.LOAD);
|
||||||
|
|
|
@ -50,10 +50,12 @@ public class WalletExportDialog extends Dialog<Wallet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Accordion exportAccordion = new Accordion();
|
Accordion exportAccordion = new Accordion();
|
||||||
for (WalletExport exporter : exporters) {
|
for(WalletExport exporter : exporters) {
|
||||||
|
if(!exporter.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
|
||||||
FileWalletExportPane exportPane = new FileWalletExportPane(wallet, exporter);
|
FileWalletExportPane exportPane = new FileWalletExportPane(wallet, exporter);
|
||||||
exportAccordion.getPanes().add(exportPane);
|
exportAccordion.getPanes().add(exportPane);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exportAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
|
exportAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
|
||||||
scrollPane.setContent(exportAccordion);
|
scrollPane.setContent(exportAccordion);
|
||||||
|
|
|
@ -51,15 +51,19 @@ public class WalletImportDialog extends Dialog<Wallet> {
|
||||||
importAccordion = new Accordion();
|
importAccordion = new Accordion();
|
||||||
List<KeystoreFileImport> keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new Jade(), new KeystoneSinglesig(), new PassportSinglesig(), new GordianSeedTool(), new SeedSigner(), new SpecterDIY());
|
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) {
|
for(KeystoreFileImport importer : keystoreImporters) {
|
||||||
|
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
|
||||||
FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer);
|
FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer);
|
||||||
importAccordion.getPanes().add(importPane);
|
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());
|
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) {
|
for(WalletImport importer : walletImporters) {
|
||||||
|
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
|
||||||
FileWalletImportPane importPane = new FileWalletImportPane(importer);
|
FileWalletImportPane importPane = new FileWalletImportPane(importer);
|
||||||
importAccordion.getPanes().add(importPane);
|
importAccordion.getPanes().add(importPane);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
importAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
|
importAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
|
||||||
|
|
||||||
|
|
|
@ -67,4 +67,9 @@ public class CoboVaultMultisig extends ColdcardMultisig {
|
||||||
public boolean isWalletExportScannable() {
|
public boolean isWalletExportScannable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDeprecated() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,11 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDeprecated() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static class CoboVaultSinglesigKeystore {
|
private static class CoboVaultSinglesigKeystore {
|
||||||
public String ExtPubKey;
|
public String ExtPubKey;
|
||||||
public String MasterFingerprint;
|
public String MasterFingerprint;
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class Config {
|
||||||
private boolean showTransactionHex = true;
|
private boolean showTransactionHex = true;
|
||||||
private boolean showLoadingLog = true;
|
private boolean showLoadingLog = true;
|
||||||
private boolean showAddressTransactionCount = false;
|
private boolean showAddressTransactionCount = false;
|
||||||
|
private boolean showDeprecatedImportExport = false;
|
||||||
private boolean preventSleep = false;
|
private boolean preventSleep = false;
|
||||||
private List<File> recentWalletFiles;
|
private List<File> recentWalletFiles;
|
||||||
private Integer keyDerivationPeriod;
|
private Integer keyDerivationPeriod;
|
||||||
|
@ -301,6 +302,15 @@ public class Config {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowDeprecatedImportExport() {
|
||||||
|
return showDeprecatedImportExport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowDeprecatedImportExport(boolean showDeprecatedImportExport) {
|
||||||
|
this.showDeprecatedImportExport = showDeprecatedImportExport;
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPreventSleep() {
|
public boolean isPreventSleep() {
|
||||||
return preventSleep;
|
return preventSleep;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@ package com.sparrowwallet.sparrow.io;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public interface FileImport extends Import {
|
public interface FileImport extends ImportExport {
|
||||||
boolean isEncrypted(File file);
|
boolean isEncrypted(File file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package com.sparrowwallet.sparrow.io;
|
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.wallet.WalletModel;
|
|
||||||
|
|
||||||
public interface Import {
|
|
||||||
String getName();
|
|
||||||
WalletModel getWalletModel();
|
|
||||||
}
|
|
|
@ -2,7 +2,10 @@ package com.sparrowwallet.sparrow.io;
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.wallet.WalletModel;
|
import com.sparrowwallet.drongo.wallet.WalletModel;
|
||||||
|
|
||||||
public interface Export {
|
public interface ImportExport {
|
||||||
String getName();
|
String getName();
|
||||||
WalletModel getWalletModel();
|
WalletModel getWalletModel();
|
||||||
|
default boolean isDeprecated() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
package com.sparrowwallet.sparrow.io;
|
package com.sparrowwallet.sparrow.io;
|
||||||
|
|
||||||
public interface KeystoreImport extends Import {
|
public interface KeystoreImport extends ImportExport {
|
||||||
String getKeystoreImportDescription();
|
String getKeystoreImportDescription();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public interface WalletExport extends Export {
|
public interface WalletExport extends ImportExport {
|
||||||
void exportWallet(Wallet wallet, OutputStream outputStream) throws ExportException;
|
void exportWallet(Wallet wallet, OutputStream outputStream) throws ExportException;
|
||||||
String getWalletExportDescription();
|
String getWalletExportDescription();
|
||||||
String getExportFileExtension(Wallet wallet);
|
String getExportFileExtension(Wallet wallet);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public interface WalletImport extends Import, FileImport {
|
public interface WalletImport extends FileImport {
|
||||||
String getWalletImportDescription();
|
String getWalletImportDescription();
|
||||||
Wallet importWallet(InputStream inputStream, String password) throws ImportException;
|
Wallet importWallet(InputStream inputStream, String password) throws ImportException;
|
||||||
boolean isWalletImportScannable();
|
boolean isWalletImportScannable();
|
||||||
|
|
|
@ -24,11 +24,13 @@ public class HwAirgappedController extends KeystoreImportDetailController {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(KeystoreFileImport importer : importers) {
|
for(KeystoreFileImport importer : importers) {
|
||||||
|
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
|
||||||
FileKeystoreImportPane importPane = new FileKeystoreImportPane(getMasterController().getWallet(), importer, getMasterController().getRequiredDerivation());
|
FileKeystoreImportPane importPane = new FileKeystoreImportPane(getMasterController().getWallet(), importer, getMasterController().getRequiredDerivation());
|
||||||
if(getMasterController().getRequiredModel() == null || getMasterController().getRequiredModel() == importer.getWalletModel()) {
|
if(getMasterController().getRequiredModel() == null || getMasterController().getRequiredModel() == importer.getWalletModel()) {
|
||||||
importAccordion.getPanes().add(importPane);
|
importAccordion.getPanes().add(importPane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
importAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
|
importAccordion.getPanes().sort(Comparator.comparing(o -> ((TitledDescriptionPane) o).getTitle()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@ public class SwController extends KeystoreImportDetailController {
|
||||||
List<KeystoreImport> importers = List.of(new Bip39(), new Electrum(), new Bip32());
|
List<KeystoreImport> importers = List.of(new Bip39(), new Electrum(), new Bip32());
|
||||||
|
|
||||||
for(KeystoreImport importer : importers) {
|
for(KeystoreImport importer : importers) {
|
||||||
|
if(importer.isDeprecated() && !Config.get().isShowDeprecatedImportExport()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
TitledDescriptionPane importPane = null;
|
TitledDescriptionPane importPane = null;
|
||||||
|
|
||||||
if(importer instanceof KeystoreFileImport) {
|
if(importer instanceof KeystoreFileImport) {
|
||||||
|
|
Loading…
Reference in a new issue