mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Merge pull request #5615 from jmacxx/import_account_backups
Enable lost payment accounts to be imported from backups
This commit is contained in:
commit
325c1a76f6
@ -52,6 +52,7 @@ import bisq.core.trade.txproof.AssetTxProofResult;
|
|||||||
import bisq.core.user.DontShowAgainLookup;
|
import bisq.core.user.DontShowAgainLookup;
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.user.Preferences;
|
||||||
import bisq.core.user.User;
|
import bisq.core.user.User;
|
||||||
|
import bisq.core.user.UserPayload;
|
||||||
import bisq.core.util.FormattingUtils;
|
import bisq.core.util.FormattingUtils;
|
||||||
import bisq.core.util.coin.BsqFormatter;
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
@ -270,7 +271,40 @@ public class GUIUtil {
|
|||||||
new Popup().warning(Res.get("guiUtil.accountImport.noAccountsFound", path, fileName)).show();
|
new Popup().warning(Res.get("guiUtil.accountImport.noAccountsFound", path, fileName)).show();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.error("The selected file is not the expected file for import. The expected file name is: " + fileName + ".");
|
/* =============================================================================
|
||||||
|
* TEMP CODE TO ALLOW USERS RECOVERY OF ACCOUNTS FROM BACKED-UP USER PAYLOAD.
|
||||||
|
* typical location of backed-up user payload: ~/.local/share/Bisq/btc_mainnet/db/backup/backups_UserPayload
|
||||||
|
* TODO: remove this once issue #5613 has been resolved (est. 2021-Q4)
|
||||||
|
* =============================================================================
|
||||||
|
*/
|
||||||
|
String chosenFile = Paths.get(path).getFileName().toString();
|
||||||
|
String matchingRegex = "[0-9]{13}_UserPayload";
|
||||||
|
if (chosenFile.matches(matchingRegex)) {
|
||||||
|
String directory = Paths.get(path).getParent().toString();
|
||||||
|
preferences.setDirectoryChooserPath(directory);
|
||||||
|
PersistenceManager<UserPayload> persistenceManager = new PersistenceManager<>(new File(directory), persistenceProtoResolver, corruptedStorageFileHandler);
|
||||||
|
persistenceManager.readPersisted(chosenFile, persisted -> {
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
HashSet<PaymentAccount> paymentAccounts = new HashSet<>();
|
||||||
|
persisted.getPaymentAccounts().forEach(paymentAccount -> {
|
||||||
|
String id = paymentAccount.getId();
|
||||||
|
if (user.getPaymentAccount(id) == null) {
|
||||||
|
paymentAccounts.add(paymentAccount);
|
||||||
|
msg.append(Res.get("guiUtil.accountExport.tradingAccount", id));
|
||||||
|
} else {
|
||||||
|
msg.append(Res.get("guiUtil.accountImport.noImport", id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
user.addImportedPaymentAccounts(paymentAccounts);
|
||||||
|
new Popup().feedback(Res.get("guiUtil.accountImport.imported", path, msg)).show();
|
||||||
|
},
|
||||||
|
() -> {
|
||||||
|
new Popup().warning(Res.get("guiUtil.accountImport.noAccountsFound", path, chosenFile)).show();
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.error("The selected file is not the expected file for import. The expected file name is: {} or {}", fileName, matchingRegex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user