diff --git a/drongo b/drongo index 66d4e11b..2e1012da 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 66d4e11bf6f05da79d67c955b9b1cb37095360f4 +Subproject commit 2e1012da8b1135ba1569a6bc4c8b2fc856af17c8 diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 2eea39d7..15582133 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -529,6 +529,8 @@ public class AppController implements Initializable { FXMLLoader walletLoader = new FXMLLoader(getClass().getResource("wallet/wallet.fxml")); tab.setContent(walletLoader.load()); WalletController controller = walletLoader.getController(); + + //Note that only one WalletForm is created per wallet tab, and registered to listen for events. All wallet controllers (except SettingsController) share this instance. WalletForm walletForm = new WalletForm(storage, wallet); EventManager.get().register(walletForm); controller.setWalletForm(walletForm); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java index d3270228..c4c68830 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java @@ -141,7 +141,9 @@ public class ElectrumServer { WalletNode purposeNode = wallet.getNode(keyPurpose); getHistory(wallet, purposeNode.getChildren(), nodeTransactionMap, 0); + //Because node children are added sequentially in WalletNode.fillToIndex, we can simply look at the number of children to determine the highest filled index int historySize = purposeNode.getChildren().size(); + //The gap limit size takes the highest used index in the retrieved history and adds the gap limit (plus one to be comparable to the number of children since index is zero based) int gapLimitSize = getGapLimitSize(nodeTransactionMap); while(historySize < gapLimitSize) { purposeNode.fillToIndex(gapLimitSize - 1); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java index 59d898c2..7b969800 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java @@ -7,6 +7,10 @@ import com.sparrowwallet.sparrow.io.Storage; import java.io.IOException; +/** + * This class extends WalletForm to allow rollback of wallet changes. It is used exclusively by SettingsController for this purpose. + * Note it should not be registered to listen for events - this will cause double wallet updates. + */ public class SettingsWalletForm extends WalletForm { private Wallet walletCopy;