diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java
index e3cc73e9..9f176df1 100644
--- a/src/main/java/com/sparrowwallet/sparrow/AppController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -33,6 +33,7 @@ import com.sparrowwallet.sparrow.wallet.WalletForm;
import de.codecentric.centerdevice.MenuToolkit;
import javafx.animation.*;
import javafx.application.Platform;
+import javafx.beans.binding.Bindings;
import javafx.collections.ListChangeListener;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@@ -99,6 +100,9 @@ public class AppController implements Initializable {
@FXML
private CheckMenuItem showTxHex;
+ @FXML
+ private MenuItem refreshWallet;
+
@FXML
private StackPane rootStack;
@@ -223,6 +227,7 @@ public class AppController implements Initializable {
hideEmptyUsedAddresses.setSelected(Config.get().isHideEmptyUsedAddresses());
showTxHex.setSelected(Config.get().isShowTransactionHex());
exportWallet.setDisable(true);
+ refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not())));
setServerType(Config.get().getServerType());
serverToggle.setSelected(isConnected());
@@ -828,6 +833,18 @@ public class AppController implements Initializable {
messageSignDialog.showAndWait();
}
+ public void refreshWallet(ActionEvent event) {
+ Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
+ TabData tabData = (TabData)selectedTab.getUserData();
+ if(tabData.getType() == TabData.TabType.WALLET) {
+ WalletTabData walletTabData = (WalletTabData) tabData;
+ Wallet wallet = walletTabData.getWallet();
+ Wallet pastWallet = wallet.copy();
+ wallet.clearHistory();
+ EventManager.get().post(new WalletSettingsChangedEvent(wallet, pastWallet, walletTabData.getStorage().getWalletFile()));
+ }
+ }
+
public void addWalletTabOrWindow(Storage storage, Wallet wallet, boolean forceSameWindow) {
Window existingWalletWindow = AppServices.get().getWindowForWallet(storage);
if(existingWalletWindow instanceof Stage) {
diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java
index 6827da0d..cd41af46 100644
--- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java
+++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java
@@ -10,8 +10,10 @@ import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.WalletTabData;
import com.sparrowwallet.sparrow.event.*;
+import com.sparrowwallet.sparrow.io.Config;
import com.sparrowwallet.sparrow.net.ElectrumServer;
import com.sparrowwallet.sparrow.io.Storage;
+import com.sparrowwallet.sparrow.net.ServerType;
import javafx.application.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -25,6 +27,7 @@ public class WalletForm {
private final Storage storage;
protected Wallet wallet;
+ private Wallet savedPastWallet;
private WalletTransactionsEntry walletTransactionsEntry;
private WalletUtxosEntry walletUtxosEntry;
@@ -245,6 +248,13 @@ public class WalletForm {
walletUtxosEntry = null;
accountEntries.clear();
EventManager.get().post(new WalletNodesChangedEvent(wallet));
+
+ //It is necessary to save the past wallet because the actual copying of the past labels only occurs on a later ConnectionEvent with bwt
+ //The savedPastWallet variable can be removed once bwt supports dynamic loading of wallets without needing to disconnect/reconnect
+ if(Config.get().getServerType() == ServerType.BITCOIN_CORE) {
+ savedPastWallet = event.getPastWallet();
+ }
+
refreshHistory(AppServices.getCurrentBlockHeight(), event.getPastWallet());
}
}
@@ -259,7 +269,8 @@ public class WalletForm {
@Subscribe
public void connected(ConnectionEvent event) {
- refreshHistory(event.getBlockHeight(), null);
+ refreshHistory(event.getBlockHeight(), savedPastWallet);
+ savedPastWallet = null;
}
@Subscribe
diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml
index 9eaec982..6d211e83 100644
--- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml
+++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml
@@ -22,7 +22,7 @@
-
+
@@ -82,6 +82,8 @@