From cda4e30e3f346a1520927742d972871f30895b7a Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 7 Aug 2020 17:31:40 +0200 Subject: [PATCH] auto open recent wallets --- .../com/sparrowwallet/sparrow/AppController.java | 13 +++++++++++-- .../java/com/sparrowwallet/sparrow/io/Config.java | 11 +++++++++++ .../sparrow/wallet/SendController.java | 2 -- .../resources/com/sparrowwallet/sparrow/app.fxml | 2 +- .../com/sparrowwallet/sparrow/wallet/receive.fxml | 2 +- .../com/sparrowwallet/sparrow/wallet/send.fxml | 8 ++++---- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index b05646dc..ce34e0d8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -252,8 +252,14 @@ public class AppController implements Initializable { openTransactionIdItem.disableProperty().bind(onlineProperty.not()); - openWalletFile(new File("/Users/scy/.sparrow/wallets/sparta.json")); - openWalletFile(new File("/Users/scy/.sparrow/wallets/sparta-test.json")); + List recentWalletFiles = Config.get().getRecentWalletFiles(); + if(recentWalletFiles != null) { + for(File walletFile : recentWalletFiles) { + if(walletFile.exists()) { + openWalletFile(walletFile); + } + } + } } private ElectrumServer.ConnectionService createConnectionService() { @@ -1085,6 +1091,9 @@ public class AppController implements Initializable { @Subscribe public void openWallets(OpenWalletsEvent event) { + List walletFiles = event.getWalletsMap().values().stream().map(storage -> storage.getWalletFile()).collect(Collectors.toList()); + Config.get().setRecentWalletFiles(walletFiles); + boolean usbWallet = false; for(Map.Entry entry : event.getWalletsMap().entrySet()) { Wallet wallet = entry.getKey(); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index 0196e2db..e837b7d2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; import java.io.*; import java.lang.reflect.Type; import java.util.Currency; +import java.util.List; public class Config { private static final Logger log = LoggerFactory.getLogger(Config.class); @@ -22,6 +23,7 @@ public class Config { private boolean groupByAddress = true; private boolean includeMempoolChange = true; private boolean notifyNewTransactions = true; + private List recentWalletFiles; private Integer keyDerivationPeriod; private File hwi; private String electrumServer; @@ -133,6 +135,15 @@ public class Config { flush(); } + public List getRecentWalletFiles() { + return recentWalletFiles; + } + + public void setRecentWalletFiles(List recentWalletFiles) { + this.recentWalletFiles = recentWalletFiles; + flush(); + } + public Integer getKeyDerivationPeriod() { return keyDerivationPeriod; } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 24fa83f8..23b6b044 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -272,8 +272,6 @@ public class SendController extends WalletFormController implements Initializabl createButton.setDisable(walletTransaction == null || label.getText().isEmpty()); }); - address.setText("19Sp9dLinHy3dKo2Xxj53ouuZWAoVGGhg8"); - addValidation(); } diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml index 6495d9ca..de2902a4 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml @@ -22,7 +22,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/receive.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/receive.fxml index 54d24bc6..000c427f 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/receive.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/receive.fxml @@ -27,7 +27,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml index fb8edfdc..26442b4e 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml @@ -29,15 +29,15 @@ - - - + + +
-
+