Skip to content

Commit 922fb6d

Browse files
authored
add preference to clear sensitive data after days (#1859)
1 parent ca1dde0 commit 922fb6d

24 files changed

+132
-18
lines changed

core/src/main/java/haveno/core/api/CoreTradesService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ void closeTrade(String tradeId) {
189189
verifyTradeIsNotClosed(tradeId);
190190
var trade = getOpenTrade(tradeId).orElseThrow(() ->
191191
new IllegalArgumentException(format("trade with id '%s' not found", tradeId)));
192-
log.info("Keeping funds received from trade {}", tradeId);
193192
tradeManager.onTradeCompleted(trade);
194193
}
195194

core/src/main/java/haveno/core/support/dispute/Dispute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public void maybeClearSensitiveData() {
392392
change += "chat messages;";
393393
}
394394
if (change.length() > 0) {
395-
log.info("cleared sensitive data from {} of dispute for trade {}", change, Utilities.getShortId(getTradeId()));
395+
log.info("Cleared sensitive data from {} of dispute for trade {}", change, Utilities.getShortId(getTradeId()));
396396
}
397397
}
398398

core/src/main/java/haveno/core/trade/Contract.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,12 @@ public boolean isMyRoleMaker(PubKeyRing myPubKeyRing) {
261261
}
262262

263263
public boolean maybeClearSensitiveData() {
264-
return false; // TODO: anything to clear?
264+
return false; // nothing to clear
265265
}
266266

267267
// edits a contract json string
268268
public static String sanitizeContractAsJson(String contractAsJson) {
269-
return contractAsJson
270-
.replaceAll(
271-
"\"takerPaymentAccountPayload\": \\{[^}]*}",
272-
"\"takerPaymentAccountPayload\": null")
273-
.replaceAll(
274-
"\"makerPaymentAccountPayload\": \\{[^}]*}",
275-
"\"makerPaymentAccountPayload\": null");
269+
return contractAsJson; // nothing to sanitize because the contract does not contain the payment account payloads
276270
}
277271

278272
public void printDiff(@Nullable String peersContractAsJson) {

core/src/main/java/haveno/core/trade/Trade.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,11 +1586,24 @@ private void clearProcessData() {
15861586

15871587
public void maybeClearSensitiveData() {
15881588
String change = "";
1589+
if (contract != null && contract.maybeClearSensitiveData()) {
1590+
change += "contract;";
1591+
}
1592+
if (processModel != null && processModel.maybeClearSensitiveData()) {
1593+
change += "processModel;";
1594+
}
1595+
if (contractAsJson != null) {
1596+
String edited = Contract.sanitizeContractAsJson(contractAsJson);
1597+
if (!edited.equals(contractAsJson)) {
1598+
contractAsJson = edited;
1599+
change += "contractAsJson;";
1600+
}
1601+
}
15891602
if (removeAllChatMessages()) {
15901603
change += "chat messages;";
15911604
}
15921605
if (change.length() > 0) {
1593-
log.info("cleared sensitive data from {} of trade {}", change, getShortId());
1606+
log.info("Cleared sensitive data from {} of {} {}", change, getClass().getSimpleName(), getShortId());
15941607
}
15951608
}
15961609

core/src/main/java/haveno/core/trade/protocol/ProcessModel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,17 @@ void witnessDebugLog(Trade trade) {
326326
getAccountAgeWitnessService().getAccountAgeWitnessUtils().witnessDebugLog(trade, null);
327327
}
328328

329+
public boolean maybeClearSensitiveData() {
330+
boolean changed = false;
331+
for (TradePeer tradingPeer : getTradePeers()) {
332+
if (tradingPeer.getPaymentAccountPayload() != null || tradingPeer.getContractAsJson() != null) {
333+
tradingPeer.setPaymentAccountPayload(null);
334+
tradingPeer.setContractAsJson(null);
335+
changed = true;
336+
}
337+
}
338+
return changed;
339+
}
329340

330341
///////////////////////////////////////////////////////////////////////////////////////////
331342
// Delegates

core/src/main/java/haveno/core/user/Preferences.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public boolean isUseTorForXmr() {
109109
));
110110

111111
public static final boolean USE_SYMMETRIC_SECURITY_DEPOSIT = true;
112-
public static final int CLEAR_DATA_AFTER_DAYS_INITIAL = 99999; // feature effectively disabled until user agrees to settings notification
113-
public static final int CLEAR_DATA_AFTER_DAYS_DEFAULT = 60; // used when user has agreed to settings notification
112+
public static final int CLEAR_DATA_AFTER_DAYS_DEFAULT = 60; // used with new instance or when existing user has agreed to settings notification
113+
public static final int CLEAR_DATA_AFTER_DAYS_DISABLED = 99999; // feature effectively disabled until existing user agrees to settings notification
114114

115115

116116
// payload is initialized so the default values are available for Property initialization.
@@ -309,6 +309,10 @@ private void setupPreferences() {
309309
setIgnoreDustThreshold(600);
310310
}
311311

312+
if (prefPayload.getClearDataAfterDays() < 1) {
313+
setClearDataAfterDays(Preferences.CLEAR_DATA_AFTER_DAYS_DISABLED);
314+
}
315+
312316
// For users from old versions the 4 flags a false but we want to have it true by default
313317
// PhoneKeyAndToken is also null so we can use that to enable the flags
314318
if (prefPayload.getPhoneKeyAndToken() == null) {

core/src/main/java/haveno/core/user/PreferencesPayload.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public final class PreferencesPayload implements PersistableEnvelope {
122122
private String takeOfferSelectedPaymentAccountId;
123123
private double securityDepositAsPercent = getDefaultSecurityDepositAsPercent();
124124
private int ignoreDustThreshold = 600;
125-
private int clearDataAfterDays = Preferences.CLEAR_DATA_AFTER_DAYS_INITIAL;
125+
private int clearDataAfterDays = Preferences.CLEAR_DATA_AFTER_DAYS_DEFAULT;
126126
private double securityDepositAsPercentForCrypto = getDefaultSecurityDepositAsPercent();
127127
private int blockNotifyPort;
128128
private boolean tacAcceptedV120;

core/src/main/resources/i18n/displayStrings.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,7 @@ setting.preferences.notifyOnPreRelease=Receive pre-release notifications
13371337
setting.preferences.resetAllFlags=Reset all \"Don't show again\" flags
13381338
settings.preferences.languageChange=To apply the language change to all screens requires a restart.
13391339
settings.preferences.supportLanguageWarning=In case of a dispute, please note that arbitration is handled in {0}.
1340+
setting.preferences.clearDataAfterDays=Clear sensitive data after (days)
13401341
settings.preferences.editCustomExplorer.headline=Explorer Settings
13411342
settings.preferences.editCustomExplorer.description=Choose a system defined explorer from the list on the left, and/or \
13421343
customize to suit your own preferences.
@@ -1346,6 +1347,15 @@ settings.preferences.editCustomExplorer.name=Name
13461347
settings.preferences.editCustomExplorer.txUrl=Transaction URL
13471348
settings.preferences.editCustomExplorer.addressUrl=Address URL
13481349

1350+
setting.info.headline=New data-privacy feature
1351+
settings.preferences.sensitiveDataRemoval.msg=To protect the privacy of yourself and other traders, Haveno intends to \
1352+
remove sensitive data from old trades. This is particularly important for fiat trades which may include bank \
1353+
account details.\n\n\
1354+
The threshold for data removal can be configured on this screen via the field "Clear sensitive data after (days)". \
1355+
It is recommended to set it as low as possible, for example 60 days. That means trades from more than 60 \
1356+
days ago will have sensitive data cleared, as long as they are completed. Completed trades are found in the \
1357+
Portfolio / History tab.
1358+
13491359
settings.net.xmrHeader=Monero network
13501360
settings.net.p2pHeader=Haveno network
13511361
settings.net.onionAddressLabel=My onion address

core/src/main/resources/i18n/displayStrings_cs.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,9 @@ settings.preferences.editCustomExplorer.name=Jméno
13091309
settings.preferences.editCustomExplorer.txUrl=Transakční URL
13101310
settings.preferences.editCustomExplorer.addressUrl=Adresa URL
13111311

1312+
setting.info.headline=Nová funkce ochrany osobních údajů
1313+
settings.preferences.sensitiveDataRemoval.msg=Aby byla chráněna vaše soukromí i soukromí ostatních obchodníků, Haveno zamýšlí odstranit citlivá data ze starých obchodů.\n\nDoporučuje se nastavit tento limit co nejníže, například na 60 dní. To znamená, že obchody starší než 60 dní budou mít citlivá data odstraněna, pokud jsou dokončené. Dokončené obchody najdete na záložce Portfolio / Historie.
1314+
13121315
settings.net.xmrHeader=Síť Monero
13131316
settings.net.p2pHeader=Síť Haveno
13141317
settings.net.onionAddressLabel=Moje onion adresa

core/src/main/resources/i18n/displayStrings_de.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,9 @@ settings.preferences.editCustomExplorer.name=Name
10441044
settings.preferences.editCustomExplorer.txUrl=Transaktions-URL
10451045
settings.preferences.editCustomExplorer.addressUrl=Adress-URL
10461046

1047+
setting.info.headline=Neue Datenschutzfunktion
1048+
settings.preferences.sensitiveDataRemoval.msg=Zum Schutz der Privatsphäre von Ihnen und anderen Händlern beabsichtigt Haveno, sensible Daten aus alten Trades zu entfernen. Dies ist besonders wichtig bei Fiat-Trades, die Bankkontodaten enthalten können.\n\nEs wird empfohlen, den Wert so niedrig wie möglich zu setzen, zum Beispiel 60 Tage. Das bedeutet, dass Trades, die älter als 60 Tage sind, sensible Daten gelöscht bekommen, sofern sie abgeschlossen sind. Abgeschlossene Trades finden Sie im Portfolio- / Verlauf-Reiter.
1049+
10471050
settings.net.xmrHeader=Monero-Netzwerk
10481051
settings.net.p2pHeader=Haveno-Netzwerk
10491052
settings.net.onionAddressLabel=Meine Onion-Adresse

0 commit comments

Comments
 (0)