|
4 | 4 | import com.google.protobuf.Any;
|
5 | 5 | import com.google.protobuf.ByteString;
|
6 | 6 | import com.google.protobuf.InvalidProtocolBufferException;
|
| 7 | +import java.util.Arrays; |
7 | 8 | import lombok.extern.slf4j.Slf4j;
|
8 | 9 | import org.tron.common.utils.StringUtil;
|
9 | 10 | import org.tron.core.Wallet;
|
10 | 11 | import org.tron.core.capsule.AccountCapsule;
|
11 | 12 | import org.tron.core.capsule.TransactionResultCapsule;
|
| 13 | +import org.tron.core.config.args.Args; |
12 | 14 | import org.tron.core.db.Manager;
|
13 | 15 | import org.tron.core.exception.ContractExeException;
|
14 | 16 | import org.tron.core.exception.ContractValidateException;
|
@@ -84,12 +86,20 @@ public boolean validate() throws ContractValidateException {
|
84 | 86 | "Account[" + readableOwnerAddress + "] not exists");
|
85 | 87 | }
|
86 | 88 |
|
| 89 | + String readableOwnerAddress = StringUtil.createReadableString(ownerAddress); |
87 | 90 | if (!dbManager.getWitnessStore().has(ownerAddress)) {
|
88 |
| - String readableOwnerAddress = StringUtil.createReadableString(ownerAddress); |
89 | 91 | throw new ContractValidateException(
|
90 | 92 | "Account[" + readableOwnerAddress + "] is not a witnessAccount");
|
91 | 93 | }
|
92 | 94 |
|
| 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 | + |
93 | 103 | long latestWithdrawTime = accountCapsule.getLatestWithdrawTime();
|
94 | 104 | long now = dbManager.getHeadBlockTimeStamp();
|
95 | 105 | long witnessAllowanceFrozenTime =
|
|
0 commit comments