From 0bbb8a4183b42d766d177e70011e3cb10c6b93bf Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 11 Jun 2023 10:33:39 -0400 Subject: [PATCH] swap address entries when app fully initialized --- .../main/java/haveno/core/app/HavenoSetup.java | 4 ++++ .../main/java/haveno/core/trade/TradeManager.java | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/haveno/core/app/HavenoSetup.java b/core/src/main/java/haveno/core/app/HavenoSetup.java index a28f52c50e..d25e4ffed9 100644 --- a/core/src/main/java/haveno/core/app/HavenoSetup.java +++ b/core/src/main/java/haveno/core/app/HavenoSetup.java @@ -779,4 +779,8 @@ public class HavenoSetup { public BooleanProperty getWalletInitialized() { return walletInitialized; } + + public AppStartupState getAppStartupState() { + return appStartupState; + } } diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 25f03f2f52..58357f70c8 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -88,7 +88,6 @@ import org.bitcoinj.core.Coin; import org.bouncycastle.crypto.params.KeyParameter; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; -import org.fxmisc.easybind.monadic.MonadicBinding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -450,13 +449,17 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi // process after all wallets initialized if (HavenoUtils.havenoSetup != null) { // null for seednode - MonadicBinding walletsInitialized = EasyBind.combine(HavenoUtils.havenoSetup.getWalletInitialized(), persistedTradesInitialized, (a, b) -> a && b); - walletsInitialized.subscribe((observable, oldValue, newValue) -> { - if (!newValue) return; - + + // TODO: this subscription fails to fire about 50% on startup + // MonadicBinding walletsInitialized = EasyBind.combine(HavenoUtils.havenoSetup.getWalletInitialized(), persistedTradesInitialized, (a, b) -> a && b); + // walletsInitialized.subscribe((observable, oldValue, newValue) -> {} + + EasyBind.subscribe(HavenoUtils.havenoSetup.getAppStartupState().applicationFullyInitializedProperty(), appInitialized -> { + if (!appInitialized) return; + // thaw unreserved outputs thawUnreservedOutputs(); - + // reset any available funded address entries xmrWalletService.getAddressEntriesForAvailableBalanceStream() .filter(addressEntry -> addressEntry.getOfferId() != null)