Skip to content

Commit 121fff3

Browse files
author
Bill
committed
add java tron lib
1 parent ace748c commit 121fff3

File tree

16 files changed

+71825
-23
lines changed

16 files changed

+71825
-23
lines changed

actuator/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>actuator</name>
4+
<comment>Project actuator created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

chainbase/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>chainbase</name>
4+
<comment>Project chainbase created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

chainbase/src/main/java/org/tron/core/actuator/TransactionFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class TransactionFactory {
2222
public static void register(ContractType type, Class<? extends Actuator> actuatorClass,
2323
Class<? extends GeneratedMessageV3> clazz) {
2424
Set<String> actuatorSet = CommonParameter.getInstance().getActuatorSet();
25+
2526
if (actuatorClass != null && !actuatorSet.isEmpty() && !actuatorSet
2627
.contains(actuatorClass.getSimpleName())) {
2728
return;
@@ -33,6 +34,7 @@ public static void register(ContractType type, Class<? extends Actuator> actuato
3334
if (type != null && clazz != null) {
3435
contractMap.put(type, clazz);
3536
}
37+
3638
}
3739

3840
public static Class<? extends Actuator> getActuator(ContractType type) {

chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ public Sha256Hash getMerkleHash() {
525525
}
526526

527527
private Sha256Hash getRawHash() {
528+
// System.out.println("get hash param "+CommonParameter.getInstance().isECKeyCryptoEngine());
528529
return Sha256Hash.of(CommonParameter.getInstance().isECKeyCryptoEngine(),
529530
this.transaction.getRawData().toByteArray());
530531
}

common/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>common</name>
4+
<comment>Project common created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

common/src/main/java/org/tron/common/utils/StringUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static String createReadableString(byte[] bytes) {
2929
}
3030

3131
public static String encode58Check(byte[] input) {
32+
// System.out.println("encode58Check param ="+CommonParameter.getInstance().isECKeyCryptoEngine());
3233
byte[] hash0 = Sha256Hash.hash(CommonParameter.getInstance().isECKeyCryptoEngine(), input);
3334
byte[] hash1 = Sha256Hash.hash(CommonParameter.getInstance().isECKeyCryptoEngine(), hash0);
3435
byte[] inputCheck = new byte[input.length + 4];

consensus/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>consensus</name>
4+
<comment>Project consensus created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

crypto/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>crypto</name>
4+
<comment>Project crypto created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

example/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>example</name>
4+
<comment>Project example created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

example/actuator-example/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>actuator-example</name>
4+
<comment>Project actuator-example created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

framework/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>framework</name>
4+
<comment>Project framework created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ public static Transaction packTransaction(String strTransaction, boolean selfTyp
272272
JsonFormat.merge(parameter.getJSONObject(VALUE).toJSONString(), builder, selfType);
273273
any = Any.pack(builder.build());
274274
}
275+
System.out.println(any.toString());
275276
if (any != null) {
276277
String value = ByteArray.toHexString(any.getValue().toByteArray());
277278
parameter.put(VALUE, value);
@@ -289,6 +290,8 @@ public static Transaction packTransaction(String strTransaction, boolean selfTyp
289290
Transaction.Builder transactionBuilder = Transaction.newBuilder();
290291
try {
291292
JsonFormat.merge(jsonTransaction.toJSONString(), transactionBuilder, selfType);
293+
System.out.println(jsonTransaction.toJSONString());
294+
System.out.println(transactionBuilder.toString());
292295
return transactionBuilder.build();
293296
} catch (ParseException e) {
294297
logger.debug("ParseException: {}", e.getMessage());

framework/src/main/java/org/tron/program/FullNode.java

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import ch.qos.logback.classic.LoggerContext;
44
import ch.qos.logback.classic.joran.JoranConfigurator;
55
import java.io.File;
6+
import java.math.BigInteger;
67
import lombok.extern.slf4j.Slf4j;
78
import org.slf4j.LoggerFactory;
89
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
910
import org.tron.common.application.Application;
1011
import org.tron.common.application.ApplicationFactory;
1112
import org.tron.common.application.TronApplicationContext;
13+
import org.tron.common.crypto.ECKey;
1214
import org.tron.common.parameter.CommonParameter;
15+
import org.tron.common.utils.ByteArray;
1316
import org.tron.core.Constant;
1417
import org.tron.core.config.DefaultConfig;
1518
import org.tron.core.config.args.Args;
@@ -62,6 +65,21 @@ public static void main(String[] args) {
6265
logger.info("not in debug mode, it will check energy time");
6366
}
6467

68+
System.out.println("start to test");
69+
String priKey = "a551a5a55ffb2d7225660962b193cbda57b911e2d0fcedaf29d6d7c1f1e710c4";
70+
ECKey temKey = null;
71+
try {
72+
BigInteger priK = new BigInteger(priKey, 16);
73+
temKey = ECKey.fromPrivate(priK);
74+
String message = "4c92858ca5e2100593638670c474fcc4eae2e267a58f7e4035309d9789f1b51a";
75+
System.out.println(ByteArray.fromHexString(message).length);
76+
System.out.println(temKey.sign(ByteArray.fromHexString(message)));
77+
} catch (Exception ex) {
78+
ex.printStackTrace();
79+
}
80+
81+
82+
6583
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
6684
beanFactory.setAllowCircularReferences(false);
6785
TronApplicationContext context =
@@ -73,8 +91,8 @@ public static void main(String[] args) {
7391
shutdown(appT);
7492

7593
// grpc api server
76-
RpcApiService rpcApiService = context.getBean(RpcApiService.class);
77-
appT.addService(rpcApiService);
94+
// RpcApiService rpcApiService = context.getBean(RpcApiService.class);
95+
// appT.addService(rpcApiService);
7896

7997
// http api server
8098
FullNodeHttpApiService httpApiService = context.getBean(FullNodeHttpApiService.class);
@@ -84,32 +102,32 @@ public static void main(String[] args) {
84102

85103
// full node and solidity node fuse together
86104
// provide solidity rpc and http server on the full node.
87-
if (Args.getInstance().getStorage().getDbVersion() == dbVersion) {
88-
RpcApiServiceOnSolidity rpcApiServiceOnSolidity = context
89-
.getBean(RpcApiServiceOnSolidity.class);
90-
appT.addService(rpcApiServiceOnSolidity);
91-
HttpApiOnSolidityService httpApiOnSolidityService = context
92-
.getBean(HttpApiOnSolidityService.class);
93-
if (CommonParameter.getInstance().solidityNodeHttpEnable) {
94-
appT.addService(httpApiOnSolidityService);
95-
}
96-
}
97-
98-
// PBFT API (HTTP and GRPC)
99-
if (Args.getInstance().getStorage().getDbVersion() == dbVersion) {
100-
RpcApiServiceOnPBFT rpcApiServiceOnPBFT = context
101-
.getBean(RpcApiServiceOnPBFT.class);
102-
appT.addService(rpcApiServiceOnPBFT);
103-
HttpApiOnPBFTService httpApiOnPBFTService = context
104-
.getBean(HttpApiOnPBFTService.class);
105-
appT.addService(httpApiOnPBFTService);
106-
}
105+
// if (Args.getInstance().getStorage().getDbVersion() == dbVersion) {
106+
// RpcApiServiceOnSolidity rpcApiServiceOnSolidity = context
107+
// .getBean(RpcApiServiceOnSolidity.class);
108+
// appT.addService(rpcApiServiceOnSolidity);
109+
// HttpApiOnSolidityService httpApiOnSolidityService = context
110+
// .getBean(HttpApiOnSolidityService.class);
111+
// if (CommonParameter.getInstance().solidityNodeHttpEnable) {
112+
// appT.addService(httpApiOnSolidityService);
113+
// }
114+
// }
115+
116+
// // PBFT API (HTTP and GRPC)
117+
// if (Args.getInstance().getStorage().getDbVersion() == dbVersion) {
118+
// RpcApiServiceOnPBFT rpcApiServiceOnPBFT = context
119+
// .getBean(RpcApiServiceOnPBFT.class);
120+
// appT.addService(rpcApiServiceOnPBFT);
121+
// HttpApiOnPBFTService httpApiOnPBFTService = context
122+
// .getBean(HttpApiOnPBFTService.class);
123+
// appT.addService(httpApiOnPBFTService);
124+
// }
107125

108126
appT.initServices(parameter);
109127
appT.startServices();
110128
appT.startup();
111129

112-
rpcApiService.blockUntilShutdown();
130+
// rpcApiService.blockUntilShutdown();
113131
}
114132

115133
public static void shutdown(final Application app) {

protocol/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>protocol</name>
4+
<comment>Project protocol created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

0 commit comments

Comments
 (0)