If AutoConfirmSettings contain a retired address we reset to the default values

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2024-07-21 13:55:12 +07:00
parent b8e3296a5e
commit 2e25342530
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307
2 changed files with 12 additions and 2 deletions

View File

@ -29,8 +29,10 @@ import java.util.Optional;
import java.util.concurrent.CopyOnWriteArrayList;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
@ToString
@Slf4j
@Getter
public final class AutoConfirmSettings implements PersistablePayload {
@ -43,7 +45,7 @@ public final class AutoConfirmSettings implements PersistablePayload {
private long tradeLimit;
private List<String> serviceAddresses;
private String currencyCode;
private List<Listener> listeners = new CopyOnWriteArrayList<>();
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
@SuppressWarnings("SameParameterValue")
static Optional<AutoConfirmSettings> getDefault(List<String> serviceAddresses, String currencyCode) {

View File

@ -378,12 +378,20 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
setUsePriceNotifications(true);
}
if (prefPayload.getAutoConfirmSettingsList().isEmpty()) {
// Remove retired XMR AutoConfirm address
var doApplyDefaults = prefPayload.getAutoConfirmSettingsList().stream()
.map(autoConfirmSettings -> autoConfirmSettings.getServiceAddresses().stream()
.anyMatch(address -> address.contains("monero3bec7m26vx6si6qo7q7imlaoz45ot5m2b5z2ppgoooo6jx2rqd")))
.findAny()
.orElse(true);
if (doApplyDefaults) {
prefPayload.getAutoConfirmSettingsList().clear();
List<String> defaultXmrTxProofServices = getDefaultXmrTxProofServices();
AutoConfirmSettings.getDefault(defaultXmrTxProofServices, "XMR")
.ifPresent(xmrAutoConfirmSettings -> {
getAutoConfirmSettingsList().add(xmrAutoConfirmSettings);
});
persistenceManager.forcePersistNow();
}
// We set the capability in CoreNetworkCapabilities if the program argument is set.