diff --git a/src/main/java/com/sparrowwallet/sparrow/control/CoinTreeTable.java b/src/main/java/com/sparrowwallet/sparrow/control/CoinTreeTable.java index 24002fd1..ddc76df0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/CoinTreeTable.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/CoinTreeTable.java @@ -38,21 +38,23 @@ public class CoinTreeTable extends TreeTableView { } public void updateHistoryStatus(WalletHistoryStatusEvent event) { - Entry entry = getRoot().getValue(); - if(entry != null && event.getWallet() != null && entry.getWallet() == event.getWallet()) { - Platform.runLater(() -> { - if(event.getErrorMessage() != null) { - setPlaceholder(new Label("Error loading transactions: " + event.getErrorMessage())); - } else if(event.isLoading()) { - if(event.getStatusMessage() != null) { - setPlaceholder(new Label(event.getStatusMessage() + "...")); + if(getRoot() != null) { + Entry entry = getRoot().getValue(); + if(entry != null && event.getWallet() != null && entry.getWallet() == event.getWallet()) { + Platform.runLater(() -> { + if(event.getErrorMessage() != null) { + setPlaceholder(new Label("Error loading transactions: " + event.getErrorMessage())); + } else if(event.isLoading()) { + if(event.getStatusMessage() != null) { + setPlaceholder(new Label(event.getStatusMessage() + "...")); + } else { + setPlaceholder(new Label("Loading transactions...")); + } } else { - setPlaceholder(new Label("Loading transactions...")); + setPlaceholder(new Label("No transactions")); } - } else { - setPlaceholder(new Label("No transactions")); - } - }); + }); + } } } } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java index 01d66e89..a01f41a5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileKeystoreImportPane.java @@ -14,7 +14,7 @@ public class FileKeystoreImportPane extends FileImportPane { private final 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.importer = importer; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java index 4be440fc..8fb3b055 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java @@ -12,7 +12,7 @@ public class FileWalletImportPane extends FileImportPane { private final 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; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java index 799eafd9..642c4194 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletKeystoreImportPane.java @@ -36,7 +36,7 @@ public class FileWalletKeystoreImportPane extends FileImportPane { private byte[] fileBytes; 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; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java index e67ec4dc..e4a69d75 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java @@ -35,6 +35,10 @@ import org.controlsfx.tools.Borders; import org.slf4j.Logger; 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.regex.Matcher; import java.util.regex.Pattern; @@ -257,7 +261,16 @@ public class QRScanDialog extends Dialog { //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)) { CryptoPSBT cryptoPSBT = (CryptoPSBT)ur.decodeFromRegistry(); try { diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java index 4ee9bfa0..81b50734 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultMultisig.java @@ -29,7 +29,7 @@ public class CoboVaultMultisig extends ColdcardMultisig { @Override 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 @@ -54,7 +54,12 @@ public class CoboVaultMultisig extends ColdcardMultisig { } @Override - public boolean isScannable() { + public boolean isWalletImportScannable() { + return true; + } + + @Override + public boolean isKeystoreImportScannable() { return true; } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java index 2f607573..0c229b9d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java @@ -20,7 +20,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { @Override 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 @@ -87,7 +87,12 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { } @Override - public boolean isScannable() { + public boolean isWalletImportScannable() { + return true; + } + + @Override + public boolean isKeystoreImportScannable() { return true; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index 3c3ed108..f7d31e9f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -211,7 +211,12 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle } @Override - public boolean isScannable() { + public boolean isWalletImportScannable() { + return false; + } + + @Override + public boolean isKeystoreImportScannable() { return false; } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index fd2fcdce..a308e3b2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -38,7 +38,12 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { } @Override - public boolean isScannable() { + public boolean isWalletImportScannable() { + return false; + } + + @Override + public boolean isKeystoreImportScannable() { return false; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java index 4b5f92b2..795ebb70 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java @@ -323,7 +323,12 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport } @Override - public boolean isScannable() { + public boolean isWalletImportScannable() { + return false; + } + + @Override + public boolean isKeystoreImportScannable() { return false; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/FileImport.java b/src/main/java/com/sparrowwallet/sparrow/io/FileImport.java index 1cf3bc8c..ef2a6114 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/FileImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/FileImport.java @@ -4,5 +4,4 @@ import java.io.File; public interface FileImport extends Import { boolean isEncrypted(File file); - boolean isScannable(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java index 6d7db71e..aff61c42 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreFileImport.java @@ -3,9 +3,9 @@ package com.sparrowwallet.sparrow.io; import com.sparrowwallet.drongo.protocol.ScriptType; import com.sparrowwallet.drongo.wallet.Keystore; -import java.io.File; import java.io.InputStream; public interface KeystoreFileImport extends KeystoreImport, FileImport { Keystore getKeystore(ScriptType scriptType, InputStream inputStream, String password) throws ImportException; + boolean isKeystoreImportScannable(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Specter.java b/src/main/java/com/sparrowwallet/sparrow/io/Specter.java index 7afe04b2..0ea9b83f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Specter.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Specter.java @@ -79,7 +79,7 @@ public class Specter implements WalletImport, WalletExport { } @Override - public boolean isScannable() { + public boolean isWalletImportScannable() { return true; } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java b/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java index bb516927..8d74aabe 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/WalletImport.java @@ -2,10 +2,10 @@ package com.sparrowwallet.sparrow.io; import com.sparrowwallet.drongo.wallet.Wallet; -import java.io.File; import java.io.InputStream; public interface WalletImport extends Import, FileImport { String getWalletImportDescription(); Wallet importWallet(InputStream inputStream, String password) throws ImportException; + boolean isWalletImportScannable(); }