Skip to content

Commit b3dc660

Browse files
authored
Merge pull request #1352 from tronprotocol/createaccount_add_fee_to_blackhole
Include AccountCreateContract fees in the black hole account
2 parents 36834ca + dc1e98c commit b3dc660

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ public boolean execute(TransactionResultCapsule ret)
2828
long fee = calcFee();
2929
try {
3030
AccountCreateContract accountCreateContract = contract.unpack(AccountCreateContract.class);
31-
AccountCapsule accountCapsule = new AccountCapsule(accountCreateContract,
32-
dbManager.getHeadBlockTimeStamp());
33-
dbManager.getAccountStore()
34-
.put(accountCreateContract.getAccountAddress().toByteArray(), accountCapsule);
31+
AccountCapsule accountCapsule = new AccountCapsule(accountCreateContract, dbManager.getHeadBlockTimeStamp());
32+
33+
dbManager.getAccountStore().put(accountCreateContract.getAccountAddress().toByteArray(), accountCapsule);
3534

3635
dbManager.adjustBalance(accountCreateContract.getOwnerAddress().toByteArray(), -fee);
36+
// Add to blackhole address
37+
dbManager.adjustBalance(dbManager.getAccountStore().getBlackhole().createDbKey(), fee);
38+
3739
ret.setStatus(fee, code.SUCESS);
3840
} catch (BalanceInsufficientException e) {
3941
logger.debug(e.getMessage(), e);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.tron.core.capsule.ExchangeCapsule;
1212
import org.tron.core.capsule.TransactionResultCapsule;
1313
import org.tron.core.db.Manager;
14+
import org.tron.core.exception.BalanceInsufficientException;
1415
import org.tron.core.exception.ContractExeException;
1516
import org.tron.core.exception.ContractValidateException;
1617
import org.tron.protos.Contract.ExchangeCreateContract;
@@ -37,7 +38,7 @@ public boolean execute(TransactionResultCapsule ret) throws ContractExeException
3738
long firstTokenBalance = exchangeCreateContract.getFirstTokenBalance();
3839
long secondTokenBalance = exchangeCreateContract.getSecondTokenBalance();
3940

40-
long newBalance = accountCapsule.getBalance() - calcFee();
41+
long newBalance = accountCapsule.getBalance() - fee;
4142

4243
accountCapsule.setBalance(newBalance);
4344

@@ -70,7 +71,13 @@ public boolean execute(TransactionResultCapsule ret) throws ContractExeException
7071
dbManager.getExchangeStore().put(exchangeCapsule.createDbKey(), exchangeCapsule);
7172
dbManager.getDynamicPropertiesStore().saveLatestExchangeNum(id);
7273

74+
dbManager.adjustBalance(dbManager.getAccountStore().getBlackhole().createDbKey(), fee);
75+
7376
ret.setStatus(fee, code.SUCESS);
77+
} catch (BalanceInsufficientException e) {
78+
logger.debug(e.getMessage(), e);
79+
ret.setStatus(fee, code.FAILED);
80+
throw new ContractExeException(e.getMessage());
7481
} catch (InvalidProtocolBufferException e) {
7582
logger.debug(e.getMessage(), e);
7683
ret.setStatus(fee, code.FAILED);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public boolean execute(TransactionResultCapsule ret) throws ContractExeException
4444
fee = fee + dbManager.getDynamicPropertiesStore().getCreateNewAccountFeeInSystemContract();
4545
}
4646
dbManager.adjustBalance(ownerAddress, -fee);
47+
dbManager.adjustBalance(dbManager.getAccountStore().getBlackhole().createDbKey(), fee);
4748
ret.setStatus(fee, code.SUCESS);
4849
dbManager.adjustBalance(ownerAddress, -amount);
4950
dbManager.adjustBalance(toAddress, amount);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public boolean execute(TransactionResultCapsule ret) throws ContractExeException
6262
long amount = transferAssetContract.getAmount();
6363

6464
dbManager.adjustBalance(ownerAddress, -fee);
65+
dbManager.adjustBalance(dbManager.getAccountStore().getBlackhole().createDbKey(), fee);
6566

6667
AccountCapsule ownerAccountCapsule = accountStore.get(ownerAddress);
6768
if (!ownerAccountCapsule.reduceAssetAmount(assetName.toByteArray(), amount)) {

0 commit comments

Comments
 (0)