Skip to content

Commit

Permalink
Merge update to v1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
retoaccess1 authored Jun 25, 2024
2 parents 86b501e + 7acba27 commit 7bd23d1
Show file tree
Hide file tree
Showing 39 changed files with 3,743 additions and 133 deletions.
26 changes: 14 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ configure(subprojects) {
gsonVersion = '2.8.5'
guavaVersion = '32.1.1-jre'
guiceVersion = '7.0.0'
moneroJavaVersion = '0.8.29'
moneroJavaVersion = '0.8.31'
httpclient5Version = '5.0'
hamcrestVersion = '2.2'
httpclientVersion = '4.5.12'
Expand Down Expand Up @@ -452,14 +452,14 @@ configure(project(':core')) {
doLast {
// get monero binaries download url
Map moneroBinaries = [
'linux-x86_64' : 'https://github.com/haveno-dex/monero/releases/download/release2/monero-bins-haveno-linux.tar.gz',
'linux-x86_64-sha256' : '3537fe2006997a1065748d27e9513ac3e0c942ab56a97a6e43065ddfd1820394',
'linux-aarch64' : 'https://github.com/haveno-dex/monero/releases/download/release2/monero-bins-haveno-linux-aarch64.tar.gz',
'linux-aarch64-sha256' : '6ff81c61780fe08defbd6576bd93c6711cf5ad3e79be0e3bc2184ff11cc6a472',
'mac' : 'https://github.com/haveno-dex/monero/releases/download/release2/monero-bins-haveno-mac.tar.gz',
'mac-sha256' : 'c7cafe1000a5839f02d02ed2edce5b1df3a06b5c77f4d91eaba106d948347730',
'windows' : 'https://github.com/haveno-dex/monero/releases/download/release2/monero-bins-haveno-windows.zip',
'windows-sha256' : '9b900faefa75f354870646989484978d1fb11add392ffd05eb5abe7e514e395a'
'linux-x86_64' : 'https://github.com/haveno-dex/monero/releases/download/release3/monero-bins-haveno-linux-x86_64.tar.gz',
'linux-x86_64-sha256' : '591e63c1e3249e0cfbba74f0302022160f64f049d06abff95417ad3ecb588581',
'linux-aarch64' : 'https://github.com/haveno-dex/monero/releases/download/release3/monero-bins-haveno-linux-aarch64.tar.gz',
'linux-aarch64-sha256' : 'fb0a91d07dbbc30646af8007205dbd11c59fb1d124a3b2d703511d8ee2739acc',
'mac' : 'https://github.com/haveno-dex/monero/releases/download/release3/monero-bins-haveno-mac.tar.gz',
'mac-sha256' : '9eb01951976767372a3d10180c092af937afe6494928ea73e311476be5c0eba3',
'windows' : 'https://github.com/haveno-dex/monero/releases/download/release3/monero-bins-haveno-windows.zip',
'windows-sha256' : '49b84fab3a1f69564068fecff105b6079b843d99792409dffca4a66eb279288f'
]

String osKey
Expand Down Expand Up @@ -532,6 +532,7 @@ configure(project(':core')) {

ext.downloadAndVerifyDependencies = { String archiveURL, String archiveSHA256, File destinationArchiveFile ->
ext.dependencyDownloadedAndVerified = false

// if archive exists, check to see if its already up to date
if (destinationArchiveFile.exists()) {
println "Verifying existing archive ${destinationArchiveFile}"
Expand All @@ -545,14 +546,15 @@ configure(project(':core')) {
}
}

// download archives
println "Downloading ${archiveURL}"
ant.get(src: archiveURL, dest: destinationArchiveFile)
println 'Download saved to ' + destinationArchiveFile

// verify checksum
println 'Verifying checksum for downloaded binary ...'
ant.archiveHash = archiveSHA256
// use a different verifyProperty name from existing verification or it will always fail
ant.checksum(file: destinationArchiveFile, algorithm: 'SHA-256', property: '${archiveHash}', verifyProperty: 'downloadedHashMatches')
ant.checksum(file: destinationArchiveFile, algorithm: 'SHA-256', property: '${archiveHash}', verifyProperty: 'downloadedHashMatches') // use a different verifyProperty name from existing verification or it will always fail
if (ant.properties['downloadedHashMatches'] != 'true') {
ant.fail('Checksum mismatch: Downloaded archive has a different checksum than expected')
}
Expand Down Expand Up @@ -603,7 +605,7 @@ configure(project(':desktop')) {
apply plugin: 'com.github.johnrengelman.shadow'
apply from: 'package/package.gradle'

version = '1.0.7-SNAPSHOT'
version = '1.0.8-SNAPSHOT'

jar.manifest.attributes(
"Implementation-Title": project.name,
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/haveno/common/app/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class Version {
// The application versions
// We use semantic versioning with major, minor and patch
public static final String VERSION = "1.0.7";
public static final String VERSION = "1.0.8";

/**
* Holds a list of the tagged resource files for optimizing the getData requests.
Expand Down
17 changes: 10 additions & 7 deletions common/src/main/java/haveno/common/util/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
Expand All @@ -38,13 +39,14 @@ public class ZipUtils {
* @param dir The directory to create the zip from.
* @param out The stream to write to.
*/
public static void zipDirToStream(File dir, OutputStream out, int bufferSize) throws Exception {
public static void zipDirToStream(File dir, OutputStream out, int bufferSize, Collection<File> excludedFiles) throws Exception {

// Get all files in directory and subdirectories.
ArrayList<String> fileList = new ArrayList<>();
getFilesRecursive(dir, fileList);
List<File> fileList = new ArrayList<>();
getFilesRecursive(dir, fileList, excludedFiles);
try (ZipOutputStream zos = new ZipOutputStream(out)) {
for (String filePath : fileList) {
for (File file : fileList) {
String filePath = file.getAbsolutePath();
log.info("Compressing: " + filePath);

// Creates a zip entry.
Expand Down Expand Up @@ -73,14 +75,15 @@ public static void zipDirToStream(File dir, OutputStream out, int bufferSize) th
/**
* Get files list from the directory recursive to the subdirectory.
*/
public static void getFilesRecursive(File directory, List<String> fileList) {
public static void getFilesRecursive(File directory, List<File> fileList, Collection<File> excludedFiles) {
File[] files = directory.listFiles();
if (files != null && files.length > 0) {
for (File file : files) {
if (excludedFiles != null && excludedFiles.contains(file)) continue;
if (file.isFile()) {
fileList.add(file.getAbsolutePath());
fileList.add(file);
} else {
getFilesRecursive(file, fileList);
getFilesRecursive(file, fileList, excludedFiles);
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion core/src/main/java/haveno/core/api/CoreAccountService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
import haveno.common.file.FileUtil;
import haveno.common.persistence.PersistenceManager;
import haveno.common.util.ZipUtils;
import haveno.core.xmr.wallet.XmrWalletService;
import java.io.File;
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import lombok.Getter;
Expand Down Expand Up @@ -139,6 +141,7 @@ public void closeAccount() {
}
}

// TODO: share common code with BackupView to backup
public void backupAccount(int bufferSize, Consumer<InputStream> consume, Consumer<Exception> error) {
if (!accountExists()) throw new IllegalStateException("Cannot backup non existing account");

Expand All @@ -149,9 +152,16 @@ public void backupAccount(int bufferSize, Consumer<InputStream> consume, Consume
PipedInputStream in = new PipedInputStream(bufferSize); // pipe the serialized account object to stream which will be read by the consumer
PipedOutputStream out = new PipedOutputStream(in);
log.info("Zipping directory " + dataDir);

// exclude monero binaries from backup so they're reinstalled with permissions
List<File> excludedFiles = Arrays.asList(
new File(XmrWalletService.MONERO_WALLET_RPC_PATH),
new File(XmrLocalNode.MONEROD_PATH)
);

new Thread(() -> {
try {
ZipUtils.zipDirToStream(dataDir, out, bufferSize);
ZipUtils.zipDirToStream(dataDir, out, bufferSize, excludedFiles);
} catch (Exception ex) {
error.accept(ex);
}
Expand Down
46 changes: 28 additions & 18 deletions core/src/main/java/haveno/core/api/XmrConnectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ public void setAutoSwitch(boolean autoSwitch) {
connectionList.setAutoSwitch(autoSwitch);
}

public boolean isConnectionLocal() {
return isConnectionLocal(getConnection());
public boolean isConnectionLocalHost() {
return isConnectionLocalHost(getConnection());
}

public boolean isConnectionTor() {
return useTorProxy(getConnection());
public boolean isProxyApplied() {
return isProxyApplied(getConnection());
}

public long getRefreshPeriodMs() {
Expand Down Expand Up @@ -328,26 +328,26 @@ private void doneDownload() {
downloadListener.doneDownload();
}

private boolean isConnectionLocal(MoneroRpcConnection connection) {
private boolean isConnectionLocalHost(MoneroRpcConnection connection) {
return connection != null && HavenoUtils.isLocalHost(connection.getUri());
}

private long getDefaultRefreshPeriodMs() {
MoneroRpcConnection connection = getConnection();
if (connection == null) return XmrLocalNode.REFRESH_PERIOD_LOCAL_MS;
if (isConnectionLocal(connection)) {
if (isConnectionLocalHost(connection)) {
if (lastInfo != null && (lastInfo.isBusySyncing() || (lastInfo.getHeightWithoutBootstrap() != null && lastInfo.getHeightWithoutBootstrap() > 0 && lastInfo.getHeightWithoutBootstrap() < lastInfo.getHeight()))) return REFRESH_PERIOD_HTTP_MS; // refresh slower if syncing or bootstrapped
else return XmrLocalNode.REFRESH_PERIOD_LOCAL_MS; // TODO: announce faster refresh after done syncing
} else if (useTorProxy(connection)) {
} else if (isProxyApplied(connection)) {
return REFRESH_PERIOD_ONION_MS;
} else {
return REFRESH_PERIOD_HTTP_MS;
}
}

private boolean useTorProxy(MoneroRpcConnection connection) {
private boolean isProxyApplied(MoneroRpcConnection connection) {
if (connection == null) return false;
return connection.isOnion() || (preferences.getUseTorForXmr().isUseTorForXmr() && !HavenoUtils.isLocalHost(connection.getUri()));
return connection.isOnion() || (preferences.getUseTorForXmr().isUseTorForXmr() && !HavenoUtils.isPrivateIp(connection.getUri()));
}

private void initialize() {
Expand Down Expand Up @@ -475,7 +475,7 @@ public void onConnectionChanged(MoneroRpcConnection connection) {
// set connection proxies
log.info("TOR proxy URI: " + getProxyUri());
for (MoneroRpcConnection connection : connectionManager.getConnections()) {
if (useTorProxy(connection)) connection.setProxyUri(getProxyUri());
if (isProxyApplied(connection)) connection.setProxyUri(getProxyUri());
}

// restore auto switch
Expand All @@ -495,7 +495,7 @@ public void onConnectionChanged(MoneroRpcConnection connection) {
// set connection from startup argument if given
connectionManager.setAutoSwitch(false);
MoneroRpcConnection connection = new MoneroRpcConnection(config.xmrNode, config.xmrNodeUsername, config.xmrNodePassword).setPriority(1);
if (useTorProxy(connection)) connection.setProxyUri(getProxyUri());
if (isProxyApplied(connection)) connection.setProxyUri(getProxyUri());
connectionManager.setConnection(connection);

// start local node if applicable
Expand Down Expand Up @@ -530,7 +530,7 @@ private void maybeStartLocalNode() {
}

private void onConnectionChanged(MoneroRpcConnection currentConnection) {
if (isShutDownStarted) return;
if (isShutDownStarted || !accountService.isAccountOpen()) return;
if (currentConnection == null) {
log.warn("Setting daemon connection to null");
Thread.dumpStack();
Expand All @@ -557,6 +557,7 @@ private void onConnectionChanged(MoneroRpcConnection currentConnection) {

// update polling
doPollDaemon();
if (currentConnection != getConnection()) return; // polling can change connection
UserThread.runAfter(() -> updatePolling(), getRefreshPeriodMs() / 1000);

// notify listeners in parallel
Expand Down Expand Up @@ -607,13 +608,22 @@ private void doPollDaemon() {
try {
lastInfo = daemon.getInfo();
} catch (Exception e) {
try {
log.warn("Failed to fetch daemon info, trying to switch to best connection: " + e.getMessage());
switchToBestConnection();
lastInfo = daemon.getInfo();
} catch (Exception e2) {
throw e2; // caught internally

// skip handling if shutting down
if (isShutDownStarted) return;

// fallback to provided nodes if custom connection fails on startup
if (lastInfo == null && "".equals(config.xmrNode) && preferences.getMoneroNodesOption() == XmrNodes.MoneroNodesOption.CUSTOM) {
log.warn("Failed to fetch daemon info from custom node on startup, falling back to provided nodes: " + e.getMessage());
preferences.setMoneroNodesOptionOrdinal(XmrNodes.MoneroNodesOption.PROVIDED.ordinal());
initializeConnections();
return;
}

// switch to best connection
log.warn("Failed to fetch daemon info, trying to switch to best connection: " + e.getMessage());
switchToBestConnection();
lastInfo = daemon.getInfo(); // caught internally if still fails
}

// connected to daemon
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/haveno/core/app/HavenoSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private void maybeInstallDependencies() {
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.toString());
log.warn("Failed to install Monero binaries: " + e.toString());
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/haveno/core/app/WalletAppSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ void setRejectedTxErrorMessageHandler(Consumer<String> rejectedTxErrorMessageHan

private String getXmrDaemonNetworkAsString() {
String postFix;
if (xmrConnectionService.isConnectionLocal())
if (xmrConnectionService.isConnectionLocalHost())
postFix = " " + Res.get("mainView.footer.localhostMoneroNode");
else if (xmrConnectionService.isConnectionTor())
else if (xmrConnectionService.isProxyApplied())
postFix = " " + Res.get("mainView.footer.usingTor");
else
postFix = "";
Expand All @@ -279,7 +279,7 @@ else if (xmrConnectionService.isConnectionTor())

private String getXmrWalletNetworkAsString() {
String postFix;
if (xmrConnectionService.isConnectionLocal())
if (xmrConnectionService.isConnectionLocalHost())
postFix = " " + Res.get("mainView.footer.localhostMoneroNode");
else if (xmrWalletService.isProxyApplied())
postFix = " " + Res.get("mainView.footer.usingTor");
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/haveno/core/locale/LanguageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public class LanguageUtil {
"fa", // Persian
"it", // Italian
"cs", // Czech
"pl" // Polish
"pl", // Polish
"tr" // Turkish
/*
// not translated yet
"el", // Greek
"sr-Latn-RS", // Serbian [Latin] (Serbia)
"hu", // Hungarian
"ro", // Romanian
"tr" // Turkish
"iw", // Hebrew
"hi", // Hindi
"ko", // Korean
Expand Down
Loading

0 comments on commit 7bd23d1

Please sign in to comment.