|
26 | 26 | import static org.apache.commons.lang3.ArrayUtils.nullToEmpty; |
27 | 27 | import static org.tron.common.runtime.utils.MUtil.convertToTronAddress; |
28 | 28 | import static org.tron.common.runtime.utils.MUtil.transfer; |
| 29 | +import static org.tron.common.runtime.utils.MUtil.transferAllToken; |
29 | 30 | import static org.tron.common.utils.BIUtil.isPositive; |
30 | 31 | import static org.tron.common.utils.BIUtil.toBI; |
| 32 | +import static org.tron.common.utils.ByteUtil.stripLeadingZeroes; |
31 | 33 |
|
32 | 34 | import com.google.protobuf.ByteString; |
33 | 35 | import java.io.ByteArrayOutputStream; |
34 | 36 | import java.math.BigInteger; |
35 | 37 | import java.util.Arrays; |
36 | 38 | import java.util.BitSet; |
| 39 | +import java.util.HashMap; |
37 | 40 | import java.util.Map; |
38 | 41 | import java.util.NavigableSet; |
39 | 42 | import java.util.Objects; |
@@ -194,12 +197,12 @@ public int getCallDeep() { |
194 | 197 | */ |
195 | 198 | private InternalTransaction addInternalTx(DataWord energyLimit, byte[] senderAddress, |
196 | 199 | byte[] transferAddress, |
197 | | - long value, byte[] data, String note, long nonce, String tokenId) { |
| 200 | + long value, byte[] data, String note, long nonce, Map<String, Long> tokenInfo) { |
198 | 201 |
|
199 | 202 | InternalTransaction addedInternalTx = null; |
200 | 203 | if (internalTransaction != null) { |
201 | 204 | addedInternalTx = getResult().addInternalTransaction(internalTransaction.getHash(), getCallDeep(), |
202 | | - senderAddress, transferAddress, value, data, note, nonce, tokenId); |
| 205 | + senderAddress, transferAddress, value, data, note, nonce, tokenInfo); |
203 | 206 | } |
204 | 207 |
|
205 | 208 | return addedInternalTx; |
@@ -411,14 +414,24 @@ public void suicide(DataWord obtainerAddress) { |
411 | 414 | } |
412 | 415 |
|
413 | 416 | increaseNonce(); |
414 | | - addInternalTx(null, owner, obtainer, balance, null, "suicide", nonce, null); |
| 417 | + |
| 418 | + addInternalTx(null, owner, obtainer, balance, null, "suicide", nonce, |
| 419 | + getContractState().getAccount(owner).getAssetMap()); |
415 | 420 |
|
416 | 421 | if (FastByteComparisons.compareTo(owner, 0, 20, obtainer, 0, 20) == 0) { |
417 | 422 | // if owner == obtainer just zeroing account according to Yellow Paper |
418 | 423 | getContractState().addBalance(owner, -balance); |
| 424 | + byte[] blackHoleAddress = getContractState().getBlackHoleAddress(); |
| 425 | + if (VMConfig.getEnergyLimitHardFork()) { |
| 426 | + getContractState().addBalance(blackHoleAddress, balance); |
| 427 | + transferAllToken(getContractState(),owner,blackHoleAddress); |
| 428 | + } |
419 | 429 | } else { |
420 | 430 | try { |
421 | 431 | transfer(getContractState(), owner, obtainer, balance); |
| 432 | + if (VMConfig.getEnergyLimitHardFork()) { |
| 433 | + transferAllToken(getContractState(), owner, obtainer); |
| 434 | + } |
422 | 435 | } catch (ContractValidateException e) { |
423 | 436 | throw new BytecodeExecutionException("transfer failure"); |
424 | 437 | } |
@@ -671,9 +684,13 @@ public void callToAddress(MessageCall msg) { |
671 | 684 |
|
672 | 685 | // CREATE CALL INTERNAL TRANSACTION |
673 | 686 | increaseNonce(); |
| 687 | + HashMap<String,Long> tokenInfo = new HashMap<>(); |
| 688 | + if (msg.getTokenId()!= null) { |
| 689 | + tokenInfo.put(new String(stripLeadingZeroes(msg.getTokenId().getData())),endowment); |
| 690 | + } |
674 | 691 | InternalTransaction internalTx = addInternalTx(null, senderAddress, contextAddress, |
675 | | - endowment, data, "call", nonce , msg.getTokenId() == null ? null: new String(MUtil.removeZeroes(msg.getTokenId().getData()))); |
676 | | - |
| 692 | + endowment, data, "call", nonce , |
| 693 | + msg.getTokenId() == null ? null: tokenInfo); |
677 | 694 | ProgramResult callResult = null; |
678 | 695 | if (isNotEmpty(programCode)) { |
679 | 696 | long vmStartInUs = System.nanoTime() / 1000; |
|
0 commit comments