Skip to content

Commit

Permalink
Merge pull request #230 from ApolloFoundation/dev
Browse files Browse the repository at this point in the history
1.21.6
  • Loading branch information
0486 authored Nov 7, 2018
2 parents eab8a4a + 4e1908c commit 3b56c6d
Show file tree
Hide file tree
Showing 44 changed files with 720 additions and 253 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.0
1.21.6
2 changes: 1 addition & 1 deletion conf/apl-default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,5 @@ apl.disableSecurityPolicy=false
# Enable update feature for automatic installing updates to avoid forks and keep software up-to-date
apl.allowUpdates=true
# NRS version.
apl.version=1.21.0
apl.version=1.21.6

2 changes: 1 addition & 1 deletion html/www/html/pages/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ <h1>
</div>
<div class="block_info_dashboard_tile col-lg-3 col-xs-6">
<div class="white-box light-font whitebox-sections">
<h3 classlong-data="box-title">
<h3 class="long-data box-title">
<a href="#" class="small-box-footer goto-page" data-page="blocks">LAST UPDATED</a>
</h3>
<div class="text-right"> <span>BLOCK: <span class="nrs_current_block loading_dots"><span>.</span><span>.</span><span>.</span></span></span>
Expand Down
2 changes: 1 addition & 1 deletion html/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<!-- Pages moved to own files in html/pages/ -->
</aside>
<footer class="footer text-center">
<br>Copyright © 2017-2018 Apollo Foundation. Apollo Version: <a href="" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">1.21.0</a></br>
<br>Copyright © 2017-2018 Apollo Foundation. Apollo Version: <a href="" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">1.21.6</a></br>
<br>Copyright © 2016-2017 Jelurida IP B.V.</br>
<br>Copyright © 2013-2016 The Nxt Core Developers.</br>
</footer>
Expand Down
2 changes: 1 addition & 1 deletion html/www/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apl-blockchain",
"version": "1.21.0",
"version": "1.21.6",
"description": "Client API library for the APL Blockchain",
"main": "nrs.node.bridge.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.apollocurrency</groupId>
<artifactId>apollo-wallet</artifactId>
<version>1.21.0</version>
<version>1.21.6</version>
<packaging>jar</packaging>
<name>Apollo wallet</name>

Expand Down
2 changes: 1 addition & 1 deletion run-secure-transport.bat
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rem @echo off
cd secureTransport
start runClient.bat
cd ..
"%javaDir%"\bin\java.exe -jar -DsocksProxyHost=10.0.0.1 -DsocksProxyPort=1088 -Dapl.runtime.mode=desktop Apollo.jar
"%javaDir%"\bin\java.exe -jar -DsocksProxyHost=10.75.110.1 -DsocksProxyPort=1088 -Dapl.runtime.mode=desktop -Dapl.enablePeerUPnP=false Apollo.jar

:endProcess
endlocal
26 changes: 26 additions & 0 deletions run-secure-transport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# WARNING: java still bypasses the tor proxy when sending DNS queries and
# this can reveal the fact that you are running Apl, however blocks and
# transactions will be sent over tor only. Requires a tor proxy running
# at localhost:9050. Set apl.shareMyAddress=false when using tor.

if [ -x jre/bin/java ]; then
JAVA=./jre/bin/java
else
JAVA=java
fi

unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then

cd secureTransport
sudo ./runClient.sh
cd ..
fi



${JAVA} -DsocksProxyHost=10.75.110.1 -DsocksProxyPort=1088 -Dapl.runtime.mode=desktop -Dapl.enablePeerUPnP=false -jar Apollo.jar


12 changes: 10 additions & 2 deletions run-tor.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# WARNING: java still bypasses the tor proxy when sending DNS queries and
# this can reveal the fact that you are running Apl, however blocks and
Expand All @@ -10,5 +10,13 @@ if [ -x jre/bin/java ]; then
else
JAVA=java
fi
${JAVA} -DsocksProxyHost=localhost -DsocksProxyPort=9050 -cp target/classes:target/lib/*:conf:addons/classes:addons/lib/* com.apollocurrency.aplwallet.apl.Apl

if [[ "$unamestr" == 'Linux' ]]; then
cd tor
./tor &
cd ..
fi

${JAVA} -DsocksProxyHost=localhost -DsocksProxyPort=9050 -Dapl.runtime.mode=desktop -jar Apollo.jar


20 changes: 16 additions & 4 deletions src/main/java/com/apollocurrency/aplwallet/apl/Apl.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package com.apollocurrency.aplwallet.apl;


import com.apollocurrency.aplwallet.apl.dbmodel.Option;
import static com.apollocurrency.aplwallet.apl.Constants.DEFAULT_PEER_PORT;
import static com.apollocurrency.aplwallet.apl.Constants.TESTNET_API_SSLPORT;
import static com.apollocurrency.aplwallet.apl.Constants.TESTNET_PEER_PORT;
Expand Down Expand Up @@ -66,7 +68,7 @@
public final class Apl {
private static Logger LOG;

public static final Version VERSION = Version.from("1.21.0");
public static final Version VERSION = Version.from("1.21.6");
public static final String APPLICATION = "Apollo";
private static Thread shutdownHook;
private static volatile Time time = new Time.EpochTime();
Expand Down Expand Up @@ -455,7 +457,7 @@ private static class Init {
LOG.info("Copyright © 2013-2016 The NXT Core Developers.");
LOG.info("Copyright © 2016-2017 Jelurida IP B.V..");
LOG.info("Copyright © 2017-2018 Apollo Foundation.");
LOG.info("Distributed under the Apollo Foundation Public License version 1.0 for the Apl Public Blockchain Platform, with ABSOLUTELY NO WARRANTY.");
LOG.info("See LICENSE.txt for more information");
if (API.getWelcomePageUri() != null) {
LOG.info("Client UI is at " + API.getWelcomePageUri());
}
Expand All @@ -464,9 +466,11 @@ private static class Init {
runtimeMode.updateAppStatus("Starting desktop application...");
launchDesktopApplication();
}

if (Constants.isTestnet) {
LOG.info("RUNNING ON TESTNET - DO NOT USE REAL ACCOUNTS!");
}

}
catch (final RuntimeException e) {
if (e.getMessage() == null || (!e.getMessage().contains(JdbcSQLException.class.getName()) && !e.getMessage().contains(SQLException.class.getName()))) {
Expand Down Expand Up @@ -535,6 +539,7 @@ static Set<Integer> collectWorkingPorts() {

public static boolean isTcpPortAvailable(int port) {
try (ServerSocket serverSocket = new ServerSocket(port)) {
serverSocket.setReuseAddress(true);
return true;
} catch (Exception ex) {
return false;
Expand All @@ -559,13 +564,20 @@ private static void setSystemProperties() {
String[] systemProperties = new String[] {
"socksProxyHost",
"socksProxyPort",
"apl.enablePeerUPnP"
};

for (String propertyName : systemProperties) {
String propertyValue;
if ((propertyValue = getStringProperty(propertyName)) != null) {
System.setProperty(propertyName, propertyValue);
if ((propertyValue = System.getProperty(propertyName)) != null) {
//System.setProperty(propertyName, propertyValue);
properties.setProperty(propertyName, propertyValue);
LOG.info("System property set: ", propertyName + " " + propertyValue);
}
else
{
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,16 @@ protected void update(int nextUpdate) {
+ "confirmed BOOLEAN NOT NULL DEFAULT FALSE,"
+ ")"
);

case 243:
apply("CREATE TABLE IF NOT EXISTS option (name VARCHAR(100) not null, value VARCHAR(250))");

case 244:
apply("CREATE UNIQUE INDEX option_name_value_idx ON option(name, value)");

case 245:
return;

default:
throw new RuntimeException("Blockchain database inconsistent with code, at update " + nextUpdate
+ ", probably trying to run older code on newer database");
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/com/apollocurrency/aplwallet/apl/PrunableMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

package com.apollocurrency.aplwallet.apl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.apollocurrency.aplwallet.apl.crypto.Crypto;
import com.apollocurrency.aplwallet.apl.crypto.EncryptedData;
import com.apollocurrency.aplwallet.apl.db.DbIterator;
Expand All @@ -28,11 +33,6 @@
import com.apollocurrency.aplwallet.apl.db.PrunableDbTable;
import com.apollocurrency.aplwallet.apl.util.Convert;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public final class PrunableMessage {

private static final DbKey.LongKeyFactory<PrunableMessage> prunableMessageKeyFactory = new DbKey.LongKeyFactory<PrunableMessage>("id") {
Expand Down Expand Up @@ -250,15 +250,10 @@ public int getHeight() {
}

public byte[] decrypt(String secretPhrase) {
if (encryptedData == null) {
return null;
}
byte[] publicKey = senderId == Account.getId(Crypto.getPublicKey(secretPhrase))
? Account.getPublicKey(recipientId) : Account.getPublicKey(senderId);
return Account.decryptFrom(publicKey, encryptedData, Crypto.getKeySeed(secretPhrase), isCompressed);
return decryptUsingKeySeed(Crypto.getKeySeed(secretPhrase));
}

public byte[] decrypt(byte[] sharedKey) {
public byte[] decryptUsingSharedKey(byte[] sharedKey) {
if (encryptedData == null) {
return null;
}
Expand All @@ -269,6 +264,15 @@ public byte[] decrypt(byte[] sharedKey) {
return data;
}

public byte[] decryptUsingKeySeed(byte[] keySeed) {
if (encryptedData == null) {
return null;
}
byte[] publicKey = senderId == Account.getId(Crypto.getPublicKey(keySeed))
? Account.getPublicKey(recipientId) : Account.getPublicKey(senderId);
return Account.decryptFrom(publicKey, encryptedData, keySeed, isCompressed);
}

static void add(TransactionImpl transaction, Appendix.PrunablePlainMessage appendix) {
add(transaction, appendix, Apl.getBlockchain().getLastBlockTimestamp(), Apl.getBlockchain().getHeight());
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/apollocurrency/aplwallet/apl/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@

package com.apollocurrency.aplwallet.apl;

import java.util.Arrays;

import com.apollocurrency.aplwallet.apl.crypto.Crypto;
import com.apollocurrency.aplwallet.apl.util.Convert;

import java.util.Arrays;

public final class Token {

public static String generateToken(String secretPhrase, String messageString) {
return generateToken(secretPhrase, Convert.toBytes(messageString));
public static String generateToken(byte[] keySeed, String messageString) {
return generateToken(keySeed, Convert.toBytes(messageString));
}

public static String generateToken(String secretPhrase, byte[] message) {
public static String generateToken(byte[] keySeed, byte[] message) {
byte[] data = new byte[message.length + 32 + 4];
System.arraycopy(message, 0, data, 0, message.length);
System.arraycopy(Crypto.getPublicKey(secretPhrase), 0, data, message.length, 32);
System.arraycopy(Crypto.getPublicKey(keySeed), 0, data, message.length, 32);
int timestamp = Apl.getEpochTime();
data[message.length + 32] = (byte)timestamp;
data[message.length + 32 + 1] = (byte)(timestamp >> 8);
Expand All @@ -43,7 +43,7 @@ public static String generateToken(String secretPhrase, byte[] message) {

byte[] token = new byte[100];
System.arraycopy(data, message.length, token, 0, 32 + 4);
System.arraycopy(Crypto.sign(data, secretPhrase), 0, token, 32 + 4, 64);
System.arraycopy(Crypto.sign(data, keySeed), 0, token, 32 + 4, 64);

StringBuilder buf = new StringBuilder();
for (int ptr = 0; ptr < 100; ptr += 5) {
Expand Down
96 changes: 96 additions & 0 deletions src/main/java/com/apollocurrency/aplwallet/apl/dbmodel/Option.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright © 2018 Apollo Foundation
*/

package com.apollocurrency.aplwallet.apl.dbmodel;

import com.apollocurrency.aplwallet.apl.Db;
import org.slf4j.Logger;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import static org.slf4j.LoggerFactory.getLogger;

//TODO: Refactor as ORM

public class Option {
private static final Logger LOG = getLogger(Option.class);

public static String get(String optionName)
{
try (Connection con = Db.db.getConnection())
{
PreparedStatement stmt = con.prepareStatement("SELECT * FROM option WHERE name = ?");
stmt.setString(1, optionName);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getString("value");
}
}
}
catch (SQLException e)
{
LOG.error(e.getMessage());
}
return null;
}

public static boolean set(String optionName, String optionValue)
{
if (get(optionName) == null)
{
try (Connection con = Db.db.getConnection())
{
PreparedStatement stmt = con.prepareStatement("INSERT INTO option (name, value) VALUES (?, ?)");
stmt.setString(1, optionName);
stmt.setString(2, optionValue);
stmt.execute();
}
catch (SQLException e)
{
LOG.error(e.getMessage());
}
}
else
{
try (Connection con = Db.db.getConnection())
{
PreparedStatement stmt = con.prepareStatement("UPDATE option set value = ? WHERE name = ?");
stmt.setString(1, optionValue);
stmt.setString(2, optionName);
stmt.execute();
}
catch (SQLException e)
{
LOG.error(e.getMessage());
}
}
return true;
}

public static boolean delete(String optionName)
{
if (get(optionName) == null)
{
return false;
}
else
{
try (Connection con = Db.db.getConnection()) {
PreparedStatement stmt = con.prepareStatement("DELETE FROM option WHERE name = ?");
stmt.setString(1, optionName);
}
catch (SQLException e)
{
LOG.error(e.getMessage());
return false;
}
}

return true;
}

}
Loading

0 comments on commit 3b56c6d

Please sign in to comment.