mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-22 00:11:19 -04:00
reset internal state and popup warning if main wallet swapped
This commit is contained in:
parent
ffdbe73693
commit
bee93bf45f
6 changed files with 43 additions and 1 deletions
|
@ -97,6 +97,7 @@ import javafx.beans.property.BooleanProperty;
|
|||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.SetChangeListener;
|
||||
|
@ -139,6 +140,7 @@ public class HavenoSetup {
|
|||
private final MediationManager mediationManager;
|
||||
private final RefundManager refundManager;
|
||||
private final ArbitrationManager arbitrationManager;
|
||||
private final StringProperty topErrorMsg = new SimpleStringProperty();
|
||||
@Setter
|
||||
@Nullable
|
||||
private Consumer<Runnable> displayTacHandler;
|
||||
|
@ -717,6 +719,10 @@ public class HavenoSetup {
|
|||
return walletAppSetup.getWalletServiceErrorMsg();
|
||||
}
|
||||
|
||||
public StringProperty getTopErrorMsg() {
|
||||
return topErrorMsg;
|
||||
}
|
||||
|
||||
public StringProperty getXmrSplashSyncIconId() {
|
||||
return walletAppSetup.getXmrSplashSyncIconId();
|
||||
}
|
||||
|
|
|
@ -140,6 +140,11 @@ public final class XmrAddressEntryList implements PersistableEnvelope, Persisted
|
|||
return newAddressEntry;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
entrySet.clear();
|
||||
requestPersistence();
|
||||
}
|
||||
|
||||
public void requestPersistence() {
|
||||
persistenceManager.requestPersistence();
|
||||
}
|
||||
|
|
|
@ -1372,6 +1372,9 @@ public class XmrWalletService {
|
|||
// reapply connection after wallet synced
|
||||
onConnectionChanged(xmrConnectionService.getConnection());
|
||||
|
||||
// reset internal state if main wallet was swapped
|
||||
resetIfWalletChanged();
|
||||
|
||||
// signal that main wallet is synced
|
||||
doneDownload();
|
||||
|
||||
|
@ -1409,6 +1412,23 @@ public class XmrWalletService {
|
|||
}
|
||||
}
|
||||
|
||||
private void resetIfWalletChanged() {
|
||||
getAddressEntryListAsImmutableList(); // TODO: using getter to create base address if necessary
|
||||
List<XmrAddressEntry> baseAddresses = getAddressEntries(XmrAddressEntry.Context.BASE_ADDRESS);
|
||||
if (baseAddresses.size() > 1 || (baseAddresses.size() == 1 && !baseAddresses.get(0).getAddressString().equals(wallet.getPrimaryAddress()))) {
|
||||
String warningMsg = "New Monero wallet detected. Resetting internal state.";
|
||||
if (!tradeManager.getOpenTrades().isEmpty()) warningMsg += "\n\nWARNING: Your open trades will settle to the payout address in the OLD wallet!"; // TODO: allow payout address to be updated in PaymentSentMessage, PaymentReceivedMessage, and DisputeOpenedMessage?
|
||||
HavenoUtils.havenoSetup.getTopErrorMsg().set(warningMsg);
|
||||
|
||||
// reset address entries
|
||||
xmrAddressEntryList.clear();
|
||||
getAddressEntryListAsImmutableList(); // recreate base address
|
||||
|
||||
// cancel offers
|
||||
tradeManager.getOpenOfferManager().removeAllOpenOffers(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncWithProgress() {
|
||||
|
||||
// show sync progress
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue