mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
exporting fixes
This commit is contained in:
parent
7fc0e9b530
commit
6f2a0cd3c3
6 changed files with 36 additions and 15 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
@ -109,8 +109,9 @@ public class AppController implements Initializable {
|
|||
exportWallet.setDisable(true);
|
||||
showTxHex.setDisable(false);
|
||||
} else if(tabData.getType() == TabData.TabType.WALLET) {
|
||||
WalletTabData walletTabData = (WalletTabData)tabData;
|
||||
EventManager.get().post(new WalletTabSelectedEvent(selectedTab));
|
||||
exportWallet.setDisable(false);
|
||||
exportWallet.setDisable(walletTabData.getWallet() == null || !walletTabData.getWallet().isValid());
|
||||
showTxHex.setDisable(true);
|
||||
}
|
||||
}
|
||||
|
@ -511,6 +512,11 @@ public class AppController implements Initializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void walletChanged(WalletChangedEvent event) {
|
||||
exportWallet.setDisable(!event.getWallet().isValid());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void timedWorker(TimedEvent event) {
|
||||
if(event.getTimeMills() == 0) {
|
||||
|
|
|
@ -62,6 +62,21 @@ public class FileWalletExportPane extends TitledDescriptionPane {
|
|||
decryptWalletService.setOnSucceeded(workerStateEvent -> {
|
||||
EventManager.get().post(new StorageEvent(file, TimedEvent.Action.END, "Done"));
|
||||
Wallet decryptedWallet = decryptWalletService.getValue();
|
||||
exportWallet(file, decryptedWallet);
|
||||
});
|
||||
decryptWalletService.setOnFailed(workerStateEvent -> {
|
||||
EventManager.get().post(new StorageEvent(file, TimedEvent.Action.END, "Failed"));
|
||||
setError("Export Error", decryptWalletService.getException().getMessage());
|
||||
});
|
||||
EventManager.get().post(new StorageEvent(file, TimedEvent.Action.START, "Decrypting wallet..."));
|
||||
decryptWalletService.start();
|
||||
}
|
||||
} else {
|
||||
exportWallet(file, copy);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportWallet(File file, Wallet decryptedWallet) {
|
||||
try {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
exporter.exportWallet(decryptedWallet, outputStream);
|
||||
|
@ -75,14 +90,5 @@ public class FileWalletExportPane extends TitledDescriptionPane {
|
|||
} finally {
|
||||
decryptedWallet.clearPrivate();
|
||||
}
|
||||
});
|
||||
decryptWalletService.setOnFailed(workerStateEvent -> {
|
||||
EventManager.get().post(new StorageEvent(file, TimedEvent.Action.END, "Failed"));
|
||||
setError("Export Error", decryptWalletService.getException().getMessage());
|
||||
});
|
||||
EventManager.get().post(new StorageEvent(file, TimedEvent.Action.START, "Decrypting wallet..."));
|
||||
decryptWalletService.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class WalletNameDialog extends Dialog<String> {
|
|||
Platform.runLater( () -> {
|
||||
validationSupport.registerValidator(name, Validator.combine(
|
||||
Validator.createEmptyValidator("Wallet name is required"),
|
||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Wallet name is not unique", Storage.getWalletFile(newValue).exists())
|
||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Wallet name is not unique", Storage.walletExists(newValue))
|
||||
));
|
||||
validationSupport.setValidationDecorator(new StyleClassValidationDecoration());
|
||||
});
|
||||
|
|
|
@ -206,6 +206,13 @@ public class Storage {
|
|||
return "BIE1".getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static boolean walletExists(String walletName) {
|
||||
File encrypted = new File(getWalletsDir(), walletName);
|
||||
File unencrypted = new File(getWalletsDir(), walletName + ".json");
|
||||
|
||||
return (encrypted.exists() || unencrypted.exists());
|
||||
}
|
||||
|
||||
public static File getWalletFile(String walletName) {
|
||||
//TODO: Check for existing file
|
||||
return new File(getWalletsDir(), walletName);
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
<MenuItem text="Examples" onAction="#openExamples"/>
|
||||
</items>
|
||||
</Menu>
|
||||
<SeparatorMenuItem />
|
||||
<MenuItem mnemonicParsing="false" text="Import Wallet..." onAction="#importWallet"/>
|
||||
<MenuItem fx:id="exportWallet" mnemonicParsing="false" text="Export Wallet..." onAction="#exportWallet"/>
|
||||
<SeparatorMenuItem />
|
||||
<MenuItem mnemonicParsing="false" text="Close" onAction="#closeTab"/>
|
||||
</items>
|
||||
</Menu>
|
||||
|
|
Loading…
Reference in a new issue