Search in sources :

Example 1 with RejectedStatus

use of org.aion.types.InternalTransaction.RejectedStatus in project aion by aionnetwork.

the class AionTxInfo method fromRlp.

private static InternalTransaction fromRlp(SharedRLPList rlpInternalTx) {
    Objects.requireNonNull(rlpInternalTx);
    AionAddress from = new AionAddress(rlpInternalTx.get(INDEX_FROM).getRLPData());
    AionAddress to;
    boolean isCreate;
    byte[] rlpTo = rlpInternalTx.get(INDEX_TO).getRLPData();
    if (rlpTo == null || rlpTo.length == 0) {
        to = null;
        isCreate = true;
    } else {
        to = new AionAddress(rlpTo);
        isCreate = false;
    }
    BigInteger nonce = new BigInteger(1, rlpInternalTx.get(INDEX_NONCE).getRLPData());
    BigInteger value = new BigInteger(1, rlpInternalTx.get(INDEX_VALUE).getRLPData());
    byte[] data = rlpInternalTx.get(INDEX_DATA).getRLPData();
    long energyLimit = new BigInteger(1, rlpInternalTx.get(INDEX_LIMIT).getRLPData()).longValue();
    long energyPrice = new BigInteger(1, rlpInternalTx.get(INDEX_PRICE).getRLPData()).longValue();
    RejectedStatus status = // checking the length because zero (i.e. false) decodes to empty byte array
    (rlpInternalTx.get(INDEX_STATUS).getRLPData().length == 1) ? RejectedStatus.REJECTED : RejectedStatus.NOT_REJECTED;
    if (isCreate) {
        return InternalTransaction.contractCreateTransaction(status, from, nonce, value, data, energyLimit, energyPrice);
    } else {
        return InternalTransaction.contractCallTransaction(status, from, to, nonce, value, data, energyLimit, energyPrice);
    }
}
Also used : AionAddress(org.aion.types.AionAddress) RejectedStatus(org.aion.types.InternalTransaction.RejectedStatus) BigInteger(java.math.BigInteger)

Example 2 with RejectedStatus

use of org.aion.types.InternalTransaction.RejectedStatus in project aion by aionnetwork.

the class AionTxInfo method fromRlp.

private static InternalTransaction fromRlp(RLPList encoded) {
    AionAddress from = new AionAddress(encoded.get(INDEX_FROM).getRLPData());
    AionAddress to;
    boolean isCreate;
    byte[] rlpTo = encoded.get(INDEX_TO).getRLPData();
    if (rlpTo == null || rlpTo.length == 0) {
        to = null;
        isCreate = true;
    } else {
        to = new AionAddress(rlpTo);
        isCreate = false;
    }
    BigInteger nonce = new BigInteger(1, encoded.get(INDEX_NONCE).getRLPData());
    BigInteger value = new BigInteger(1, encoded.get(INDEX_VALUE).getRLPData());
    byte[] data = encoded.get(INDEX_DATA).getRLPData();
    long energyLimit = new BigInteger(1, encoded.get(INDEX_LIMIT).getRLPData()).longValue();
    long energyPrice = new BigInteger(1, encoded.get(INDEX_PRICE).getRLPData()).longValue();
    RejectedStatus status = // checking the length because zero (i.e. false) decodes to empty byte array
    (encoded.get(INDEX_STATUS).getRLPData().length == 1) ? RejectedStatus.REJECTED : RejectedStatus.NOT_REJECTED;
    if (isCreate) {
        return InternalTransaction.contractCreateTransaction(status, from, nonce, value, data, energyLimit, energyPrice);
    } else {
        return InternalTransaction.contractCallTransaction(status, from, to, nonce, value, data, energyLimit, energyPrice);
    }
}
Also used : AionAddress(org.aion.types.AionAddress) RejectedStatus(org.aion.types.InternalTransaction.RejectedStatus) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)2 AionAddress (org.aion.types.AionAddress)2 RejectedStatus (org.aion.types.InternalTransaction.RejectedStatus)2