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
#include "Entry.h"
8

9
#include "Address.h"
10
#include "Signer.h"
11
#include "RLP.h"
12

13
using namespace TW::Ethereum;
14
using namespace std;
15

16 1
bool Entry::validateAddress(TWCoinType coin, const string& address, TW::byte, TW::byte, const char*) const {
17 1
    return Address::isValid(address);
18
}
19

20 1
string Entry::normalizeAddress(TWCoinType coin, const string& address) const {
21
    // normalized with EIP55 checksum
22 1
    return Address(address).string();
23
}
24

25 1
string Entry::deriveAddress(TWCoinType coin, const PublicKey& publicKey, TW::byte, const char*) const {
26 1
    return Address(publicKey).string();
27
}
28

29 1
void Entry::sign(TWCoinType coin, const TW::Data& dataIn, TW::Data& dataOut) const {
30 1
    signTemplate<Signer, Proto::SigningInput>(dataIn, dataOut);
31
}
32

33 1
string Entry::signJSON(TWCoinType coin, const std::string& json, const Data& key) const { 
34 1
    return Signer::signJSON(json, key);
35
}
36

37 1
void Entry::encodeRawTx(TWCoinType coin, const TW::Data& dataIn, TW::Data& dataOut) const {
38 1
    encodeTemplate<Signer, Proto::SigningInput>(dataIn, dataOut);
39
}
40

41 1
void Entry::decodeRawTx(TWCoinType coin, const TW::Data& dataIn, TW::Data& dataOut) const {
42
    try {
43 1
        auto data = RLP::decodeRawTransaction(dataIn);
44 1
        dataOut.insert(dataOut.end(), data.begin(), data.end());
45 1
    } catch(...) {
46
        return;
47
    }
48
}

Read our documentation on viewing source code .

Loading