Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/main/java/org/tron/core/actuator/TransferActuator.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public boolean execute(TransactionResultCapsule ret) throws ContractExeException
long fee = calcFee();
try {

// if account with to_address is not existed, create it.
AccountCapsule toAccount = dbManager.getAccountStore()
.get(transferContract.getToAddress().toByteArray());
if (toAccount == null) {
toAccount = new AccountCapsule(ByteString.copyFrom(toAddress), AccountType.Normal,
dbManager.getHeadBlockTimeStamp());
dbManager.getAccountStore().put(toAddress, toAccount);
}
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -calcFee());
ret.setStatus(fee, code.SUCESS);
dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(),
Expand Down Expand Up @@ -113,9 +121,6 @@ public boolean validate() throws ContractValidateException {
throw new ContractValidateException(
"For a non-existent account transfer, the minimum amount is 1 TRX");
}
toAccount = new AccountCapsule(ByteString.copyFrom(toAddress), AccountType.Normal,
dbManager.getHeadBlockTimeStamp());
dbManager.getAccountStore().put(toAddress, toAccount);
} else {
//check to account balance if overflow
balance = Math.addExact(toAccount.getBalance(), amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,10 @@ public void noExitToAccount() {
.get(ByteArray.fromHexString(To_ACCOUNT_INVALIATE));
Assert.assertTrue(null == noExitAccount);
actuator.validate();
actuator.execute(ret);
noExitAccount = dbManager.getAccountStore()
.get(ByteArray.fromHexString(To_ACCOUNT_INVALIATE));
Assert.assertFalse(null == noExitAccount); //Had created.
Assert.assertEquals(noExitAccount.getBalance(), 0);
actuator.execute(ret);
AccountCapsule owner = dbManager.getAccountStore()
.get(ByteArray.fromHexString(OWNER_ADDRESS));
AccountCapsule toAccount = dbManager.getAccountStore()
Expand Down