separate keystore and wallet scannable, improve cobo importing

This commit is contained in:
Craig Raw 2020-11-18 08:37:51 +02:00
parent 8e23bd64c7
commit 80b7ee803b
14 changed files with 67 additions and 28 deletions

View file

@ -38,6 +38,7 @@ public class CoinTreeTable extends TreeTableView<Entry> {
} }
public void updateHistoryStatus(WalletHistoryStatusEvent event) { public void updateHistoryStatus(WalletHistoryStatusEvent event) {
if(getRoot() != null) {
Entry entry = getRoot().getValue(); Entry entry = getRoot().getValue();
if(entry != null && event.getWallet() != null && entry.getWallet() == event.getWallet()) { if(entry != null && event.getWallet() != null && entry.getWallet() == event.getWallet()) {
Platform.runLater(() -> { Platform.runLater(() -> {
@ -55,4 +56,5 @@ public class CoinTreeTable extends TreeTableView<Entry> {
}); });
} }
} }
}
} }

View file

@ -14,7 +14,7 @@ public class FileKeystoreImportPane extends FileImportPane {
private final KeystoreFileImport importer; private final KeystoreFileImport importer;
public FileKeystoreImportPane(Wallet wallet, KeystoreFileImport importer) { public FileKeystoreImportPane(Wallet wallet, KeystoreFileImport importer) {
super(importer, importer.getName(), "Keystore import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isScannable()); super(importer, importer.getName(), "Keystore import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable());
this.wallet = wallet; this.wallet = wallet;
this.importer = importer; this.importer = importer;
} }

View file

@ -12,7 +12,7 @@ public class FileWalletImportPane extends FileImportPane {
private final WalletImport importer; private final WalletImport importer;
public FileWalletImportPane(WalletImport importer) { public FileWalletImportPane(WalletImport importer) {
super(importer, importer.getName(), "Wallet import", importer.getWalletImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isScannable()); super(importer, importer.getName(), "Wallet import", importer.getWalletImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isWalletImportScannable());
this.importer = importer; this.importer = importer;
} }

View file

@ -36,7 +36,7 @@ public class FileWalletKeystoreImportPane extends FileImportPane {
private byte[] fileBytes; private byte[] fileBytes;
public FileWalletKeystoreImportPane(KeystoreFileImport importer) { public FileWalletKeystoreImportPane(KeystoreFileImport importer) {
super(importer, importer.getName(), "Wallet import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isScannable()); super(importer, importer.getName(), "Wallet import", importer.getKeystoreImportDescription(), "image/" + importer.getWalletModel().getType() + ".png", importer.isKeystoreImportScannable());
this.importer = importer; this.importer = importer;
} }

View file

@ -35,6 +35,10 @@ import org.controlsfx.tools.Borders;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -257,7 +261,16 @@ public class QRScanDialog extends Dialog<QRScanDialog.Result> {
//ignore, bytes not parsable as tx //ignore, bytes not parsable as tx
} }
result = new Result(new URException("Parsed UR of type " + urRegistryType + " was not a PSBT or transaction")); try {
CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
ByteBuffer buf = ByteBuffer.wrap(urBytes);
CharBuffer charBuffer = decoder.decode(buf);
return new Result(charBuffer.toString());
} catch(Exception e) {
//ignore, bytes not parsable as utf-8
}
result = new Result(new URException("Parsed UR of type " + urRegistryType + " was not a PSBT, transaction or UTF-8 text"));
} else if(urRegistryType.equals(RegistryType.CRYPTO_PSBT)) { } else if(urRegistryType.equals(RegistryType.CRYPTO_PSBT)) {
CryptoPSBT cryptoPSBT = (CryptoPSBT)ur.decodeFromRegistry(); CryptoPSBT cryptoPSBT = (CryptoPSBT)ur.decodeFromRegistry();
try { try {

View file

@ -29,7 +29,7 @@ public class CoboVaultMultisig extends ColdcardMultisig {
@Override @Override
public String getKeystoreImportDescription() { public String getKeystoreImportDescription() {
return "Import file or QR created by using the Multisig Wallet > Show/Export XPUB > Export All > Export feature on your Cobo Vault."; return "Import file or QR created by using the Multisig Wallet > Show/Export XPUB feature on your Cobo Vault.";
} }
@Override @Override
@ -54,7 +54,12 @@ public class CoboVaultMultisig extends ColdcardMultisig {
} }
@Override @Override
public boolean isScannable() { public boolean isWalletImportScannable() {
return true;
}
@Override
public boolean isKeystoreImportScannable() {
return true; return true;
} }
} }

View file

@ -20,7 +20,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
@Override @Override
public String getKeystoreImportDescription() { public String getKeystoreImportDescription() {
return "Import file or QR created by using the Watch-Only Wallet > Generic Wallet > Export Wallet feature on your Cobo Vault."; return "Import file or QR created by using the Settings > Watch-Only Wallet > Generic Wallet > Export Wallet feature on your Cobo Vault.";
} }
@Override @Override
@ -87,7 +87,12 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
} }
@Override @Override
public boolean isScannable() { public boolean isWalletImportScannable() {
return true;
}
@Override
public boolean isKeystoreImportScannable() {
return true; return true;
} }

View file

@ -211,7 +211,12 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle
} }
@Override @Override
public boolean isScannable() { public boolean isWalletImportScannable() {
return false;
}
@Override
public boolean isKeystoreImportScannable() {
return false; return false;
} }
} }

View file

@ -38,7 +38,12 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport {
} }
@Override @Override
public boolean isScannable() { public boolean isWalletImportScannable() {
return false;
}
@Override
public boolean isKeystoreImportScannable() {
return false; return false;
} }

View file

@ -323,7 +323,12 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport
} }
@Override @Override
public boolean isScannable() { public boolean isWalletImportScannable() {
return false;
}
@Override
public boolean isKeystoreImportScannable() {
return false; return false;
} }

View file

@ -4,5 +4,4 @@ import java.io.File;
public interface FileImport extends Import { public interface FileImport extends Import {
boolean isEncrypted(File file); boolean isEncrypted(File file);
boolean isScannable();
} }

View file

@ -3,9 +3,9 @@ package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.protocol.ScriptType; import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.Keystore;
import java.io.File;
import java.io.InputStream; 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;
boolean isKeystoreImportScannable();
} }

View file

@ -79,7 +79,7 @@ public class Specter implements WalletImport, WalletExport {
} }
@Override @Override
public boolean isScannable() { public boolean isWalletImportScannable() {
return true; return true;
} }

View file

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