mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
separate keystore and wallet scannable, improve cobo importing
This commit is contained in:
parent
8e23bd64c7
commit
80b7ee803b
14 changed files with 67 additions and 28 deletions
|
@ -38,21 +38,23 @@ public class CoinTreeTable extends TreeTableView<Entry> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHistoryStatus(WalletHistoryStatusEvent event) {
|
public void updateHistoryStatus(WalletHistoryStatusEvent event) {
|
||||||
Entry entry = getRoot().getValue();
|
if(getRoot() != null) {
|
||||||
if(entry != null && event.getWallet() != null && entry.getWallet() == event.getWallet()) {
|
Entry entry = getRoot().getValue();
|
||||||
Platform.runLater(() -> {
|
if(entry != null && event.getWallet() != null && entry.getWallet() == event.getWallet()) {
|
||||||
if(event.getErrorMessage() != null) {
|
Platform.runLater(() -> {
|
||||||
setPlaceholder(new Label("Error loading transactions: " + event.getErrorMessage()));
|
if(event.getErrorMessage() != null) {
|
||||||
} else if(event.isLoading()) {
|
setPlaceholder(new Label("Error loading transactions: " + event.getErrorMessage()));
|
||||||
if(event.getStatusMessage() != null) {
|
} else if(event.isLoading()) {
|
||||||
setPlaceholder(new Label(event.getStatusMessage() + "..."));
|
if(event.getStatusMessage() != null) {
|
||||||
|
setPlaceholder(new Label(event.getStatusMessage() + "..."));
|
||||||
|
} else {
|
||||||
|
setPlaceholder(new Label("Loading transactions..."));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setPlaceholder(new Label("Loading transactions..."));
|
setPlaceholder(new Label("No transactions"));
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
setPlaceholder(new Label("No transactions"));
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class Specter implements WalletImport, WalletExport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isScannable() {
|
public boolean isWalletImportScannable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue