add passport hww single and multisig importing

This commit is contained in:
Craig Raw 2021-01-28 10:43:54 +02:00
parent 2fc01e0345
commit a121bb5f26
10 changed files with 97 additions and 7 deletions

2
drongo

@ -1 +1 @@
Subproject commit 4b682fb3e710c4b2303295fdfde72195854097dc Subproject commit a38206f17cd125044d87eb85bf2cf6dcd055e9a0

View file

@ -686,7 +686,11 @@ public class AppController implements Initializable {
} }
private boolean attemptImportWallet(File file, SecureString password) { private boolean attemptImportWallet(File file, SecureString password) {
List<WalletImport> walletImporters = List.of(new ColdcardSinglesig(), new ColdcardMultisig(), new Electrum(), new SpecterDesktop(), new CoboVaultSinglesig(), new CoboVaultMultisig()); List<WalletImport> walletImporters = List.of(new ColdcardSinglesig(), new ColdcardMultisig(),
new Electrum(),
new SpecterDesktop(),
new CoboVaultSinglesig(), new CoboVaultMultisig(),
new PassportSinglesig());
for(WalletImport importer : walletImporters) { for(WalletImport importer : walletImporters) {
try(FileInputStream inputStream = new FileInputStream(file)) { try(FileInputStream inputStream = new FileInputStream(file)) {
if(importer.isEncrypted(file) && password == null) { if(importer.isEncrypted(file) && password == null) {

View file

@ -39,7 +39,7 @@ public class WalletImportDialog extends Dialog<Wallet> {
AnchorPane.setRightAnchor(scrollPane, 0.0); AnchorPane.setRightAnchor(scrollPane, 0.0);
Accordion importAccordion = new Accordion(); Accordion importAccordion = new Accordion();
List<KeystoreFileImport> keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig()); List<KeystoreFileImport> keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new PassportSinglesig());
for(KeystoreFileImport importer : keystoreImporters) { for(KeystoreFileImport importer : keystoreImporters) {
FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer); FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer);
importAccordion.getPanes().add(importPane); importAccordion.getPanes().add(importPane);

View file

@ -57,7 +57,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport {
Map<String, JsonElement> map = gson.fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), stringStringMap); Map<String, JsonElement> map = gson.fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), stringStringMap);
if (map.get("xfp") == null) { if (map.get("xfp") == null) {
throw new ImportException("File was not a valid Coldcard wallet export"); throw new ImportException("File was not a valid " + getName() + " wallet export");
} }
String masterFingerprint = map.get("xfp").getAsString(); String masterFingerprint = map.get("xfp").getAsString();
@ -107,7 +107,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport {
try { try {
wallet.checkWallet(); wallet.checkWallet();
} catch(InvalidWalletException e) { } catch(InvalidWalletException e) {
throw new ImportException("Imported Coldcard wallet was invalid: " + e.getMessage()); throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage());
} }
return wallet; return wallet;

View file

@ -0,0 +1,38 @@
package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.WalletModel;
import java.io.InputStream;
public class PassportMultisig extends ColdcardMultisig {
@Override
public String getName() {
return "Passport Multisig";
}
@Override
public WalletModel getWalletModel() {
return WalletModel.PASSPORT;
}
@Override
public Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException {
Keystore keystore = super.getKeystore(scriptType, inputStream, password);
keystore.setLabel("Passport");
keystore.setWalletModel(getWalletModel());
return keystore;
}
@Override
public String getKeystoreImportDescription() {
return "Import file or QR created from Settings > Pair Software Wallet > Sparrow > Multisig > microSD/QR on your Passport.";
}
@Override
public boolean isKeystoreImportScannable() {
return true;
}
}

View file

@ -0,0 +1,48 @@
package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.WalletModel;
import java.io.InputStream;
public class PassportSinglesig extends ColdcardSinglesig {
@Override
public String getName() {
return "Passport";
}
@Override
public String getKeystoreImportDescription() {
return "Import file or QR created from Settings > Pair Software Wallet > Sparrow > Single Sig > microSD/QR on your Passport.";
}
@Override
public Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException {
Keystore keystore = super.getKeystore(scriptType, inputStream, password);
keystore.setLabel("Passport");
keystore.setWalletModel(getWalletModel());
return keystore;
}
@Override
public WalletModel getWalletModel() {
return WalletModel.PASSPORT;
}
@Override
public boolean isWalletImportScannable() {
return true;
}
@Override
public boolean isKeystoreImportScannable() {
return true;
}
@Override
public String getWalletImportDescription() {
return getKeystoreImportDescription();
}
}

View file

@ -16,9 +16,9 @@ public class HwAirgappedController extends KeystoreImportDetailController {
public void initializeView() { public void initializeView() {
List<KeystoreFileImport> importers = Collections.emptyList(); List<KeystoreFileImport> importers = Collections.emptyList();
if(getMasterController().getWallet().getPolicyType().equals(PolicyType.SINGLE)) { if(getMasterController().getWallet().getPolicyType().equals(PolicyType.SINGLE)) {
importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new SpecterDIY()); importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new PassportSinglesig(), new SpecterDIY());
} else if(getMasterController().getWallet().getPolicyType().equals(PolicyType.MULTI)) { } else if(getMasterController().getWallet().getPolicyType().equals(PolicyType.MULTI)) {
importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new SpecterDIY()); importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new PassportMultisig(), new SpecterDIY());
} }
for(KeystoreImport importer : importers) { for(KeystoreImport importer : importers) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB