Skip to content

Commit 579ea95

Browse files
authored
Merge pull request #1063 from tronprotocol/feature/addGRWithdrawLimit
feature: add GR withdraw limit
2 parents 5718fdc + 61fb9ad commit 579ea95

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import com.google.protobuf.Any;
55
import com.google.protobuf.ByteString;
66
import com.google.protobuf.InvalidProtocolBufferException;
7+
import java.util.Arrays;
78
import lombok.extern.slf4j.Slf4j;
89
import org.tron.common.utils.StringUtil;
910
import org.tron.core.Wallet;
1011
import org.tron.core.capsule.AccountCapsule;
1112
import org.tron.core.capsule.TransactionResultCapsule;
13+
import org.tron.core.config.args.Args;
1214
import org.tron.core.db.Manager;
1315
import org.tron.core.exception.ContractExeException;
1416
import org.tron.core.exception.ContractValidateException;
@@ -84,12 +86,20 @@ public boolean validate() throws ContractValidateException {
8486
"Account[" + readableOwnerAddress + "] not exists");
8587
}
8688

89+
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
8790
if (!dbManager.getWitnessStore().has(ownerAddress)) {
88-
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
8991
throw new ContractValidateException(
9092
"Account[" + readableOwnerAddress + "] is not a witnessAccount");
9193
}
9294

95+
boolean isGP = Args.getInstance().getGenesisBlock().getWitnesses().stream().anyMatch(witness ->
96+
Arrays.equals(ownerAddress, witness.getAddress()));
97+
if (isGP) {
98+
throw new ContractValidateException(
99+
"Account[" + readableOwnerAddress
100+
+ "] is a guard representative and is not allowed to withdraw Balance");
101+
}
102+
93103
long latestWithdrawTime = accountCapsule.getLatestWithdrawTime();
94104
long now = dbManager.getHeadBlockTimeStamp();
95105
long witnessAllowanceFrozenTime =

0 commit comments

Comments
 (0)