Skip to content

Commit f554d2e

Browse files
committed
Merge branch 'develop' of https://github.com/tronprotocol/java-tron into hotfix/splitDBConfig
2 parents 3c68299 + c4ad831 commit f554d2e

File tree

8 files changed

+34
-105
lines changed

8 files changed

+34
-105
lines changed

README.md

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,21 @@ TRON enables large-scale development and engagement. With over 2000 transactions
6464

6565
# Quick Start
6666

67-
* [Quick Start](./quickstart.md) TRON Quickstart image setup
67+
[TRON Quick Start](./quickstart.md)
6868

69-
# Deploy
70-
* [Build](./build.md) Please build java-tron after cloning the project
71-
* [Run](./run.md) Run java-tron
69+
# Deployment
70+
[https://tronprotocol.github.io/documentation-en/developers/deployment/](https://tronprotocol.github.io/documentation-en/developers/deployment/)
7271

73-
# Developer Community
72+
# Channel
73+
[Core Devs Gitter](https://gitter.im/tronprotocol/allcoredev)
7474

75-
* [Discord](https://discord.gg/GsRgsTD) Please join our Developer Discord
76-
* [Gitter](https://gitter.im/tronprotocol/allcoredev) the core dev gitter
75+
# Contribution
76+
[https://tronprotocol.github.io/documentation-en/developers/contribution/](https://tronprotocol.github.io/documentation-en/developers/contribution/)
7777

78-
# Projects
79-
* [TRON Protocol](https://github.com/tronprotocol/protocol)
80-
* [Wallet Client](https://github.com/tronprotocol/wallet-cli)
81-
* [Wallet Web](https://github.com/tronprotocol/wallet-web)
82-
83-
# Resource
84-
* [Website](https://tron.network/)
85-
* [Documentation](http://developers.tron.network)
86-
* [Blog](https://tronprotocol.github.io/tron-blog/)
87-
* [Tronscan](https://tronscan.org/)
88-
* [Trxplorer](https://www.trxplorer.io/)
78+
# Resources
79+
* [Medium](https://medium.com/@coredevs)
80+
* [Documentation](https://tronprotocol.github.io/documentation-en/introduction/)
8981
* [White Paper](https://tron.network/resources?lng=&name=1)
90-
* [TRON Quickstart](https://developers.tron.network/docs/getting-started-1)
91-
* [About](https://tron.network/about)
92-
* [FAQ](https://tron.network/faq)
93-
94-
# Contributing
95-
Thank you for all of [our contributors](https://github.com/tronprotocol/java-tron/graphs/contributors); this project wouldn’t be what it is without you! If you want to help out, please see [CONTRIBUTING.md](CONTRIBUTING.md).
96-
97-
If you'd like to contribute to java-tron, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base.
98-
If you wish to submit more complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/tronprotocol/allcoredev) to ensure those changes are
99-
in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.
10082

10183
# License
102-
* [MIT](https://github.com/tronprotocol/java-tron/blob/master/LICENSE)
84+
[MIT](https://github.com/tronprotocol/java-tron/blob/master/LICENSE)

actuator/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.tron.common.zksnark.MerkleContainer;
2424
import org.tron.core.capsule.AccountCapsule;
2525
import org.tron.core.capsule.BytesCapsule;
26+
import org.tron.core.capsule.TransactionCapsule;
2627
import org.tron.core.capsule.TransactionResultCapsule;
2728
import org.tron.core.exception.BalanceInsufficientException;
2829
import org.tron.core.exception.ContractExeException;
@@ -283,7 +284,7 @@ private void checkProof(List<SpendDescription> spendDescriptions,
283284
}
284285

285286
long shieldedTransactionFee = calcFee();
286-
byte[] signHash = TransactionUtil.getShieldTransactionHashIgnoreTypeException(tx.getInstance());
287+
byte[] signHash = TransactionCapsule.getShieldTransactionHashIgnoreTypeException(tx.getInstance());
287288

288289
if (CollectionUtils.isNotEmpty(spendDescriptions)
289290
|| CollectionUtils.isNotEmpty(receiveDescriptions)) {

actuator/src/main/java/org/tron/core/utils/TransactionUtil.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -131,63 +131,6 @@ public static boolean isNumber(byte[] id) {
131131
return !(id.length > 1 && id[0] == '0');
132132
}
133133

134-
/**
135-
* Get sender.
136-
*/
137-
/* public static byte[] getSender(Transaction tx) {
138-
byte[] pubKey = tx.getRawData().getVin(0).getRawData().getPubKey().toByteArray();
139-
return ECKey.computeAddress(pubKey);
140-
} */
141-
142-
//make sure that contractType is validated before
143-
//No exception will be thrown here
144-
public static byte[] getShieldTransactionHashIgnoreTypeException(Transaction tx) {
145-
try {
146-
return hashShieldTransaction(tx);
147-
} catch (ContractValidateException | InvalidProtocolBufferException e) {
148-
logger.debug(e.getMessage(), e);
149-
}
150-
return null;
151-
}
152-
153-
public static byte[] hashShieldTransaction(Transaction tx)
154-
throws ContractValidateException, InvalidProtocolBufferException {
155-
Any contractParameter = tx.getRawData().getContract(0).getParameter();
156-
if (!contractParameter.is(ShieldedTransferContract.class)) {
157-
throw new ContractValidateException(
158-
"contract type error,expected type [ShieldedTransferContract],real type["
159-
+ contractParameter
160-
.getClass() + "]");
161-
}
162-
163-
ShieldedTransferContract shieldedTransferContract = contractParameter
164-
.unpack(ShieldedTransferContract.class);
165-
ShieldedTransferContract.Builder newContract = ShieldedTransferContract.newBuilder();
166-
newContract.setFromAmount(shieldedTransferContract.getFromAmount());
167-
newContract.addAllReceiveDescription(shieldedTransferContract.getReceiveDescriptionList());
168-
newContract.setToAmount(shieldedTransferContract.getToAmount());
169-
newContract.setTransparentFromAddress(shieldedTransferContract.getTransparentFromAddress());
170-
newContract.setTransparentToAddress(shieldedTransferContract.getTransparentToAddress());
171-
for (SpendDescription spendDescription : shieldedTransferContract.getSpendDescriptionList()) {
172-
newContract
173-
.addSpendDescription(spendDescription.toBuilder().clearSpendAuthoritySignature().build());
174-
}
175-
176-
Transaction.raw.Builder rawBuilder = tx.toBuilder()
177-
.getRawDataBuilder()
178-
.clearContract()
179-
.addContract(
180-
Transaction.Contract.newBuilder().setType(ContractType.ShieldedTransferContract)
181-
.setParameter(
182-
Any.pack(newContract.build())).build());
183-
184-
Transaction transaction = tx.toBuilder().clearRawData()
185-
.setRawData(rawBuilder).build();
186-
187-
return Sha256Hash.of(transaction.getRawData().toByteArray())
188-
.getBytes();
189-
}
190-
191134
public static Sha256Hash getTransactionId(Transaction transaction) {
192135
return Sha256Hash.of(transaction.getRawData().toByteArray());
193136
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,18 @@ public static long checkWeight(Permission permission, List<ByteString> sigs, byt
224224

225225
//make sure that contractType is validated before
226226
//No exception will be thrown here
227-
public static byte[] getShieldTransactionHashIgnoreTypeException(TransactionCapsule tx) {
227+
public static byte[] getShieldTransactionHashIgnoreTypeException(Transaction tx) {
228228
try {
229229
return hashShieldTransaction(tx);
230230
} catch (ContractValidateException | InvalidProtocolBufferException e) {
231231
logger.debug(e.getMessage(), e);
232232
}
233-
return new byte[0];
233+
return null;
234234
}
235235

236-
public static byte[] hashShieldTransaction(TransactionCapsule tx)
236+
public static byte[] hashShieldTransaction(Transaction tx)
237237
throws ContractValidateException, InvalidProtocolBufferException {
238-
Any contractParameter = tx.getInstance().getRawData().getContract(0).getParameter();
238+
Any contractParameter = tx.getRawData().getContract(0).getParameter();
239239
if (!contractParameter.is(ShieldedTransferContract.class)) {
240240
throw new ContractValidateException(
241241
"contract type error,expected type [ShieldedTransferContract],real type["
@@ -256,15 +256,15 @@ public static byte[] hashShieldTransaction(TransactionCapsule tx)
256256
.addSpendDescription(spendDescription.toBuilder().clearSpendAuthoritySignature().build());
257257
}
258258

259-
Transaction.raw.Builder rawBuilder = tx.getInstance().toBuilder()
259+
Transaction.raw.Builder rawBuilder = tx.toBuilder()
260260
.getRawDataBuilder()
261261
.clearContract()
262262
.addContract(
263263
Transaction.Contract.newBuilder().setType(ContractType.ShieldedTransferContract)
264264
.setParameter(
265265
Any.pack(newContract.build())).build());
266266

267-
Transaction transaction = tx.getInstance().toBuilder().clearRawData()
267+
Transaction transaction = tx.toBuilder().clearRawData()
268268
.setRawData(rawBuilder).build();
269269

270270
return Sha256Hash.of(transaction.getRawData().toByteArray())

framework/src/main/java/org/tron/core/Wallet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ public BytesMessage getShieldTransactionHash(Transaction transaction)
22402240
}
22412241
TransactionCapsule transactionCapsule = new TransactionCapsule(transaction);
22422242
byte[] transactionHash = TransactionCapsule
2243-
.getShieldTransactionHashIgnoreTypeException(transactionCapsule);
2243+
.getShieldTransactionHashIgnoreTypeException(transactionCapsule.getInstance());
22442244
return BytesMessage.newBuilder().setValue(ByteString.copyFrom(transactionHash)).build();
22452245
}
22462246

framework/src/main/java/org/tron/core/zen/ZenTransactionBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public TransactionCapsule build(boolean withAsk) throws ZksnarkException {
153153
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
154154
contractBuilder.build(), ContractType.ShieldedTransferContract);
155155

156-
dataHashToBeSigned = TransactionUtil
156+
dataHashToBeSigned = TransactionCapsule
157157
.getShieldTransactionHashIgnoreTypeException(transactionCapsule.getInstance());
158158

159159
if (dataHashToBeSigned == null) {

framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.tron.core.zksnark;
22

3+
import static org.tron.core.capsule.TransactionCapsule.getShieldTransactionHashIgnoreTypeException;
4+
35
import com.alibaba.fastjson.JSONArray;
46
import com.google.common.base.Charsets;
57
import com.google.common.io.Files;
@@ -655,7 +657,7 @@ public void checkZksnark() throws BadItemException, ZksnarkException {
655657
TransactionCapsule transactionCap = builder.build();
656658
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
657659
boolean ret = ZksnarkClient.getInstance().checkZksnarkProof(transactionCap.getInstance(),
658-
TransactionCapsule.getShieldTransactionHashIgnoreTypeException(transactionCap),
660+
getShieldTransactionHashIgnoreTypeException(transactionCap.getInstance()),
659661
10 * 1000000);
660662
Assert.assertTrue(ret);
661663
}

framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public String[] generateSpendAndOutputParams() throws ZksnarkException, BadItemE
382382
// begin to generate dataToBeSigned
383383
TransactionCapsule transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
384384
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
385-
byte[] dataToBeSigned = TransactionUtil
385+
byte[] dataToBeSigned = TransactionCapsule
386386
.getShieldTransactionHashIgnoreTypeException(transactionCapsule.getInstance());
387387
TransactionCapsule transactionCap = generateTransactionCapsule(builder, ctx, dataToBeSigned,
388388
transactionCapsule);
@@ -613,7 +613,7 @@ public void testReceiveDescriptionWithEmptyCv()
613613
TransactionExtention transactionExtention = TransactionExtention.newBuilder()
614614
.setTransaction(transactionCapsule.getInstance()).build();
615615

616-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
616+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
617617
} catch (Exception ex) {
618618
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
619619
throw new RuntimeException("Could not construct signature hash: " + ex.getMessage());
@@ -655,7 +655,7 @@ public void testReceiveDescriptionWithEmptyCm()
655655
try {
656656
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
657657
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
658-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
658+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
659659
} catch (Exception ex) {
660660
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
661661
throw new RuntimeException("Could not construct signature hash: " + ex.getMessage());
@@ -697,7 +697,7 @@ public void testReceiveDescriptionWithEmptyEpk()
697697
try {
698698
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
699699
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
700-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
700+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
701701
} catch (Exception ex) {
702702
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
703703
throw new RuntimeException("Could not construct signature hash: " + ex.getMessage());
@@ -739,7 +739,7 @@ public void testReceiveDescriptionWithEmptyZkproof()
739739
try {
740740
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
741741
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
742-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
742+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
743743
} catch (Exception ex) {
744744
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
745745
throw new RuntimeException("Could not construct signature hash: " + ex.getMessage());
@@ -781,7 +781,7 @@ public void testReceiveDescriptionWithEmptyCenc()
781781
try {
782782
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
783783
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
784-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
784+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
785785
} catch (Exception ex) {
786786
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
787787
throw new RuntimeException("Could not construct signature hash: " + ex.getMessage());
@@ -823,7 +823,7 @@ public void testReceiveDescriptionWithEmptyCout()
823823
try {
824824
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
825825
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
826-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
826+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
827827
} catch (Exception ex) {
828828
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
829829
throw new RuntimeException("Could not construct signature hash: " + ex.getMessage());
@@ -975,7 +975,7 @@ private TransactionCapsule changeBuildOutputProof(ZenTransactionBuilder builder,
975975
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
976976
contractBuilder.build(), ContractType.ShieldedTransferContract);
977977

978-
dataToBeSigned = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
978+
dataToBeSigned = TransactionCapsule.hashShieldTransaction(transactionCapsule.getInstance());
979979
} catch (Exception ex) {
980980
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);
981981
throw new ZksnarkException("Could not construct signature hash: " + ex.getMessage());
@@ -2004,7 +2004,8 @@ public void testSpendSignatureWithWrongColumn()
20042004
transactionCapsule = wallet.createTransactionCapsuleWithoutValidate(
20052005
builder.getContractBuilder().build(), ContractType.ShieldedTransferContract);
20062006

2007-
hashOfTransaction = TransactionUtil.hashShieldTransaction(transactionCapsule.getInstance());
2007+
hashOfTransaction = TransactionCapsule
2008+
.hashShieldTransaction(transactionCapsule.getInstance());
20082009

20092010
} catch (Exception ex) {
20102011
JLibrustzcash.librustzcashSaplingProvingCtxFree(ctx);

0 commit comments

Comments
 (0)