From 4d6609990c162d927bf45ae7930cf5569169e468 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 22 Jun 2021 10:13:37 +0200 Subject: [PATCH] fix error messages on subclassed importers/exporters --- .../sparrowwallet/sparrow/io/CoboVaultSinglesig.java | 6 +++--- .../sparrowwallet/sparrow/io/ColdcardMultisig.java | 8 ++++---- .../sparrowwallet/sparrow/io/ColdcardSinglesig.java | 4 ++-- .../sparrowwallet/sparrow/io/KeystoneSinglesig.java | 10 +++++----- .../java/com/sparrowwallet/sparrow/io/Sparrow.java | 2 +- .../com/sparrowwallet/sparrow/io/SpecterDIY.java | 8 ++++---- .../com/sparrowwallet/sparrow/io/SpecterDesktop.java | 12 ++++++------ .../sparrow/wallet/TransactionsController.java | 7 +++++-- 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java index 3862cf2b..5134d04f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java @@ -57,8 +57,8 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { return keystore; } catch (Exception e) { - log.error("Error getting Cobo Vault keystore", e); - throw new ImportException("Error getting Cobo Vault keystore", e); + log.error("Error getting " + getName() + " keystore", e); + throw new ImportException("Error getting " + getName() + " keystore", e); } } @@ -81,7 +81,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { try { wallet.checkWallet(); } catch(InvalidWalletException e) { - throw new ImportException("Imported Cobo Vault wallet was invalid: " + e.getMessage()); + throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage()); } return wallet; diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index 885d7824..e02ab58c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -150,8 +150,8 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle return wallet; } catch(Exception e) { - log.error("Error importing Coldcard multisig wallet", e); - throw new ImportException("Error importing Coldcard multisig wallet", e); + log.error("Error importing " + getName() + " wallet", e); + throw new ImportException("Error importing " + getName() + " wallet", e); } } @@ -203,8 +203,8 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle writer.flush(); } catch(Exception e) { - log.error("Error exporting Coldcard multisig wallet", e); - throw new ExportException("Error exporting Coldcard multisig wallet", e); + log.error("Error exporting " + getName() + " wallet", e); + throw new ExportException("Error exporting " + getName() + " wallet", e); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index 52aa34fd..b614a440 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -86,8 +86,8 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { } } } catch (Exception e) { - log.error("Error getting Coldcard keystore", e); - throw new ImportException("Error getting Coldcard keystore", e); + log.error("Error getting " + getName() + " keystore", e); + throw new ImportException("Error getting " + getName() + " keystore", e); } throw new ImportException("Correct derivation not found for script type: " + scriptType); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java index df877a04..88a8eced 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java @@ -62,11 +62,11 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport { return keystore; } catch (IllegalArgumentException e) { - log.error("Error getting Keystone keystore - not an output descriptor"); - throw new ImportException("Error getting Keystone keystore", e); + log.error("Error getting " + getName() + " keystore - not an output descriptor"); + throw new ImportException("Error getting " + getName() + " keystore", e); } catch (Exception e) { - log.error("Error getting Keystone keystore", e); - throw new ImportException("Error getting Keystone keystore", e); + log.error("Error getting " + getName() + " keystore", e); + throw new ImportException("Error getting " + getName() + " keystore", e); } } @@ -89,7 +89,7 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport { try { wallet.checkWallet(); } catch(InvalidWalletException e) { - throw new ImportException("Imported Keystone wallet was invalid: " + e.getMessage()); + throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage()); } return wallet; diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Sparrow.java b/src/main/java/com/sparrowwallet/sparrow/io/Sparrow.java index aeea0641..fd884876 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Sparrow.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Sparrow.java @@ -46,7 +46,7 @@ public class Sparrow implements WalletImport, WalletExport { @Override public String getWalletExportDescription() { - return "Exports your Sparrow wallet file, which can be imported into another Sparrow instance running on any supported platform."; + return "Exports your Sparrow wallet file, which can be imported into another Sparrow instance running on any supported platform. If the wallet is encrypted, the same password is used to encrypt the exported file."; } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java b/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java index 7df6f828..33f92c6e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/SpecterDIY.java @@ -35,8 +35,8 @@ public class SpecterDIY implements KeystoreFileImport, WalletExport { return keystore; } catch(IOException e) { - log.error("Error getting Specter DIY keystore", e); - throw new ImportException("Error getting Specter DIY keystore", e); + log.error("Error getting " + getName() + " keystore", e); + throw new ImportException("Error getting " + getName() + " keystore", e); } } @@ -72,8 +72,8 @@ public class SpecterDIY implements KeystoreFileImport, WalletExport { writer.append("addwallet ").append(wallet.getName()).append("&").append(OutputDescriptor.getOutputDescriptor(wallet).toString().replace('\'', 'h')).append("\n"); writer.flush(); } catch(Exception e) { - log.error("Error exporting Specter DIY wallet", e); - throw new ExportException("Error exporting Specter DIY wallet", e); + log.error("Error exporting " + getName() + " wallet", e); + throw new ExportException("Error exporting " + getName() + " wallet", e); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/SpecterDesktop.java b/src/main/java/com/sparrowwallet/sparrow/io/SpecterDesktop.java index b2c15a86..e6989eac 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/SpecterDesktop.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/SpecterDesktop.java @@ -30,8 +30,8 @@ public class SpecterDesktop implements WalletImport, WalletExport { outputStream.write(json.getBytes(StandardCharsets.UTF_8)); outputStream.flush(); } catch(Exception e) { - log.error("Error exporting Specter Desktop wallet", e); - throw new ExportException("Error exporting Specter Desktop wallet", e); + log.error("Error exporting " + getName() + " wallet", e); + throw new ExportException("Error exporting " + getName() + " wallet", e); } } @@ -87,17 +87,17 @@ public class SpecterDesktop implements WalletImport, WalletExport { try { wallet.checkWallet(); } catch(InvalidWalletException e) { - throw new ImportException("Imported Specter wallet was invalid: " + e.getMessage()); + throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage()); } return wallet; } } catch(Exception e) { - log.error("Error importing Specter Desktop wallet", e); - throw new ImportException("Error importing Specter Desktop wallet", e); + log.error("Error importing " + getName() + " wallet", e); + throw new ImportException("Error importing " + getName() + " wallet", e); } - throw new ImportException("File was not a valid Specter Desktop wallet"); + throw new ImportException("File was not a valid " + getName() + " wallet"); } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java index 2c5fd7c2..4d3df480 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java @@ -161,8 +161,11 @@ public class TransactionsController extends WalletFormController implements Init String date = LOG_DATE_FORMAT.format(new Date()); String logLine = "\n" + date + " " + logMessage; Platform.runLater(() -> { - loadingLog.appendText(logLine); - loadingLog.setScrollLeft(0); + int lastLineStart = loadingLog.getText().lastIndexOf("\n"); + if(lastLineStart < 0 || !loadingLog.getText().substring(lastLineStart).equals(logLine)) { + loadingLog.appendText(logLine); + loadingLog.setScrollLeft(0); + } }); } }