Coverage Summary for Class: RemascTransaction (co.rsk.remasc)
Class |
Method, %
|
Line, %
|
RemascTransaction |
16.7%
(1/6)
|
20%
(2/10)
|
RemascTransaction$1 |
66.7%
(2/3)
|
66.7%
(2/3)
|
Total |
33.3%
(3/9)
|
30.8%
(4/13)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package co.rsk.remasc;
20
21 import co.rsk.core.RskAddress;
22 import org.ethereum.config.Constants;
23 import org.ethereum.config.blockchain.upgrades.ActivationConfig;
24 import org.ethereum.core.Transaction;
25 import org.ethereum.util.ByteUtil;
26 import org.ethereum.vm.PrecompiledContracts;
27
28 import static org.ethereum.rpc.TypeConverter.toUnformattedJsonHex;
29
30 /**
31 * Tx that invokes Remasc's processMinersFees method.
32 * @author Oscar Guindzberg
33 */
34 public class RemascTransaction extends Transaction {
35 private static final byte[] ZERO_BYTE_ARRAY = new byte[]{0};
36
37 /**
38 * The Remasc transaction is not signed so it has no sender.
39 * Due to a bug in the implementation before mainnet release, this address has a special encoding.
40 * Instead of the empty array, it is encoded as the array with just one zero.
41 * This instance should not be used for any other reason.
42 */
43 public static final RskAddress REMASC_ADDRESS = new RskAddress(new byte[20]) {
44 @Override
45 public String toJsonString() {
46 return toUnformattedJsonHex(new byte[20]);
47 }
48
49 @Override
50 public byte[] getBytes() {
51 return new byte[]{0};
52 }
53 };
54
55 public RemascTransaction(byte[] rawData) {
56 super(rawData);
57 }
58
59 public RemascTransaction(long blockNumber) {
60 super(ByteUtil.longToBytesNoLeadZeroes(blockNumber - 1),
61 ZERO_BYTE_ARRAY,
62 ZERO_BYTE_ARRAY,
63 PrecompiledContracts.REMASC_ADDR.getBytes(),
64 ZERO_BYTE_ARRAY,
65 null,
66 (byte) 0);
67 }
68
69 @Override
70 public long transactionCost(Constants constants, ActivationConfig.ForBlock activations) {
71 // RemascTransaction does not pay any fees
72 return 0;
73 }
74
75 @Override
76 public RskAddress getSender() {
77 return REMASC_ADDRESS;
78 }
79
80 @Override
81 public boolean acceptTransactionSignature(byte chainId) {
82 // RemascTransaction is not signed and not signature validation should be done
83 return true;
84 }
85
86 }