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 "../Data.h"
10
#include "../Ethereum/RLP.h"
11
#include "../Ethereum/Transaction.h"
12
#include "../Hash.h"
13
#include "../PrivateKey.h"
14
#include "../proto/Ethereum.pb.h"
15

16
#include <boost/multiprecision/cpp_int.hpp>
17
#include <cstdint>
18
#include <tuple>
19
#include <vector>
20

21
namespace TW::Wanchain {
22

23
/// Helper class that performs Wanchain transaction signing.
24
class Signer {
25
  public:
26
    /// Signs a Proto::SigningInput transaction
27
    static Ethereum::Proto::SigningOutput sign(const Ethereum::Proto::SigningInput& input) noexcept;
28
  public:
29
    boost::multiprecision::uint256_t chainID;
30

31
    /// Initializes a signer with a chain identifier.
32 1
    Signer(boost::multiprecision::uint256_t chainID) : chainID(std::move(chainID)) {}
33

34
    /// Signs the given transaction.
35
    void sign(const PrivateKey &privateKey, Ethereum::Transaction &transaction) const noexcept;
36

37
    /// Encodes a transaction.
38
    Data encode(const Ethereum::Transaction &transaction) const noexcept;
39

40
  protected:
41
    /// Computes the transaction hash.
42
    Data hash(const Ethereum::Transaction &transaction) const noexcept;
43
};
44

45
} // namespace TW::Wanchain

Read our documentation on viewing source code .

Loading