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 <string>
10
#include <vector>
11

12
#include "Coins.h"
13
#include "../Data.h"
14
#include "../Ethereum/Address.h"
15

16
namespace TW::Theta {
17

18 1
class TxInput {
19
  public:
20
    Ethereum::Address address;
21
    Coins coins;
22
    uint64_t sequence;
23
    Data signature;
24

25 1
    TxInput(Ethereum::Address address, Coins coins, uint64_t sequence)
26 1
        : address(std::move(address)), coins(std::move(coins)), sequence(sequence) {}
27
    TxInput(Ethereum::Address address, Coins coins, uint64_t sequence, const Data& signature)
28
        : address(std::move(address)), coins(std::move(coins)), sequence(sequence), signature(std::move(signature)) {}
29
};
30

31 1
class TxOutput {
32
  public:
33
    Ethereum::Address address;
34
    Coins coins;
35

36 1
    TxOutput(Ethereum::Address address, Coins coins)
37 1
        : address(std::move(address)), coins(std::move(coins)) {}
38
};
39

40 1
class Transaction {
41
  public:
42
    Coins fee;
43
    std::vector<TxInput> inputs;
44
    std::vector<TxOutput> outputs;
45

46
    Transaction() = default;
47
    Transaction(Coins fee, std::vector<TxInput> inputs, std::vector<TxOutput> outputs)
48
        : fee(std::move(fee)), inputs(std::move(inputs)), outputs(std::move(outputs)) {}
49

50
    Transaction(Ethereum::Address from, Ethereum::Address to,
51
                uint256_t thetaAmount, uint256_t tfuelAmount, uint64_t sequence,
52
                uint256_t feeAmount = 1000000000000);
53

54
    /// Encodes the transaction
55
    Data encode() const noexcept;
56

57
    /// Sets signature
58
    bool setSignature(const Ethereum::Address& address, const Data& signature) noexcept;
59
};
60

61
} // namespace TW::Theta

Read our documentation on viewing source code .

Loading