Skip to content

Commit a32147c

Browse files
authored
Merge pull request tronprotocol#692 from tronprotocol/feature/fix_createTimeError
fix createTime error
2 parents 89325f7 + 1e21b3f commit a32147c

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public boolean execute(TransactionResultCapsule ret) throws ContractExeException
4444
long fee = calcFee();
4545
try {
4646

47+
// if account with to_address is not existed, create it.
48+
AccountCapsule toAccount = dbManager.getAccountStore()
49+
.get(transferContract.getToAddress().toByteArray());
50+
if (toAccount == null) {
51+
toAccount = new AccountCapsule(ByteString.copyFrom(toAddress), AccountType.Normal,
52+
dbManager.getHeadBlockTimeStamp());
53+
dbManager.getAccountStore().put(toAddress, toAccount);
54+
}
4755
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -calcFee());
4856
ret.setStatus(fee, code.SUCESS);
4957
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(),
@@ -113,9 +121,6 @@ public boolean validate() throws ContractValidateException {
113121
throw new ContractValidateException(
114122
"For a non-existent account transfer, the minimum amount is 1 TRX");
115123
}
116-
toAccount = new AccountCapsule(ByteString.copyFrom(toAddress), AccountType.Normal,
117-
dbManager.getHeadBlockTimeStamp());
118-
dbManager.getAccountStore().put(toAddress, toAccount);
119124
} else {
120125
//check to account balance if overflow
121126
balance = Math.addExact(toAccount.getBalance(), amount);

‎src/test/java/org/tron/core/actuator/TransferActuatorTest.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,10 @@ public void noExitToAccount() {
311311
.get(ByteArray.fromHexString(To_ACCOUNT_INVALIATE));
312312
Assert.assertTrue(null == noExitAccount);
313313
actuator.validate();
314+
actuator.execute(ret);
314315
noExitAccount = dbManager.getAccountStore()
315316
.get(ByteArray.fromHexString(To_ACCOUNT_INVALIATE));
316317
Assert.assertFalse(null == noExitAccount); //Had created.
317-
Assert.assertEquals(noExitAccount.getBalance(), 0);
318-
actuator.execute(ret);
319318
AccountCapsule owner = dbManager.getAccountStore()
320319
.get(ByteArray.fromHexString(OWNER_ADDRESS));
321320
AccountCapsule toAccount = dbManager.getAccountStore()

0 commit comments

Comments
 (0)