1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#pragma once
8

9
#include "Transaction.h"
10

11
#include "Ethereum/RLP.h"
12

13
#include <boost/multiprecision/cpp_int.hpp>
14
#include <cstdint>
15
#include <string>
16
#include <vector>
17

18
namespace TW::Aion {
19

20
/// Aion's RLP encoging for long numbers
21
/// https://github.com/aionnetwork/aion/issues/680
22
struct RLP {
23 1
    static Data encodeLong(boost::multiprecision::uint128_t l) noexcept {
24 1
        if ((l & 0x00000000FFFFFFFFL) == l) {
25 1
            return Ethereum::RLP::encode(static_cast<uint256_t>(l));
26
        }
27 1
        Data result(9);
28 1
        result[0] = 0x80 + 8;
29 1
        for (int i = 8; i > 0; i--) {
30 1
            result[i] = (byte)(l & 0xFF);
31 1
            l >>= 8;
32
        }
33 1
        return result;
34
    }
35
};
36

37
} // namespace TW::Aion

Read our documentation on viewing source code .

Loading