Skip to content

Commit 1785ad5

Browse files
committed
Merge branch 'feature/zenToken' of https://github.com/tronprotocol/java-tron into feature/zenToken
2 parents e61965a + c0392f6 commit 1785ad5

8 files changed

Lines changed: 1315 additions & 1954 deletions

File tree

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.tron.protos.Protocol.AccountType;
3333
import org.tron.protos.Protocol.Transaction.Result.code;
3434

35+
import static org.tron.core.zen.note.ZenChainParams.*;
36+
3537

3638
@Slf4j(topic = "actuator")
3739
public class ShieldedTransferActuator extends AbstractActuator {
@@ -56,7 +58,8 @@ public boolean execute(TransactionResultCapsule ret)
5658
executeTransparentFrom(shieldedTransferContract.getTransparentFromAddress().toByteArray(),
5759
shieldedTransferContract.getFromAmount(), ret);
5860
}
59-
dbManager.adjustAssetBalanceV2(dbManager.getAccountStore().getBlackhole().createDbKey(), zenTokenId, fee);
61+
dbManager.adjustAssetBalanceV2(dbManager.getAccountStore().getBlackhole().createDbKey(),
62+
zenTokenId, fee);
6063
} catch (BalanceInsufficientException e) {
6164
logger.debug(e.getMessage(), e);
6265
ret.setStatus(fee, code.FAILED);
@@ -242,9 +245,9 @@ public boolean validate() throws ContractValidateException {
242245
}
243246

244247
for (ReceiveDescription receiveDescription : receiveDescriptions) {
245-
if (receiveDescription.getCEnc().size() != 580
246-
|| receiveDescription.getCOut().size() != 80) {
247-
throw new ContractValidateException("receive description null");
248+
if (receiveDescription.getCEnc().size() != ZC_ENCCIPHERTEXT_SIZE
249+
|| receiveDescription.getCOut().size() != ZC_OUTCIPHERTEXT_SIZE) {
250+
throw new ContractValidateException("Cout or CEnc size error");
248251
}
249252
if (!Librustzcash.librustzcashSaplingCheckOutput(
250253
new CheckOutputParams(ctx,
@@ -351,7 +354,7 @@ private void validateTransparent(ShieldedTransferContract shieldedTransferContra
351354
throw new ContractValidateException("no transparent_to_address, to_amount should be 0");
352355
}
353356
if (hasTransparentFrom && hasTransparentTo && Arrays.equals(toAddress, ownerAddress)) {
354-
throw new ContractValidateException("Can't transfer trx to yourself");
357+
throw new ContractValidateException("Can't transfer zen to yourself");
355358
}
356359

357360
if (hasTransparentFrom) {
@@ -402,13 +405,6 @@ public ByteString getOwnerAddress() throws InvalidProtocolBufferException {
402405
@Override
403406
public long calcFee() {
404407
long fee = 0;
405-
// byte[] toAddress = shieldedTransferContract.getTransparentToAddress().toByteArray();
406-
// if (Wallet.addressValid(toAddress)) {
407-
// AccountCapsule transparentToAccount = dbManager.getAccountStore().get(toAddress);
408-
// if (transparentToAccount == null) {
409-
// fee = dbManager.getDynamicPropertiesStore().getCreateAccountFee();
410-
// }
411-
// }
412408
fee += dbManager.getDynamicPropertiesStore().getShieldedTransactionFee();
413409
return fee;
414410
}

0 commit comments

Comments
 (0)